- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有两个列表,它们看起来像这样
<List> ads
[0]
Headline = "Sony Ericsson Arc silver"
[1]
Headline = "Sony Ericsson Play R800I"
<List> feedItems
[0]
Headline = "Sony Ericsson Xperia Arc Silver"
[1]
Headline = "Sony Ericsson Xperia Play R800i Black"
创建新的第三个列表的最简单方法是什么,其中的元素与至少两个 词相互匹配?您能否以 LINQ 方式完成此操作?
第三个列表看起来像这样
[0]
AdHeadline = "Sony Ericsson Arc silver"
MatchingFeed = "Sony Ericsson Xperia Arc Silver"
// etc
我已经尝试遍历第一个列表并使用 Regex.Match 类,如果我找到一个匹配项,我将填充第三个列表 - 我想知道你更喜欢这样做的方式是什么是,以及如何检查最小值。表达式中有 2 个以上的词。
最佳答案
我不确定正则表达式能为这里的聚会带来什么。下面的怎么样?
// Define a helper function to split a string into its words.
Func<string, HashSet<string>> GetWords = s =>
new HashSet<string>(
s.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries)
);
// Pair up each string with its words. Materialize the second one as
// we'll be querying it multiple times.
var aPairs = ads.Select(a => new { Full = a, Words = GetWords(a) });
var fPairs = feedItems
.Select(f => new { Full = f, Words = GetWords(f) })
.ToArray();
// For each ad, select all the feeds that match more than one word.
// Then just select the original ad and feed strings.
var result = aPairs.SelectMany(
a => fPairs
.Where(f => a.Words.Intersect(f.Words).Skip(1).Any())
.Select(f => new { AdHeadline = a.Full, MatchingFeed = f.Full })
);
关于c# - 基于相似性比较字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11134789/
我需要在基于 Java 的应用程序中使用 Wordnet。我想: 搜索同义词集 找到同义词集之间的相似性/相关性 我的应用程序使用 RDF 图,我知道 Wordnet 有 SPARQL 端点,但我想最
假设我们有一个 IEnumerable Collection,其中包含 20 000 人 对象项。那么假设我们创建了另一个 Person 对象。 我们想列出所有与这个人相似的人。这意味着,例如,如果姓
我使用 JAWS 作为普通的 wordnet 来查找单词之间的相似性。 我安装了 wordnet 2.1 并添加了 jar 文件:edu.mit.jwi_2.1.4.jar 和 edu.sussex.
我用这段代码做了一个词嵌入: with open("text.txt",'r') as longFile: sentences = [] single= []
我正在尝试找出确定各种对象或数组之间的共性或相似性的最佳方法,并且有兴趣获得社区的意见。我目前正在用 javascript 构建一个早期研究原型(prototype),我需要采用一种巧妙的方式来比较对
我在将 Flash 游戏转换为 C# 时遇到问题。在 Flash 中我会使用这种语法: public function doMove() { eaze(this).to(actionTime,
我有一批形状为 (bs, m, n) 的向量(即维度为 mxn 的 bs 向量)。对于每个批处理,我想计算第一个向量与其余 (m-1) 个向量的 Jaccard 相似度 例子: a = [ [
如何使用 Whoosh 获取文档的相似性度量? 我想创建一个“相关”特征,对与文档具有高度相似性的其他先前编入索引的文档进行排名。 我是否将文档作为长查询字符串输入?我是否将文档添加到索引并以某种方式
我编写了一个 Python 函数,它接受两个列表,使用 Levenshtein 比较它们并将足够相似的单词合并到一个名为“merged”的列表中。 我如何为超过 6 个列表执行此操作?确保将每个列表与
请原谅我对 Go 的了解非常有限。我有这样的定义 type ErrorVal int const ( LEV_ERROR ErrorVal = iota LEV_WARNING
我正在从事文本分析项目,一次比较两个不同的报告并将结果保存到 pandas 数据框中。 我能够得到 cosine 和 jacard 的相似性,但需要确保我得到正确的度量。作为参数,我使用位于给定文件夹
我是一名优秀的程序员,十分优秀!