我想从文本中提取一些关键字并打印出来,但是如何提取呢
这是我想从中提取的示例文本
text = "Merhaba bugun bir miktar bas agrisi var, genellikle sonbahar gunlerinde baslayan bu bas agrisi insanin canini sikmakta. Bu durumdan kurtulmak icin neler yapmali."
这是从文本中提取关键字的示例
keywords = ('bas agrisi', 'kurtulmak')
我想检测这些关键词并打印出来
bas agrisi
kurtulmak
如何在python中实现这一点
您希望python理解关键字,还是希望在特定文本中将单词视为标记?因为对于第一个,您可能需要建立一个机器学习机制或神经网络来理解和提取文本中的关键字。但是对于第二种情况,您可以使用非常简单的步骤来标记单词
比如说,
我希望我能解释清楚。此外,如果你想继续前进,创建一个神经网络或类似的机制,你可以使用一个热编码
试试这个:
输出:
使用
re
库查找所有可能的关键字相关问题 更多 >
编程相关推荐