(review)
| 52 | # 4) count the distinct words in the list, map it to a dictionary. |
| 53 | |
| 54 | def instance(review): # "Great book!" |
| 55 | v = tag(review) # [("Great", "JJ"), ("book", "NN"), ("!", "!")] |
| 56 | v = [word for (word, pos) in v if pos in ("JJ", "RB") or word in ("!")] |
| 57 | v = [predicative(word) for word in v] # ["great", "!", "!"] |
| 58 | v = count(v) # {"great": 1, "!": 1} |
| 59 | return v |
| 60 | |
| 61 | # We can add any kind of features to a custom instance dict. |
| 62 | # For example, in a deception detection experiment |
no test coverage detected
searching dependent graphs…