简体   繁体   English

javascript:返回两个字符串之间的字符串相似度分数

[英]javascript: return a string similarity score between two strings

Is there a library or a certain technique to measure similarity between two strings in Javascript? 是否有一个库或某种技术来测量Javascript中两个字符串之间的相似性? Would levensctein distance be relevant use here? levensctein距离是否在这里有用?

for example 例如

some/dir/index[3]/out
some/dir/index[4]/out

should return a decimal score indicating how close the strings are. 应该返回一个十进制分数,指示字符串的接近程度。

vs VS

some/dir/index[3]/out
some/dir/index[3]/out/more/dir

should represent a much further apart in similarity. 应该在相似性上代表更大的距离。

Here is reference to a library called jsdifflib . 这里是对名为jsdifflib的库的引用

Here is a demo which gives this. 是一个演示的例子。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 javascript 中的两个字符串之间替换字符串? - How to replace string between two strings in javascript? 在Javascript中获取两个字符串之间的字符串 - Get a string between two strings in Javascript 在 Javascript 或 jQuery 中的两个字符串之间查找字符串 - Find string between two strings in Javascript or jQuery 如何使用 JavaScript 语言比较两个对象并返回一个介于 0 和 100 之间的数字,表示相似度的百分比作为结果 - How to compare two objects using JavaScript language and return a number between 0 and 100 representing the percentage of similarity as the result 我需要比较两个字符串(或数组)并返回它们的相似度百分比,而不管它们的顺序 - I need to compare two strings (or arrays) and return their % of similarity regardless of their order 如何检查一个javascript字符串是否在其他两个字符串之间 - How to check if a javascript string is between two other strings 两个字符串之间的JavaScript Regexp而不捕获第一个字符串 - JavaScript Regexp between two strings without capturing first string 用javascript中的正则表达式匹配其他两个字符串之间的字符串 - Match a string between two other strings with regex in javascript Javascript两个字符串之间的get字符串中的正则表达式错误 - Javascript Regular expression error in get string between two strings 通过JavaScript获取两个字符串之间的字符串值 - Get String value between two strings through javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM