【问题标题】:Tf-Idf using cosine similarity for document similarity of almost similar sentence使用余弦相似度的 Tf-Idf 用于几乎相似句子的文档相似度
【发布时间】:2017-10-19 12:13:04
【问题描述】:

我正在使用具有余弦相似度的 tf-idf 来计算描述(句子)相似度

输入字符串:

    3/4x1/2x3/4 blk mi tee

以下是我需要在其中找到与输入字符串相似的句子

      smith-cooper® 33rt1 reducing pipe tee 3/4 x 1/2 x 3/4 in npt 150 lb malleable iron black
      smith-cooper® 33rt1 reducing pipe tee 1 x 1/2 x 3/4 in npt 150 lb malleable iron black
      smith-cooper® 33rt1 reducing pipe tee 1-1/4 x 1 x 3/4 in npt 150 lb malleable iron black 
      smith-cooper® 33rt1 reducing pipe tee 1-1/2 x 3/4 x 1-1/2 in npt 150 lb malleable iron black
      smith-cooper® 33rt1 reducing pipe tee 1-1/2 x 1-1/4 x 1 in npt 150 lb malleable iron black 
      smith-cooper® 33rt1 reducing pipe tee 2 x 2 x 3/4 in npt 150 lb malleable iron black 
      smith-cooper® 33rt1 reducing pipe tee 2 x 1-1/2 x 1-1/4 in npt 150 lb malleable iron black
      smith-cooper® 33rt1 reducing pipe tee 2-1/2 x 2 x 2 in npt 150 lb malleable iron black
      smith-cooper® 33rt1 reducing pipe tee 3 x 3 x 2 in npt 150 lb malleable iron black

由于句子几乎相似,我使用 tf-idf 方法,它对出现在所有文档( Idf )中的单词给予低分,而对唯一单词给予更高的分数,这有助于更容易地找到相似的文档。

有没有比这更好的方法?

【问题讨论】:

    标签: tf-idf cosine-similarity sentence-similarity


    【解决方案1】:

    当然还有其他方法,例如潜在语义分析,但最有效的方法完全取决于您的数据/语料库。根据我的经验,TF-IDF 是一个很好的起点。更复杂的方法可能不如 TF-IDF,或者相对于它们的复杂性提供的改进可以忽略不计。

    使用 TF-IDF 进行实验的是不同大小的 n-gram,以及针对您的语料库的其他预处理策略。鉴于您的示例,您可能不想基于单词边界拆分来标记单词;也许您想将其中一些句子成分视为一个术语,例如3/4 x 1/2 x 3/4 作为一个术语。我会先尝试不同大小的 n-gram。

    在您的示例中,除了测量/尺寸之外,句子是相同的。如果此样本具有代表性,您可能需要更多地考虑如何测量这些测量值之间的距离。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-20
      • 2020-02-20
      • 2017-02-03
      • 2014-02-25
      • 2013-02-03
      • 2010-12-31
      • 1970-01-01
      相关资源
      最近更新 更多