Text display method, device, equipment, and medium
Through text segmentation and keyword matching processing, the most relevant text segments are determined and highlighted, which solves the problem of low display efficiency of matching results in long documents and improves user experience and information acquisition efficiency.
Patent Information
- Application Number
- CN202210636405.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-07
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2042-06-07
AI Technical Summary
During the long document retrieval process, existing highlight rendering methods cannot effectively display the optimal matching results, making it difficult for users to quickly locate content that is most relevant to query intent.
By dividing the text to be rendered, each fragment contains multiple reference words, determines the keyword and its weight value based on the search terms, performs matching and merging processing, and calculates the red score of each fragment to determine the optimal fragment And highlight rendering.
Display the content that is most relevant to the user's query intention in a long document, improve the efficiency and user experience of users' reading information, reduce user doubts, and quickly identify the degree of correlation between search results and search terms.
Smart Images

Figure CN114942989B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a text display method and device, equipment, and medium. Background Art
[0002] As we gradually enter the information society, the degree of digitization continues to increase, and information is growing explosively. Finding the information people need from massive data has become an important demand. Information retrieval is an information search function widely used in various systems, such as commercial search engines, internal data retrieval systems, library retrieval systems, etc. In the retrieval system, the user will be informed of which text in the search results is related to the user's query through text highlighting, which is convenient for users to quickly view important information and quickly determine whether the result is what they want. However, in the retrieval process of long documents, there may be multiple matches, and the existing highlighting method cannot show the best matching results to users. Summary of the invention
[0003] The main purpose of the embodiments of the present disclosure is to propose a text display method, device, equipment, and medium, which can display the content most relevant to the user's query intention in a long document information to the user, and render the most relevant words for prompts, thereby greatly improving the user's efficiency in reading information and greatly improving the user's usage experience.
[0004] To achieve the above object, a first aspect of an embodiment of the present disclosure provides a text display method, comprising:
[0005] Dividing the text to be rendered into text segments to obtain a plurality of text segments to be rendered, each of the text segments to be rendered including a plurality of reference words;
[0006] Determine multiple keywords and a weight value corresponding to each keyword according to the search term;
[0007] In each of the text segments to be rendered, matching is performed with the reference words according to the keyword to obtain a matching result, and if the matching result is successful, the number of successful matches is recorded, and the weight value of the keyword is added to the total weight value, and the first red score of the text segment to be rendered is determined according to the number of successful matches and the total weight value;
[0008] If at least one of the plurality of first red scores is not zero, determining an optimal text segment to be rendered from the plurality of text segments to be rendered according to the first red score;
[0009] Merging the successfully matched reference words in the optimal text segment to be rendered to obtain a reference word group, and recording position information of the reference word group in the optimal text segment to be rendered;
[0010] Obtaining a second floating red score of the reference word group according to the weight value of each reference word in the reference word group;
[0011] The optimal text segment to be rendered is rendered according to the second red score and the position information to obtain and output a final rendered text.
[0012] In some embodiments, dividing the text to be rendered into text segments to obtain a plurality of text segments to be rendered includes:
[0013] Determine a total word count threshold for a sentence set;
[0014] Splitting the text to be rendered according to commas, periods, semicolons, and question marks to obtain a plurality of sentences;
[0015] Dividing the sentences into the sentence sets one by one according to the order, and recording the current total number of words in the sentence sets;
[0016] If the sum of the current total number of words in the sentence set and the number of words in the next sentence is greater than the total word count threshold, the sentence set is taken as a text segment to be rendered, and the next text segment to be rendered is constructed with the next sentence set until all sentences are divided.
[0017] In some embodiments, rendering the optimal text segment to be rendered according to the second red score and the position information to obtain and output a final rendered text includes:
[0018] Determining an optimal reference word phrase from the plurality of reference word phrases according to the second red score;
[0019] If the optimal reference word phrase is the same as the search word, the optimal text segment to be rendered is rendered according to the position information corresponding to the optimal reference word phrase to obtain and output a final rendered text.
[0020] In some embodiments, further comprising:
[0021] If the first red scores are all zero, performing common substring matching on the text to be rendered;
[0022] If there is a common substring, the text to be rendered is rendered according to the common substring, and a final rendered text is output.
[0023] In some embodiments, the step of merging the reference words successfully matched in the optimal text segment to be rendered to obtain a reference word group, and recording the position information of the reference word group in the optimal text segment to be rendered includes:
[0024] Among the successfully matched reference words, the reference words with adjacent positions are merged to obtain a reference word group, and the position information of the reference word group is recorded.
[0025] In some embodiments, rendering the optimal text segment to be rendered according to the second red score and the position information to obtain and output a final rendered text includes:
[0026] Arrange the plurality of reference word phrases in reverse order according to the second red score, and sequentially add the reference word phrases in reverse order to a final result list until the number of characters in the final result list exceeds a preset character number threshold;
[0027] The text segment to be rendered is rendered according to the position information corresponding to the reference word phrase in the final result list to obtain and output a final rendered text.
[0028] In some embodiments, rendering the optimal text segment to be rendered according to the second red score and the position information to obtain and output a final rendered text includes:
[0029] Arrange the plurality of reference word phrases in reverse order according to the second red score to obtain the reference word phrases after a sorting, obtain an initial reference word phrase set according to the first N reference word phrases after the sorting, wherein N is a positive integer, render the text segment to be rendered according to the position information corresponding to the reference word phrases in the initial reference word phrase set, and obtain and output a final rendered text;
[0030] or,
[0031] An initial reference word phrase set is obtained according to the reference word phrases whose second red score is higher than a preset red threshold, and the text segment to be rendered is rendered according to the position information corresponding to the reference word phrases in the initial reference word phrase set to obtain and output a final rendered text.
[0032] A second aspect of an embodiment of the present disclosure provides a text display device, including:
[0033] A text segmentation module, used for segmenting the text to be rendered into text segments to obtain a plurality of text segments to be rendered, each of which includes a plurality of reference words;
[0034] A keyword determination module, used to determine a plurality of keywords and a weight value corresponding to each of the keywords according to the search term;
[0035] A first red score calculation module is used to match the keyword with the reference word in each of the text segments to be rendered to obtain a matching result, and if the matching result is successful, record the number of successful matches, add the weight value of the keyword to the total weight value, and determine the first red score of the text segment to be rendered according to the number of successful matches and the total weight value;
[0036] an optimal text segment determination module, configured to determine an optimal text segment to be rendered from the plurality of text segments to be rendered according to the first red scores if at least one of the plurality of first red scores is not zero;
[0037] A reference word group determination module, configured to merge the reference words successfully matched in the optimal text segment to be rendered to obtain a reference word group, and record position information of the reference word group in the optimal text segment to be rendered;
[0038] A second red score calculation module, used for obtaining a second red score of the reference word group according to a weight value of each reference word in the reference word group;
[0039] The final rendered text display module is used to render the optimal text segment to be rendered according to the second red score and the position information, and obtain and output the final rendered text.
[0040] A third aspect of the embodiments of the present disclosure provides a computer device, comprising a memory and a processor, wherein the memory stores a program, and when the program is executed by the processor, the processor is used to execute the method described in any one of the embodiments of the first aspect of the present application.
[0041] A fourth aspect of the embodiments of the present disclosure proposes a storage medium, which is a computer-readable storage medium. The storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute a method as described in any one of the embodiments of the first aspect of the present application.
[0042] The text display method, device, equipment, and medium proposed in the embodiment of the present disclosure divide the text to be rendered into text segments to obtain multiple text segments to be rendered, each of which includes multiple reference words; determine multiple keywords and the weight value corresponding to each keyword according to the search word; in each text segment to be rendered, match the keyword with the reference word to obtain a matching result, if the matching result is successful, record the number of successful matches, add the weight value of the keyword to the total weight value, and determine the first red floating score of the text segment to be rendered according to the number of successful matches and the total weight value; determine the optimal text segment to be rendered from multiple text segments to be rendered according to the first red floating score; and be able to display the content most relevant to the user's query intention in the long document information to the user. And merge the successfully matched reference words in the optimal text segment to be rendered to obtain a reference word phrase, and record the position information of the reference word phrase in the optimal text segment to be rendered; obtain the second red floating score of the reference word phrase according to the weight value of the reference word in each reference word phrase; render the optimal text segment to be rendered according to the second red floating score and the position information, and obtain and output the final rendered text. The most relevant words can be rendered for prompts to improve the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 is a flowchart of a text display method provided by an embodiment of the present disclosure;
[0044] Figure 2 yes Figure 1 Flow chart of step S110 in FIG.
[0045] Figure 3 yes Figure 1 Flow chart of step S150 in FIG.
[0046] Figure 4 yes Figure 1 A first flow chart of step S170 in FIG. 1 ;
[0047] Figure 5 yes Figure 1 A second flow chart of step S170 in FIG. 1 ;
[0048] Figure 6 yes Figure 1 A third flow chart of step S170 in FIG.
[0049] Figure 7 yes Figure 1 A fourth flow chart of step S170 in FIG. 1 ;
[0050] Figure 8 A module structure block diagram of a text display device provided in an embodiment of the present disclosure;
[0051] Fig. 9 It is a schematic diagram of the hardware structure of the computer device provided in the embodiment of the present disclosure. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0053] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein are only for the purpose of describing the embodiments of the present invention and are not intended to limit the present invention.
[0055] First, some nouns involved in this application are analyzed:
[0056] Artificial intelligence (AI): Artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operating / interactive systems, and mechatronics. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0057] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. The natural language involved in this field is the language used by people in daily life, so it is also closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.
[0058] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0059] As we gradually enter the information society, the degree of digitization continues to increase, and information is growing explosively. Finding the information people need from massive data has become an important demand. Information retrieval is an information search function widely used in various systems, such as commercial search engines, internal data retrieval systems, library retrieval systems, etc. In the retrieval system, the user will be informed of which text in the search results is related to the user's query through text highlighting, so that the user can quickly view important information and quickly determine whether the result is what he wants. However, in the retrieval process of long documents, there may be multiple matches, but the content displayed to the user on the front end is generally limited to two or three lines or dozens of words. How to select the fragments displayed to the user and highlight the content related to the search term is a problem that needs to be solved.
[0060] Based on this, the main purpose of the embodiments of the present disclosure is to propose a text display method and apparatus, device, and medium, which divides the text to be rendered into text segments to obtain multiple text segments to be rendered, each of which includes multiple reference words; determines multiple keywords and weight values corresponding to each keyword based on the search words; in each text segment to be rendered, matches are performed based on the keywords and reference words to obtain matching results, and if the matching result is successful, the number of successful matches is recorded, and the weight value of the keyword is added to the total weight value, and the first red score of the text segment to be rendered is determined based on the number of successful matches and the total weight value; the optimal text segment to be rendered is determined from the multiple text segments to be rendered based on the first red score; and the content most relevant to the user's query intention can be displayed to the user in a long document information. The reference words that successfully match in the optimal text segment to be rendered are merged to obtain a reference word group, and the position information of the reference word group in the optimal text segment to be rendered is recorded; the second red floating score of the reference word group is obtained according to the weight value of the reference word in each reference word group; the optimal text segment to be rendered is rendered according to the second red floating score and the position information, and the final rendered text is obtained and output. The most relevant words can be rendered for prompts to improve the user experience. Taking search as an example, the content most relevant to the user's query intention can be displayed to the user in a relatively long document information, and the most relevant words can be highlighted for prompts, which greatly improves the efficiency of reading information when the user uses it and greatly improves the user experience. The user can more intuitively feel the relevance of the search results to the search terms. When the search results have the same keywords as the search terms, they will be highlighted to highlight the key content so that the user can see it at a glance, which can reduce the user's confusion and improve the efficiency of information acquisition.
[0061] The text display method provided in the embodiments of the present disclosure can be applied to a terminal or a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, or a smart watch, etc.; the server can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the above method, etc., but is not limited to the above forms.
[0062] The disclosed embodiments can be used in numerous general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer computer devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0063] The embodiments of the present disclosure provide a text display method, apparatus, device, and medium, which are specifically described through the following embodiments. First, the text display method in the embodiments of the present disclosure is described.
[0064] Reference Figure 1 , according to the text display method of the embodiment of the present disclosure, includes but is not limited to steps S110 to S170.
[0065] S110, dividing the text to be rendered into text segments to obtain a plurality of text segments to be rendered, each of which includes a plurality of reference words;
[0066] S120, determining a plurality of keywords and a weight value corresponding to each keyword according to the search term;
[0067] S130, in each text segment to be rendered, matching is performed based on the keyword and the reference word to obtain a matching result, if the matching result is successful, recording the number of successful matches, and adding the weight value of the keyword to the total weight value, and determining the first red score of the text segment to be rendered based on the number of successful matches and the total weight value;
[0068] S140, if at least one of the multiple first red scores is not zero, determining the optimal text segment to be rendered from the multiple text segments to be rendered according to the first red scores;
[0069] S150, merging the successfully matched reference words in the optimal text segment to be rendered to obtain a reference word group, and recording the position information of the reference word group in the optimal text segment to be rendered;
[0070] S160, obtaining a second floating red score of the reference word group according to the weight value of each reference word in the reference word group;
[0071] S170, rendering the optimal text segment to be rendered according to the second red score and the position information, and obtaining and outputting a final rendered text.
[0072] Specifically, through step S110 to step S170, the long text is divided into segments, the first red score of each segment is calculated based on the matching relationship between the search term and the reference term of the segment, the segment most relevant to the search term is selected according to the first red score, and the keyword phrase related to the search term is highlighted in the segment. The content most relevant to the user's query intention can be displayed to the user in the relatively long document information, and the most relevant words can be prompted in red, which greatly improves the efficiency of the user's reading information and greatly enhances the user's experience.
[0073] In step S110, the text to be rendered is segmented into text segments to obtain multiple text segments to be rendered, and each text segment to be rendered includes multiple reference words. In the application, the above-mentioned text to be rendered can be a Baidu entry, a Weibo article, a news article, etc., which is not limited to this. The method of obtaining the text to be rendered can be based on the user inputting a search word into the retrieval system. Among them, the text language of the text segment to be rendered can be Chinese, English or other text languages, which is not limited to this. In order to better explain the text display method, this embodiment uses the text language in Chinese as an example for explanation. For example, in a search engine, a search term input by a user will be searched, and multiple long texts that meet the search term will be displayed to the user. However, the number of words displayed on the front end is limited, and it is still difficult for users to read each long text. Although in the related art, the corresponding keywords will be rendered in the long text according to the search term, there are multiple keyword matches in a long text, so the user still needs to find the corresponding matching content. The present solution is to segment the long text into text segments to obtain multiple text segments to be rendered, and each text segment to be rendered includes at least one sentence. This solution renders a long text in the form of text fragments, selects the most appropriate fragment to display to the user, so that the user can quickly locate the most matching text fragment in the long text. In one embodiment, the maximum number of displayed words is determined, and the long text is segmented according to the maximum number of displayed words to obtain multiple text fragments to be rendered.
[0074] In step S120, multiple keywords and weight values corresponding to the keywords are determined according to the search terms. For example, the search term is "how to buy Ping An Fu", and the keywords obtained after word segmentation include "how", "buy", and "Ping An Fu", and the corresponding weight values are 0.0035601594, 0.9744007, and 0.8743519, respectively. It should be noted that after the user enters the search term into the retrieval system, the retrieval system processes the search term according to the preset word segmentation strategy. Specifically, the search term (query) is segmented, punctuation is removed, and multiple keywords are obtained. Specifically, it also includes: synonyms related to the keyword are also used as keywords in the preset word library, and the weight value of the synonym is the weight value of the corresponding keyword. Specifically, the synonyms related to the keyword can be obtained according to the similarity calculation, or the synonyms can be obtained based on semantic mining. Among them, the synonyms corresponding to the keyword can be understood as: words with similar meanings to the keyword, for example, arm and arm can be understood as synonyms of each other, and thigh and leg can be understood as synonyms of each other. It should be noted that after determining multiple keywords, the weight values corresponding to the keywords can be obtained from the word library information set in the search system, and the word library information stores multiple words and the weight values corresponding to each word. The weight value can be set according to the number of historical searches, and the more historical searches, the higher the weight value. Among them, the search system includes search engines such as Google, Baidu, Yahoo, etc.
[0075] In step S130, the first red score of the text segment to be rendered is mainly calculated based on the number of reference words that successfully match the keyword in the text segment to be rendered, and the weight value. Because the weight value of each keyword is different, some keywords have very high weight values, but there are very few reference words that successfully match in the segment. If the number of successful matches is not considered, the reference words with many matches but a single weight value that is too low will be ignored. In one embodiment, the text segment to be rendered is segmented and a reference word list (tokenlist) separated by spaces is obtained. The reference word list (tokenlist) is traversed, and for each reference word, when the reference word (token) successfully matches the keyword, the weight value of the corresponding keyword is obtained and recorded, and the weight value is added to the total weight value (TermWeightSum), and the number of successful matches (Tokencount) is increased by one. The first red score of the text segment to be rendered is obtained according to the total weight value (TermWeightSum) and the number of successful matches (Tokencount). If there is at least one successfully matched reference word, the first red score is calculated in the following manner, specifically including: Score = TermWeightSum + ln(Tokencount). If there is no successfully matched reference word, the first red score is zero. It should be noted that the keyword and reference word can be matched according to the forward maximum matching algorithm or the reverse maximum matching algorithm.
[0076] In step S140, if there is at least one first red score that is not zero, the optimal text segment to be rendered is determined from multiple text segments to be rendered according to the first red score. In the case where there are multiple keyword matches in a long text, the optimal text segment to be rendered is determined according to the first red score, so that the user can quickly locate the most matching text segment in a long text. In one embodiment, the text segment to be rendered with the highest first red score is determined as the optimal text segment to be rendered.
[0077] In one embodiment, if the first floating red scores are all zero, a common substring match is performed on the text to be rendered; if a common substring exists, the text to be rendered is rendered according to the common substring, and the final rendered text is output. Specifically, if all the first floating red scores are 0, that is, there is no word granularity match, then the floating red is performed using the character granularity match, as follows: a common substring match is performed on each segment in turn, and if a common substring exists, the common substring is floated red, and the segment is returned, and the subsequent segments are no longer processed.
[0078] In step S150, the successfully matched reference words in the optimal text segment to be rendered are merged to obtain a reference word phrase, and the position information of the reference word phrase in the optimal text segment to be rendered is recorded. If there are multiple successfully matched reference words in an optimal text segment to be rendered, these reference words are merged to obtain a reference word phrase. Because it is difficult to reflect the matching situation with the search word from one reference word, the reference words with adjacent positions are merged in this step. The purpose is to obtain a reference word phrase that can better reflect the matching degree with the search word, and the position information of the reference word phrase is recorded so that the optimal segment to be rendered can be highlighted according to the position information later. It should be noted that each reference word phrase includes at least one reference word, and there is at least one reference word phrase in an optimal text segment to be rendered.
[0079] In one embodiment, if there is only one successfully matched reference word in an optimal text segment to be rendered, this reference word is merged with adjacent unmatched reference words to obtain a reference word phrase. Because it is difficult to reflect the complete sentence semantics from one reference word, the reference words are merged and the position information of the reference word phrase is recorded so that the optimal segment to be rendered can be highlighted later based on the position information.
[0080] In step S160, the second red score of the reference word group is obtained according to the weight of each reference word in the reference word group; the second red score further reflects the degree of matching with the search word in the optimal text segment, and the higher the second red score, the more matching the reference word group with the search word. It should be noted that the weight value of each reference word group is obtained by adding up the weight values of the reference words that make it up. For example, if the reference word group consists of three reference words, the weight value of the reference word group is equal to the sum of the weight values of the three reference words.
[0081] In step S170, the optimal text segment to be rendered is rendered according to the second red score and the position information, and the final rendered text is obtained and output. There are multiple keyword phrases in an optimal segment to be rendered. If all keyword phrases are directly highlighted, the content most relevant to the search term in the segment cannot be reflected. Therefore, multiple reference word phrases are screened according to the second red score to obtain a reference word phrase with a higher score, and then the optimal text segment to be rendered is rendered according to the corresponding position information to obtain and output the final rendered text.
[0082] It should be noted that rendering the optimal text segment to be rendered according to the second red floating score and position information includes but is not limited to: determining the reference word phrase to be rendered according to the second red floating score, marking the keyword phrase in red according to the position information corresponding to the reference word phrase to be rendered, adding background color to the keyword, highlighting the keyword, etc. Any display method that can facilitate users to quickly locate the document content and keyword phrases of interest is available, and the embodiment of the present invention does not impose specific restrictions.
[0083] In some embodiments, Figure 2 As shown, step S110 specifically includes the following steps:
[0084] S210, determining a total word count threshold of a sentence set;
[0085] S220, dividing the text to be rendered according to the comma, the period, the semicolon, and the question mark to obtain a plurality of sentences;
[0086] S230, dividing the sentences into sentence sets one by one according to the order, and recording the current total number of words in the sentence set;
[0087] S240: If the sum of the current total number of words in the sentence set and the number of words in the next sentence is greater than the total word count threshold, the sentence set is taken as a text segment to be rendered, and the next text segment to be rendered is constructed with the next sentence set until all sentences are divided.
[0088] Specifically, in step S210 to step S240, the number of words displayed on the front end is limited, so the total word count threshold is determined in advance. The text to be rendered is divided into multiple sentences according to commas, periods, semicolons, and question marks to ensure sentence integrity and semantic integrity. Sentences are taken in order and added to the sentence set. If the sum of the current total word count and the number of words in the next sentence is greater than the total word count threshold, the sentence set corresponding to the current total word count is used as a text segment to be rendered, and the next sentence set is divided until all sentences are divided. The semantic integrity of each text segment to be rendered is guaranteed.
[0089] In some embodiments, if the optimal text segment to be rendered is the same as the search term, the optimal text segment to be rendered is rendered to obtain and output a final rendered text.
[0090] In some embodiments, Figure 3 As shown, step S150 specifically includes the steps of:
[0091] S310 , among the successfully matched reference words, merge the reference words with adjacent positions to obtain a reference word group, and record the position information of the reference word group.
[0092] Specifically, in step S310, when matching the reference word with the keyword, if the match is successful, the position information of the reference word is recorded. The reference words at adjacent positions in the position information are merged to obtain a reference word phrase. Each individual reference word may not be able to express complete semantics, so in this step, adjacent reference words are merged to achieve semantic integrity and further improve the user's reading efficiency.
[0093] In some embodiments, Figure 4 As shown, step S170 specifically includes the following steps:
[0094] S410, determining an optimal reference word phrase from a plurality of reference word phrases according to the second floating red score;
[0095] S420: If the optimal reference word phrase is the same as the search word, the optimal text segment to be rendered is rendered according to the position information corresponding to the optimal reference word phrase to obtain and output a final rendered text.
[0096] Specifically, in step S410 to step S420, if there is a reference word phrase that completely matches the search term, the reference word phrase is highlighted in the optimal text segment to be rendered, so as to better implement the ability to render the most relevant words for prompts in this application and improve the user experience.
[0097] In some embodiments, Figure 5 As shown, step S170 specifically includes the following steps:
[0098] S510, arranging the plurality of reference word phrases in reverse order according to the second red score, and sequentially adding the reference word phrases in reverse order to a final result list until the number of characters in the final result list exceeds a preset character number threshold;
[0099] S520: Render the text segment to be rendered according to the position information corresponding to the reference word phrase in the final result list to obtain and output the final rendered text.
[0100] Specifically, after determining the optimal text segment to be rendered, it is not necessary to highlight all the reference words. In steps S510 to S520, multiple reference words are sorted in reverse order according to the second red score. It can be understood that the higher the second red score, the greater the degree of match with the search term. By setting a preset character count threshold, the maximum number of rendered characters is limited. Because if a reference word phrase is too long and is fully rendered, there will be a situation where the user cannot quickly locate the matching content. The embodiment of the present invention limits the maximum number of rendered characters of the optimal text segment to be rendered, and then renders the segment according to the second red score, which can highlight the key content and let the user see it at a glance, which can reduce the user's confusion and improve the efficiency of information acquisition.
[0101] In some embodiments, Figure 6 As shown, step S170 specifically includes the following steps:
[0102] S610, sorting the plurality of reference word phrases in reverse order according to the second red score, and obtaining an initial reference word phrase set according to the first N reference word phrases after the sorting, where N is a positive integer;
[0103] S620, rendering the text segment to be rendered according to the position information corresponding to the reference word phrase in the initial reference word phrase set, and obtaining and outputting the final rendered text;
[0104] In step S610 to step S620, only the reference word phrases ranked first according to the second red score can be rendered, so as to avoid multiple highlighted reference word phrases in the optimal text segment to be rendered, but with poor matching degree with the keywords, which reduces user reading efficiency and affects user experience.
[0105] In one embodiment, the first five reference word phrases in the second red score are selected as candidates, and all are selected if the score is less than 5. If the first reference word phrase completely matches the search term, only the first reference word phrase is selected as red.
[0106] In another embodiment, if there is no complete match, the first to the fifth are sequentially added to the final result list, and a highlight tag is added to the optimal text segment to be rendered according to the position information of the reference word phrase in the final list.
[0107] In another embodiment, if there is no exact match, the first to the fifth are added to the final result list in sequence, and the addition is stopped when the total number of characters in the final result list exceeds 60%, and a highlight tag is added to the optimal text segment to be rendered based on the position information of the reference word phrase in the final list.
[0108] In some embodiments, Figure 7 As shown, step S170 specifically includes the following steps:
[0109] S710, obtaining an initial reference word phrase set according to reference word phrases whose second red scores are higher than a preset red threshold;
[0110] S720, rendering the text segment to be rendered according to the position information corresponding to the reference word phrase in the initial reference word phrase set, and obtaining and outputting a final rendered text.
[0111] Specifically, in step S710 to step S720, a preset red threshold is set, and only reference word phrases with a second red score higher than the preset red threshold can be rendered, so as to avoid the appearance of multiple highlighted reference word phrases in the optimal text segment to be rendered, but with a poor match with the keywords, thereby reducing user reading efficiency and affecting user experience.
[0112] The text display method proposed in the embodiment of the present disclosure is to divide the text to be rendered into text segments to obtain multiple text segments to be rendered, each of which includes multiple reference words; determine multiple keywords and the weight value corresponding to each keyword according to the search word; in each text segment to be rendered, match the keyword with the reference word to obtain a matching result, if the matching result is successful, record the number of successful matches, add the weight value of the keyword to the total weight value, determine the first red floating score of the text segment to be rendered according to the number of successful matches and the total weight value; determine the optimal text segment to be rendered from multiple text segments to be rendered according to the first red floating score; and be able to display the content most relevant to the user's query intention in the long document information to the user. And merge the successfully matched reference words in the optimal text segment to be rendered to obtain a reference word phrase, and record the position information of the reference word phrase in the optimal text segment to be rendered; obtain the second red floating score of the reference word phrase according to the weight value of the reference word in each reference word phrase; render the optimal text segment to be rendered according to the second red floating score and the position information, and obtain and output the final rendered text. The most relevant words can be rendered for prompts to improve the user experience. Taking search as an example, users can more intuitively feel the relevance of search results to search terms. When the search results have the same keywords as the search terms, they will be highlighted to highlight the key content, so that users can see it at a glance, which can reduce user confusion and improve information acquisition efficiency.
[0113] The present disclosure also provides a text display device, such as Figure 8 As shown, Figure 8The module structure block diagram of the text display device provided in the embodiment of the present disclosure can realize the above-mentioned text display method, and the device includes: a text segment division module 810, a keyword determination module 820, a first red score determination module 830, an optimal text segment determination module 840, a reference word phrase determination module 850, a second red score calculation module 860 and a final rendered text display module 870. Among them, the text segment division module 810 is used to divide the text to be rendered into text segments to obtain multiple text segments to be rendered, each of which includes multiple reference words; the keyword determination module 820 is used to determine multiple keywords and the weight value corresponding to each keyword according to the search word; the first red score calculation module 830 is used to match the keyword with the reference word in each text segment to be rendered to obtain a matching result. If the matching result is successful, the number of successful matches is recorded, and the weight value of the keyword is added to the total weight value, and the first red score of the text segment to be rendered is determined according to the number of successful matches and the total weight value; the optimal text segment determination module 840 If at least one of the multiple first red scores is not zero, the optimal text segment to be rendered is determined from the multiple text segments to be rendered according to the first red score; the reference word phrase determination module 850 is used to merge the successfully matched reference words in the optimal text segment to be rendered to obtain the reference word phrase, and record the position information of the reference word phrase in the optimal text segment to be rendered; the second red score calculation module 860 is used to obtain the second red score of the reference word phrase according to the weight value of each reference word in the reference word phrase; the final rendered text display module 870 is used to render the optimal text segment to be rendered according to the second red score and the position information, and obtain and output the final rendered text.
[0114] The text display device of the embodiment of the present disclosure is used to execute the text display method in the above embodiment. Its specific processing process is the same as the text display method in the above embodiment, and will not be repeated here.
[0115] The text display device proposed in the embodiment of the present disclosure can divide the text to be rendered into text segments to obtain multiple text segments to be rendered, each of which includes multiple reference words, by implementing the above-mentioned text display method; determine multiple keywords and the weight value corresponding to each keyword according to the search word; in each text segment to be rendered, match the keyword with the reference word to obtain a matching result, if the matching result is successful, record the number of successful matches, add the weight value of the keyword to the total weight value, determine the first red score of the text segment to be rendered according to the number of successful matches and the total weight value; determine the optimal text segment to be rendered from the multiple text segments to be rendered according to the first red score; and be able to display the content most relevant to the user's query intention in front of the user in the long document information. The successfully matched reference words in the optimal text segment to be rendered are merged to obtain a reference word phrase, and the position information of the reference word phrase in the optimal text segment to be rendered is recorded; the second red floating score of the reference word phrase is obtained according to the weight value of each reference word in the reference word phrase; the optimal text segment to be rendered is rendered according to the second red floating score and the position information, and the final rendered text is obtained and output. The most relevant words can be rendered for prompts to improve the user experience. Taking search as an example, users can more intuitively feel the relevance of search results to search terms. When there are the same keywords as the search terms in the search results, they will be highlighted to highlight the key content so that users can see it at a glance, which can reduce user confusion and improve information acquisition efficiency.
[0116] An embodiment of the present disclosure also provides a computer device, comprising: at least one processor, and a memory communicatively connected to the at least one processor; wherein the memory stores instructions, and the instructions are executed by the at least one processor, so that when the at least one processor executes the instructions, a text display method as in the embodiment of the present disclosure is implemented.
[0117] The computer device proposed in the embodiment of the present disclosure implements the above-mentioned text display method, divides the long text into segments, calculates the first red score of each segment based on the matching relationship between the search term and the reference term of the segment, selects the segment most relevant to the search term according to the first red score, and highlights the keyword phrase related to the search term in the segment. The content most relevant to the user's query intention can be displayed to the user in a relatively long document information, and the most relevant words are prompted in red, which greatly improves the efficiency of the user's reading information and greatly enhances the user's experience.
[0118] Combine the following Fig. 9 Describe the hardware structure of the computer equipment in detail. Fig. 99 is a schematic diagram of the hardware structure of a computer device provided in an embodiment of the present disclosure. The computer device includes: a processor 901 , a memory 902 , an input / output interface 903 , a communication interface 904 and a bus 905 .
[0119] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present disclosure;
[0120] The memory 902 can be implemented in the form of ROM (Read Only Memory), static storage device, dynamic storage device or RAM (Random Access Memory). The memory 902 can store operating systems and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 902, and the processor 901 calls and executes the text display method of the embodiment of the present disclosure;
[0121] Input / output interface 903, used to implement information input and output;
[0122] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0123] and bus 905, to transmit information between the various components of the device (e.g., processor 901, memory 902, input / output interface 903, and communication interface 904); wherein processor 901, memory 902, input / output interface 903, and communication interface 904 are communicatively connected to each other within the device via bus 905.
[0124] The embodiment of the present disclosure further provides a storage medium, which is a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the text display method of the embodiment of the present disclosure.
[0125] The storage medium proposed in the embodiment of the present disclosure implements the above-mentioned text display method to divide the long text into segments, calculate the first red score of each segment based on the matching relationship between the search term and the reference term of the segment, select the segment most relevant to the search term according to the first red score, and highlight the keyword phrase related to the search term in the segment. The content most relevant to the user's query intention can be displayed to the user in a relatively long document information, and the most relevant words can be prompted in red, which greatly improves the efficiency of the user's reading information and greatly enhances the user's experience.
[0126] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0127] The embodiments described in the embodiments of the present disclosure are intended to more clearly illustrate the technical solutions of the embodiments of the present disclosure and do not constitute a limitation on the technical solutions provided by the embodiments of the present disclosure. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present disclosure are also applicable to similar technical problems.
[0128] It can be understood by those skilled in the art that Figures 1 to 7 The technical solutions shown in the figure do not constitute a limitation on the embodiments of the present disclosure, and may include more or fewer steps than those shown in the figure, or a combination of certain steps, or different steps.
[0129] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0130] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0131] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0132] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0133] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0134] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0135] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0136] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0137] The preferred embodiments of the present disclosure are described above with reference to the accompanying drawings, but the scope of the rights of the present disclosure is not limited thereto. Any modification, equivalent substitution and improvement made by those skilled in the art without departing from the scope and essence of the present disclosure should be within the scope of the rights of the present disclosure.
Claims
1. A text display method, characterized in that: include: Dividing the text to be rendered into text segments to obtain a plurality of text segments to be rendered, each of the text segments to be rendered including a plurality of reference words; Determine multiple keywords and a weight value corresponding to each keyword according to the search term; In each of the text segments to be rendered, the keyword is matched with the reference word to obtain a matching result. If the matching result is successful, the number of successful matches is recorded, and the weight value of the keyword is added to the total weight value. The first red score of the text segment to be rendered is determined according to the number of successful matches and the total weight value; wherein the first red score is TermWeightSum+ln(Tokencount), TermWeightSum refers to the total weight value, and Tokencount refers to the number of successful matches; If at least one of the plurality of first red scores is not zero, determining an optimal text segment to be rendered from the plurality of text segments to be rendered according to the first red score; Merging the successfully matched reference words in the optimal text segment to be rendered to obtain a reference word group, and recording position information of the reference word group in the optimal text segment to be rendered; Obtaining a second floating red score of the reference word group according to the weight value of each reference word in the reference word group; The optimal text segment to be rendered is rendered according to the second red score and the position information to obtain and output a final rendered text.
2. The method according to claim 1, characterized in that The step of dividing the text to be rendered into text segments to obtain a plurality of text segments to be rendered includes: Determine a total word count threshold for a sentence set; Splitting the text to be rendered according to commas, periods, semicolons, and question marks to obtain a plurality of sentences; Dividing the sentences into the sentence sets one by one according to the order, and recording the current total number of words in the sentence sets; If the sum of the current total number of words in the sentence set and the number of words in the next sentence is greater than the total word count threshold, the sentence set is taken as a text segment to be rendered, and the next text segment to be rendered is constructed with the next sentence set until all sentences are divided.
3. The method according to claim 2, characterized in that The step of merging the successfully matched reference words in the optimal text segment to be rendered to obtain a reference word group, and recording position information of the reference word group in the optimal text segment to be rendered includes: Among the successfully matched reference words, the reference words with adjacent positions are merged to obtain a reference word group, and the position information of the reference word group is recorded.
4. The method according to claim 1, characterized in that: Also includes: If the first red scores are all zero, performing common substring matching on the text to be rendered; If there is a common substring, the text to be rendered is rendered according to the common substring, and a final rendered text is output.
5. The method according to any one of claims 1 to 4, characterized in that: The step of rendering the optimal text segment to be rendered according to the second red score and the position information to obtain and output a final rendered text includes: Determining an optimal reference word phrase from the plurality of reference word phrases according to the second red score; If the optimal reference word phrase is the same as the search word, the optimal text segment to be rendered is rendered according to the position information corresponding to the optimal reference word phrase to obtain and output a final rendered text.
6. The method according to any one of claims 1 to 4, characterized in that: The step of rendering the optimal text segment to be rendered according to the second red score and the position information to obtain and output a final rendered text includes: Arrange the plurality of reference word phrases in reverse order according to the second red score, and sequentially add the reference word phrases in reverse order to a final result list until the number of characters in the final result list exceeds a preset character number threshold; The text segment to be rendered is rendered according to the position information corresponding to the reference word phrase in the final result list to obtain and output a final rendered text.
7. The method according to any one of claims 1 to 4, characterized in that: The step of rendering the optimal text segment to be rendered according to the second red score and the position information to obtain and output a final rendered text includes: Arrange the plurality of reference word phrases in reverse order according to the second red score to obtain the reference word phrases after a sorting, obtain an initial reference word phrase set according to the first N reference word phrases after the sorting, wherein N is a positive integer, render the text segment to be rendered according to the position information corresponding to the reference word phrases in the initial reference word phrase set, and obtain and output a final rendered text; or, An initial reference word phrase set is obtained according to the reference word phrases whose second red score is higher than a preset red threshold, and the text segment to be rendered is rendered according to the position information corresponding to the reference word phrases in the initial reference word phrase set to obtain and output a final rendered text.
8. A text display device, characterized in that: include: A text segmentation module, used for segmenting the text to be rendered into text segments to obtain a plurality of text segments to be rendered, each of which includes a plurality of reference words; A keyword determination module, used to determine a plurality of keywords and a weight value corresponding to each of the keywords according to the search term; A first red score calculation module is used to match the keyword with the reference word in each of the text segments to be rendered to obtain a matching result. If the matching result is successful, the number of successful matches is recorded, and the weight value of the keyword is added to the total weight value, and the first red score of the text segment to be rendered is determined according to the number of successful matches and the total weight value; wherein the first red score is TermWeightSum+ln(Tokencount), TermWeightSum refers to the total weight value, and Tokencount refers to the number of successful matches; an optimal text segment determination module, configured to determine an optimal text segment to be rendered from the plurality of text segments to be rendered according to the first red scores if at least one of the plurality of first red scores is not zero; A reference word group determination module, configured to merge the reference words successfully matched in the optimal text segment to be rendered to obtain a reference word group, and record position information of the reference word group in the optimal text segment to be rendered; A second red score calculation module, used for obtaining a second red score of the reference word group according to a weight value of each reference word in the reference word group; The final rendered text display module is used to render the optimal text segment to be rendered according to the second red score and the position information, and obtain and output the final rendered text.
9. A computer device, characterized in that: The computer device includes a memory and a processor, wherein the memory stores a program, and when the program is executed by the processor, the processor is used to execute: The method according to any one of claims 1 to 7.
10. A storage medium, the storage medium being a computer-readable storage medium, characterized in that: The computer readable storage has a computer program, and when the computer program is executed by the computer, the computer is used to perform: The method according to any one of claims 1 to 7.
