Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fixing WordNetCorpusReader object has no attribute _LazyCorpusLoader_… (#13600)

apps-lycusinc8b984c9d5f7c
diff --git a/rag/nlp/synonym.py b/rag/nlp/synonym.py
index 0956ee8e83..53a4ce1f1c 100644
--- a/rag/nlp/synonym.py
+++ b/rag/nlp/synonym.py
@@ -23,6 +23,13 @@ from nltk.corpus import wordnet
from common.file_utils import get_project_base_directory
+# Forces NLTK to load the corpus synchronously once, preventing concurrent tasks
+# from triggering the lazy-loading race condition.
+try:
+ wordnet.ensure_loaded()
+except Exception:
+ logging.warning("Fail to load wordnet.ensure_loaded()")
+
class Dealer:
def __init__(self, redis=None):