MCPcopy Index your code
hub / github.com/clips/pattern / instance

Function instance

examples/05-vector/06-svm.py:54–59  ·  view source on GitHub ↗
(review)

Source from the content-addressed store, hash-verified

52# 4) count the distinct words in the list, map it to a dictionary.
53
54def 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

Callers 1

06-svm.pyFile · 0.85

Calls 3

tagFunction · 0.90
predicativeFunction · 0.90
countFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…