You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2026/07/07 09:48:50 UTC
(incubator-ponymail-foal) branch master updated: Filter stopwords from word cloud results (#318)
This is an automated email from the ASF dual-hosted git repository.
sebbASF pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
The following commit(s) were added to refs/heads/master by this push:
new cda03a4 Filter stopwords from word cloud results (#318)
cda03a4 is described below
commit cda03a4628b86fce0e1536fb51fe77ff99eb6dda
Author: Rich Bowen <rb...@rcbowen.com>
AuthorDate: Tue Jul 7 05:48:44 2026 -0400
Filter stopwords from word cloud results (#318)
The significant_terms aggregation can surface common English stopwords
and email-specific noise (re, fwd, by) because on mailing lists these
terms are frequent in both foreground and background sets. Filter the
returned buckets against a stopword set and drop terms shorter than 3
characters.
Closes #196
---
server/plugins/messages.py | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/server/plugins/messages.py b/server/plugins/messages.py
index 4e834d8..cfd9136 100644
--- a/server/plugins/messages.py
+++ b/server/plugins/messages.py
@@ -436,6 +436,28 @@ async def wordcloud(session: plugins.session.SessionObject, query_defuzzed: dict
Wordclouds via significant terms query in ES
The query must include a private mail filter if necessary
"""
+ # Filter out common stopwords and email-specific noise from the word cloud.
+ # OpenSearch's significant_terms can still surface these because on mailing
+ # lists, terms like "re" (from Re: subjects) are statistically frequent in
+ # both foreground and background sets.
+ STOPWORDS = frozenset({
+ # English stopwords
+ "a", "an", "and", "are", "as", "at", "be", "but", "by", "for",
+ "if", "in", "into", "is", "it", "no", "not", "of", "on", "or",
+ "such", "that", "the", "their", "then", "there", "these", "they",
+ "this", "to", "was", "will", "with", "from", "has", "have", "had",
+ "been", "would", "could", "should", "do", "does", "did", "can",
+ "may", "might", "shall", "we", "you", "he", "she", "its", "our",
+ "your", "my", "me", "him", "her", "us", "them", "who", "what",
+ "which", "when", "where", "how", "all", "each", "every", "both",
+ "few", "more", "most", "other", "some", "any", "only", "own",
+ "same", "so", "than", "too", "very", "just", "about", "above",
+ "after", "again", "also", "because", "before", "between", "down",
+ "during", "here", "new", "now", "off", "old", "one", "out",
+ "over", "still", "under", "up", "well",
+ # Email-specific junk (Re:, Fwd:, Fw:, Aw: prefixes after tokenization)
+ "re", "fwd", "fw", "aw",
+ })
wc = {}
try:
@@ -451,7 +473,9 @@ async def wordcloud(session: plugins.session.SessionObject, query_defuzzed: dict
)
for hit in res["aggregations"]["cloud"]["buckets"]:
- wc[hit["key"]] = hit["doc_count"]
+ term = hit["key"]
+ if term not in STOPWORDS and len(term) > 2:
+ wc[term] = hit["doc_count"]
except plugins.database.Timeout: # If we time out, just return empty WC.
pass