计算两个句子之间的语法相似度

Calculating grammar similarity between two sentences

我正在制作一个程序,提供一些用户必须学习更多的英语句子。

例如:

First, I provide a sentence "I have to go school today" to user. Then if the user wants to learn more sentences like that, I find some sentences which have high grammar similarity with that sentence.

我认为提供句子的唯一方法是计算相似度。

有没有办法计算两个句子之间的语法相似度?

或者是否有更好的方法来制作该算法?

如有任何意见或建议,我们将不胜感激。谢谢。

我解决此问题的方法是使用 NLTK 之类的工具进行 词性标注,并将您的短语的树结构与您的短语进行比较数据库。

否则,如果您已有训练数据集,请使用 WEKA 使用机器学习方法来连接短语。

您可以将句子解析为成分树或依存树,并使用这些表示形式来制定某种形式的查询,您可以使用该查询来查找具有相似结构的候选句子。

您可以从 Stanford NLP 查看此可用工具:

Tregex is a utility for matching patterns in trees, based on tree relationships and regular expression matches on nodes (the name is short for "tree regular expressions"). Tregex comes with Tsurgeon, a tree transformation language. Also included from version 2.0 on is a similar package which operates on dependency graphs (class SemanticGraph, called semgrex.