-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparser.py
More file actions
24 lines (17 loc) · 734 Bytes
/
parser.py
File metadata and controls
24 lines (17 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import stanfordparser
class Parser:
"""Parses the text using stanford-parser"""
def __init__(self):
self.__parsedText = ""
self.__mentionPOSMap = {}
def process(self, text):
parser = stanfordparser.Parser()
self.__parsedText = parser.parseToStanfordDependencies(text)
for key in self.__parsedText.tokensToPosTags.keys():
self.__mentionPOSMap[key.range] = self.__parsedText.tokensToPosTags[key]
def getDependencies(self):
"""Returns dependencies list"""
return self.__parsedText.dependencies
def getMentionPOSMap(self):
"""Returns dictionary of token to POS tag"""
return self.__mentionPOSMap