AllWordIDsAndWeightings
是搜索查询中出现的字词的Dictionary<int, double>
唯一ID,以及相应的权重。
给出以下查询:
returnedObjectIDs = new List<int>(db.WordObjectMaps
.Where(c =>
c.ForObjectTypeID == TopicObjectTypeID
&& AllWordIDsAndWeightings.Select(w=> w.Key).ToList().Contains(c.WordID)
)
.GroupBy(c => c.ForObjectID)
.Select(c => c.Key)
);
我想修改它以便:
group by语句包含每个单词的word frequency * word weighting
之和。然后我可以通过此值降序排序并获取最高n
条记录。
这可能吗?
答案 0 :(得分:0)
returnedObjectIDs = new List<int>(db.WordObjectMaps
.Where(c =>
c.ForObjectTypeID == TopicObjectTypeID
&& AllWordIDsAndWeightings.ContainsKey(c.WordID)
)
.Select(c => new { Word = c, Weight = AllWordIDsAndWeightings[c.WordID])
.GroupBy(c => x.Word.Value * c.Weight) // replace with your condition
.Select(c => c.Key)
);