def find_feature_for_row(self, feature_list, feature_name_list, x, y, yy, np1, np2):
		np1_parts = np1.split(' ')
		if np1 == np2:
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("row feature: if the nps are the same")
		if np2.startswith(np1_parts[0]) or np2.endswith(np1_parts[len(np1_parts) - 1]):
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("row feature: if np has the same begging or head")
		if math_modifiers.check_for_unit(np1) != '000' and math_modifiers.check_for_unit(np2) != '000':
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("row feature: if both nps are units")
		if math_modifiers.check_for_unit(np1) != '000' or math_modifiers.check_for_unit(np2) != '000':
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("row feature: if one of the nps is unit")
		if math_modifiers.check_for_unit(np1) != math_modifiers.check_for_unit(np2) and math_modifiers.check_for_unit(np2) != '000':
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("row feature: if both nps are same units")
		self.calc_wordsim_feature(feature_list, feature_name_list, np1, np2)
		cosigne = self.find_the_cosinge(np1, np2, 300)
		feature_list.append(cosigne)
		feature_name_list.append("row feature: cosigne of nps")
		if y in self.number_cells and yy in self.number_cells:
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("row feature: both index are number cells.")
		if y in self.number_cells or yy in self.number_cells:
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("row feature: one index are number cells.")
		if (y in self.number_cells and yy  not in self.number_cells) or (yy in self.number_cells and y not in self.number_cells):
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("row feature: exactly one index are number cells.")
		if self.have_same_head(np1, np2) == 1:
			feature_list.append(1)
			feature_list.append(self.find_the_cosinge(self.same_head_noun_phrases_ms[self.same_head_noun_phrases.index(np1)], self.same_head_noun_phrases_ms[self.same_head_noun_phrases.index(np2)], 300))
		else:
			feature_list.append(-1)
			feature_list.append(0)
		feature_name_list.append("row feature: the nps have same head")
		feature_name_list.append("row feature: the cosigne between the adj")
		return (feature_list, feature_name_list)
 def calc_merge_unit_features(self, feature_list, feature_name_list, chain1,
                              chain2):
     chain1_all_unit = True
     chain1_has_unit = False
     for np1 in chain1:
         if math_modifiers.check_for_unit(np1) != '000':
             chain1_has_unit = True
         else:
             chain1_all_unit = False
     chain2_has_unit = False
     chain2_all_unit = True
     for np2 in chain2:
         if math_modifiers.check_for_unit(np2) != '000':
             chain2_has_unit = True
         else:
             chain2_all_unit = False
     if chain1_has_unit == True and chain2_has_unit == True:
         feature_list.append(1)
     else:
         feature_list.append(-1)
     feature_name_list.append("chain 1 has unit and chain 2 has unit")
     if chain1_has_unit == True or chain2_has_unit == True:
         feature_list.append(1)
     else:
         feature_list.append(-1)
     feature_name_list.append("chain 1 has unit or chain 2 has unit")
     if chain1_all_unit == True and chain2_all_unit == True:
         feature_list.append(1)
     else:
         feature_list.append(-1)
     feature_name_list.append(
         "chain 1 is all units and chain 2 is all units")
     if chain1_all_unit == True or chain2_all_unit == True:
         feature_list.append(1)
     else:
         feature_list.append(-1)
     feature_name_list.append("chain 1 is all units or chain2 is all units")
     return (feature_list, feature_name_list)
	def find_feature_for_cell(self, feature_list, feature_name_list, x, y, word_in_cell):
		if word_in_cell in self.repeated_noun_phrases:
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("cell feature: if np in cell is repeated")
		if word_in_cell in self.noun_phrase_with_counts:
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("cell feature: if np in cell has count")
		if math_modifiers.check_for_unit(word_in_cell) != '000':
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("cell feature: if np in cell is unit")
		if '%' in word_in_cell:
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("cell feature: if percent is in np")
		if '-' in word_in_cell:
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("cell feature: if np in cell has - in it")
		if y in self.number_cells:
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("cell feature: if the cell is a number cell")
		if word_in_cell in self.noun_phrases_in_question:
			feature_list.append(1)
		else:
			feature_list.append(-1)
		feature_name_list.append("cell feature: if np in cell is a np questioned about")
		return (feature_list, feature_name_list)
Example #4
0
def find_unit_type(np1):
    return math_modifiers.check_for_unit(np1)
 def find_unit_type(self, np1):
     if len(np1.split(' ')) > 1:
         parts = np1.split(' ')
         return math_modifiers.check_for_unit(parts[len(parts) - 1])
     return math_modifiers.check_for_unit(np1)
Example #6
0
	def find_unit_type(self, np1):
		if len(np1.split(' ')) > 1:
			head_np1, modifier_np1 = self.parse_np(np1)
			return math_modifiers.check_for_unit(head_np1)
		return math_modifiers.check_for_unit(np1)