首页 > 解决方案 > 使用 SPACY 查找匹配的公司名称

问题描述

例如,我有两个表,如下所示:(实际上我有巨大的数据集)

表格1:

|COMPANY|ADDRESS    |
|BOSCH  |18th main  |
|Infra  |19th main  |
|AB     |21st main  |

表2:

|COMPANY|ADDRESS    |
|BOSCH  |18th main  |
|Infran |20th main  |
|AB     |21st main  |

现在,我如何使用 SPACY 来匹配两个表中的公司名称?要求是,如果 table1.company 与 table2.company 匹配,则结果应为 true,否则为 false。在地址的情况下也一样。

输出:匹配:

BOSCH BOSCH True 
AB    AB    True 

无与伦比:

Infra Infran False

也需要同样的地址

我已经尝试通过以下链接:

https://www.geeksforgeeks.org/python-word-similarity-using-spacy/

https://www.geeksforgeeks.org/python-named-entity-recognition-ner-using-spacy/

https://www.machinelearningplus.com/spacy-tutorial-nlp/#stringstohashes

我尝试使用 spacy 的示例代码:

import spacy
nlp = spacy.load('en_core_web_lg')
print("Enter two space-separated words")
words = input()
tokens = nlp(words)

for token in tokens:
  # Printing the following attributes of each token.
  # text: the word string, has_vector: if it contains
  # a vector representation in the model, 
  # vector_norm: the algebraic norm of the vector,
  # is_oov: if the word is out of vocabulary.
  print(token.text, token.has_vector, token.vector_norm, token.is_oov)

token1, token2 = tokens[0], tokens[1]
print("Similarity:", token1.similarity(token2))

上面的代码给了我给定输入之间的相似度分数。

有人可以帮助我了解如何使用 SPACY 在 table2 中找出 table1 的匹配公司名称吗?或者有没有其他方法可以在 PYTHON 中找到匹配的公司名称及其地址?

标签: python-3.xnlpspacy

解决方案


推荐阅读