70
70
71
71
POS_LIST = [NOUN , VERB , ADJ , ADV ]
72
72
73
+ # Convert from Universal Tags (Petrov et al., 2012) to Wordnet Pos
74
+ UTAG2WN_POS = {"NOUN" : "n" , "VERB" : "v" , "ADJ" : "a" , "ADV" : "r" }
75
+
73
76
# A table of strings that are used to express verb frames.
74
77
VERB_FRAME_STRINGS = (
75
78
None ,
@@ -2108,7 +2111,7 @@ def filter_forms(forms):
2108
2111
# 2. Return all that are in the database (and check the original too)
2109
2112
return filter_forms ([form ] + forms )
2110
2113
2111
- def tag2pos (self , tag , tagset = "en-ptb" ) -> Optional [ str ] :
2114
+ def tag2pos (self , tag , tagset = "en-ptb" ):
2112
2115
"""
2113
2116
Convert a tag from one of the tagsets in nltk_data/taggers/universal_tagset to a
2114
2117
WordNet Part-of-Speech, using Universal Tags (Petrov et al., 2012) as intermediary.
@@ -2119,7 +2122,7 @@ def tag2pos(self, tag, tagset="en-ptb") -> Optional[str]:
2119
2122
tagset (str): The tagset of the input tag. Defaults to "en-ptb".
2120
2123
2121
2124
Returns:
2122
- Optional[str]: The corresponding WordNet POS tag ('n', 'v', 'a', 'r') or None
2125
+ The corresponding WordNet POS tag ('n', 'v', 'a', 'r') or None
2123
2126
if the tag cannot be mapped to a WordNet POS.
2124
2127
2125
2128
Example:
0 commit comments