Return a set of "weak" rule ids made entirely of junk tokens: they can only be matched exactly using an automaton.
(len_legalese, tids_by_rid, _idx)
| 1215 | |
| 1216 | |
| 1217 | def get_weak_rids(len_legalese, tids_by_rid, _idx): |
| 1218 | """ |
| 1219 | Return a set of "weak" rule ids made entirely of junk tokens: they can only |
| 1220 | be matched exactly using an automaton. |
| 1221 | """ |
| 1222 | weak_rids = set() |
| 1223 | weak_rids_add = weak_rids.add |
| 1224 | for rid, tids in enumerate(tids_by_rid): |
| 1225 | if any(t < len_legalese for t in tids): |
| 1226 | continue |
| 1227 | weak_rids_add(rid) |
| 1228 | |
| 1229 | if TRACE: |
| 1230 | tokens_by_tid = _idx.tokens_by_tid |
| 1231 | for rid in sorted(weak_rids): |
| 1232 | rule = _idx.rules_by_rid[rid] |
| 1233 | message = ( |
| 1234 | 'WARNING: Weak rule, made only of frequent junk tokens. ' |
| 1235 | 'Can only be matched exactly:', |
| 1236 | rule.identifier, |
| 1237 | u' '.join(tokens_by_tid[t] for t in tids)) |
| 1238 | logger_debug(u' '.join(message)) |
| 1239 | |
| 1240 | return weak_rids |
| 1241 | |
| 1242 | |
| 1243 | def get_matched_rule_ids(matches, query_run): |
nothing calls this directly
no test coverage detected