Method and device for optimizing display of keywords with first appearing positions exceeding two rows in multi-row text and computer storage medium

In front-end project development, the content that appears more than two lines of keywords in multiple lines of text for the first time is optimized, and the omitted tags and keyword highlighting is used to solve the problem that users find it difficult to quickly identify key information, and the effect of efficiently displaying key information in a limited space is achieved.

CN119646210APending Publication Date: 2025-03-18SUZHOU REKTEC INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411598319.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

In front-end project development, when searching for content by searching keywords, the page space is limited and the text content is too long, making it difficult for users to quickly identify key information and reduce user experience.

Method used

Provide a display optimization method where the first appearance of keywords in multi-line text exceeds two lines. By obtaining user-defined keywords, accessing the server-side data set, intercepting the text content before the first appearance of keywords, and determining whether the pixel height of the text to be optimized exceeds the specified number of lines based on the page pixel width. If it exceeds the number of lines, the omitted process is performed, and the omitted marker is used instead of the text to be optimized, and the keywords are highlighted.

Benefits of technology

Display key information more efficiently in a limited control space, improve space utilization, and make it easier for users to obtain key information associated with keywords, greatly speeding up the speed of information screening and positioning, and improving user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119646210A_ABST
    Figure CN119646210A_ABST
Patent Text Reader

Abstract

The invention discloses an optimization method for displaying a keyword in a multi-line text with the first appearing position exceeding two lines, and relates to the technical field of software management, the method comprises the following steps: obtaining a keyword defined by a user; accessing a data set of a server side according to the keyword, and obtaining each text field associated with the keyword; obtaining the first appearing position of the keyword in the text field, and intercepting the text field content before the first appearing position of the keyword as a to-be-optimized text; obtaining a pixel height value of a to-be-optimized text in the current page; judging whether the pixel height value of the to-be-optimized text exceeds the pixel height value of a specified line number or not, and performing omission processing on the to-be-optimized text exceeding the height of the specified line number; and matching characters same as the keywords based on the keywords, and highlighting the characters. According to the method, the text fields exceeding the specified line number are optimally displayed, higher information display efficiency is realized in a limited control space, and the readability of the text and the information acquisition efficiency are greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software management, and in particular to a display optimization method, device and computer storage medium for a keyword in a multi-line text that first appears in a position exceeding two lines. Background Art

[0002] In front-end project development, when retrieving content by searching keywords, it is generally displayed in a list, which often faces the problem of limited page space and too long text content. This may make it difficult for users to quickly identify key information, which will undoubtedly reduce the user experience. Therefore, new methods need to be proposed to allow users to quickly capture key information in a limited space. Summary of the invention

[0003] The present invention overcomes the shortcomings of the prior art and provides a method for optimizing the display of a keyword in a multi-line text when the first appearance position exceeds two lines, which has the advantage of allowing users to quickly capture key information in a limited page control space.

[0004] To achieve the above object, the technical solution adopted by the present invention is: a method for optimizing the display of a keyword in a multi-line text when the first occurrence position exceeds two lines, characterized in that it comprises the following steps:

[0005] Obtain keywords defined by the user; access the data set on the server side according to the keywords, and obtain each text field associated with the keywords; obtain the position where the keywords first appear in the text field, and intercept the text field content before the position where the keywords first appear as the text to be optimized; obtain the pixel height value of the text to be optimized in the current page; obtain the pixel width value of the front page that currently displays the text field, determine and obtain the height value of the single-line text according to the pixel width value of the current front page, compare the pixel height value of the single-line text with the pixel height value of the text to be optimized by the specified number of lines to determine whether the pixel height value of the text to be optimized exceeds the pixel height value of the specified number of lines, and omit the text to be optimized that exceeds the specified number of lines; wherein the specified number of lines is based on the program setting on the server side; the omission processing includes: using a specific omission marker to replace the text to be optimized. Match the text in the text field that is the same as the keyword based on the keyword and highlight it.

[0006] The present invention is further configured such that an event listener is generated in association with the omission marker, and the event listener is used to convert the omission marker displayed in the front-end page and the complete content of the text to be optimized.

[0007] The present invention is further configured such that: highlighting the keyword includes: changing the color of the keyword, highlighting the background color of the keyword, or underlining the keyword.

