使用 python 或 SQL 根据相似的句子对行进行排名?
如何根据行值对数据框进行排名。即我有一行包含文本数据想要提供基于相似性的排名?下面是示例数据集,原始数据集包含大约 100000 条记录。请参考此问题对句子匹配进行排序
有一些方法已被测试用于对相似句子小数据集进行聚类,请参阅上面的附加链接。输出我们需要对相似的句子进行聚类,无论长度如何。
示例 - 要使用 python 匹配句子,感谢 laurent。如果句子长度较短,下面的代码效果很好
df = (
df
.assign(
match=df["text"].map(
lambda x: [
i
for i, text in enumerate(df["text"])
if textdistance.jaro_winkler(x, text) >= 0.9
]
)
)
.sort_values(by="match")
.drop(columns="match")
)
How to rank the data frame based on the row value. i.e I have a row that contains text data want to provide the rank based on the similarity? Below is the sample datasets,the original datasets contain around 100000 records. Kindly refer this question for Sort sentence matching
There are some methods are tested to cluster the similar sentences small datasets please the refer the above attached link . Output we need to cluster the similar sentences irrespective the length.
Example - To match sentence using python , thanks to laurent. The below code works well if the sentence length is less
df = (
df
.assign(
match=df["text"].map(
lambda x: [
i
for i, text in enumerate(df["text"])
if textdistance.jaro_winkler(x, text) >= 0.9
]
)
)
.sort_values(by="match")
.drop(columns="match")
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以试试这个:
You could try this: