Movatterモバイル変換


[0]ホーム

URL:


CN114330232B - A text display method, device, equipment and storage medium - Google Patents

A text display method, device, equipment and storage medium
Download PDF

Info

Publication number
CN114330232B
CN114330232BCN202111644854.XACN202111644854ACN114330232BCN 114330232 BCN114330232 BCN 114330232BCN 202111644854 ACN202111644854 ACN 202111644854ACN 114330232 BCN114330232 BCN 114330232B
Authority
CN
China
Prior art keywords
text
target
segment
container
cutting
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111644854.XA
Other languages
Chinese (zh)
Other versions
CN114330232A (en
Inventor
陈秋鑫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Douyin Vision Co Ltd
Original Assignee
Douyin Vision Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Douyin Vision Co LtdfiledCriticalDouyin Vision Co Ltd
Priority to CN202111644854.XApriorityCriticalpatent/CN114330232B/en
Publication of CN114330232ApublicationCriticalpatent/CN114330232A/en
Application grantedgrantedCritical
Publication of CN114330232BpublicationCriticalpatent/CN114330232B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Landscapes

Abstract

Translated fromChinese

本公开提供了一种文本显示方法、装置、设备及存储介质,该方法包括:通过获取目标文本、用于显示所述目标文本的文本容器,以及所述文本容器在目标页面中显示文本的容器参数,在基于所述容器参数确定需要对目标文本进行裁剪时,可以确定裁剪参数,进而根据所述裁剪参数以及目标文本各字符的排列序号对目标文本进行至少一次裁剪,得到待显示文本。这样,可以从目标文本中的相应位置对目标文本进行至少一次裁剪,从而可以大大减少文本裁剪的次数,降低文本处理时间,以提高文本处理的效率和速度,同时还会减少裁剪掉的元素的数量,以减少了机身内存的无效占用,以保证终端运行的流畅度。

The present disclosure provides a text display method, device, equipment and storage medium, the method comprising: by obtaining a target text, a text container for displaying the target text, and a container parameter of the text container for displaying the text in a target page, when it is determined based on the container parameter that the target text needs to be cropped, the cropping parameter can be determined, and then the target text can be cropped at least once according to the cropping parameter and the arrangement sequence number of each character of the target text to obtain the text to be displayed. In this way, the target text can be cropped at least once from the corresponding position in the target text, thereby greatly reducing the number of text cropping times, reducing the text processing time, so as to improve the efficiency and speed of text processing, and at the same time reducing the number of cropped elements, so as to reduce the invalid occupation of the body memory, so as to ensure the smoothness of terminal operation.

Description

Text display method, device, equipment and storage medium
Technical Field
The disclosure relates to the technical field of data processing, and in particular relates to a text display method, text display equipment and a storage medium.
Background
With the continuous development and progress of technology, the internet becomes a part of people's life, work and study in the process of the gradual rise and maturation of internet technology, and people can acquire knowledge and information through the internet. People acquire information through the Internet, and most of the information is acquired through a terminal in a webpage browsing mode, and brief title information is displayed in interfaces of some webpages for people to browse.
In order to display more information on a web page during web page information browsing, the information is mostly simplified, for example, by displaying part of information or displaying a brief title on the web page, so that when some text contents to be displayed cannot be displayed completely or the text is too long and cannot be displayed in the second half, the part of text needs to be cut. At present, text is cut, one character is mostly removed from the tail part, particularly when the text content is overlong, the text needs to be processed for a plurality of times, the processing time is long, a large amount of processing time and processing resources are required to be consumed, more processing elements are generated during processing, so that a large memory is occupied during program operation, and fuselage jam and webpage collapse are easily caused, so that the processing efficiency and loading speed are greatly reduced.
Disclosure of Invention
The embodiment of the disclosure at least provides a text display method, a text display device, text display equipment and a storage medium.
The embodiment of the disclosure provides a text display method, which comprises the following steps:
acquiring a target text, a text container for displaying the target text, and container parameters of the text container for displaying the text in a target page;
determining whether the target text needs to be cut based on the container parameters;
If the target text needs to be cut, determining cutting parameters aiming at the target text;
Cutting the target text at least once based on the cutting parameters and the arrangement sequence numbers of the characters in the target text to obtain a text to be displayed;
and adding the obtained text to be displayed into the text container to display the text to be displayed in the target page.
In an alternative embodiment, the determining whether the target text needs to be clipped based on the container parameters includes:
Initializing the text container;
Determining a preset display height of the text container based on the preset display line number and the preset single line height in the container parameters;
adding a preset character to a preset position in the text container after initialization;
Adding the target text into the text container added with the preset characters to obtain a target display height for displaying the target text through the text container;
And if the target display height is larger than the preset display height, determining that the target text needs to be cut.
In an alternative embodiment, the determining the clipping parameters for the target text if clipping is required includes:
If the target text needs to be cut, determining cutting parameters for the target text based on the total amount of characters in the target text and the container parameters, or
If the target text needs to be cut, acquiring preset cutting parameters aiming at the target text.
In an optional implementation manner, the clipping the target text at least once based on the clipping parameters and the arrangement sequence number of the characters in the target text to obtain the text to be displayed includes:
Determining a first clipping position for the target text based on the arrangement sequence number of the first character and the arrangement sequence number of the last character in the target text and the clipping parameters;
Cutting the target text according to the first cutting position to obtain a first text segment in which a first character in the target text is located, wherein the first text segment comprises the first character in the target text and a second character corresponding to the first cutting position;
Determining whether clipping of the first text segment is required based on the container parameters;
If necessary, continuing to cut the first text segment as the target text until after cutting for a plurality of times, stopping when the real-time display height of the finally cut second text segment added into the text container is smaller than or equal to the preset display height of the text container determined based on the container parameters, and taking the second text segment as the text to be displayed;
and if not, taking the first text segment obtained by the first cutting as the text to be displayed.
In an alternative embodiment, the determining the first clipping location for the target text based on the sequence number of the first character and the sequence number of the last character in the target text and the clipping parameters includes:
Determining the numerical sum of the arrangement sequence number of the first character and the arrangement sequence number of the last character in the target text;
calculating a calculation result between the numerical value and the clipping parameter;
rounding the calculation result to obtain a target sequence number closest to the calculation result;
and determining the target sequence number as a first clipping position.
In an alternative embodiment, the method comprises:
When the first text segment or the second text segment serving as a text to be displayed is added into the text container, and the real-time display height of the text container is smaller than the preset display height of the text container, which is determined based on the container parameters, the first text segment or the second text segment is used as a text segment to be spliced, and a third text segment adjacent to the text segment to be spliced in the target text is determined, wherein the third text segment comprises a target character and a last character in the target text, and the target character is a first character after the last character of the text segment to be spliced in the target text;
cutting the third text segment at least once based on the sequence numbers of the characters in the third text segment and the cutting parameters to obtain a fourth text segment, wherein the real-time display height of the text segment spliced by the fourth text segment and the text segment to be spliced is equal to the preset display height;
and taking the text segment spliced by the text segment to be spliced and the fourth text segment as the text to be displayed.
In an optional implementation manner, the clipping the third text segment at least once based on the sequence number of the characters in the third text segment and the clipping parameter to obtain a fourth text segment includes:
Determining a second clipping position for the third text segment based on the arrangement sequence number of the first character and the arrangement sequence number of the last character in the third text segment and the clipping parameters;
Cutting the third text segment according to the second cutting position to obtain a fifth text segment and a sixth text segment, wherein the fifth text segment is a text segment comprising a first character in the third text segment, and the sixth text segment is a text segment adjacent to the fifth text segment and comprising a last character in the third text segment;
When the text segments after the fifth text segment and the text segments to be spliced are added into the text container, and the real-time display height of the text container is still smaller than the preset display height, cutting the sixth text segment again as the third text segment until the text segments to be spliced and at least two text segments after the fifth text segment are spliced, which are obtained by cutting, are added into the text container, and cutting is stopped when the real-time display height of the text container is equal to the preset display height;
And taking the text segment spliced by the at least two cut fifth text segments as the fourth text segment.
In an alternative embodiment, after the third text segment is cut according to the second cutting position to obtain a fifth text segment and a sixth text segment, the method includes:
When the fifth text segment and the text segment to be spliced are spliced and then added into the text container, and the real-time display height of the text container is larger than the preset display height, cutting the fifth text segment as the target text until the real-time display height of the seventh text segment obtained by cutting and the text segment to be spliced after being spliced is equal to the preset height after cutting for a plurality of times;
And taking the seventh text segment as the fourth text segment.
In an alternative embodiment, in the process of clipping the target text, the method includes:
And stopping cutting if the arrangement sequence number of the first character and the arrangement sequence number of the last character in the text segment are the same for the text segment obtained by cutting each time.
In an alternative embodiment, after the target text is cut at least once based on the cutting parameter and the sequence number of the characters in the target text, the method includes:
detecting whether the last character in the text to be displayed belongs to a special character which is counted in advance and does not need to be displayed;
If yes, cutting out the last character in the text to be displayed, and obtaining the processed text to be displayed.
The disclosed examples also provide a text display device, the device comprising:
The system comprises an acquisition module, a display module and a display module, wherein the acquisition module is used for acquiring a target text, a text container used for displaying the target text and container parameters of the text container for displaying the text in a target page;
The first determining module is used for determining whether the target text needs to be cut or not based on the container parameters;
The second determining module is used for determining cutting parameters aiming at the target text if the target text needs to be cut;
The text clipping module is used for clipping the target text at least once based on the clipping parameters and the arrangement sequence numbers of the characters in the target text to obtain a text to be displayed;
And the text display module is used for adding the obtained text to be displayed into the text container so as to display the text to be displayed in the target page.
In an alternative embodiment, the first determining module is specifically configured to:
Initializing the text container;
Determining a preset display height of the text container based on the preset display line number and the preset single line height in the container parameters;
adding a preset character to a preset position in the text container after initialization;
Adding the target text into the text container added with the preset characters to obtain a target display height for displaying the target text through the text container;
And if the target display height is larger than the preset display height, determining that the target text needs to be cut.
In an alternative embodiment, the second determining module is specifically configured to:
If the target text needs to be cut, determining cutting parameters for the target text based on the total amount of characters in the target text and the container parameters, or
If the target text needs to be cut, acquiring preset cutting parameters aiming at the target text.
In an alternative embodiment, the text clipping module is specifically configured to:
Determining a first clipping position for the target text based on the arrangement sequence number of the first character and the arrangement sequence number of the last character in the target text and the clipping parameters;
Cutting the target text according to the first cutting position to obtain a first text segment in which a first character in the target text is located, wherein the first text segment comprises the first character in the target text and a second character corresponding to the first cutting position;
Determining whether clipping of the first text segment is required based on the container parameters;
If necessary, continuing to cut the first text segment as the target text until after cutting for a plurality of times, stopping when the real-time display height of the finally cut second text segment added into the text container is smaller than or equal to the preset display height of the text container determined based on the container parameters, and taking the second text segment as the text to be displayed;
and if not, taking the first text segment obtained by the first cutting as the text to be displayed.
In an alternative embodiment, the text clipping module is specifically configured to, when determining the first clipping location for the target text based on the sequence number of the first character and the sequence number of the last character in the target text, and the clipping parameter:
Determining the numerical sum of the arrangement sequence number of the first character and the arrangement sequence number of the last character in the target text;
calculating a calculation result between the numerical value and the clipping parameter;
rounding the calculation result to obtain a target sequence number closest to the calculation result;
and determining the target sequence number as a first clipping position.
In an alternative embodiment, the text clipping module is further configured to:
When the first text segment or the second text segment serving as a text to be displayed is added into the text container, and the real-time display height of the text container is smaller than the preset display height of the text container, which is determined based on the container parameters, the first text segment or the second text segment is used as a text segment to be spliced, and a third text segment adjacent to the text segment to be spliced in the target text is determined, wherein the third text segment comprises a target character and a last character in the target text, and the target character is a first character after the last character of the text segment to be spliced in the target text;
cutting the third text segment at least once based on the sequence numbers of the characters in the third text segment and the cutting parameters to obtain a fourth text segment, wherein the real-time display height of the text segment spliced by the fourth text segment and the text segment to be spliced is equal to the preset display height;
and taking the text segment spliced by the text segment to be spliced and the fourth text segment as the text to be displayed.
In an optional implementation manner, the text clipping module is specifically configured to, when being configured to clip the third text segment at least once based on the sequence number of the characters in the third text segment and the clipping parameter, obtain a fourth text segment:
Determining a second clipping position for the third text segment based on the arrangement sequence number of the first character and the arrangement sequence number of the last character in the third text segment and the clipping parameters;
Cutting the third text segment according to the second cutting position to obtain a fifth text segment and a sixth text segment, wherein the fifth text segment is a text segment comprising a first character in the third text segment, and the sixth text segment is a text segment adjacent to the fifth text segment and comprising a last character in the third text segment;
When the text segments after the fifth text segment and the text segments to be spliced are added into the text container, and the real-time display height of the text container is still smaller than the preset display height, cutting the sixth text segment again as the third text segment until the text segments to be spliced and at least two text segments after the fifth text segment are spliced, which are obtained by cutting, are added into the text container, and cutting is stopped when the real-time display height of the text container is equal to the preset display height;
And taking the text segment spliced by the at least two cut fifth text segments as the fourth text segment.
In an alternative embodiment, the text clipping module is further configured to:
When the fifth text segment and the text segment to be spliced are spliced and then added into the text container, and the real-time display height of the text container is larger than the preset display height, cutting the fifth text segment as the target text until the real-time display height of the seventh text segment obtained by cutting and the text segment to be spliced after being spliced is equal to the preset height after cutting for a plurality of times;
And taking the seventh text segment as the fourth text segment.
In an alternative embodiment, the text clipping module is specifically configured to, during clipping the target text:
And stopping cutting if the arrangement sequence number of the first character and the arrangement sequence number of the last character in the text segment are the same for the text segment obtained by cutting each time.
In an alternative embodiment, the apparatus further comprises a character detection module for:
detecting whether the last character in the text to be displayed belongs to a special character which is counted in advance and does not need to be displayed;
If yes, cutting out the last character in the text to be displayed, and obtaining the processed text to be displayed.
The embodiment of the disclosure also provides an electronic device, which comprises a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, when the electronic device is operated, the processor and the memory are communicated through the bus, and the machine-readable instructions are executed by the processor to execute the steps of the text display method.
The disclosed embodiments also provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the text display method described above.
The text display method, device, equipment and storage medium provided by the embodiment of the disclosure are characterized by obtaining a target text, a text container for displaying the target text and container parameters of the text container for displaying the text in a target page, determining whether the target text needs to be cut based on the container parameters, determining cutting parameters for the target text if the target text needs to be cut, cutting the target text at least once based on the cutting parameters and the arrangement sequence number of characters in the target text to obtain a text to be displayed, and adding the obtained text to be displayed into the text container to display the text to be displayed in the target.
Therefore, the target text can be cut at least once from the corresponding position in the target text through the container parameters when the text is displayed by the text container, the cutting parameters of the target text and the arrangement sequence numbers of the characters in the target text, so that the cutting times of the text can be greatly reduced, the text processing time is shortened, the efficiency and the speed of text processing are improved, the number of cut elements is reduced, the invalid occupation of the memory of a machine body is reduced, and the running smoothness of the terminal is ensured.
The foregoing objects, features and advantages of the disclosure will be more readily apparent from the following detailed description of the preferred embodiments taken in conjunction with the accompanying drawings.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for the embodiments are briefly described below, which are incorporated in and constitute a part of the specification, these drawings showing embodiments consistent with the present disclosure and together with the description serve to illustrate the technical solutions of the present disclosure. It is to be understood that the following drawings illustrate only certain embodiments of the present disclosure and are therefore not to be considered limiting of its scope, for the person of ordinary skill in the art may admit to other equally relevant drawings without inventive effort.
FIG. 1 illustrates a flow chart of a text display method provided by an embodiment of the present disclosure;
FIG. 2 illustrates a flow chart of another text display method provided by an embodiment of the present disclosure;
fig. 3 is a schematic view of clipping logic of a text display method according to an embodiment of the disclosure;
FIG. 4 shows one of the schematic diagrams of a text display device provided by embodiments of the present disclosure;
FIG. 5 is a second schematic diagram of a text display device according to an embodiment of the present disclosure;
Fig. 6 shows a schematic diagram of an electronic device provided by an embodiment of the disclosure.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are only some embodiments of the present disclosure, but not all embodiments. The components of the embodiments of the present disclosure, which are generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure provided in the accompanying drawings is not intended to limit the scope of the disclosure, as claimed, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be made by those skilled in the art based on the embodiments of this disclosure without making any inventive effort, are intended to be within the scope of this disclosure.
It should be noted that like reference numerals and letters refer to like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures.
The term "and/or" is used herein to describe only one relationship, and means that three relationships may exist, for example, A and/or B, and that three cases exist, A alone, A and B together, and B alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, may mean including any one or more elements selected from the group consisting of A, B and C.
According to research, at present, text is cut, one character is removed from the tail, particularly when the text content is overlong, repeated processing is needed to be carried out on the text for many times, the processing time is long, a large amount of processing time and processing resources are needed to be consumed, more processing elements are generated during processing, so that a large memory is occupied during program operation, and fuselage blocking and webpage collapse are easy to cause, so that the processing efficiency and loading speed are greatly reduced.
Based on the above study, the disclosure provides a text display method, which comprises the steps of obtaining a target text, a text container for displaying the target text, and container parameters of the text container for displaying the text in a target page, determining whether the target text needs to be cut based on the container parameters, determining cutting parameters for the target text if the target text needs to be cut, cutting the target text at least once based on the cutting parameters and the arrangement sequence number of characters in the target text to obtain a text to be displayed, and adding the obtained text to be displayed into the text container to display the text to be displayed in the target.
Therefore, the target text can be cut at least once from the corresponding position in the target text through the container parameters when the text is displayed by the text container, the cutting parameters of the target text and the arrangement sequence numbers of the characters in the target text, so that the cutting times of the text can be greatly reduced, the text processing time is shortened, the efficiency and the speed of text processing are improved, the number of cut elements is reduced, the invalid occupation of the memory of a machine body is reduced, and the running smoothness of the terminal is ensured.
For the sake of understanding the present embodiment, first, a detailed description will be given of a text display method disclosed in the present embodiment, where an execution subject of the text display method provided in the present embodiment is generally a computer device with a certain computing capability, and the computer device includes, for example, a terminal device or a server or other processing device, and the terminal device may be a User Equipment (UE), a mobile device, a User terminal, a cellular phone, a cordless phone, a Personal digital assistant (Personal DIGITAL ASSISTANT, PDA), a handheld device, a computing device, a wearable device, or the like. In some possible implementations, the text display method can be implemented by way of a processor invoking computer readable instructions stored in a memory.
Referring to fig. 1, fig. 1 is a flowchart of a text display method according to an embodiment of the disclosure. As shown in fig. 1, a text display method provided by an embodiment of the present disclosure includes:
S101, acquiring a target text, a text container for displaying the target text, and a container parameter of the text container for displaying the text in a target page.
In the step, when a user needs to use the terminal to browse information in a webpage, the user can use the terminal to open a corresponding webpage, brief titles of all the information can be displayed in the webpage, at the moment, for one piece of information needing to display the brief titles, a target text of the information and a text container needed to be used for displaying the target text through the webpage can be obtained, and meanwhile, preset container parameters when the text container is used for displaying the text in the target webpage can be obtained.
The preset container parameters may include a preset number of display lines (total number of display lines) of the text container when the target text is displayed, a preset number of display words (total number of words), a preset single line height, a preset number of single line words (maximum number of words that each line can display) of the text container when the target text is displayed, a preset display height (overall height when the text is displayed), and the like.
The preset container parameters can be set by the user according to the browsing needs of the user, the page display needs and other factors, and can be default or real-time dynamic adjustment of the web page.
S102, determining whether the target text needs to be cut or not based on the container parameters.
In this step, after the container parameter and the target text are acquired, whether the display specification of the text container is exceeded or not, that is, whether the container parameter specification of the text container is met or not when the target text is displayed through the text container can be detected through comparison, matching and the like between the container parameter and the target text, so that whether the target text needs to be cut or not can be determined.
The display specification of the text container may be a display specification under the container parameter, for example, within a preset display line number, or within a preset display word number, etc.
When a thumbnail text or a brief title of the target text needs to be displayed on the target page through the text container, special words or characters such as "thumbnail" or ". The brief title is attached to the thumbnail text or the brief title to indicate that only part of the text is displayed, the special words or characters can be used as fixed display content added in the text container, and the text container can not occupy the text content, for example, the maximum display word number of the text container is 100 characters, and then the maximum display word number of the text container relative to the text is 99 because of the special words or characters.
When determining whether the target text needs to be cut, specifically, the text container may be initialized first to ensure the practicability of the text container, reduce factors that may affect cutting of subsequent text content, further, the preset display height of the text container may be determined based on the preset display line number and the preset single line height in the container parameter, that is, by means of the preset display height, the range or the text amount that the target text is allowed to be displayed in the target page may be determined by taking the preset display height as a reference, then a preset character may be added to a preset position in the text container after initialization, so as to occupy a position in advance, and thus, in an experimental stage, further determine a range or a text amount that may affect cutting of the subsequent text content, the preset character may represent a portion of text that cannot be displayed in the target text, then the preset display height may be added to the text container added with the preset character, so that the target text is displayed in the target page by the preset display height, that is allowed to display the preset display height in the target page may be determined based on the preset display height, that is actually the preset display height in the text container, that is based on the preset display height in the preset display height, that is actually the text container height in the target page, and the preset display height may be determined, therefore, whether the specification is exceeded or not can be judged through comparison between the target display height and the preset display height, and finally, if the target display height is larger than the preset display height, the target text can be determined to be needed to be cut.
Conversely, if the target display height is less than or equal to the preset display height, then no cropping of the text is required.
Besides the comparison by height, the method can determine whether the target text needs to be cut through the number of words and other factors, for example, the total number of characters in the target text and the preset display word number of the text container indicated by the container parameter can be obtained, if the total number of characters in the target text is greater than the preset display word number, the method can also determine whether the target text needs to be cut, and in addition, the method can determine whether the target text needs to be cut through the number of lines, namely, whether the number of lines to be specifically displayed after the target text is put into the text container exceeds the maximum display line number.
For example, taking the case that the target text to be displayed is "two three five six seven ninety hundred thousand trillions", the preset display line number of the text container for displaying the text is 2 lines, the preset display word number of each line is 3 characters, the preset single line word height is 20 pixels as an example, since the preset single line word height is 20 pixels, the preset display line number is 2 lines, the preset display height allowed to be displayed when the text container displays the text on the target page is 40 pixels, and in the case that the target text is added into the text container, because the preset display word number of each line of the text container is 3 characters, and the special words to be displayed bound in the text container are "slightly", 5 lines of contents are actually required to be displayed, the target display height reaches 100 pixels, and the target display height is far greater than the preset display word number, so that the target text needs to be cut.
S103, if the target text needs to be cut, determining cutting parameters aiming at the target text.
The clipping parameters may refer to the determined clipping position, clipping amount, and other related parameters for the target text when the target text needs to be clipped.
The clipping parameters can be fixed parameters, such as fixed parameters bound with the text container and bound with the target page, or dynamic parameters dynamically adjusted according to the actual display condition of the target page, the text container and the actual text condition of the target text.
Specifically, for determining the clipping parameters, when the target text needs to be clipped, that is, if the target text needs to be clipped, a preset clipping parameter for the target text, that is, a preset fixed parameter may be directly obtained, or when it is determined that the target text needs to be clipped, that is, if the target text needs to be clipped, the total amount of characters in the target text is determined first, the container parameters are obtained, and based on the total amount of characters in the target text and the container parameters, that is, by comparing parameters, such as a preset display word number, included in the container parameters with the total amount of characters, the clipping parameters for the target text are dynamically determined.
For example, if the total amount of characters in the target text is larger, and the amount of text allowed to be displayed in the target page is smaller, or is far smaller than the total amount of characters, then the number of times of cutting is considered to be larger, correspondingly, the cutting parameter can be appropriately increased, and conversely, the cutting parameter can be appropriately decreased. Here, the clipping parameter may refer to a parameter indicating a position, a number of words, or the like from the text end of the target text toward the text front end, for example, the clipping parameter may be one third, or may be a parameter indicating a position, a number of words, or the like from the text end of the target text toward about one third.
And S104, cutting the target text at least once based on the cutting parameters and the arrangement sequence numbers of the characters in the target text to obtain a text to be displayed.
In this step, after determining the clipping parameters, the clipping parameters may be used to combine the arrangement condition of each character in the target text, such as the arrangement sequence number of each character, so as to determine factors such as clipping position of single clipping, character amount of single clipping, etc. in the text when clipping the target text, and then clipping the target text to obtain the text to be displayed that can be displayed.
The characters in the target text may be characters, numbers, symbols, english words, english letters, etc. occupying one character position.
The sequence number of each character may be a number set for each character in sequence in advance according to the amount of characters in the target text and the arrangement condition of the characters.
Specifically, when the target text is cut, the following procedure may be adopted:
And determining a first clipping position for the target text based on the arrangement sequence number of the first character and the arrangement sequence number of the last character in the target text and the clipping parameters.
Here, the sequence numbers of the characters in the text may be added in advance, or may be added to each character according to the sequence of each character in the text after each time the text is acquired, where the sequence numbers of two adjacent characters are consecutive natural numbers. The arrangement numbers of the characters may be 0,1, 2, and 3, or 1, 2, 3, and 4, respectively, and are not limited in any way.
After the sequence numbers added to the characters are obtained, the first clipping position which can be clipped in the target text can be calculated by means of the sequence numbers of the characters, such as the sequence number of the first character and the sequence number of the last character, and the clipping parameters obtained before.
Specifically, the determining the first clipping position may be firstly obtaining the sequence number of the first character and the sequence number of the last character in the target text, then calculating through the values of the sequence number of the first character and the sequence number of the last character to determine the sum of the values of the sequence number of the first character and the sequence number of the last character in the target text, then calculating the calculation result between the sum of the values and the clipping parameters, and since the calculated calculation result may have a remainder, the calculation result may include decimal points and decimal points, the calculation result needs to be rounded to obtain a target sequence number closest to the calculation result, wherein the difference between the calculation result and the target sequence number is smaller than or equal to the difference between the calculation result and other sequence numbers, and finally determining the target sequence number as the first clipping position.
The calculation mode of the numerical value sum and the clipping parameter can be determined according to the expression form of the clipping parameter, for example, in the case that the text needs to be clipped in two parts, namely, in the case that the text is clipped in 2 parts, in most cases, the clipping parameter can be expressed as 1/2 and used for expressing clipping half, at this time, the numerical value sum and the clipping parameter can be calculated by multiplying the numerical value sum and the clipping parameter to obtain a calculation result, otherwise, if the clipping parameter is expressed in other modes, for example, in the case that the clipping parameter is expressed in two parts, namely, in the case that the clipping parameter is 2 in two parts, the numerical value sum and the clipping parameter are calculated, namely, the numerical value sum and the clipping parameter need to be divided to obtain the calculation result.
The target sequence number is a natural number and is one of the arrangement sequence numbers of a plurality of characters in the target text.
The calculation result is rounded, which can be rounded upwards, rounded downwards, or dynamically determined to be rounded upwards or rounded downwards according to the specific numerical value of the calculation result, so as to obtain the nearest integer, namely, the difference value between the calculated result and the target sequence number is smaller than or equal to the difference value between the calculated result and other sequence numbers.
The determining the target sequence number as the first clipping position may refer to determining a position where a character corresponding to the target sequence number is located as the first clipping position, that is, a position before or after the character corresponding to the target sequence number is the first clipping position, specifically, a position before or after the character corresponding to the target sequence number when clipping, and it may be determined which clipping position to take by referring to factors such as a rounding direction, a size of clipping parameters, and the like.
For example, when the target sequence number is determined to be rounded up, when the clipping position is taken, the corresponding position before the character corresponding to the target sequence number can be used as the first clipping position to balance the influence of rounding up.
Then, the target text can be cut according to the first cutting position, and a first text segment where a first character in the target text is located is obtained, wherein the first text segment comprises the first character in the target text and a second character corresponding to the first cutting position.
Here, after the first clipping position is determined, clipping may be performed on the target text at the first clipping position in the target text, so as to obtain a front text after clipping, which is used as the first text segment.
Here, when the first text segment is taken, the text content composed of the first character in the target text and the second character corresponding to the first clipping position is taken as the first text segment, that is, if the first clipping position is after the second character corresponding to the target sequence number, the first text segment may include the second character, but is not limited thereto, and in other embodiments, for example, if the first clipping position is before the second character corresponding to the target sequence number, the first text segment may not include the second character, that is, after clipping, the first text segment includes the first character in the target text and the second character corresponding to the first clipping position.
And then determining whether the first text segment needs to be cut based on the container parameters, if so, namely, if so, continuing cutting the first text segment as the target text until after cutting for a plurality of times, stopping when the real-time display height of the finally cut second text segment added into the text container is smaller than or equal to the preset display height of the text container determined based on the container parameters, taking the second text segment as the text to be displayed, and if not, taking the first text segment obtained by cutting for the first time as the text to be displayed.
Here, since the text to be displayed meeting the display requirement cannot be obtained through one-time clipping, multiple clipping is required, and conversely, after the target text is clipped for the first time to obtain the first text segment, if the arrangement sequence number of the first character in the first text segment is the same as the arrangement sequence number of the last character, that is, only one character in the first text segment cannot be clipped any more, clipping can be directly stopped.
Therefore, after the first text segment is obtained by first clipping, the first text segment may be detected again based on the container parameter to detect whether the first text segment needs to be clipped again, specifically, the first text segment may be added to the text container to see the actual display height of the first text segment, then the actual display height may be compared with a preset display height indicated in the container parameter, and the like, and if the actual display height is less than or equal to the preset display height, it may be considered that clipping of the first text segment is not needed any more, and the first text segment obtained by first clipping may be directly used as the text to be displayed.
Conversely, if the actual display height is greater than the preset display height, it may be considered that the second text segment needs to be cut, where the first text segment may be used as the target text, the first cutting position of the target text, that is, the first text segment, may be determined again by a cutting parameter or the like to cut, after the second text segment is obtained by the second cutting, if the second text segment needs to be cut again, the second text segment may be cut according to the above process, until after the second text segment obtained by the last cutting does not need to be cut again, after the second text segment obtained by the last cutting is added to the text container, the actual display height may be less than or equal to the preset display height of the text container determined based on the container parameter, where the second text segment obtained by the last cutting may be used as the text to be displayed.
After the target text is cut for multiple times, if the content in the second text segment obtained by cutting exactly, that is, the content of the text to be displayed is adapted to the text container, for example, the actual display height is equal to the preset display height, and the number of characters in the second text segment is the same as the preset display words of the text container, it may be considered as the most suitable cutting result, but often in the cutting process, the second text segment obtained by cutting exactly cannot be adapted due to excessive cutting, that is, the real-time display height of adding the second text segment to the text container is smaller than the preset height, or although the real-time display height is equal to the preset height, the number of words of the last line is smaller, resulting in that the content actually displayed on the target page is smaller or insufficient, so that a further part of the characters after the first text segment may be cut, spliced after the first text segment, thereby making the final text to be adapted to the text container exactly.
Specifically, when the target text is cut for multiple times, after the first text segment or the second text segment is obtained by cutting the target text, the first text segment or the second text segment serving as the text to be displayed may be added to the text container, if the first text segment or the second text segment serving as the text to be displayed is added to the text container, the real-time display height of the text container is smaller than the preset display height of the text container determined based on the container parameter, the text displayed in the target page may be considered to be insufficient, and at this time, the first text segment or the second text segment may be used as the text segment to be spliced, and then a third text segment adjacent to the text segment to be spliced in the target text may be determined, where the third text segment includes a target character and a last character in the target text, and the target character is the last character in the target text after the first character in the target text segment to be spliced.
And then, based on the arrangement sequence numbers of the characters in the third text segment and the cutting parameters, cutting the third text segment at least once to obtain a fourth text segment, and finally, taking the text segment to be spliced and the text segment spliced by the fourth text segment as the text to be displayed.
And adding the text segment spliced by the fourth text segment and the text segment to be spliced into the text container, wherein the real-time display height of the text segment is equal to the preset display height.
Specifically, for at least one clipping of the third text segment, the following procedure may be implemented:
first, a second clipping location for the third text segment may be determined based on the sequence number of the first character and the sequence number of the last character in the third text segment, and the clipping parameters.
Here, the manner and the specific procedure of determining the second clipping position may be the same as the manner and the specific procedure of determining the first clipping position.
And then, cutting the third text segment according to the second cutting position to obtain a fifth text segment and a sixth text segment, wherein the fifth text segment is a text segment comprising a first character in the third text segment, and the sixth text segment is a text segment adjacent to the fifth text segment and comprising a last character in the third text segment.
Here, after the second clipping position is determined, the third text segment may be clipped at the second clipping position in the third text segment, to obtain a clipped fifth text segment and sixth text segment.
Wherein the third text segment is a text segment including a first character in the second text segment, and the fourth text segment is a text segment adjacent to the third text segment and including a last character in the second text segment.
Here, when the third text segment is taken, the text content may be formed by the first character in the second text segment, the fourth character corresponding to the second clipping position, and at least one fifth character located between the first character and the fourth character in the second text segment, as the third text segment. Accordingly, the third text segment may be included with the fourth character if the second clipping location is after the fourth character, and the third text segment may be excluded from the fourth character if the second clipping location is before the fourth character.
Then, a fifth text segment obtained after cutting the third text segment is spliced with the text segment to be spliced, the text segment after splicing the fifth text segment and the text segment to be spliced is added into the text container, when the real-time display height of the text container is still smaller than the preset display height, the sixth text segment is used as the third text segment to be cut again until the text segment to be spliced and at least two text segments after splicing the fifth text segment obtained by cutting are added into the text container, cutting is stopped when the real-time display height of the text container is equal to the preset display height, and the text segment after splicing the at least two text segments after splicing the fifth text segment obtained by cutting is used as the fourth text segment.
Here, after the fifth text segment is obtained, the obtained fifth text segment and the text segment to be spliced may be spliced, and the spliced text may be detected again, if the real-time display height of the spliced text segment in the text container is still smaller than the preset display height, the spliced text segment may be considered to be insufficient, and some additional text segments may be further required, at this time, the cut sixth text segment may be cut again as the third text segment to supplement the spliced text segment again, specifically, the sixth text segment as the third text segment may be cut again according to the above process, until after multiple cutting, the spliced text segment to be spliced and at least two text segments obtained by cutting the fifth text segment may be added to the text container, and when the real-time display height of the text container is equal to the preset display height, all cut text segments may be considered to meet the requirement of stopping the display of the target page.
Conversely, when the fifth text segment is obtained, the obtained fifth text segment and the text segment to be spliced are spliced, and the fifth text segment and the text segment to be spliced are detected again after being spliced and added into the text container, and when the fifth text segment and the text segment to be spliced are spliced and added into the text container, the real-time display height of the text container is larger than the preset display height, the spliced text can be considered to be exceeded, the fifth text segment can be cut as the target text at the moment, until the real-time display height of the seventh text segment obtained by cutting and the text segment to be spliced after being spliced is equal to the preset height after being spliced for a plurality of times, and the seventh text segment can be regarded as the fourth text segment at the moment.
Furthermore, in order to align the content displayed on the target page with other information, the integrity of each piece of information in the target page is ensured, when the sixth text segment is cut again as the third text segment, the cutting may be stopped in a plurality of cutting processes until the number of characters in the text segment to be spliced and the text segment spliced by at least two fifth text segments obtained by cutting is equal to the preset character capacity in the text container determined based on the container parameter.
In addition, since each time of cutting is required to splice the cut text, the cut text is put into the text container for detection, in order to reduce the detection content and simplify the detection flow, the arrangement sequence number of each character in the cut text can be used as a reference for comparison, specifically, when the sixth text segment is used as the third text segment for cutting again in the cutting process, the cutting is stopped until the arrangement sequence number corresponding to the second cutting position is the same as the arrangement sequence number of the last character in the cut third text.
Finally, when the second text segment obtained by cutting is used as the text to be displayed, a fourth text segment needing to be supplemented is newly obtained, so that the text segment to be spliced and the text segment spliced by the fourth text segment can be used as the text to be displayed.
For example, still taking the target text to be displayed as "two, three, four, six, seven, ninety and ten trillion", the preset display line number of the text container for displaying the text is 2 lines, the preset display word number of each line is 3 characters, the preset single line word height is 20 pixels as an example, when it is determined that the target text needs to be cut, a cutting parameter for the target text can be obtained, for example, 1/2, taking the starting label of "two, three, four, five, seven, ninety and ten trillion" for "two, three, four, six, seventy and ten trillion" as an example, the arrangement sequence numbers of the characters are 0,1, 2,3,..:
M= (0+13)/2=6.5, wherein m is a first clipping position, 0 is an arrangement sequence number of a first character 'one' in the target text, 13 is an arrangement sequence number of a last character 'one' in the target text, taking down the whole as an example, wherein m takes 6, namely taking a position of a character 'seven' with the arrangement sequence number of 6 as the first clipping position, taking clipping before 'seven' as an example, a first text segment obtained by clipping for the first time is 'two, three, four, five and six', at the moment, the first text segment is added into a text container, a special word 'slightly' which needs to be displayed is added in advance, at the moment, the actual display line number is three lines, and is larger than the preset display line number 2, so that the first text segment obtained by clipping needs to be clipped for the second time as the target text;
M= (0+5)/2=2.5, m is a new first clipping position, 0 is a new target text, namely, the arrangement sequence number of the first character "one" in the first text segment after the first clipping, 5 is a new target text, namely, the arrangement sequence number of the last character "six" in the first text segment after the first clipping is still taking the downward rounding as an example, m is taken as 2, namely, the position where the character "three" with the arrangement sequence number of 2 is located is taken as a new first clipping position, the first text segment obtained by the second clipping is taken as an example before the third, at this time, the new first text segment is added into a text container, the special characters "slightly" which are required to be displayed are added, at this time, the actual display line number is one line, which is smaller than the preset display line number 2, but the clipping can be stopped when the last character is displayed in the target page, therefore, the text of the obtained first text segment can be supplemented, the text needs to be supplemented from the later clipping part, and the first text segment is spliced;
And (3) cutting for the third time, wherein m= (2+5)/2=3.5, m is the second cutting position, 2 is the arrangement sequence number of the first character 'three' in the second text after cutting, 5 is the arrangement sequence number of the character 'six' corresponding to the first cutting position in the first time, still taking the downward rounding as an example, wherein m takes 3, namely taking the position of the character 'four' with the arrangement sequence number of 3 as the second cutting position, taking the cutting before 'four' as an example, adding special characters 'slightly', adding 2 lines of actual display lines after the first text segment and the third text segment are spliced, and the actual display line number is equal to the preset display line number 2, stopping cutting at this time, and cutting the fourth text segment again in order to enable the final text to be displayed to be just matched with the text container:
M= (3+5)/2=4, m is a new second clipping position, 3 is an arrangement serial number of a first character 'four' in the fourth text after clipping, 5 is an arrangement serial number of a character 'six' corresponding to the first clipping position when clipping is performed for the first time, a position where a character 'five' with the arrangement serial number of 4 is located is taken as the second clipping position, a third text segment obtained by clipping before clipping is taken as an example, after the first text segment and the obtained two third text segments are spliced, a special word 'slightly' is added to a text container, the actual display line number is 2 lines, and is equal to the preset display line number 2, but the second line only has two characters and needs to be added;
And a fifth clipping step, wherein m= (4+5)/2=4.5, m is a new second clipping position, 4 bits of the arrangement serial number of the first character 'five' in the fourth text after clipping, 5 is the arrangement serial number of the character 'six' corresponding to the first clipping position when clipping is performed for the first time, the position where the character 'five' with the arrangement serial number of 4 is located is used as the second clipping position, if clipping is still performed before 'five', the result is the same as the result of the last clipping, therefore, the third text segment obtained by clipping after 'five' is clipped after 'five', after the first text segment and the obtained three third text segments are clipped, the special characters 'slightly' are added after the first text segment and the obtained three third text segments are clipped, the actual display text is 'two, three and four and five', the display line number is 2 lines, the total character number is 6, and the total character number is the same as the preset display number, namely clipping can be stopped.
And S105, adding the obtained text to be displayed into the text container to display the text to be displayed in the target page.
The text display method comprises the steps of obtaining a target text, a text container used for displaying the target text, and container parameters of the text container for displaying the text in a target page, determining whether the target text needs to be cut based on the container parameters, determining cutting parameters for the target text if the target text needs to be cut, cutting the target text at least once based on the cutting parameters and the arrangement sequence number of characters in the target text to obtain a text to be displayed, and adding the obtained text to be displayed into the text container to display the text to be displayed in the target page.
Therefore, the target text can be cut at least once from the corresponding position in the target text through the container parameters when the text is displayed by the text container, the cutting parameters of the target text and the arrangement sequence numbers of the characters in the target text, so that the cutting times of the text can be greatly reduced, the text processing time is shortened, the efficiency and the speed of text processing are improved, the number of cut elements is reduced, the invalid occupation of the memory of a machine body is reduced, and the running smoothness of the terminal is ensured.
Referring to fig. 2, fig. 2 is a flowchart of another text display method provided by an example of the disclosure, as shown in fig. 2, the method includes:
s201, acquiring a target text, a text container for displaying the target text, and a container parameter of the text container for displaying the text in a target page.
S202, determining whether the target text needs to be cut or not based on the container parameters.
S203, if the target text needs to be cut, determining cutting parameters aiming at the target text.
S204, cutting the target text at least once based on the cutting parameters and the arrangement sequence numbers of the characters in the target text to obtain a text to be displayed.
S205, detecting whether the last character in the text to be displayed belongs to special characters which are counted in advance and do not need to be displayed.
In the step, after the text to be displayed is preliminarily obtained, special characters which are counted in advance and do not need to be displayed can be obtained, and whether the last character is the special character or not is detected through matching of the last character in the text to be displayed and the special characters.
The special character may refer to punctuation marks, special symbols, calculation symbols, and the like, which do not need to appear in the form of title information or the like.
And S206, if yes, cutting out the last character in the text to be displayed, and obtaining the processed text to be displayed.
And S207, adding the obtained text to be displayed into the text container to display the text to be displayed in the target page.
Referring to fig. 3 at the same time, fig. 3 is a schematic view of clipping logic of a text display method according to an embodiment of the disclosure. As shown in fig. 3, after initializing a text container storing texts, adding preset characters required to be displayed at the end of the texts into the text container, then placing a target text into the text container added with the preset characters to obtain a target display height of the target text, further, calculating the preset display height of the text container according to the preset display line number and the preset single height in container parameters, and then determining whether cutting is required for the target text by comparing the target display height with the preset display height, and if the target display height is less than or equal to the preset display height, cutting is not required for the current text, so that the processing is completed; if the target display height is larger than the preset display height, the target text word number is exceeded, a cutting link can be entered, when the arrangement sequence number of the first character in the first text segment obtained after at least one cutting of the target text entering the cutting link is smaller than the arrangement sequence number of the last character, cyclic cutting is entered, if the arrangement sequence number of the first character in the first text segment obtained after at least one cutting is equal to the arrangement sequence number of the last character, a cyclic cutting stage can be skipped to obtain a text to be displayed, meanwhile, if the number of the characters in the first text segment obtained after at least one cutting of the target text is far smaller than the preset number of the characters, the first text segment can be supplemented by cutting text from text segments adjacent to the first text segment until the arrangement sequence number of the first character in the text after supplementation is equal to the arrangement sequence number of the last character, the text to be displayed is obtained, then the obtained text to be displayed is detected, and circularly detecting whether the last character in the text to be displayed belongs to a special character which is counted in advance and does not need to be displayed, if so, cutting off the last character of the current text, further obtaining the final text to be displayed, and if not, directly jumping out of the circle, and directly obtaining the final text to be displayed.
The text display method includes the steps of obtaining a target text, a text container used for displaying the target text, and container parameters of the text container for displaying the text in a target page, determining whether the target text needs to be cut based on the container parameters, determining cutting parameters for the target text if the target text needs to be cut, cutting the target text at least once based on the cutting parameters and the arrangement sequence number of characters in the target text to obtain a text to be displayed, detecting whether the last character in the text to be displayed belongs to a special character which is counted in advance and does not need to be displayed, cutting the last character in the text to be displayed if the last character belongs to the special character which is needed to be displayed, obtaining the processed text to be displayed, and adding the obtained text to be displayed into the text container to display the text to be displayed in the target.
Therefore, the target text can be cut at least once from the corresponding position in the target text through the container parameters when the text is displayed by the text container, the cutting parameters of the target text and the arrangement sequence numbers of the characters in the target text, and the last character in the text can be screened after the text to be displayed is obtained, so that special characters which are not required to be displayed are removed, the cutting times of the text can be greatly reduced, the text processing time is shortened, the efficiency and the speed of the text processing are improved, the number of elements cut off is reduced, the invalid occupation of the memory of a machine body is reduced, and the running smoothness of the terminal is ensured.
It will be appreciated by those skilled in the art that in the above-described method of the specific embodiments, the written order of steps is not meant to imply a strict order of execution but rather should be construed according to the function and possibly inherent logic of the steps.
Based on the same inventive concept, the embodiments of the present disclosure further provide a text display device corresponding to the text display method, and since the principle of solving the problem of the device in the embodiments of the present disclosure is similar to that of the text display method in the embodiments of the present disclosure, the implementation of the device may refer to the implementation of the method, and the repetition is omitted.
Referring to fig. 4 and 5, fig. 4 is a schematic diagram of a text display device according to an embodiment of the disclosure, and fig. 5 is a schematic diagram of a second text display device according to an embodiment of the disclosure. As shown in fig. 4, a text display device 400 provided by an example of the present disclosure includes:
The obtaining module 410 is configured to obtain a target text, a text container for displaying the target text, and a container parameter of the text container for displaying the text in a target page.
A first determining module 420 is configured to determine, based on the container parameter, whether clipping of the target text is required.
A second determining module 430, configured to determine clipping parameters for the target text if clipping is required for the target text.
And a text clipping module 440, configured to clip the target text at least once based on the clipping parameters and the sequence numbers of the characters in the target text, so as to obtain a text to be displayed.
And the text display module 450 is used for adding the obtained text to be displayed into the text container so as to display the text to be displayed in the target page.
In an alternative embodiment, the first determining module 420 is specifically configured to:
Initializing the text container;
Determining a preset display height of the text container based on the preset display line number and the preset single line height in the container parameters;
adding a preset character to a preset position in the text container after initialization;
Adding the target text into the text container added with the preset characters to obtain a target display height for displaying the target text through the text container;
And if the target display height is larger than the preset display height, determining that the target text needs to be cut.
In an alternative embodiment, the second determining module 430 is specifically configured to:
If the target text needs to be cut, determining cutting parameters for the target text based on the total amount of characters in the target text and the container parameters, or
If the target text needs to be cut, acquiring preset cutting parameters aiming at the target text.
In an alternative embodiment, the text clipping module 440 is specifically configured to:
Determining a first clipping position for the target text based on the arrangement sequence number of the first character and the arrangement sequence number of the last character in the target text and the clipping parameters;
Cutting the target text according to the first cutting position to obtain a first text segment in which a first character in the target text is located, wherein the first text segment comprises the first character in the target text and a second character corresponding to the first cutting position;
Determining whether clipping of the first text segment is required based on the container parameters;
If necessary, continuing to cut the first text segment as the target text until after cutting for a plurality of times, stopping when the real-time display height of the finally cut second text segment added into the text container is smaller than or equal to the preset display height of the text container determined based on the container parameters, and taking the second text segment as the text to be displayed;
and if not, taking the first text segment obtained by the first cutting as the text to be displayed.
In an alternative embodiment, the text clipping module 440 is specifically configured to, when determining the first clipping location for the target text based on the arrangement number of the first character and the arrangement number of the last character in the target text, and the clipping parameter:
Determining the numerical sum of the arrangement sequence number of the first character and the arrangement sequence number of the last character in the target text;
calculating a calculation result between the numerical value and the clipping parameter;
rounding the calculation result to obtain a target sequence number closest to the calculation result;
and determining the target sequence number as a first clipping position.
In an alternative embodiment, the text clipping module 440 is further configured to:
When the first text segment or the second text segment serving as a text to be displayed is added into the text container, and the real-time display height of the text container is smaller than the preset display height of the text container, which is determined based on the container parameters, the first text segment or the second text segment is used as a text segment to be spliced, and a third text segment adjacent to the text segment to be spliced in the target text is determined, wherein the third text segment comprises a target character and a last character in the target text, and the target character is a first character after the last character of the text segment to be spliced in the target text;
cutting the third text segment at least once based on the sequence numbers of the characters in the third text segment and the cutting parameters to obtain a fourth text segment, wherein the real-time display height of the text segment spliced by the fourth text segment and the text segment to be spliced is equal to the preset display height;
and taking the text segment spliced by the text segment to be spliced and the fourth text segment as the text to be displayed.
In an alternative embodiment, the text clipping module 440 is specifically configured to, when performing clipping on the third text segment at least once based on the sequence number of the characters in the third text segment and the clipping parameter to obtain a fourth text segment:
Determining a second clipping position for the third text segment based on the arrangement sequence number of the first character and the arrangement sequence number of the last character in the third text segment and the clipping parameters;
Cutting the third text segment according to the second cutting position to obtain a fifth text segment and a sixth text segment, wherein the fifth text segment is a text segment comprising a first character in the third text segment, and the sixth text segment is a text segment adjacent to the fifth text segment and comprising a last character in the third text segment;
When the text segments after the fifth text segment and the text segments to be spliced are added into the text container, and the real-time display height of the text container is still smaller than the preset display height, cutting the sixth text segment again as the third text segment until the text segments to be spliced and at least two text segments after the fifth text segment are spliced, which are obtained by cutting, are added into the text container, and cutting is stopped when the real-time display height of the text container is equal to the preset display height;
And taking the text segment spliced by the at least two cut fifth text segments as the fourth text segment.
In an alternative embodiment, the text clipping module 440 is specifically configured to, after clipping the third text segment according to the second clipping location to obtain a fifth text segment and a sixth text segment:
When the fifth text segment and the text segment to be spliced are spliced and then added into the text container, and the real-time display height of the text container is larger than the preset display height, cutting the fifth text segment as the target text until the real-time display height of the seventh text segment obtained by cutting and the text segment to be spliced after being spliced is equal to the preset height after cutting for a plurality of times;
And taking the seventh text segment as the fourth text segment.
In an alternative embodiment, the text clipping module 440 is specifically configured to:
And stopping cutting if the arrangement sequence number of the first character and the arrangement sequence number of the last character in the text segment are the same for the text segment obtained by cutting each time.
In a possible implementation, as shown in fig. 5, the text display device 400 further includes a character detection module 460, where the character detection module 460 is configured to:
detecting whether the last character in the text to be displayed belongs to a special character which is counted in advance and does not need to be displayed;
If yes, cutting out the last character in the text to be displayed, and obtaining the processed text to be displayed.
The text display device provided by the embodiment of the disclosure is used for obtaining a target text, a text container for displaying the target text and container parameters of the text container for displaying the text in a target page, determining whether the target text needs to be cut based on the container parameters, determining cutting parameters for the target text if the target text needs to be cut, cutting the target text at least once based on the cutting parameters and the arrangement sequence number of characters in the target text to obtain a text to be displayed, and adding the obtained text to be displayed into the text container to display the text to be displayed in the target.
Therefore, the target text can be cut at least once from the corresponding position in the target text through the container parameters when the text is displayed by the text container, the cutting parameters of the target text and the arrangement sequence numbers of the characters in the target text, so that the cutting times of the text can be greatly reduced, the text processing time is shortened, the efficiency and the speed of text processing are improved, the number of cut elements is reduced, the invalid occupation of the memory of a machine body is reduced, and the running smoothness of the terminal is ensured.
The process flow of each module in the apparatus and the interaction flow between the modules may be described with reference to the related descriptions in the above method embodiments, which are not described in detail herein.
Corresponding to the text display method in fig. 1 and fig. 2, the embodiment of the disclosure further provides an electronic device 600, as shown in fig. 6, which is a schematic structural diagram of the electronic device 600 provided in the embodiment of the disclosure, including:
The electronic device 600 comprises a processor 610, a memory 620 and a bus 630, wherein the memory 620 is used for storing execution instructions, and comprises a memory 621 and an external memory 622, the memory 621 is also called an internal memory, and is used for temporarily storing operation data in the processor 610 and data exchanged with the external memory 622 such as a hard disk, the processor 610 exchanges data with the external memory 622 through the memory 621, and when the electronic device 600 is operated, the processor 610 and the memory 620 are communicated through the bus 630, so that the processor 610 can execute the steps of the text display method in the method example shown in fig. 1 and 2 when executing.
The disclosed embodiments also provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the text display method described in the above method embodiments. Wherein the storage medium may be a volatile or nonvolatile computer readable storage medium.
Embodiments of the present disclosure further provide a computer program product, where the computer program product carries program code, where instructions included in the program code may be used to perform steps of the text display method described in the foregoing method embodiments, and specifically reference may be made to the foregoing method embodiments, which are not described herein.
Wherein the above-mentioned computer program product may be realized in particular by means of hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied as a computer storage medium, and in another alternative embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK), or the like.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described system and apparatus may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of 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.
In addition, each functional unit in each embodiment of the present disclosure may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in essence or a part contributing to the prior art or a part of the technical solution, or in the form of a software product stored in a storage medium, including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in the embodiments of the present disclosure. The storage medium includes a U disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, an optical disk, or other various media capable of storing program codes.
It should be noted that the foregoing embodiments are merely specific implementations of the disclosure, and are not intended to limit the scope of the disclosure, and although the disclosure has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that any modification, variation or substitution of some of the technical features described in the foregoing embodiments may be made or equivalents may be substituted for those within the scope of the disclosure without departing from the spirit and scope of the technical aspects of the embodiments of the disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (13)