[0008] The present invention is further configured to: perform security verification on the keyword when acquiring the keyword, and the security verification includes: format verification, length verification and special character filtering.

[0009] The present invention is further configured as: a display optimization device for a multi-line text where the first appearance position of a keyword exceeds two lines, comprising: a keyword receiving unit, used to receive and obtain a keyword input by a user; a data set traversal unit, used to extract text fields associated with the keyword after traversing the data set according to the keyword; a text to be optimized acquisition unit, used to obtain the content of the text to be optimized according to the first appearance position of the keyword in the text field; a judgment unit, used to calculate the pixel height value of the text to be optimized and judge whether it is greater than the pixel height value of a specified number of lines; and an omission processing unit, used to omit the text to be optimized whose pixel height value exceeds the specified number of lines.

[0010] The present invention is further configured as: a computer-readable storage medium, which stores program instructions therein, and the program instructions are executed by a processor to implement any one of the methods described above.

[0011] The present invention solves the defects existing in the background technology and has the following beneficial effects:

[0012] (1) The present invention proposes a method for optimizing the display of a keyword in a multi-line text when the first appearance position exceeds two lines. The method is implemented based on scientific and reasonable logic, while ensuring the safety and versatility of the implementation process. The text to be optimized that exceeds the specified number of lines is omitted, and the omitted data is displayed in the form of omitted identifier + keyword + subsequent content. This method achieves the purpose of more efficiently displaying key information in a limited control space, and effectively improves space utilization. The innovative method proposed by the present invention is simple and scientific, easy to implement, and conducive to a wide range of reasonable applications.

[0013] (2) Taking into account the user's usage habits, the present invention dynamically adjusts the pixel height value of the text to be optimized according to the user's device screen size to determine the amount of content to be omitted. Compared with the method of only marking and displaying keywords and then displaying text in the prior art, the present invention allows users to capture key information. At the same time, the present invention also proposes a function that can switch between the omitted identifier and the complete content of the text to be optimized according to the user's preferences, which greatly improves the user's usage experience and enhances the interactivity between the user and the front-end page. Compared with the prior art, it takes the user's actual experience into consideration more. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work.

[0015] Figure 1 The figure shows a flowchart of the implementation steps of the preferred embodiment of the present application.

[0016] Figure 2 The diagram illustrates a block diagram of a device for optimizing the display of a keyword in a multi-line text when the first occurrence position of the keyword exceeds two lines according to an embodiment of the present application. DETAILED DESCRIPTION

[0017] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0018] Application Overview

[0019] In front-end project development, when retrieving content by searching keywords, it is generally displayed in a list, which often faces the problem of limited page space and too long text content, which may make it difficult for users to quickly identify key information.

[0020] There are usually two solutions to this problem:

[0021] The first is that the front end can use the search keywords entered by the user to perform special processing on the matching text in the search results, such as highlighting the keywords, so that the user can quickly locate the content related to the search;

[0022] The second is to limit the display of part of the text content, usually the first two lines, and provide a "see more" button. After the user clicks the button, they can expand and view the full text content.

[0023] In the above two solutions, if the keyword is located at the end of the text content, the user may need to scroll or view the full content to find it, which may reduce the user experience; although the second method can solve the problem of page space, the user needs to manually click the button and cannot directly see the complete context directly related to the search keyword, which may increase the user's operating cost and reduce retrieval efficiency.

[0024] In response to the above technical problems, the concept of this application is to propose a method for optimizing the display of a keyword in a multi-line text when the first appearance position exceeds two lines. The method is implemented based on scientific and reasonable logic. First, the text to be optimized is obtained according to the keyword, and the pixel height of the text to be optimized is obtained according to the pixel width of the page. It is judged whether the pixel height of the text to be optimized exceeds the pixel height of the specified number of lines set by the program. Finally, the text to be optimized that exceeds the pixel height of the specified number of lines is omitted, so that the text field content searched by the user is displayed on the page in a way that omits the identifier + keyword + subsequent content, and the keyword is highlighted by highlighting the keyword background and other methods. This optimization method is implemented based on the implementation logic of the programming language, achieving the purpose of more efficient display of key information in a limited control space, and effectively improving space utilization.

[0025] After introducing the basic principles of the present application, various non-limiting embodiments of the present application will be described in detail with reference to the accompanying drawings.

[0026] Exemplary Methods

