コード例 #1
0
def get_adv(sent, adv):
    ##takes in an adverb, finds it in the dependency, pulls out everything
    ##it governs
    verb = None
    for node in sent:
        if node['dependent'] == adv:
            nodes = sisters.get_nodes(sent, node['governor'])[1]
            verb = node['governor']
    return (verb, nodes)
コード例 #2
0
def get_negs(sent):
    ##looks for a negation node, then gets all nodes governed by its governor
    ##which is, presumably, the main verb or the negated verb
    verb = None
    for node in sent:
        if node['relation'] == "neg":
            nodes = sisters.get_nodes(sent, node['governor'])[1]
            verb = node['governor']
    return (verb, nodes)
コード例 #3
0
def get_idiom(sent, gov_dep):
    ##takes a tuple/list consisting of a two-part idiom, the first one should
    ##be the word that governs the other. this could maybe be changed so it
    ##could be a list of any size
    nodes = None
    for node in sent:
        ##finds two nodes with the appropriate relation, pulls everything they
        ##govern, and returns that list
        if node['dependent'].lower() == gov_dep[1] and node['governor'].lower() == gov_dep[0]:
            nodes = sisters.get_nodes(sent, node['governor'])[1]
    return [node for node in nodes if node['dependent'].lower() not in gov_dep]
コード例 #4
0
def get_commit(commit, first, second, tree):
    ##Go through each set of verbs and pull out its dependents
    ##Keep those lists that are committed
    ##Exactly like get_oppose, just swapped you and i and changed to commit regardless
    to_return = []
    for word in first:
        nodes = sisters.get_nodes(word, tree)
        if (nodes[0] != None):
            if nodes[0].word.lower() == 'i':
                to_return.append((word, nodes[1]))
    for word in second:
        nodes = sisters.get_nodes(word, tree)
        if (nodes[0] != None):
            if nodes[0].word.lower() == 'you':
                to_return.append((word, nodes[1]))
    for word in commit:
        nodes = sisters.get_nodes(word, tree)
        if (nodes[0] != None):
            if nodes[0].word.lower() == 'you' or nodes[0].word.lower() == 'i':
                to_return.append((word, nodes[1]))            
    return to_return
コード例 #5
0
def get_oppose(first, second, oppose, tree):
    to_return = []
    ##Go through each set of verbs and pull out its dependents
    ##Keep those lists that are opposed
    for word in first:
        ##Finds nodes that are complements of first-person commit
        nodes = sisters.get_nodes(word, tree)
        if (nodes[0] != None):
            if nodes[0].word.lower() == 'you':
                to_return.append((word, nodes[1]))
    for word in second:
        ##Of second person commmit
        nodes = sisters.get_nodes(word, tree)
        if (nodes[0] != None):
            if nodes[0].word.lower() == 'i':
                to_return.append((word, nodes[1]))
    for word in oppose:
        ##Of either oppose
        nodes = sisters.get_nodes(word, tree)
        if (nodes[0] != None):
            if nodes[0].word.lower() == 'you' or nodes[0].word.lower() == 'i':
                to_return.append((word, nodes[1])) 
    return to_return