Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python-在大型非结构化数据中搜索大型关键字列表_Python_Machine Learning_Nlp_Tagging - Fatal编程技术网

Python-在大型非结构化数据中搜索大型关键字列表

Python-在大型非结构化数据中搜索大型关键字列表,python,machine-learning,nlp,tagging,Python,Machine Learning,Nlp,Tagging,我有一大袋的关键字,我想在大型非结构化数据中搜索并自动标记这些内容 我采取的最初几个步骤是消除对数据的预处理,例如:删除停止词、标点符号、区分大小写、检查高频词并在不需要时删除它们。我从这篇文章中改编了一些东西: 在预处理之后,我不确定应该如何搜索关键字,以及如何以有效的方式自动标记关键字。有没有什么好的机器学习教程、算法和/或自然语言处理可以比我现在做的更好 以下是一个例子: 关键词包: keywords_to_search = ['Harry Potter','LOTR','Lord of

我有一大袋的关键字,我想在大型非结构化数据中搜索并自动标记这些内容

我采取的最初几个步骤是消除对数据的预处理,例如:删除停止词、标点符号、区分大小写、检查高频词并在不需要时删除它们。我从这篇文章中改编了一些东西:

在预处理之后,我不确定应该如何搜索关键字,以及如何以有效的方式自动标记关键字。有没有什么好的机器学习教程、算法和/或自然语言处理可以比我现在做的更好

以下是一个例子: 关键词包:

keywords_to_search = ['Harry Potter','LOTR','Lord of the Rings','Secret Garden','Pinocchio'] # Some example, I have over 100K list of keywords to search
l1 = ['abc','def','ghi','jkl']
l2 = ['Pinocchio and Harry Potter is a famous children\'s book..','LOTR was written by J. R. R. Tolkien','Fordo Baggins is a character in Lord of the Rings Book Series.','blank']
df = pd.DataFrame({'some_col':l1,'text':l2})
尝试:

寻找这个:

some_col    text                                                                tags
abc         Pinocchio and Harry Potter is a famous children's book.             Pinocchio,Harry Potter
def         LOTR was written by J. R. R. Tolkien                                LOTR
ghi         Fordo Baggins is a character in Lord of the Ri...                   Lord of the Rings

每个标签有多少个条目/句子?您是否在寻找比字符串匹配更快的ML、NLP替代方案?您的数据集是一次性的还是您希望将来会有更多的句子需要使用培训期间开发的相同模型进行标记?每行大约有25个句子,但一旦我进行预处理,它应该小于25个句子。是的,我正在寻找ML或NLP路由,而不是使用正则表达式在数据帧上搜索。只需一次运行即可捕获结果并在需要时增强。不确定NLP/ML算法在您的特定情况下是否比正则表达式更快。可能是其他人想到了一个,但在您的用例中我什么也没想到。@AdnanS好的。我想我得走regex路线了。我刚刚遇到了这个,它可能会帮助你更快地替代regex
some_col    text                                                                tags
abc         Pinocchio and Harry Potter is a famous children's book.             Pinocchio,Harry Potter
def         LOTR was written by J. R. R. Tolkien                                LOTR
ghi         Fordo Baggins is a character in Lord of the Ri...                   Lord of the Rings