root/gapp/pangramming/utils.py
| Revision 7cdcb8409bf6c806d19d3c1816a27e8eb22cff9a, 457 bytes (checked in by Antonio Cavedoni <antonio@…>, 8 months ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | import re |
| 2 | |
| 3 | pangram_r = re.compile(r'[^A-Za-z]', re.UNICODE) |
| 4 | tags_r = re.compile(r'\<.*?\>|^http://(?:.*?)\.[a-z]{1,6}', re.UNICODE) |
| 5 | |
| 6 | def bare_pangram(pangram): |
| 7 | return pangram_r.sub('', pangram.lower()) |
| 8 | |
| 9 | def is_pangram(pangram): |
| 10 | alphabet = 'abcdefghijklmnpqrstuvwxyz' |
| 11 | for letter in alphabet: |
| 12 | if letter not in pangram.lower(): |
| 13 | return False |
| 14 | else: |
| 15 | return True |
| 16 | |
| 17 | def strip_tags(input): |
| 18 | return tags_r.sub('', input) |
Note: See TracBrowser
for help on using the browser.