Skip to content

Commit 5064164

Browse files
committed
Support Universal Tags as input
1 parent 1bf5dee commit 5064164

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

nltk/corpus/reader/wordnet.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2139,8 +2139,10 @@ def tag2pos(self, tag, tagset="en-ptb"):
21392139
>>> print([(word, tag, nltk.corpus.wordnet.tag2pos(tag)) for word, tag in tagged])
21402140
[('Banks', 'NNS', 'n'), ('check', 'VBP', 'v'), ('books', 'NNS', 'n'), ('.', '.', None)]
21412141
"""
2142+
if tagset != "universal":
2143+
tag = map_tag(tagset, "universal", tag)
21422144

2143-
return UNIVERSAL_TAG_TO_WN_POS.get(map_tag(tagset, "universal", tag), None)
2145+
return UNIVERSAL_TAG_TO_WN_POS.get(tag, None)
21442146

21452147
#############################################################
21462148
# Create information content from corpus

0 commit comments

Comments
 (0)