👔 Improve sphere word cloud again...

This commit is contained in:
2025-12-27 15:10:01 +08:00
parent 5d3bd1144d
commit 009f66154c

View File

@@ -88,8 +88,9 @@ public class SphereRewindServiceGrpc(
.Take(1000) .Take(1000)
.ToListAsync(); .ToListAsync();
var segmenter = new JiebaSegmenter(); var segmenter = new JiebaSegmenter();
var words = segmenter.CutInParallel(postContents); var words = segmenter.CutForSearchInParallel(postContents);
var allWords = words.SelectMany(w => w); var allWords = words.SelectMany(w => w)
.Where(word => !word.All(c => char.IsPunctuation(c) || char.IsWhiteSpace(c)));
var topWords = allWords var topWords = allWords
.GroupBy(w => w) .GroupBy(w => w)
.Select(g => new { Word = g.Key, Count = g.Count() }) .Select(g => new { Word = g.Key, Count = g.Count() })
@@ -270,5 +271,4 @@ public class SphereRewindServiceGrpc(
Data = GrpcTypeHelper.ConvertObjectToByteString(data), Data = GrpcTypeHelper.ConvertObjectToByteString(data),
}; };
} }
} }