Yield tuples of matched positions as (rid, qstart, qend, istart, iend) such that these start and end positions are suitable as range() arguments. Match `tokens` sequence of token ids starting at the `qbegin` absolute query start position position using the `automaton`.
(tokens, qbegin, automaton)
| 160 | |
| 161 | |
| 162 | def get_matched_positions(tokens, qbegin, automaton): |
| 163 | """ |
| 164 | Yield tuples of matched positions as (rid, qstart, qend, istart, iend) such |
| 165 | that these start and end positions are suitable as range() arguments. Match |
| 166 | `tokens` sequence of token ids starting at the `qbegin` absolute query start |
| 167 | position position using the `automaton`. |
| 168 | """ |
| 169 | for qend, matched_rule_segments in get_matches(tokens, qbegin, automaton): |
| 170 | for rid, istart, iend in matched_rule_segments: |
| 171 | if TRACE_DEEP: |
| 172 | logger_debug(' #EXACT get_matches: found match to rule:', rid) |
| 173 | iend = iend + 1 |
| 174 | match_len = iend - istart |
| 175 | qstart = qend - match_len |
| 176 | yield rid, qstart, qend, istart, iend |
| 177 | |
| 178 | |
| 179 | def get_matches(tokens, qbegin, automaton): |
no test coverage detected