如何创建多词文档术语表?

2024-09-28 03:13:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我以前使用NLTK构建了一个文本分类模型。 现在我需要构建一个类似的模型,但这次我必须使用多字标记,而不是单字标记。 另外,我的输入数据包含已经从要分类的文档中提取的特征(历史数据)和多字标记。 我没有原始数据。你知道吗

我打算建立一个文档短语矩阵,然后是一个分类器。你知道吗

PS:NLTK允许ngram标记器,但是这里我没有源数据。我只给多字的代币。你知道吗

输入:

features = ['food security','indigenous groups','national forest','wood forest']

Doc1 = ['food security','indigenous groups','wood forest']

Doc2 = ['national forest','wood forest']

Doc3 = ['tree products', 'forest resources']

Doc4 = ['local population']

Doc5 = []

输出:

+----------+---------------+-------------------+-----------------+-------------+
| Features | food security | indigenous groups | national forest | wood forest |
+----------+---------------+-------------------+-----------------+-------------+
| Doc1     |             1 |                 1 |               0 |           1 |
| Doc2     |             0 |                 0 |               1 |           1 |
| Doc3     |             0 |                 0 |               0 |           0 |
| Doc4     |             0 |                 0 |               0 |           0 |
| Doc5     |             0 |                 0 |               0 |           0 |
+----------+---------------+-------------------+-----------------+-------------+

从这里开始,我计划建立一个分类器。你知道吗

现在我的计划是将这些多字标记/功能转换为单字,方法是将“”替换为'.'“粮食安全”变成“粮食安全”。但我知道这样做很不好。我在寻找更好的方法


Tags: 数据文档标记模型分类器food分类单字

热门问题