def left_token_pos(tl): left = get_tlink_context(tl)[0] try: if left[-1].type == 'WordToken': return left[-1].pos except IndexError: return
def right_token_pos(tl): right = get_tlink_context(tl)[2] try: if right[0].type == 'WordToken': return right[0].pos except IndexError: return
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
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
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
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
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
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
def to_obj_to(tl): mid = get_tlink_context(tl)[1] if len(mid) > 0: if mid[-1].pos == 'TO': return 'true'
def to_obj_from(tl): left = get_tlink_context(tl)[0] if len(left) > 0: if left[-1].pos == 'TO': return 'true'
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
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
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'
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'
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'
def short_mid_concat(tl): if token_dis(tl) <= 3: mid = get_tlink_context(tl)[1] return '_'.join([t.lemma for t in mid])