对相似的单词短语进行分类

Categorise similar-like word phrases

我有一组单词短语,我想按照下面的示例对它们进行分类。

示例:

adaptive and intelligent educational system
adaptive and intelligent tutoring system
adaptive educational system

对于人类来说,很容易理解上述3个单词短语应该归为一类。

有什么简单的方法吗?

目前,我正在使用如下使用编辑距离的亲和力传播聚类算法。

words = np.asarray(words) #So that indexing with a list will work
lev_similarity = -1*np.array([[distance.levenshtein(w1,w2) for w1 in words] for w2 in words])

affprop = sklearn.cluster.AffinityPropagation(affinity="precomputed", damping=0.5)
affprop.fit(lev_similarity)
for cluster_id in np.unique(affprop.labels_):
    exemplar = words[affprop.cluster_centers_indices_[cluster_id]]
    cluster = np.unique(words[np.nonzero(affprop.labels_==cluster_id)])
    cluster_str = ", ".join(cluster)
    print(" - *%s:* %s" % (exemplar, cluster_str))

但是,我没有得到想要的输出。因此,请给我一个合适的方法来获得我想要的结果。

编辑距离适用于字符。

从这个角度来看,"educational" 和 "tutoring" 差不多。

如果要按语义相似性进行聚类,请不要使用字符级相似性。

不幸的是,语义相似性很难。您将需要以某种方式使用庞大的知识库。例如,使用整个万维网了解 "tutoring" 和 "educational" 是相关的。或者你可以尝试例如WordNet 等