public:t-malv-15-3:1
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| public:t-malv-15-3:1 [2015/08/20 09:18] – [4. NLTK functions] orvark | public:t-malv-15-3:1 [2024/04/29 13:33] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 109: | Line 109: | ||
| Apply NLTK functions to do the following: | Apply NLTK functions to do the following: | ||
| - | * Import text6 from NLTK | + | * Import text6 from nltk |
| * Show the concordance of the word " | * Show the concordance of the word " | ||
| * Find words occuring in similar contexts to " | * Find words occuring in similar contexts to " | ||
| Line 155: | Line 155: | ||
| </ | </ | ||
| + | ===== Possible Solutions ===== | ||
| + | |||
| + | <code python> | ||
| + | #1 | ||
| + | my_str.upper() | ||
| + | my_int.str() | ||
| + | my_float.is_integer() | ||
| + | my_list.pop(2) | ||
| + | |||
| + | #2 | ||
| + | def is_male(proper_name): | ||
| + | return proper_name[-3: | ||
| + | #return proper_name.endswith(" | ||
| + | |||
| + | # return ... and ' ' in proper_name and proper_name.istitle() and " | ||
| + | # return ... and proper_name.find(' | ||
| + | |||
| + | #3 | ||
| + | def str_replace(text, | ||
| + | for bad in bad_list: | ||
| + | text = text.replace(bad, | ||
| + | return text | ||
| + | |||
| + | #4 | ||
| + | from nltk.book import text6 | ||
| + | text6.concordance(" | ||
| + | text6.similar(" | ||
| + | text6.collocations() | ||
| + | |||
| + | #5 | ||
| + | sorted(w for w in set(text6) if w.startswith(' | ||
| + | sorted(set(w for w in text6 if w.isupper()))) | ||
| + | |||
| + | #6 | ||
| + | rules[" | ||
| + | rules[" | ||
| + | |||
| + | for left, right in rules.items(): | ||
| + | print(left, " | ||
| + | |||
| + | |||
| + | </ | ||
/var/www/cadia.ru.is/wiki/data/attic/public/t-malv-15-3/1.1440062300.txt.gz · Last modified: 2024/04/29 13:32 (external edit)