Load all regex patterns from a JSONL file.
(self, jsonl_file)
| 22 | return None |
| 23 | |
| 24 | def load_patterns(self, jsonl_file): |
| 25 | """Load all regex patterns from a JSONL file.""" |
| 26 | patterns = [] |
| 27 | with open(jsonl_file, 'r', encoding='utf-8') as file: |
| 28 | for line in file: |
| 29 | rule = json.loads(line.strip()) |
| 30 | patterns.append({'name': rule['name'], 'id': rule['id'], 'pattern': self.compile_pattern(rule['pattern'])}) # Precompile regex |
| 31 | return patterns |
| 32 | |
| 33 | async def check_document(self, document): |
| 34 | """Check document against regex rules asynchronously.""" |
no test coverage detected