9292}
9393
9494JUNK_PATTERNS = [
95- r"^(ok|okay|sure|yes|no|yeah|yep|nope|hmm|hm|ah|oh|uh|um|lol|haha|thanks|thank you|got it|right|cool|nice|great|fine|alright)\s*[.!?]*$" ,
96- r"^(hey|hi|hello|bye|goodbye|cheers|ciao)\s*[.!?]*$" ,
95+ re . compile ( r"^(ok|okay|sure|yes|no|yeah|yep|nope|hmm|hm|ah|oh|uh|um|lol|haha|thanks|thank you|got it|right|cool|nice|great|fine|alright)\s*[.!?]*$" , re . IGNORECASE ) ,
96+ re . compile ( r"^(hey|hi|hello|bye|goodbye|cheers|ciao)\s*[.!?]*$" , re . IGNORECASE ) ,
9797 # web/social media cruft
98- r"©\s*\d{4}" ,
99- r"(terms of service|privacy policy|cookie policy|accessibility|all rights reserved)" ,
100- r"^\s*(trending|trending now|what'?s happening)\s*$" ,
101- r"^\d[\d,\.]+\s*(views|likes|retweets|replies|reposts|followers|following)\s*$" ,
102- r"^(show more|load more|see more|view more|read more)\s*[.!?]*$" ,
103- r"(sports\s*·\s*trending|entertainment\s*·\s*trending|news\s*·\s*trending)" ,
104- r"^relevant\s+(people|chats|posts)\s*$" ,
98+ re . compile ( r"©\s*\d{4}" , re . IGNORECASE ) ,
99+ re . compile ( r"(terms of service|privacy policy|cookie policy|accessibility|all rights reserved)" , re . IGNORECASE ) ,
100+ re . compile ( r"^\s*(trending|trending now|what'?s happening)\s*$" , re . IGNORECASE ) ,
101+ re . compile ( r"^\d[\d,\.]+\s*(views|likes|retweets|replies|reposts|followers|following)\s*$" , re . IGNORECASE ) ,
102+ re . compile ( r"^(show more|load more|see more|view more|read more)\s*[.!?]*$" , re . IGNORECASE ) ,
103+ re . compile ( r"(sports\s*·\s*trending|entertainment\s*·\s*trending|news\s*·\s*trending)" , re . IGNORECASE ) ,
104+ re . compile ( r"^relevant\s+(people|chats|posts)\s*$" , re . IGNORECASE ) ,
105105 # pipe-separated nav lists (e.g. "Terms | Privacy | Cookie")
106- r"^[^|]{1,40}\|[^|]{1,40}\|" ,
106+ re . compile ( r"^[^|]{1,40}\|[^|]{1,40}\|" , re . IGNORECASE ) ,
107107]
108108
109109CODE_PATTERNS = [
110- r"[{}\[\]<>].*[{}\[\]<>]" ,
111- r"^(import |from |def |class |const |let |var |function )" ,
112- r"[a-zA-Z0-9+/]{40,}" ,
113- r"^(/|\\|[A-Z]:\\)" ,
114- r"https?://\S{50,}" ,
110+ re . compile ( r"[{}\[\]<>].*[{}\[\]<>]" ) ,
111+ re . compile ( r"^(import |from |def |class |const |let |var |function )" ) ,
112+ re . compile ( r"[a-zA-Z0-9+/]{40,}" ) ,
113+ re . compile ( r"^(/|\\|[A-Z]:\\)" ) ,
114+ re . compile ( r"https?://\S{50,}" ) ,
115115]
116116
117117META_PATTERNS = [
118- r"^(just for context|for reference|fyi|note:|update:)" ,
119- r":$" ,
120- r"^(explain|tell me about|describe|show me|help me with)\s" ,
118+ re . compile ( r"^(just for context|for reference|fyi|note:|update:)" , re . IGNORECASE ) ,
119+ re . compile ( r":$" ) ,
120+ re . compile ( r"^(explain|tell me about|describe|show me|help me with)\s" , re . IGNORECASE ) ,
121121]
122122
123123
124- def is_quality_sentence (text : str , config : QualityConfig = QualityConfig () ) -> bool :
124+ def is_quality_sentence (text : str , config : QualityConfig | None = None ) -> bool :
125125 """
126126 10-layer quality gauntlet. Returns True if sentence should be stored.
127127
@@ -130,6 +130,9 @@ def is_quality_sentence(text: str, config: QualityConfig = QualityConfig()) -> b
130130
131131 Pass config.enabled=False to store everything (some use cases want this).
132132 """
133+ if config is None :
134+ config = QualityConfig ()
135+
133136 if not config .enabled :
134137 return True
135138
@@ -143,17 +146,17 @@ def is_quality_sentence(text: str, config: QualityConfig = QualityConfig()) -> b
143146 # 2. Junk / filler / acknowledgments
144147 text_lower = text_clean .lower ().strip (".,!? " )
145148 for pattern in JUNK_PATTERNS :
146- if re .match (pattern , text_lower , re . IGNORECASE ):
149+ if pattern .match (text_lower ):
147150 return False
148151
149152 # 3. Code / credentials / file paths
150153 for pattern in CODE_PATTERNS :
151- if re .search (pattern , text_clean ):
154+ if pattern .search (text_clean ):
152155 return False
153156
154157 # 4. Meta-text / vague commands
155158 for pattern in META_PATTERNS :
156- if re .match (pattern , text_lower , re . IGNORECASE ):
159+ if pattern .match (text_lower ):
157160 return False
158161
159162 # 5. Pronoun-heavy fragments (likely context-free without surrounding text)
0 commit comments