paddlenlp/taskflow/named_entity_recognition.py
def _concat_short_text_reuslts(self, input_texts, results):
        """
        Concat the model output of short texts to the total result of long text.
        """
        long_text_lens = [len(text) for text in input_texts]
        concat_results = []
        single_results = {}
        count = 0
        for text in input_texts:
            text_len = len(text)
            while True:
                if len(single_results) == 0 or len(single_results[
                        "text"]) < text_len:
                    if len(single_results) == 0:
                        single_results = copy.deepcopy(results[count])
                    else:
                        single_results["text"] += results[count]["text"]
                        single_results["items"].extend(results[count]["items"])
                    count += 1
                elif len(single_results["text"]) == text_len:
                    concat_results.append(single_results)
                    single_results = {}
                    break
                else:
                    raise Exception(
                        "The length of input text and raw text is not equal.")
        simple_results = []
        for result in concat_results:
            simple_result = []
            if 'items' in result:
                for item in result['items']:
                    simple_result.append((item['item'], item['wordtag_label']))
            simple_results.append(simple_result)
        simple_results = simple_results[0] if len(
            simple_results) == 1 else simple_results
        return simple_results

        Concat the model output of short texts to the total result of long text.
        
Concat the model output of short texts to the total result of long text.
Concat the model output of short texts to the total result of long text .
def _concat_short_text_reuslts(self, input_texts, results):
        long_text_lens = [len(text) for text in input_texts]
        concat_results = []
        single_results = {}
        count = 0
        for text in input_texts:
            text_len = len(text)
            while True:
                if len(single_results) == 0 or len(single_results[
                        "text"]) < text_len:
                    if len(single_results) == 0:
                        single_results = copy.deepcopy(results[count])
                    else:
                        single_results["text"] += results[count]["text"]
                        single_results["items"].extend(results[count]["items"])
                    count += 1
                elif len(single_results["text"]) == text_len:
                    concat_results.append(single_results)
                    single_results = {}
                    break
                else:
                    raise Exception(
                        "The length of input text and raw text is not equal.")
        simple_results = []
        for result in concat_results:
            simple_result = []
            if 'items' in result:
                for item in result['items']:
                    simple_result.append((item['item'], item['wordtag_label']))
            simple_results.append(simple_result)
        simple_results = simple_results[0] if len(
            simple_results) == 1 else simple_results
        return simple_results
def _concat_short_text_reuslts ( self , input_texts , results ) : long_text_lens = [ len ( text ) for text in input_texts ] concat_results = [ ] single_results = { } count = 0 for text in input_texts : text_len = len ( text ) while True : if len ( single_results ) == 0 or len ( single_results [ "text" ] ) < text_len : if len ( single_results ) == 0 : single_results = copy . deepcopy ( results [ count ] ) else : single_results [ "text" ] += results [ count ] [ "text" ] single_results [ "items" ] . extend ( results [ count ] [ "items" ] ) count += 1 elif len ( single_results [ "text" ] ) == text_len : concat_results . append ( single_results ) single_results = { } break else : raise Exception ( "The length of input text and raw text is not equal." ) simple_results = [ ] for result in concat_results : simple_result = [ ] if 'items' in result : for item in result [ 'items' ] : simple_result . append ( ( item [ 'item' ] , item [ 'wordtag_label' ] ) ) simple_results . append ( simple_result ) simple_results = simple_results [ 0 ] if len ( simple_results ) == 1 else simple_results return simple_results
Concat the model output of short texts to the total result of long text.
Concat the model output of short texts to the total result of long text .
"""
        Concat the model output of short texts to the total result of long text.
        """
self
input_texts
results