Return an iterable of matched rule token strings given a match. Punctuation is removed, spaces are normalized (new line is replaced by a space), case is not preserved.
(match)
| 53 | |
| 54 | |
| 55 | def matched_rule_tokens_str(match): |
| 56 | """ |
| 57 | Return an iterable of matched rule token strings given a match. |
| 58 | |
| 59 | Punctuation is removed, spaces are normalized (new line is replaced by a |
| 60 | space), case is not preserved. |
| 61 | """ |
| 62 | for pos, token in enumerate(match.rule.tokens()): |
| 63 | if match.ispan.start <= pos <= match.ispan.end: |
| 64 | if pos in match.ispan: |
| 65 | yield token |
| 66 | else: |
| 67 | yield '<{}>'.format(token) |