如何计算两个字符串之间的相等字数?

Mar*_*rio 1 xpath xquery

如何计算出现在两个字符串中的单词数?

我在考虑这样的事情

      let $nequalwords := count($item[text() eq $speech])
Run Code Online (Sandbox Code Playgroud)

做这个的最好方式是什么?

我想与两个人for逐字逐句比较,但我不知道是否有更好的方法来做到这一点.

ada*_*ter 5

如何在白色空间上分割字符串,以便最终得到单词,然后创建一个字符串序列并删除那些不明显的字符串,即那些出现在两个字符串中的字符串,然后从所有单词的计数中减去它你知道两个字符串中出现了多少个单词.例如:

  let $distinct-words1 := distinct-values(tokenize($string1, "\s+"))
  let $distinct-words2 := distinct-values(tokenize($string2, "\s+"))
  let $all-words := ($distinct-words1, $distinct-words2)
  return
    count($all-words) - count(distinct-values($all-words))
Run Code Online (Sandbox Code Playgroud)