Return a sequence of LicenseMatch by matching the query_tokens sequence against the idx index.
(idx, query_run, **kwargs)
| 57 | |
| 58 | |
| 59 | def hash_match(idx, query_run, **kwargs): |
| 60 | """ |
| 61 | Return a sequence of LicenseMatch by matching the query_tokens sequence |
| 62 | against the idx index. |
| 63 | """ |
| 64 | logger_debug('match_hash: start....') |
| 65 | matches = [] |
| 66 | query_hash = tokens_hash(query_run.tokens) |
| 67 | rid = idx.rid_by_hash.get(query_hash) |
| 68 | if rid is not None: |
| 69 | rule = idx.rules_by_rid[rid] |
| 70 | itokens = idx.tids_by_rid[rid] |
| 71 | len_legalese = idx.len_legalese |
| 72 | logger_debug('match_hash: Match:', rule.identifier) |
| 73 | qspan = Span(range(query_run.start, query_run.end + 1)) |
| 74 | ispan = Span(range(0, rule.length)) |
| 75 | hispan = Span(p for p in ispan if itokens[p] < len_legalese) |
| 76 | match = LicenseMatch( |
| 77 | rule=rule, |
| 78 | qspan=qspan, |
| 79 | ispan=ispan, |
| 80 | hispan=hispan, |
| 81 | query_run_start=query_run.start, |
| 82 | matcher=MATCH_HASH, |
| 83 | matcher_order=MATCH_HASH_ORDER, |
| 84 | query=query_run.query, |
| 85 | ) |
| 86 | matches.append(match) |
| 87 | return matches |
nothing calls this directly
no test coverage detected