def set_all_states(self):
     for i in range(3):
         keys = list(self.params[i].keys())
         n = len(keys)
         lists = self.params[i].values()
         for element in list_product(*lists):
             self.all_states[i].append(
                 {keys[k]: element[k]
                  for k in range(n)})
Example #2
0
 def times(self, element):
     combinations = list_product(self.list, element.list)
     if(self.key == "t"):
         key = element.key
     elif element.key == "t":
         key = self.key
     else:
         key = "(%s X %s)" %(self.key, element.key)
     product = Element(map(lambda ((i1, e1), (i2, e2)): (i1.times(i2), e1.times(e2)), combinations), key)
     return product
Example #3
0
	def _get_possible_sense_combinations(self, taggable, tagged):
		"""Create a list of possible combinations of the tokens possible senses."""
		print("\tget possible combinations...")
		# first create a list of the already tagged senses and store for each of those one list inside that contains the one single correct sense
		tagged_sense_keys = [[(token, token.wn_sense_key)] for token in tagged]
		taggable_possible_sense_keys = []

		# for each token that has to be tagged now find all possible senses and collect them
		for token in taggable:
			token_sense_pairs = []
			# for each possible sense of the token add one to the list of that sense
			possible_senses = self._get_possible_wn_senses_for_token(token)
			for single_possible_sense in possible_senses:
				token_sense_pairs.append((token, single_possible_sense))
			taggable_possible_sense_keys.append(token_sense_pairs)

		complete_list_of_tokens = taggable_possible_sense_keys + tagged_sense_keys

		print("\t\t...building combinations")
		# return a dot product of the lists of possible senses of all tokens
		return list_product(*complete_list_of_tokens)