def __init__(self): self.dict_curr_production_rule = \ util.load_dict_from_file(config.IMPLICIT_ARG1_DICT_CURR_PRODUCTION_RULE) self.dict_prev_curr_production_rule = \ util.load_dict_from_file(config.IMPLICIT_ARG1_DICT_PREV_CURR_PRODUCTION_RULE) self.dict_prev_curr_CP_production_rule = \ util.load_dict_from_file(config.IMPLICIT_ARG1_DICT_PREV_CURR_CP_PRODUCTION_RULE) self.dict_curr_next_CP_production_rule = \ util.load_dict_from_file(config.IMPLICIT_ARG1_DICT_CURR_NEXT_CP_PRODUCTION_RULE)
def entropyMajority(self, predlist, n): entropies = util.load_dict_from_file( 'entropies' ) indices = [] stop = 0 for x in sorted(entropies, key=float, reverse=True): if entropies[x] in self.processed: continue # if prediction == majority vote => continue # first, get list of annotations for this index items = self.dict[self.mapping[entropies[x]-1]['sid']][self.mapping[entropies[x]-1]['tid']]['a'] # next, get majority vote from the annotations counts = [ (items.count(z), z) for z in set(items) ] highest = max(counts)[0] candidates = [count[1] for count in counts if count[0] == highest] # skip if prediction agrees with ??? FIXME! # truth = int(self.tagdict[random.choice(candidates)]) # if truth == predlist[entropies[x]-1]: # continue indices.append(entropies[x]-1) self.processed[entropies[x]] = 1 stop += 1 if stop == n: return indices
def entropy(self, n): entropies = util.load_dict_from_file( 'entropies' ) indices = [] stop = 0 for x in sorted(entropies, key=float, reverse=True): if entropies[x] in self.processed: continue indices.append(entropies[x]-1) self.processed[entropies[x]] = 1 stop += 1 if stop == n: return indices
def __init__(self): self.dict_CString = self.get_dict_CString() self.dict_CPOS = self.get_dict_CPOS() self.dict_prev1 = self.get_dict_prev1() self.dict_prev1POS = self.get_dict_prev1POS() self.dict_prev1_C = self.get_dict_prev1_C() self.dict_prev1POS_CPOS = self.get_dict_prev1POS_CPOS() self.dict_prev2 = self.get_dict_prev2() self.dict_prev2POS = self.get_dict_prev2POS() self.dict_prev2_C = self.get_dict_prev2_C() self.dict_prev2POS_CPOS = self.get_dict_prev2POS_CPOS() self.dict_next1 = self.get_dict_next1() self.dict_next1POS = self.get_dict_next1POS() self.dict_next1_C = self.get_dict_next1_C() self.dict_next1POS_CPOS = self.get_dict_next1POS_CPOS() self.dict_next2 = self.get_dict_next2() self.dict_next2POS = self.get_dict_next2POS() self.dict_next2_C = self.get_dict_next2_C() self.dict_next2POS_CPOS = self.get_dict_next2POS_CPOS() self.dict_conn_to_root_path = util.load_dict_from_file(config.ARG_POSITION_DICT_CONN_TO_ROOT_PATH)
def __init__(self): self.dict_CString = self.get_dict_CString() self.dict_CPOS = self.get_dict_CPOS() self.dict_prev1 = self.get_dict_prev1() self.dict_prev1POS = self.get_dict_prev1POS() self.dict_prev1_C = self.get_dict_prev1_C() self.dict_prev1POS_CPOS = self.get_dict_prev1POS_CPOS() self.dict_prev2 = self.get_dict_prev2() self.dict_prev2POS = self.get_dict_prev2POS() self.dict_prev2_C = self.get_dict_prev2_C() self.dict_prev2POS_CPOS = self.get_dict_prev2POS_CPOS() self.dict_next1 = self.get_dict_next1() self.dict_next1POS = self.get_dict_next1POS() self.dict_next1_C = self.get_dict_next1_C() self.dict_next1POS_CPOS = self.get_dict_next1POS_CPOS() self.dict_next2 = self.get_dict_next2() self.dict_next2POS = self.get_dict_next2POS() self.dict_next2_C = self.get_dict_next2_C() self.dict_next2POS_CPOS = self.get_dict_next2POS_CPOS() self.dict_conn_to_root_path = util.load_dict_from_file( config.ARG_POSITION_DICT_CONN_TO_ROOT_PATH)
def get_dict_CString(self): return util.load_dict_from_file(config.ARG_POSITION_DICT_CSTRING)
def get_left_sibling_category_dict(self): return util.load_dict_from_file(config.EXPLICIT_DICT_LEFT_SIBLING_CATEGORY_PATH)
def get_dict_CON_NT_Path_iLsib(self): return util.load_dict_from_file(config.NT_DICT_CON_NT_Path_iLsib)
def get_dict_CON_LStr(self): return util.load_dict_from_file(config.NT_DICT_CON_LStr)
def get_parent_category_dict(self): return util.load_dict_from_file(config.CONNECTIVE_DICT_PARENT_CATEGORY_PATH)
def get_compressed_CParent_to_root_path_dict(self): return util.load_dict_from_file(config.CONNECTIVE_DICT_COMPRESSED_CPARENT_TO_ROOT_PATH)
def get_dict_NT_Ctx(self): return util.load_dict_from_file(config.NT_DICT_NT_Ctx)
def __init__(self): self.dict_lowercase_verbs = \ util.load_dict_from_file(config.PS_ARG2_DICT_LOWERCASE_VERBS) self.dict_lemma_verbs = \ util.load_dict_from_file(config.PS_ARG2_DICT_LEMMA_VERBS) self.dict_curr_first = \ util.load_dict_from_file(config.PS_ARG2_DICT_CURR_FIRST) self.dict_curr_last = \ util.load_dict_from_file(config.PS_ARG2_DICT_CURR_LAST) self.dict_prev_last = \ util.load_dict_from_file(config.PS_ARG2_DICT_PREV_LAST) self.dict_next_first = \ util.load_dict_from_file(config.PS_ARG2_DICT_NEXT_FIRST) self.dict_prev_last_curr_first = \ util.load_dict_from_file(config.PS_ARG2_DICT_PREV_LAST_CURR_FIRST) self.dict_curr_last_next_first = \ util.load_dict_from_file(config.PS_ARG2_DICT_CURR_LAST_NEXT_FIRST) self.dict_curr_production_rule = \ util.load_dict_from_file(config.PS_ARG2_DICT_CURR_PRODUCTION_RULE) self.dict_con_str = \ util.load_dict_from_file(config.PS_ARG2_DICT_CONN_STR) self.dict_con_lstr = \ util.load_dict_from_file(config.PS_ARG2_DICT_CONN_LSTR) self.dict_conn_position_distance = \ util.load_dict_from_file(config.PS_ARG2_DICT_CONN_POSITION_DISTANCE) self.dict_prev_curr_CP_production_rule = \ util.load_dict_from_file(config.PS_ARG2_DICT_PREV_CURR_CP_PRODUCTION_RULE) self.dict_conn_to_root_path = \ util.load_dict_from_file(config.PS_ARG2_DICT_CONN_TO_ROOT_PATH) self.dict_conn_to_root_compressed_path = \ util.load_dict_from_file(config.PS_ARG2_DICT_CONN_TO_ROOT_COMPRESSED_PATH) self.dict_conn_position = \ util.load_dict_from_file(config.PS_ARG2_DICT_CONN_POSITION) self.dict_conn_is_adjacent_to_conn = \ util.load_dict_from_file(config.PS_ARG2_DICT_CONN_IS_ADJACENT_TO_CONN) self.dict_curr_first_curr_first_lemma_verb = \ util.load_dict_from_file(config.PS_ARG2_DICT_CURR_FIRST_CURR_FIRST_LEMMA_VERB) self.dict_curr_first_lowercased_verb = \ util.load_dict_from_file(config.PS_ARG2_DICT_FIRST_LOWERCASE_VERB) self.dict_curr_first_lemma_verb = \ util.load_dict_from_file(config.PS_ARG2_DICT_FIRST_LEMMA_VERB) self.dict_curr_first_prev_last_parse_path = \ util.load_dict_from_file(config.PS_ARG2_DICT_CURR_FIRST_PREV_LAST_PARSE_PATH) self.dict_CParent_to_root_path_node_names = \ util.load_dict_from_file(config.PS_ARG2_DICT_CPARENT_TO_ROOT_PATH_NODE_NAMES) self.dict_CPOS = \ util.load_dict_from_file(config.PS_ARG2_DICT_CPOS) self.dict_conn_connCtx = \ util.load_dict_from_file(config.PS_ARG2_DICT_CONN_CONNCTX) self.dict_conn_parent_category_Ctx = \ util.load_dict_from_file(config.PS_ARG2_DICT_CONN_PARENT_CATEGORY_CTX) self.dict_conn_curr_first = \ util.load_dict_from_file(config.PS_ARG2_DICT_CONN_CURR_FIRST)
def __init__(self): self.dict_lowercase_verbs = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_LOWERCASE_VERBS) self.dict_lemma_verbs = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_LEMMA_VERBS) self.dict_curr_first = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_CURR_FIRST) self.dict_curr_last = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_CURR_LAST) self.dict_prev_last = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_PREV_LAST) self.dict_next_first = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_NEXT_FIRST) self.dict_prev_last_curr_first = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_PREV_LAST_CURR_FIRST) self.dict_curr_last_next_first = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_CURR_LAST_NEXT_FIRST) self.dict_curr_production_rule = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_CURR_PRODUCTION_RULE) self.dict_prev_curr_production_rule = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_PREV_CURR_PRODUCTION_RULE) self.dict_prev_curr_CP_production_rule = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_PREV_CURR_CP_PRODUCTION_RULE) self.dict_curr_next_CP_production_rule = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_CURR_NEXT_CP_PRODUCTION_RULE) self.dict_prev2_pos_lemma_verb = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_2PREV_POS_LEMMA_VERB) self.dict_curr_first_to_prev_last_path = \ util.load_dict_from_file(config.IMPLICIT_ARG2_DICT_CURR_FIRST_TO_PREV_LAST_PATH)
def get_dict_prev2POS_CPOS(self): return util.load_dict_from_file(config.ARG_POSITION_DICT_PREV2POS_CPOS)
def __init__(self): self.dict_CON_Str = self.get_dict_CON_Str() self.dict_CON_LStr = self.get_dict_CON_LStr() self.dict_NT_Ctx = self.get_dict_NT_Ctx() self.dict_CON_NT_Path = self.get_dict_CON_NT_Path() self.dict_CON_NT_Path_iLsib = self.get_dict_CON_NT_Path_iLsib() self.dict_NT_prev_curr_Path = util.load_dict_from_file(config.NT_DICT_PREV_CURR_PATH) self.dict_CON_POS = util.load_dict_from_file(config.NT_DICT_CON_POS) self.dict_C_Prev = util.load_dict_from_file(config.NT_DICT_C_PREV) self.dict_NT_Name = util.load_dict_from_file(config.NT_DICT_NT_NAME) self.dict_NT_prev_curr_production_rule = util.load_dict_from_file(config.NT_DICT_NT_PREV_CURR_PRODUCTION_RULE) self.dict_nt_ntParent_ctx = util.load_dict_from_file(config.NT_DICT_NT_NTPARENT_CTX) self.dict_CParent_to_root_path = util.load_dict_from_file(config.NT_DICT_CPARENT_TO_ROOT_PATH) self.dict_CParent_to_root_path_node_names = util.load_dict_from_file(config.NT_DICT_CPARENT_TO_ROOT_PATH_NODE_NAMES) self.dict_conn_connCtx = util.load_dict_from_file(config.NT_DICT_CONN_CONNCTX) self.dict_conn_parent_categoryCtx = util.load_dict_from_file(config.NT_DICT_CONN_PARENT_CATEGORYCTX) self.dict_conn_rightSiblingCtx = util.load_dict_from_file(config.NT_DICT_CONN_RIGHTSIBLINGCTX) self.dict_self_category = util.load_dict_from_file(config.NT_DICT_SELF_CATEGORY) self.dict_parent_category = util.load_dict_from_file(config.NT_DICT_PARENT_CATEGORY) self.dict_left_sibling_category = util.load_dict_from_file(config.NT_DICT_LEFT_SIBLING_CATEGORY) self.dict_right_sibling_category = util.load_dict_from_file(config.NT_DICT_RIGHT_SIBLING_CATEGORY) self.dict_NT_Linked_ctx = util.load_dict_from_file(config.NT_DICT_NT_LINKED_CTX) self.dict_NT_to_root_path = util.load_dict_from_file(config.NT_DICT_NT_TO_ROOT_PATH) self.dict_NT_parent_linked_ctx = util.load_dict_from_file(config.NT_DICT_NT_PARENT_LINKED_CTX)
def get_conn_right_sibling_category_dict(self): return util.load_dict_from_file(config.EXPLICIT_DICT_CONN_RIGHT_SIBLING_CATEGORY_PATH)
def get_conn_left_sibling_category_dict(self): return util.load_dict_from_file(config.CONNECTIVE_DICT_CONN_LEFT_SIBLING_CATEGORY_PATH)
def get_left_sibling_category_dict(self): return util.load_dict_from_file( config.EXPLICIT_DICT_LEFT_SIBLING_CATEGORY_PATH)
def get_self_parent_dict(self): return util.load_dict_from_file(config.CONNECTIVE_DICT_SELF_PARENT_CATEGORY_PATH)
def get_self_category_dict(self): return util.load_dict_from_file(config.CONNECTIVE_DICT_SELF_CATEGORY_PATH)
def get_self_left_dict(self): return util.load_dict_from_file(config.CONNECTIVE_DICT_SELF_LEFT_CATEGORY_PATH)
def get_right_sibling_category_dict(self): return util.load_dict_from_file(config.CONNECTIVE_DICT_RIGHT_SIBLING_CATEGORY_PATH)
def get_left_right_dict(self): return util.load_dict_from_file(config.CONNECTIVE_DICT_LEFT_RIGHT_CATEGORY_PATH)
def get_CPOS_dict(self): # print "loading c pos ..." return util.load_dict_from_file(config.CONNECTIVE_DICT_CPOS_PATH)
def __init__(self): self.dict_CON_Str = self.get_dict_CON_Str() self.dict_CON_LStr = self.get_dict_CON_LStr() self.dict_NT_Ctx = self.get_dict_NT_Ctx() self.dict_CON_NT_Path = self.get_dict_CON_NT_Path() self.dict_CON_NT_Path_iLsib = self.get_dict_CON_NT_Path_iLsib() self.dict_NT_prev_curr_Path = util.load_dict_from_file( config.NT_DICT_PREV_CURR_PATH) self.dict_CON_POS = util.load_dict_from_file(config.NT_DICT_CON_POS) self.dict_C_Prev = util.load_dict_from_file(config.NT_DICT_C_PREV) self.dict_NT_Name = util.load_dict_from_file(config.NT_DICT_NT_NAME) self.dict_NT_prev_curr_production_rule = util.load_dict_from_file( config.NT_DICT_NT_PREV_CURR_PRODUCTION_RULE) self.dict_nt_ntParent_ctx = util.load_dict_from_file( config.NT_DICT_NT_NTPARENT_CTX) self.dict_CParent_to_root_path = util.load_dict_from_file( config.NT_DICT_CPARENT_TO_ROOT_PATH) self.dict_CParent_to_root_path_node_names = util.load_dict_from_file( config.NT_DICT_CPARENT_TO_ROOT_PATH_NODE_NAMES) self.dict_conn_connCtx = util.load_dict_from_file( config.NT_DICT_CONN_CONNCTX) self.dict_conn_parent_categoryCtx = util.load_dict_from_file( config.NT_DICT_CONN_PARENT_CATEGORYCTX) self.dict_conn_rightSiblingCtx = util.load_dict_from_file( config.NT_DICT_CONN_RIGHTSIBLINGCTX) self.dict_self_category = util.load_dict_from_file( config.NT_DICT_SELF_CATEGORY) self.dict_parent_category = util.load_dict_from_file( config.NT_DICT_PARENT_CATEGORY) self.dict_left_sibling_category = util.load_dict_from_file( config.NT_DICT_LEFT_SIBLING_CATEGORY) self.dict_right_sibling_category = util.load_dict_from_file( config.NT_DICT_RIGHT_SIBLING_CATEGORY) self.dict_NT_Linked_ctx = util.load_dict_from_file( config.NT_DICT_NT_LINKED_CTX) self.dict_NT_to_root_path = util.load_dict_from_file( config.NT_DICT_NT_TO_ROOT_PATH) self.dict_NT_parent_linked_ctx = util.load_dict_from_file( config.NT_DICT_NT_PARENT_LINKED_CTX)
def get_dict_next1_C(self): return util.load_dict_from_file(config.ARG_POSITION_DICT_NEXT1_C)
def get_self_category_dict(self): return util.load_dict_from_file(config.EXPLICIT_DICT_SELF_CATEGORY_PATH)
def get_dict_prev1_C(self): return util.load_dict_from_file(config.ARG_POSITION_DICT_PREV1_C)
def __init__(self): self.sorted_conns_list = self.get_sorted_conns_list() self.cpos_dict = self.get_CPOS_dict() self.prev_C_dict = self.get_prev_C_dict() self.prevPOS_dict = self.get_prevPOS_dict() self.prevPOS_CPOS_dict = self.get_prevPOS_CPOS_dict() self.C_next_dict = self.get_C_next_dict() self.nextPOS_dict = self.get_nextPOS_dict() self.CPOS_nextPOS_dict = self.get_CPOS_nextPOS() self.CParent_to_root_path_dict = self.get_CParent_to_root_path_dict() self.compressed_CParent_to_root_path_dict = self.get_compressed_CParent_to_root_path_dict() self.self_category_dict = self.get_self_category_dict() self.parent_category_dict = self.get_parent_category_dict() self.left_sibling_category_dict = self.get_left_sibling_category_dict() self.right_sibling_category_dict = self.get_right_sibling_category_dict() self.conn_self_category_dict = self.get_conn_self_category_dict() self.conn_parent_category_dict = self.get_conn_parent_category_dict() self.conn_left_sibling_category_dict = self.get_conn_left_sibling_category_dict() self.conn_right_sibling_category_dict = self.get_conn_right_sibling_category_dict() self.self_parent_dict = self.get_self_parent_dict() self.self_right_dict = self.get_self_right_dict() self.self_left_dict = self.get_self_left_dict() self.parent_left_dict = self.get_parent_left_dict() self.parent_right_dict = self.get_parent_right_dict() self.left_right_dict = self.get_left_right_dict() self.conn_category = self.get_conn_category_dict() ''' mine ''' self.dict_conn_lower_case = util.load_dict_from_file(config.CONNECTIVE_DICT_CONN_LOWER_CASE) self.dict_conn = util.load_dict_from_file(config.CONNECTIVE_DICT_CONN) self.dict_prevPOS_C = util.load_dict_from_file(config.CONNECTIVE_DICT_PREVPOS_C) self.dict_self_category_to_root_path = util.load_dict_from_file(config.CONNECTIVE_DICT_SELF_CATEGORY_TO_ROOT_PATH) self.dict_CParent_to_root_path_node_names = util.load_dict_from_file(config.CONNECTIVE_DICT_CPARENT_TO_ROOT_PATH_NODE_NAMES) self.dict_conn_connCtx = util.load_dict_from_file(config.CONNECTIVE_DICT_CONN_CONNCTX) self.dict_conn_rightSiblingCtx = util.load_dict_from_file(config.CONNECTIVE_DICT_CONN_RIGHTSIBLINGCTX) self.dict_conn_leftSiblingCtx = util.load_dict_from_file(config.CONNECTIVE_DICT_CONN_LEFTSIBLINGCTX) self.dict_conn_left_right_SiblingCtx = util.load_dict_from_file(config.CONNECTIVE_DICT_CONN_LEFT_RIGHT_SIBLINGCTX) self.dict_conn_parent_category_Ctx = util.load_dict_from_file(config.CONNECTIVE_DICT_CONN_PARENT_CATEGORY_CTX) self.dict_rightSibling_production_rules = util.load_dict_from_file(config.CONNECTIVE_DICT_CONN_RIGHTSIBLING_PRODUCTION_RULES)
def get_conn_parent_category_dict(self): return util.load_dict_from_file(config.EXPLICIT_DICT_CONN_PARENT_CATEGORY_PATH)
def get_dict_next2POS_CPOS(self): return util.load_dict_from_file(config.ARG_POSITION_DICT_NEXT2POS_CPOS)
def get_prev_C_dict(self): # print "loading c pre.." return util.load_dict_from_file(config.CONNECTIVE_DICT_PREV_C_PATH)
def get_prevPOS_CPOS_dict(self): return util.load_dict_from_file(config.CONNECTIVE_DICT_PREVPOS_CPOS_PATH)
def get_C_next_dict(self): return util.load_dict_from_file(config.CONNECTIVE_DICT_C_NEXT_PATH)
def get_CPOS_nextPOS(self): return util.load_dict_from_file(config.CONNECTIVE_DICT_CPOS_NEXTPOS_PATH)