Beispiel #1
0
def left_token_pos(tl):
    left = get_tlink_context(tl)[0]
    try:
        if left[-1].type == 'WordToken':
            return left[-1].pos
    except IndexError:
        return
Beispiel #2
0
def right_token_pos(tl):
    right = get_tlink_context(tl)[2]
    try:
        if right[0].type == 'WordToken':
            return right[0].pos
    except IndexError:
        return
Beispiel #3
0
def mid_wp(tl):
    mid = get_tlink_context(tl)[1]
    buf = []
    for t in mid:
        if t.pos[:2] == 'WP':
            buf.append(t.lemma)
    return buf
Beispiel #4
0
def mid_wrb(tl):
    mid = get_tlink_context(tl)[1]
    buf = []
    for t in mid:
        if t.pos == 'WRB':
            buf.append(t.lemma)
    return buf
Beispiel #5
0
def mid_vb_pos(tl):
    mid = get_tlink_context(tl)[1]
    buf = []
    for t in mid:
        if t.pos[:2] == 'VB':
            buf.append(t.pos)
    return buf
Beispiel #6
0
def right_prefix(tl):
    right = get_tlink_context(tl)[2]
    right = ' '.join([t.form.lower() for t in right])
    for p in ['pre', 'post', 'inter']:
        if p in right:
            return p
Beispiel #7
0
def mid_prefix(tl):
    mid = get_tlink_context(tl)[1]
    mid = ' '.join([t.form.lower() for t in mid])
    for p in ['pre', 'post', 'inter']:
        if p in mid:
            return p
Beispiel #8
0
def left_prefix(tl):
    left = get_tlink_context(tl)[0]
    left = ' '.join([t.form.lower() for t in left])
    for p in ['pre', 'post', 'inter']:
        if p in left:
            return p
Beispiel #9
0
def to_obj_to(tl):
    mid = get_tlink_context(tl)[1]
    if len(mid) > 0:
        if mid[-1].pos == 'TO':
            return 'true'
Beispiel #10
0
def to_obj_from(tl):
    left = get_tlink_context(tl)[0]
    if len(left) > 0:
        if left[-1].pos == 'TO':
            return 'true'
Beispiel #11
0
def prep_obj_to(tl):
    mid = get_tlink_context(tl)[1]
    if len(mid) > 0:
        if mid[-1].pos == 'IN':
            #return 'true'
            return mid[-1].lemma
Beispiel #12
0
def prep_obj_from(tl):
    left = get_tlink_context(tl)[0]
    if len(left) > 0:
        if left[-1].pos == 'IN':
            #return 'true'
            return left[-1].lemma
Beispiel #13
0
def wh_mid(tl):
    mid = get_tlink_context(tl)[1]
    if len(mid) == 1 and mid[0].pos[:2] in ['WD', 'WP', 'WR']:
        #return mid[0].lemma
        return 'true'
Beispiel #14
0
def prep_mid(tl):
    mid = get_tlink_context(tl)[1]
    if len(mid) == 1 and mid[0].pos[:2] in ['IN', 'TO']:
        #return mid[0].lemma
        return 'true'
Beispiel #15
0
def conj_mid(tl):
    mid = get_tlink_context(tl)[1]
    if len(mid) == 1 and mid[0].pos[:2] == 'CC':
        #return mid[0].lemma
        return 'true'
Beispiel #16
0
def short_mid_concat(tl):
    if token_dis(tl) <= 3:
        mid = get_tlink_context(tl)[1]
        return '_'.join([t.lemma for t in mid])