[0027] The innovative method proposed in the present invention is applicable to scenarios such as programs, scripts or front-end pages written in a programming language. The following is a specific implementation of the method in the front-end page as an example:

[0028] A method for optimizing the display of a keyword in a multi-line text when the first occurrence exceeds two lines, such as Figure 1 As shown, the following steps are included:

[0029] S1. Obtain keywords defined by the user;

[0030] S2. Access the data set on the server side according to the keyword and obtain each text field associated with the keyword;

[0031] S3, obtaining the position where the keyword first appears in the text field, and intercepting the text field content before the position where the keyword first appears as the text to be optimized;

[0032] S4, obtaining the pixel height value of the text to be optimized in the current page;

[0033] S5, determining whether the pixel height value of the text to be optimized exceeds the pixel height value of the specified number of lines, and omitting the text to be optimized that exceeds the specified number of lines;

[0034] S6. Based on the keyword, the text in the text field that is the same as the keyword is matched and highlighted.

[0035] Only making marks such as highlighting keywords in the retrieved associated text field to highlight the entire retrieved text field, and limiting the number of lines of the retrieved text field, greatly reduces the user's experience. Therefore, in the optimization method according to the embodiment of the present application, a logical method that conforms to the programming language can be used to first determine the content of the text to be optimized based on the first appearance position of the keyword, and then compare the pixel height value of the text to be optimized with the pixel height value of the specified number of lines obtained based on the pixel width value of the user page according to the reasonable implementation logic of the programming language, and finally use the omitted identifier to replace the text to be optimized whose pixel height value exceeds the specified number of lines. The optimization method proposed in this application conforms to the implementation logic of the programming language, and the effect after implementation by this method is very significant, with high utilization of the limited control space in the page, and can also allow users to quickly capture the context of the associated keywords.

[0036] Below, each step will be described in detail.

[0037] Specifically, in step S1, keywords defined by the user are obtained.

[0038] That is to say, the user needs to provide a keyword in a front-end page with a search function. In response to the request issued by the search function, the keyword will be sent to the back-end server corresponding to the front-end page to provide the user with the corresponding search service. In addition, for the security of program operation, when the user enters a keyword, the system should call the interface to implement security verification of the keyword. The security verification includes: format verification, length verification and special character filtering, etc., to ensure the stable operation of the system.

[0039] Specifically, in step S2, according to the keyword, the data set on the server is accessed, and each text field associated with the keyword is obtained.

[0040] When the system determines the keywords to be searched, it will access the server side, that is, access the server-side data storage system through programming (usually through API calls or database queries). On the server side, the system will retrieve relevant data sets based on the provided keywords (which can be SQL queries, NoSQL database queries or other data retrieval technologies), and extract the text fields of the associated keywords and display them on the front-end page. The text field format suitable for this method should be in string format, which is convenient for subsequent omission processing and avoids affecting the implementation of the method due to too many content formats obtained from the retrieved data set.

[0041] Specifically, in step S3, the position where the keyword first appears in the text field is obtained, and the content of the text field before the position where the keyword first appears is intercepted as the text to be optimized.

[0042] Step S3 can obtain the index of the first appearance position of the keyword in the text field through the index method in the programming language (such as JavaScript's indexOf() method), and then use the string interception method in the programming language to intercept the text field before the first appearance of the keyword as the text to be optimized.

[0043] Specifically, in step S4, the pixel height value of the text to be optimized in the current page is obtained.

[0044] The text field is displayed in a visual container specified in the front-end page. The container has pixel height and pixel width. The pixel width determines the length of the text field display, and the pixel height determines the height of the text field display. Based on scientific implementation methods, it is necessary to determine the pixel height value of the text to be optimized.

[0045] Specifically, in step S5, it is determined whether the pixel height value of the text to be optimized exceeds the pixel height value of the specified number of lines, and the text to be optimized that exceeds the specified number of lines is omitted;

[0046] The specified number of rows is based on a program setting on the server side. Considering the best implementation effect of this method, the specified number of rows can be set to two rows.

[0047] Before determining whether the height of the text to be optimized exceeds the specified number of lines in step S5, the method further includes the step of obtaining the pixel height value of a single line of text in the text field.

[0048] Reasonable implementation of the method of this application requires reasonable implementation logic based on programming language. Step S5 can only be performed after obtaining the pixel height value of a single line of text in the text field, and the steps include:

[0049] The pixel width value of the front-end page of the current displayed text field is obtained, and the pixel height value of the single-line text is determined according to the pixel width value of the current front-end page; wherein the pixel width value of the front-end page is dynamically adjusted based on the user's device screen size or reading preference. Since each user has different conditions, the format of the text field displayed on the front-end page according to the keywords is different, so the pixel height of the single-line text is also dynamically adjusted. Therefore, it is necessary to determine the height of the single-line text based on the user's conditions to improve the user experience, which also demonstrates the scientific rationality of this method.

[0050] The method for judging whether the pixel height value of the text to be optimized exceeds the pixel height value of the specified number of lines includes: comparing the specified number of lines of the pixel height value of a single-line text with the pixel height value of the text to be optimized; based on reasonable mathematical logic, an accurate judgment can be made by comparing the values ​​of the two. If the specified number of lines of the pixel height value of a single-line text is smaller than the pixel height value of the text to be optimized, it means that the number of lines of the text to be optimized is higher than the specified number of lines, and it is determined that the text to be optimized needs to be omitted to obtain the optimized display content.

[0051] The specific omission processing includes: using a specific omission marker to replace the text to be optimized, and setting the format of the text field after the omission processing to: omission marker + keyword + subsequent content, and the omission marker can be set to a special string with special meaning; displaying the content retrieved by the user in this form realizes a more efficient information display method in a limited control space, improves space utilization, and enables users to quickly capture the core theme of the text, greatly speeding up the screening and positioning of information.

[0052] Furthermore, an event listener can be associated with the omission marker to generate a event listener, which is used to convert the omission marker displayed in the front-end page with the complete content of the text to be optimized. Its implementation logic can be: by judging whether the mouse clicks the omission marker or the text content to be optimized to call the interface to realize the conversion between the two. Further improving the interactivity between users and text fields, users can be guided to further explore or click to view the complete content, which enhances the interactivity between users and interfaces and improves user experience.

[0053] Specifically, in step S6, the words in the text field that are the same as the keyword are matched based on the keyword and highlighted.

[0054] That is to say, in order to further improve the information acquisition efficiency of users, the keywords in the text field can be highlighted by methods such as changing the color of the keywords, highlighting the background color of the keywords, or underlining the keywords. At the same time, the step of matching the same text as the keywords includes: obtaining the same text as the keywords defined by regular expressions, and searching for matching items in the text field. Regular expressions are a common way of processing information in programming languages, which are applicable to various programming scenarios that require information processing, and ensure the rationality and feasibility of the implementation of the method of the present invention.

[0055] Exemplary Devices

[0056] Figure 2 The diagram illustrates a block diagram of a display optimization device for a keyword in a multi-line text where the first occurrence position exceeds two lines according to an embodiment of the present application.

[0057] like Figure 2As shown, according to an embodiment of the present application, a display optimization device 200 for a multi-line text where the first appearance position of a keyword exceeds two lines includes: a keyword receiving unit 210, used to receive and obtain a keyword input by a user; a data set traversal unit 220, used to extract text fields associated with the keywords after traversing the data set according to the keywords; a text to be optimized acquisition unit 230, used to obtain the content of the text to be optimized according to the first appearance position of the keyword in the text field; a judgment unit 240, used to calculate the pixel height value of the text to be optimized and judge whether it is greater than the pixel height value of a specified number of lines; and an omission processing unit 250, used to omit the text to be optimized whose pixel height value exceeds the specified number of lines.

[0058] In one example, in a display optimization device 200 where the first appearance position of a keyword in a multi-line text exceeds two lines, the text acquisition unit 230 to be optimized can be used to further intercept the text field content before the text field based on the first appearance position of the keyword in the text field as the text to be optimized and store it in a text container.

[0059] In one example, in a display optimization device 200 where the first appearance position of a keyword in a multi-line text exceeds two lines, the judgment unit 240 can be used to obtain the pixel height value of a single line of text based on the display page size of the current device, calculate the pixel height value of the text to be optimized, and based on a set specified number of lines, compare the specified number of lines of the pixel height value of the single line of text with the pixel height value of the text to be optimized to draw a judgment conclusion on whether it exceeds the limit or not.

[0060] In one example, in a display optimization device 200 where a keyword first appears beyond two lines in a multi-line text, the omission processing unit 250 can be used to replace the text to be optimized with an omission identifier, and display it in the text container in the form of an omission identifier + keyword + subsequent content. At the same time, the binding-associated omission identifier generates an event function that allows conversion between the complete content of the text to be optimized and the omission identifier by clicking the omission identifier or other corresponding buttons.

[0061] Exemplary computer-readable storage media

[0062] In addition, an embodiment of the present application may also be a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a processor, the processor executes the steps of a method for optimizing the display of a keyword in a multi-line text where the first occurrence position of the keyword exceeds two lines according to various embodiments of the present application as described in the above “Exemplary Method” section of this specification.

[0063] Computer readable storage media can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0064] In summary, the present invention provides a method for optimizing the display of a keyword in a multi-line text when the first appearance position exceeds two lines. The method gradually calculates data such as the width of a single line of text in a user page and the height of the text to be optimized through reasonable program programming logic, thereby ensuring the scientific rationality and correctness of the implementation of the method. In a limited control space, the omitted identifier is used to replace the text to be optimized, thereby improving the utilization rate of the space, making it easier for users to obtain key information associated with the keywords, and greatly speeding up the screening and positioning of information. In addition, an event listener is generated by associating the omitted identifier, and the mode of the text to be optimized and the omitted identifier is switched when the user hovers the mouse or clicks on the omitted identifier, thereby guiding the user to further explore or click to view the complete content, thereby enhancing the interactivity between the user and the interface and improving the user experience.

[0065] The above is based on the ideal embodiment of the present invention. Through the above description, relevant personnel can make various changes and modifications without departing from the technical concept of the present invention. The technical scope of the present invention is not limited to the content in the specification, and the technical scope must be determined according to the scope of the claims.

Claims

1. A method for optimizing the display of a keyword in a multi-line text when the first occurrence position exceeds two lines, characterized in that: The steps include: Get keywords defined by the user; According to the keyword, access the data set on the server side and obtain each text field associated with the keyword; Obtaining the position where the keyword first appears in the text field, and intercepting the text field content before the position where the keyword first appears as the text to be optimized; Get the pixel height value of the text to be optimized in the current page; Obtain the pixel width value of the front-end page that currently displays the text field, determine and obtain the height value of a single line of text based on the pixel width value of the current front-end page, compare the pixel height value of the single line of text times the specified number of lines with the pixel height value of the text to be optimized to determine whether the pixel height value of the text to be optimized exceeds the pixel height value of the specified number of lines, and omit the text to be optimized that exceeds the specified number of lines; wherein the specified number of lines is based on a program setting on the server side; the omission processing includes: using a specific omission marker to replace the display of the text to be optimized. Based on the keyword, the text in the text field that is identical to the keyword is matched and highlighted.

2. The method for optimizing the display of a keyword in a multi-line text when the first occurrence position exceeds two lines according to claim 1, characterized in that: An event listener is generated in association with the omission marker, and the event listener is used to convert the omission marker displayed in the front-end page and the complete content of the text to be optimized.

3. The method for optimizing the display of a keyword in a multi-line text when the first occurrence position exceeds two lines according to claim 1, characterized in that: Highlighting the keyword includes: changing the color of the keyword, highlighting the background color of the keyword, or underlining the keyword.

4. The method for optimizing the display of a keyword in a multi-line text when the first occurrence position exceeds two lines according to claim 1, characterized in that: When acquiring the keyword, security verification is performed on the keyword, and the security verification includes: format verification, length verification and special character filtering.

5. A display optimization device for a keyword in a multi-line text where the first occurrence position exceeds two lines, comprising: A keyword receiving unit, used to receive keywords input by a user; A data set traversal unit, used to extract text fields associated with keywords after traversing the data set according to the keywords; A text acquisition unit to be optimized, used to acquire the content of the text to be optimized according to the position where the keyword first appears in the text field; A judgment unit, used to calculate the pixel height value of the text to be optimized and judge whether it is greater than the pixel height value of a specified number of lines; as well as The omission processing unit is used to omit the text to be optimized that exceeds the specified number of lines and pixel height value.

6. A computer-readable storage medium having program instructions stored therein, characterized in that: When the program instructions are executed by a processor, the method as claimed in any one of claims 1 to 4 is implemented.