【问题标题】:Index of the matched words of the given two text给定两个文本的匹配词的索引
【发布时间】:2018-12-08 15:57:24
【问题描述】:

我一直在努力寻找给定文档中较低级别的临床术语,无论是完全相同的单词还是不同的单词但含义相同。我对给定文本使用余弦相似度匹配与我必须匹配的每个术语,我确实得到了它与给定文本匹配程度的值最高 cos 值给了我确切的值。

sent_list = process.SBD("The patient has been given paracetamol for fever in interval of every two hour. There has been sever headache and abnorm of the labor. Continuation of these medicine might lead to abdomen has been crushing.")

输出: [['Arenaviral haemorrhagic fever'], ['Abnormal labor'], ['Abdomen crushing']]

但我还需要获取文本中匹配的单词的索引 获取给定文本中匹配的单词索引的任何算法。

【问题讨论】:

  • 是 a 在 b 中的索引。

标签: python nlp cosine-similarity


【解决方案1】:

我希望这可以帮助你交配,如果没有,这就是你想要实现的目标 这就是我理解你正在尝试做的事情

a = 'this is a test of getting the words indexes'

b = [['this is a'],[ 'the words']]
for i in b:
    #using the lower() so there is no a case mismatch
    if ''.join(i).lower() in a.lower():
        print(b.index(i))

【讨论】:

  • ['this is a'] 在给定句子中的顺序可能与我们正在检查的顺序不同,但如果它出现在 ['this thing is a'] 中,那么我将需要所有单词的索引。
猜你喜欢
  • 2021-10-25
  • 1970-01-01
  • 2016-05-10
  • 2019-02-08
  • 1970-01-01
  • 2013-11-22
  • 2018-09-08
  • 2015-02-12
  • 2013-10-29
相关资源
最近更新 更多