Exemplo n.º 1
0
Arquivo: api.py Projeto: pocketman/nlp
def parseS(s):
    s = s
    parse = corenlp.raw_parse(s)
    sentences = []
    for l in parse['sentences']:
        sentence = []
        for w in l['words']:
            token = {}
            token['word'] = w[0]
            token['NER'] = w[1]['NamedEntityTag']
            token['POS'] = w[1]['PartOfSpeech']
            token['lemma'] = w[1]['Lemma']
            if token['POS'] == 'FW':
                token['lemma']=token['word']
            if token['word'] == '-LRB-':
                token['word'] = '('
            if token['word'] == '-RRB-':
                token['word'] = ')'
            token['WS'] = simp.getSynset(toString2(l['words']), token['word'])
            sentence.append(token)
        sentences.append(sentence)
    if 'coref' in parse:
        coref(parse['coref'],sentences)
    return sentences
Exemplo n.º 2
0
def getSynset(s,w):
    return simp.getSynset(s,w)

    '''wpos = ""