CN202111644854.XA2021-12-292021-12-29 A text display method, device, equipment and storage mediumActiveCN114330232B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202111644854.XACN114330232B (en)2021-12-292021-12-29 A text display method, device, equipment and storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202111644854.XACN114330232B (en)2021-12-292021-12-29 A text display method, device, equipment and storage medium

Publications (2)

Publication NumberPublication Date
CN114330232A CN114330232A (en)2022-04-12
CN114330232Btrue CN114330232B (en)2024-12-10

Family

ID=81016392

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202111644854.XAActiveCN114330232B (en)2021-12-292021-12-29 A text display method, device, equipment and storage medium

Country Status (1)

CountryLink
CN (1)CN114330232B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN113408241A (en)*2021-07-162021-09-17网易(杭州)网络有限公司Text data processing method and device, electronic equipment and readable medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN109740073A (en)*2018-11-262019-05-10国云科技股份有限公司Image real-time processing system and method based on URL
CN112560403A (en)*2019-09-262021-03-26北京国双科技有限公司Text processing method and device and electronic equipment
CN112446218B (en)*2020-12-012024-11-22平安科技(深圳)有限公司 Long and short sentence text semantic matching method, device, computer equipment and storage medium
CN112861648B (en)*2021-01-192023-09-26平安科技(深圳)有限公司Character recognition method, character recognition device, electronic equipment and storage medium
CN113591827B (en)*2021-01-252024-09-17腾讯科技(深圳)有限公司Text image processing method and device, electronic equipment and readable storage medium
CN113111624B (en)*2021-04-192023-04-18抖音视界有限公司Text display method and device, electronic equipment and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN113408241A (en)*2021-07-162021-09-17网易(杭州)网络有限公司Text data processing method and device, electronic equipment and readable medium

Also Published As

Publication numberPublication date
CN114330232A (en)2022-04-12

Similar Documents

PublicationPublication DateTitle
CN108710613B (en)Text similarity obtaining method, terminal device and medium
US20080282153A1 (en)Text-content features
CN111144370B (en)Document element extraction method, device, equipment and storage medium
US20110258202A1 (en)Concept extraction using title and emphasized text
JP6122800B2 (en) Electronic device, character string display method, and character string display program
CN110717323B (en)Document seal dividing method and device, terminal and computer readable storage medium
CN103176952A (en)Document display method and document display device
CN108989704B (en)Image generation method and device and terminal equipment
CN114330232B (en) A text display method, device, equipment and storage medium
EP2637109A1 (en)Method for improving rendering speed of browser page
CN107832341B (en)AGNSS user duplicate removal statistical method
CN111708900B (en)Expansion method and expansion device for tag synonyms, electronic equipment and storage medium
CN109542299B (en)Gold sentence display method for electronic book, electronic equipment and computer storage medium
CN111695350B (en)Word segmentation method and word segmentation device for text
CN110674286A (en)Text abstract extraction method and device and storage equipment
CN102880653A (en)Document combination method and system
CN113742106B (en)Text pasting method, device, computing equipment and readable storage medium
US9483463B2 (en)Method and system for motif extraction in electronic documents
CN106682243A (en)Browsing method and device
CN113268617A (en)Method and device for detecting metadata of papers
US20210065332A1 (en)Content aware image fitting
CN106598936B (en)Letter word extraction method and device
CN112686028B (en)Text translation method based on similar words, computing equipment and computer storage medium
CN114442897B (en)Text processing method and device, electronic equipment and storage medium
CN112949298B (en) Word segmentation method, apparatus, electronic device and readable storage medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
CB02Change of applicant information
CB02Change of applicant information

Address after:100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after:Douyin Vision Co.,Ltd.

Address before:100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before:Tiktok vision (Beijing) Co.,Ltd.

Address after:100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after:Tiktok vision (Beijing) Co.,Ltd.

Address before:100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before:BEIJING BYTEDANCE NETWORK TECHNOLOGY Co.,Ltd.

GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp