TangentCFT icon indicating copy to clipboard operation
TangentCFT copied to clipboard

TypeError: encode_tuples() takes from 4 to 8 positional arguments but 9 were given

Open adityasihag1804 opened this issue 3 years ago • 0 comments

Getting this error while trying to run the command python3 tangent_cft_front_end.py -ds "/NTCIR12_MathIR_WikiCorpus_v2.1.0/MathTagArticles" -cid 1 -em slt_encoder.tsv --mp slt_model --rf slt_ret.tsv --qd "/TestQueries" --ri 1

def for encode_tuples

def encode_tuples(self, node_map, node_id, math_tuples, embedding_type=TupleTokenizationMode.Both_Separated,
                      ignore_full_relative_path=True, tokenize_all=False, tokenize_number=True):
        """
        Takes the encoder map (which can be empty) and the last node id and enumerates the tuple tokens to converts the
        tuples to words (with n-gram as each tokenized tuple element) to make the formulas ready to be fed to fasttext
        :param node_map: dictionary of tokens and their id
        :param node_id: the last node id
        :param math_tuples: list of formula tuples (which are extracted by Tangent-S) to be encoded
        :param embedding_type: one of the four possible tokenization model
        :param ignore_full_relative_path: determines to ignore the full relative path or not (default True)
        :param tokenize_all: determines to tokenize all elements (such as numbers and text) (default False)
        :param tokenize_number: determines to tokenize the numbers or not (default True)
        :return:
        """
        self.node_id = node_id
        self.__encoder_map_node = node_map
        encoded_tuples = []
        for math_tuple in math_tuples:
            encoded_slt_tuple = ""
            slt_elements = self.__get_slt_elements(math_tuple, ignore_full_relative_path=ignore_full_relative_path)

            converted_value = self.__convert_node_elements(slt_elements[0], embedding_type,
                                                           tokenize_all=tokenize_all,
                                                           tokenize_number=tokenize_number)
            encoded_slt_tuple = encoded_slt_tuple + converted_value

            converted_value = self.__convert_node_elements(slt_elements[1], embedding_type,
                                                           tokenize_all=tokenize_all,
                                                           tokenize_number=tokenize_number)
            encoded_slt_tuple = encoded_slt_tuple + converted_value

            converted_value = self.__convert_path_elements(slt_elements[2])
            encoded_slt_tuple = encoded_slt_tuple + converted_value
            "Encode the full relative path"
            if not ignore_full_relative_path:
                converted_value = self.__convert_path_elements(slt_elements[3])
                encoded_slt_tuple = encoded_slt_tuple + converted_value
            encoded_tuples.append(encoded_slt_tuple)

        temp_update_list = self.update_list
        self.update_list = {}
        return encoded_tuples, temp_update_list, self.node_id

where encode_tuples is being called

encoded_tuples, update_map_node, update_map_edge, node_id, edge_id = \
            TupleEncoder.encode_tuples(self.encoder_map_node, self.encoder_map_edge, self.node_id, self.edge_id,
                                       list_of_tuples, embedding_type, ignore_full_relative_path, tokenize_all,
                                       tokenize_number)

adityasihag1804 avatar Sep 06 '21 06:09 adityasihag1804