Last active
October 12, 2015 15:08
-
-
Save language-engineering/4045411 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
example_dict = {} #creating an empty dictionary | |
# Only need to do this if we haven't already seen 'blue' | |
if 'blue' not in example_dict: | |
example_dict["blue"] = set() #Mapping "blue" to an empty set | |
example_dict["blue"].add("JJ") #Adding "JJ" to "blue"'s empty set | |
example_dict["blue"].add("NN") #Adding "NN" to "blue"'s empty set | |
#if you call the above line twice, only one "NN" will be in the set, because sets don't duplicate elements. | |
print len(example_dict["blue"]) #Print the size of "blue"s tag set, which is its simple ambiguity | |
ambiguities = {} #new dictionary that's going to hold the ambiguities of tokens | |
for token, tagset in example_dict.iteritems(): #iterate over all key-value pairs in our dict | |
ambiguities[token] = len(tagset) | |
print ambiguities | |
# once you have written simple_pos_ambiguity you can do the following... | |
ambiguities = simple_pos_ambiguity() | |
print ambiguities["blue"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment