CN114442897B - Text processing method and device, electronic equipment and storage medium - Google Patents

Text processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114442897B
CN114442897B CN202111597032.0A CN202111597032A CN114442897B CN 114442897 B CN114442897 B CN 114442897B CN 202111597032 A CN202111597032 A CN 202111597032A CN 114442897 B CN114442897 B CN 114442897B
Authority
CN
China
Prior art keywords
text
rendered
source text
source
page
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
CN202111597032.0A
Other languages
Chinese (zh)
Other versions
CN114442897A (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.)
Beijing Fantasy Network Technology Co ltd
Original Assignee
Beijing Fantasy Network Technology 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 Beijing Fantasy Network Technology Co ltd filed Critical Beijing Fantasy Network Technology Co ltd
Priority to CN202111597032.0A priority Critical patent/CN114442897B/en
Publication of CN114442897A publication Critical patent/CN114442897A/en
Application granted granted Critical
Publication of CN114442897B publication Critical patent/CN114442897B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0487Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser
    • G06F3/0488Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser using a touch-screen or digitiser, e.g. input of commands through traced gestures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/106Display of layout of documents; Previewing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/117Tagging; Marking up; Designating a block; Setting of attributes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/126Character encoding

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The disclosure provides a text processing method, a text processing device, an electronic device and a storage medium, wherein the method comprises the following steps: storing the source text to a temporary file; acquiring a text to be rendered in the source text based on the temporary file; dividing the source text by rows; and rendering the page corresponding to the text to be rendered based on the line information of the source text.

Description

Text processing method and device, electronic equipment and storage medium
Technical Field
The disclosure relates to the field of computer technology, and in particular, to a text processing method, a text processing device, an electronic device and a storage medium.
Background
With the popularization of various reading terminals, the reading mode of electronic reading is accepted by more and more users, and the popularity of electronic reading is also increasing.
Therefore, in the process of reading electronic text, improvement of user reading experience such as compatibility with text formats, improvement of marking functions, and acceleration of rendering speed is a constantly pursuing goal.
Disclosure of Invention
The present disclosure provides a text processing method, apparatus, electronic device, and storage medium, so as to at least solve the above technical problems in the prior art.
According to a first aspect of the present disclosure, there is provided a text processing method, the method comprising: storing the source text to a temporary file; acquiring a text to be rendered in the source text based on the temporary file; the source text is partitioned by row.
In an embodiment, before storing the source text to the temporary file, the method further comprises: analyzing the NDB file corresponding to the source text to obtain a chapter index corresponding to the source text; and acquiring the source text based on the chapter index.
In an embodiment, before storing the source text to the temporary file, the method further comprises: and storing the NDB file corresponding to the source text to a sandbox path.
In an embodiment, the obtaining the text to be rendered in the source text based on the temporary file includes: and reading the temporary file, and determining the text with the first identifier in the source text as the text to be rendered.
In an embodiment, the determining that the text with the first identifier in the source text is the text to be rendered includes: and determining a start index, an end index corresponding to the text to be rendered and a first identification of the text to be rendered.
In an embodiment, the dividing the source text by line includes: the source text is divided into a plurality of lines based on a preset page configuration.
In an implementation manner, the rendering the page corresponding to the text to be rendered based on the line information of the source text includes: filling the source text into a page according to preset page configuration; traversing the source text according to the row, and comparing the text to be rendered with the source text; and if the text to be rendered in the comparison result is a plurality of texts which are continuously overlapped with the source text of any row, rendering the plurality of texts which are continuously overlapped.
In an embodiment, the obtaining the text to be rendered in the source text based on the temporary file further includes: determining an initial touch point and an end touch point for the source text; and determining the text in the region formed by the initial touch point and the ending touch point as the text to be rendered.
In the foregoing embodiments, the method further comprises at least one of: displaying the rendered page; preloading adjacent pages of the rendered page.
According to a second aspect of the present disclosure, there is provided a text processing apparatus including: the storage module is used for storing the source text to the temporary file; the acquisition module is used for acquiring the text to be rendered in the source text based on the temporary file; the segmentation module is used for segmenting the source text according to the rows; and the rendering module is used for rendering the page corresponding to the text to be rendered based on the line information of the source text.
In an embodiment, the text processing device further includes: the analysis module is used for analyzing the NDB file corresponding to the source text to obtain a chapter index corresponding to the source text; the acquisition module is further configured to acquire the source text based on the chapter index.
In an embodiment, the storage module is further configured to store the NDB file corresponding to the source text to a sandbox path.
In an embodiment, the obtaining module is specifically configured to read the temporary file, and determine that the text with the first identifier in the source text is the text to be rendered.
In an embodiment, the obtaining module is further configured to determine a start index and an end index corresponding to the text to be rendered, and a first identifier of the text to be rendered.
In an embodiment, the segmentation module is specifically configured to segment the source text into a plurality of lines based on a preset page configuration.
In an embodiment, the text processing device further includes: the filling module is used for filling the source text into the page according to preset page configuration; the traversing module is used for traversing the source text according to the row and comparing the text to be rendered with the source text; the rendering module is specifically configured to render, if the text to be rendered in the comparison result has a plurality of texts that overlap continuously with the source text in any line, the plurality of texts that overlap continuously.
In an embodiment, the obtaining module is further configured to determine an initial touch point and an end touch point for the source text; and the method is also used for determining that the text in the area formed by the initial touch point and the end touch point is the text to be rendered.
In the foregoing embodiment, the text processing apparatus further includes at least one of: the display module is used for displaying the rendered page; and the preloading module is used for preloading adjacent pages of the rendered page.
According to a third aspect of the present disclosure, there is provided an electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the methods described in the present disclosure.
According to a fourth aspect of the present disclosure, there is provided a non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of the present disclosure.
According to the text processing method, the device, the electronic equipment and the storage medium, the source text is stored in the temporary file, the text to be rendered in the source text is acquired based on the temporary file, the source text is divided according to the rows, the page corresponding to the acquired text to be rendered is rendered according to the row information of the source text, the rendering speed is improved, the occupied memory is reduced, and the rendered page can be accurately operated.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The above, as well as additional purposes, features, and advantages of exemplary embodiments of the present disclosure will become readily apparent from the following detailed description when read in conjunction with the accompanying drawings. Several embodiments of the present disclosure are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings, in which:
in the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
FIG. 1 shows a flow diagram of a text processing method according to an embodiment of the present disclosure;
FIG. 2 illustrates another flow diagram of a text processing method according to an embodiment of the present disclosure;
FIG. 3 illustrates a detailed alternative flow diagram of a text processing method according to an embodiment of the present disclosure;
FIG. 4 illustrates another detailed alternative flow diagram of a text processing method in accordance with an embodiment of the present disclosure;
FIG. 5 is a schematic diagram showing the constitution of a text processing apparatus according to an embodiment of the present disclosure;
fig. 6 shows a schematic diagram of a composition structure of an electronic device according to an embodiment of the present disclosure.
Detailed Description
In order to make the objects, features and advantages of the present disclosure more comprehensible, the technical solutions in the embodiments of the present disclosure will be clearly described in conjunction with the accompanying 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. Based on the embodiments in this disclosure, all other embodiments that a person skilled in the art would obtain without making any inventive effort are within the scope of protection of this disclosure.
Fig. 1 shows a schematic flow chart of a text processing method according to an embodiment of the disclosure.
Referring to fig. 1, a process flow of a text processing method according to an embodiment of the disclosure includes at least the following steps:
step S101, storing the source text to the temporary file.
In the embodiment of the disclosure, the temporary file may be an NDBTmp file, and by storing the source text to the temporary file, the text to be rendered can be intercepted, the intercepted text is easier to read, the rendering speed can be increased, and the rendering efficiency is improved.
In some embodiments, the address of the temporary file may be written to a file management (Manage) class by creating the class.
In the embodiment of the disclosure, a source text path may be recorded, after the intercepted text is rendered once, the text may be intercepted again from the source text for secondary rendering, and similarly, N times of rendering may be performed, where N is greater than 2.
In some embodiments, the text may correspond to different coding modes, and thus, the coding modes of the text may be processed, for example: reading a part of text, detecting the coding format of the text, determining the corresponding coding table according to the detected coding format by corresponding to different coding tables, and performing coding conversion on the text according to the coding table to realize conversion between character coding and Chinese characters so as to avoid text messy codes.
In some embodiments, the file management class may read a preset page configuration.
In some embodiments, the page configuration may be one or more of a font size, a font color, a line spacing, a segment spacing, a page width, and a page height set by the user, or other user-defined settings, and the content of the page configuration is not limited herein.
Step S102, obtaining a text to be rendered in the source text based on the temporary file.
In some embodiments, the specific implementation process of obtaining the text to be rendered in the source text based on the temporary file may include:
And reading the temporary file, and determining the text with the first identifier in the source text as the text to be rendered. The first identifier may be a highlight mark of the text, a marking mark of the text, or a graphic mark, and the form of the first identifier is not limited herein.
In some embodiments, determining text in the source text having the first identification as text to be rendered may include:
and determining a start index (index) and an end index corresponding to the text to be rendered, and a first identification of the text to be rendered. The first mark may have feature information, and the feature information of the first mark may include a color, a line shape, whether or not there is a shadow, and the like of the first mark.
In the embodiment of the disclosure, the region corresponding to the text to be rendered is determined, so that the text is rendered conveniently.
In some embodiments, an initial touch point (point) and an end touch point for the source text may be determined, and text within an area formed based on the initial touch point and the end touch point is determined to be text to be rendered.
As an example, a user touches a screen of the terminal, the terminal acquires an initial touch point at the beginning of touch, the user continuously touches the screen of the terminal, the terminal continuously acquires the touch point of the user until the user finishes touching the screen of the terminal, the terminal acquires a finish touch point, and a text in an area formed by the initial touch point and the finish touch point is a text to be rendered.
Step S103, dividing the source text according to the rows.
In some embodiments, a specific implementation of partitioning source text by line may include:
the source text is divided into a plurality of lines based on a preset page configuration.
In some embodiments, the file management class may read the text to be rendered that is intercepted based on the temporary file before segmenting the source text by line.
As an example, if the source text is read for the first time, the file management class starts to read from the first word of the source text; if the reading record of the active text is stored, the text is continuously read from the position of the storage record by using the offset (offset) stored in the record, 1000 words are read each time, and the offset of the last word is stored after the reading is finished and is used for reading the active text again according to the reading record, wherein the offset represents the distance between the actual address of the storage record and the segment address of the segment where the actual address of the storage record is located.
In the embodiment of the disclosure, for efficiency, it is preferable to read 1000 words each time, or read 500 words or 2000 words each time, and the number of words read each time is not limited herein.
In some embodiments, a text data item class (TextDataItem) may also be created for holding text to be rendered before the source text is split by line.
In some embodiments, the text data item class divides the text to be rendered into lines to obtain text lines, where the text lines represent all lines of the text to be rendered divided into lines, text lines of each line in the text lines may be saved by creating text line item (textlineinformation) class, and start index and end index of each line of text, and text lines may be saved by creating text line array (TextLineArray).
Step S104, rendering the page corresponding to the text to be rendered based on the line information of the source text.
In some embodiments, a specific implementation process of rendering a page corresponding to a text to be rendered based on line information of a source text may include:
and filling the source text into the page according to the preset page configuration.
In some embodiments, a text page (TextPagePiece) class is created, the text page class traverses text lines according to a preset page configuration, and the accumulation of the height, the line spacing and the segment spacing is performed from the first line, and if the value obtained by accumulation exceeds the preset page height, the page is completely filled.
As an example, the text to be rendered has 1000 characters, the text page class traverses text lines obtained by dividing 1000 characters according to preset page configuration, the accumulation of the height, the line spacing and the segment spacing is performed from the first line, and if the value obtained by accumulation exceeds the preset page height, the page is completely filled.
In some embodiments, in the process of filling the page, the start line index and the end line index of the text line may be stored, if in the process of accumulating, the last line of the text line obtained after the text to be rendered is divided according to the line still does not exceed the height of the page, which indicates that the text read at this time has been fully filled into the page, the text needs to be read again, the text is divided into lines, and accumulation calculation is performed until the page is completely filled.
As an example, 1000 characters are read from the text to be rendered, the text page class traverses the text lines obtained by dividing the 1000 characters according to the preset page configuration, the accumulation of the height, the line spacing and the segment spacing is carried out from the first line, the initial line index and the end line index of the text lines are stored, in the accumulation process, the last line of the text lines obtained by dividing the 1000 characters according to the line still does not exceed the page height, the read 1000 is completely filled into the page, the text needs to be read again, the text is divided into lines, and the accumulation calculation is carried out until the page filling is completed.
Traversing the source text according to the rows, and comparing the text to be rendered with the source text.
In some embodiments, using the start line index and the end line index after the page is filled, the line to be rendered is read from the textline array, and the reading operation may be repeated until all lines of the source text are read.
And if the text to be rendered in the comparison result is a plurality of texts which are continuously overlapped with the source text of any line, rendering the plurality of texts which are continuously overlapped.
Fig. 2 shows another flow diagram of a text processing method according to an embodiment of the present disclosure.
Referring to fig. 2, another process flow of a text processing method according to an embodiment of the disclosure includes at least the following steps:
step S201, store the NDB file corresponding to the source text to a sandbox (sandbox) path.
According to the embodiment of the disclosure, the NDB file is stored in the sandbox path, so that the file can be used as a data source, and the file can be opened and read conveniently.
Step S202, analyzing the NDB file corresponding to the source text to obtain the chapter index corresponding to the source text.
Step S203, based on the chapter index, acquires the source text.
Wherein the source text may also be referred to as chapter text.
As an example, if the file is read for the first time, reading the file from the first chapter based on the chapter index obtained by parsing to obtain a source text; if the reading record of the active text is stored, the file is read by using the saved chapter index number based on the chapter index obtained by analysis, and the source text is obtained.
In the embodiment of the disclosure, based on the chapter index obtained by analysis, the NDB file is chapter-divided to obtain the source text after chapter division, so that the file is easier to read.
Step S204, the source text is stored in the temporary file.
In the embodiment of the disclosure, the temporary file may be an NDBTmp file, and by storing the source text to the temporary file, the text to be rendered can be intercepted, the intercepted text is easier to read, the rendering speed can be increased, and the rendering efficiency is improved.
In some embodiments, the address of the temporary file may be written to the file management class by creating the file management class.
In the embodiment of the disclosure, a source text path may be recorded, after the intercepted text is rendered once, the text may be intercepted again from the source text for secondary rendering, and similarly, N times of rendering may be performed, where N is greater than 2.
In some embodiments, the text may correspond to different coding modes, and thus, the coding modes of the text may be processed, for example: reading a part of text, detecting the coding format of the text, determining the corresponding coding table according to the detected coding format by corresponding to different coding tables, and performing coding conversion on the text according to the coding table to realize conversion between character coding and Chinese characters so as to avoid text messy codes.
In some embodiments, the file management class may read a preset page configuration.
In some embodiments, the page configuration may be one or more of a font size, a font color, a line spacing, a segment spacing, a page width, and a page height set by the user, or other user-defined settings, and the content of the page configuration is not limited herein.
Step S205, reading the temporary file, and determining the text with the first identifier in the source text as the text to be rendered.
The first identifier may be a highlight mark of the text, a marking mark of the text, or a graphic mark, and the form of the first identifier is not limited herein.
In some embodiments, a start index, an end index, and a first identification of text to be rendered corresponding to the text to be rendered may be determined. The first mark may have feature information, and the feature information of the first mark may include a color, a line shape, whether or not there is a shadow, and the like of the first mark.
In the embodiment of the disclosure, the region corresponding to the text to be rendered is determined, so that the text is rendered conveniently.
In some embodiments, an initial touch point and an end touch point for the source text may be determined, and text within an area formed based on the initial touch point and the end touch point is determined to be text to be rendered.
As an example, a user touches a terminal screen, the terminal acquires an initial touch point at the beginning of touch, the user continuously touches the terminal screen, the terminal continuously acquires the touch point of the user until the user finishes touching the terminal screen, the terminal acquires a finish touch point, and a text in an area formed by the initial touch point and the finish touch point is a text to be rendered.
Step S206, dividing the source text into a plurality of lines based on a preset page configuration.
In some embodiments, the file management class may read the text to be rendered that is intercepted based on the temporary file before segmenting the source text by line.
As an example, if the source text is read for the first time, the file management class starts to read from the first word of the source text; if the reading record of the active text is stored, the text is continuously read from the position of the storage record by using the offset stored in the record, 1000 words are read each time, and the offset of the last word is stored after the reading is finished and is used for reading the active text again according to the reading record, wherein the offset represents the distance between the actual address of the storage record and the segment address of the segment where the actual address is located.
In the embodiment of the disclosure, for efficiency, it is preferable to read 1000 words each time, or read 500 words or 2000 words each time, and the number of words read each time is not limited herein.
In some embodiments, the text to be rendered may also be saved by creating a text data item class prior to dividing the source text by line.
In some embodiments, after the text to be rendered is divided by lines, a text line is obtained, where the text line represents all lines of the text to be rendered divided by lines, the text line item class may be created, the text of each line in the text line may be saved, and the start index and the end index of each line of text may be saved by creating a text line array.
Step S207, filling the source text into the page according to the preset page configuration.
In some embodiments, a text page class is created, the text page class traverses text lines according to a preset page configuration, accumulation of the height, the line spacing and the segment spacing is performed from the first line, and if the value obtained by accumulation exceeds the preset page height, the page is completely filled.
As an example, the text to be rendered has 1000 characters, the text page class traverses text lines obtained by dividing 1000 characters according to preset page configuration, the accumulation of the height, the line spacing and the segment spacing is performed from the first line, and if the value obtained by accumulation exceeds the preset page height, the page is completely filled.
In some embodiments, in the process of filling the page, the start line index and the end line index of the text line may be stored, if in the process of accumulating, the last line of the text line obtained after the text to be rendered is divided according to the line still does not exceed the height of the page, which indicates that the text read at this time has been fully filled into the page, the text needs to be read again, the text is divided into lines, and accumulation calculation is performed until the page is completely filled.
As an example, 1000 characters are read from the text to be rendered, the text page class traverses the text lines obtained by dividing the 1000 characters according to the preset page configuration, the accumulation of the height, the line spacing and the segment spacing is carried out from the first line, the initial line index and the end line index of the text lines are stored, in the accumulation process, the last line of the text lines obtained by dividing the 1000 characters according to the line still does not exceed the page height, the read 1000 is completely filled into the page, the text needs to be read again, the text is divided into lines, and the accumulation calculation is carried out until the page filling is completed.
Step S208, traversing the source text according to the lines, and comparing the text to be rendered with the source text.
In some embodiments, using the start line index and the end line index after the page is filled, the line to be rendered is read from the textline array, and the reading operation may be repeated until all lines of the source text are read.
And step S209, if a plurality of texts which are continuously overlapped with the source texts of any line exist in the text to be rendered in the comparison result, rendering the plurality of texts which are continuously overlapped.
Step S210, displaying the rendered page.
In some embodiments, a text region view (textarea view) class may be created to expose the text to be rendered.
In some embodiments, the TextPagePiece class may be used to coordinate data communications between the TextDataItem class and the textarea view class.
Step S211, preloading the adjacent pages of the rendered page.
As an example, if a user slides a page to turn the page, the user can easily turn the previous page and/or the next page of the rendered current page, and by preloading the adjacent pages of the current page, the page can be turned more smoothly without any jamming, so that the user can read smoothly, the reading efficiency is improved, and the user experience is improved.
Fig. 3 shows a detailed alternative flow diagram of a text processing method according to an embodiment of the present disclosure.
Referring to fig. 3, taking an NDB rendering display scheme as an example, a detailed optional flow of the text processing method according to an embodiment of the disclosure is described, and the method at least includes the following steps:
in step S301, the NDB file is stored as a local file in a sandbox path specified by the existing application (App).
According to the embodiment of the disclosure, the NDB file is stored in the sandbox path, so that the file can be used as a data source, and the file can be opened and read conveniently.
Step S302, analyzing the NDB file to obtain the chapter index.
Step S303, reading the chapter text by the chapter index.
Optionally, if the NDB file is read for the first time, reading the NDB file from the first chapter based on the chapter index obtained by parsing; if the read record of the NDB file is stored, the NDB file is read by using the saved chapter index number based on the chapter index obtained by analysis, and a chapter text is obtained.
In the embodiment of the disclosure, based on the chapter index obtained by analysis, the NDB file is chapter-divided to obtain the chapter text after chapter division, so that the NDB file is easier to read.
Step S304, storing the chapter text to the NDBTMP file.
According to the embodiment of the disclosure, the section text is stored in the NDBTmp file, so that the text to be rendered can be intercepted, the intercepted text is easier to read, the rendering speed can be increased, and the rendering efficiency is improved.
In step S305, an NDBManager is created, and an NDBTmp address is written to the NDBManager.
In the embodiment of the disclosure, a source text path may be recorded, after the intercepted text is rendered once, the text may be intercepted again from the source text for secondary rendering, and similarly, N times of rendering may be performed, where N is greater than 2.
And step S306, performing code conversion on texts with different coding modes, and performing code conversion on characters into Chinese characters.
Optionally, a part of text is read, the coding format of the text is detected, different coding formats correspond to different coding tables, the corresponding coding tables are determined according to the detected coding format, the text is converted according to the coding tables, conversion between character coding and Chinese characters is achieved, and text messy codes are avoided.
In step S307, the ndbmmanager reads the page configuration preset by the user.
Optionally, the page configuration may be one or more of font size, font color, line spacing, segment spacing, page width and page height set by the user, or other user-defined settings, where the content of the page configuration is not limited herein.
In step S308, the ndbmmanager reads recorded user note data, such as a start index, an end index of a note highlight text, and a highlight text background color set by the user.
Step S309, creating a textDataItem class for storing the text to be rendered; creating a textarea view class for displaying characters to be rendered; a textPagePiece class is created to coordinate data communication between the textDataItem class and the textAreView class.
In step S310, the ndbmmanager reads the start position of the text to be rendered.
Optionally, if the file is read for the first time, the file management class reads from the first text of the chapter text, if the read record of the chapter text is stored, continues to read the text from the position where the record is stored by using the offset stored in the record, reads 1000 words each time, and stores the offset of the last word after the reading is completed, so as to read the chapter text according to the read record again, wherein the offset represents the distance between the actual address of the stored record and the segment address of the segment where the actual address is located.
In step S311, the TextDataItem class divides the text to be rendered into a plurality of lines based on a preset page configuration.
Optionally, the TextDataItem class stores the text to be rendered read by the NDBManager, and the text is segmented according to lines by using page configuration preset by a user and read in the NDBManager, so as to obtain text lines, wherein the text lines represent all lines of the text to be rendered after the text is segmented according to the lines, the textlineinformation class is created, the characters of each line in the text lines, and the start index and the end index of each line of characters are stored, and the text lines can be stored by creating the TextLineArray.
In step S312, the TextPagePiece class fills the chapter text into the page according to a preset page configuration.
Optionally, the TextPagePiece class traverses the text lines according to a preset page configuration stored in the NDBManager, and performs accumulation of the height, the line spacing and the segment spacing from the first line, and if the value obtained by accumulation exceeds the preset page height, the page is indicated to be filled.
Optionally, in the process of filling the page, the start line index and the end line index of the text line may be stored, if in the process of accumulating, the last line of the text line obtained after the line division still does not exceed the height of the page, which indicates that the text read at this time has been fully filled into the page, the text needs to be read again, the text is divided into lines, and accumulating calculation is performed until the page is completely filled.
Step S313, traversing the chapter text by the textAreView class according to the lines, comparing the text to be rendered with the chapter text, and detecting whether a note highlight area is overlapped with a start end area of each line, wherein the start end area starts from a start index and ends from an end index.
Optionally, the textarea view class reads the line to be rendered from the textline array by using the start line index and the end line index after the page is filled, and the reading operation can be repeated until all lines of the source text are read.
And step S314, if the text to be rendered in the comparison result has a plurality of note highlight areas which are continuously overlapped with the chapter text of any line, carrying out highlight rendering on the text in the plurality of note highlight areas which are continuously overlapped.
Step S315, the rendered page is displayed.
Step S316, preloading the adjacent pages of the rendered page.
Optionally, if the user slides the page to turn the page, the user can easily turn the previous page and/or the next page of the rendered current page, and the adjacent page of the current page is preloaded, so that the page can be turned more smoothly without any jamming, the user can read smoothly, the reading efficiency is improved, and the user experience is improved.
The NDB file is a popular format file, and currently, rendering of the NDB file by the mobile client is relatively simple, and fine operations on a rendered page cannot be performed, for example: the page individually selects the highlighted text to add notes. Even part of mobile clients are not compatible with this format, files in NDB format cannot be opened.
The text processing method provided by the embodiment of the disclosure solves the problems that rendering is simple, memory occupation is large, and fine operation cannot be performed on a rendered page in the technical scheme of NDB in the prior art, can improve rendering speed, occupies little memory, can accurately perform operation on the rendered page, selects any word, can preload a previous page and a next page, is smooth in reading by a user, and improves user experience.
Fig. 4 shows another detailed alternative flow diagram of a text processing method according to an embodiment of the present disclosure.
Referring to fig. 4, taking a scheme that a user highlights a chapter text note as an example, another detailed optional flow of the text processing method in the embodiment of the disclosure is described, and at least includes the following steps:
in step S401, the user touches the terminal screen to determine an initial touch point and an end touch point for the chapter text.
Optionally, when the user touches the mobile phone screen, the terminal acquires the point touched by the user for the first time, and maps the point to the point of the rendered page.
Optionally, the user may continuously touch the terminal screen, and the terminal continuously acquires the point touched by the user until the user touches the terminal, and acquires the last touch point.
Optionally, traversing all lines of the rendered page, detecting a line touched by a user through the y coordinate of the point, after confirming the line, acquiring an offset of the line touched by the user through the x coordinate of the point, and determining characters of the line touched by the user through the line offset, wherein the offset represents the distance between the actual address of the stored record and the segment address of the segment where the actual address is located.
In step S402, it is determined that the text in the region formed based on the initial touch point and the end touch point is the text to be rendered.
Step S403, storing the initial touch point and the end touch point, rendering the page, and displaying the note highlight.
Fig. 5 is a schematic diagram showing the constitution of a text processing apparatus according to the embodiment.
Referring to fig. 5, a text processing apparatus 50 according to an embodiment includes: a storage module 501 for storing the source text to a temporary file; an obtaining module 502, configured to obtain a text to be rendered in a source text based on a temporary file; a segmentation module 503, configured to segment the source text according to rows; and the rendering module 504 is used for rendering the page corresponding to the text to be rendered based on the line information of the source text.
In some embodiments, the text processing device 50 further comprises: the parsing module 505 is configured to parse the NDB file corresponding to the source text to obtain a chapter index corresponding to the source text; the obtaining module 502 is further configured to obtain the source text based on the chapter index.
In some embodiments, the storage module 501 is further configured to store NDB files corresponding to the source text to the sandboxed path.
In some embodiments, the obtaining module 502 is specifically configured to read the temporary file, and determine that the text with the first identifier in the source text is the text to be rendered.
In some embodiments, the obtaining module 502 is further configured to determine a start index, an end index, and a first identifier of the text to be rendered, where the start index, the end index, and the first identifier correspond to the text to be rendered.
In some embodiments, the segmentation module 503 is specifically configured to segment the source text into a plurality of lines based on a preset page configuration.
In some embodiments, the text processing device 50 further comprises: a filling module 506, configured to fill the source text to the page according to a preset page configuration; the traversing module 507 is configured to traverse the source text according to the row, and compare the text to be rendered with the source text; the rendering module 504 is specifically configured to render the plurality of consecutively overlapped texts if the text to be rendered in the comparison result and the source text of any line have consecutively overlapped texts.
In some embodiments, the obtaining module 502 is further configured to determine an initial touch point and an end touch point for the source text; and the method is also used for determining the text in the area formed based on the initial touch point and the end touch point as the text to be rendered.
In the above embodiment, the text processing device 50 further includes at least one of the following: the display module 508 is used for displaying the rendered page; a preloading module 509, configured to preload adjacent pages of the rendered page.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
Fig. 6 illustrates a schematic block diagram of an example electronic device 600 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable electronic devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 6, the electronic device 600 includes a computing unit 601 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 602 or a computer program loaded from a storage unit 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 can also be stored. The computing unit 601, ROM 602, and RAM 603 are connected to each other by a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
A number of components in the electronic device 600 are connected to the I/O interface 605, including: an input unit 606 such as a keyboard, mouse, etc.; an output unit 607 such as various types of displays, speakers, and the like; a storage unit 608, such as a magnetic disk, optical disk, or the like; and a communication unit 609 such as a network card, modem, wireless communication transceiver, etc. The communication unit 609 allows the electronic device 600 to exchange information/data with other electronic devices through a computer network, such as the internet, and/or various telecommunication networks.
The computing unit 601 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 601 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the respective methods and processes described above, such as a text processing method. For example, in some embodiments, the text processing method may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 600 via the ROM 602 and/or the communication unit 609. When a computer program is loaded into RAM 603 and executed by computing unit 601, one or more steps of the text processing method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the text processing method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel or sequentially or in a different order, provided that the desired results of the technical solutions of the present disclosure are achieved, and are not limited herein.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In the description of the present disclosure, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
The foregoing is merely specific embodiments of the disclosure, but the protection scope of the disclosure is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the disclosure, and it is intended to cover the scope of the disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (14)

1. A method of text processing, the method comprising:
storing the source text to a temporary file;
before the source text is stored to the temporary file, the method further comprises: storing the NDB file corresponding to the source text to a sandbox path; analyzing the NDB file corresponding to the source text to obtain a chapter index corresponding to the source text; acquiring the source text based on the chapter index;
acquiring a text to be rendered in the source text based on the temporary file;
creating a text data item class, wherein the text data item class is used for storing texts to be rendered;
dividing the source text by rows;
the dividing the source text by line includes: dividing the source text into a plurality of rows based on a preset page configuration;
and rendering the page corresponding to the text to be rendered based on the line information of the source text.
2. The method of claim 1, wherein the obtaining text to be rendered in the source text based on the temporary file comprises:
and reading the temporary file, and determining the text with the first identifier in the source text as the text to be rendered.
3. The method of claim 2, wherein the determining that the text of the source text having the first identifier is the text to be rendered comprises:
And determining a start index, an end index corresponding to the text to be rendered and a first identification of the text to be rendered.
4. The method of claim 1, wherein rendering the page corresponding to the text to be rendered based on the line information of the source text comprises:
filling the source text into a page according to preset page configuration;
traversing the source text according to the row, and comparing the text to be rendered with the source text;
and if the text to be rendered in the comparison result is a plurality of texts which are continuously overlapped with the source text of any row, rendering the plurality of texts which are continuously overlapped.
5. The method of claim 1, wherein the obtaining text to be rendered in the source text based on the temporary file further comprises:
determining an initial touch point and an end touch point for the source text;
and determining the text in the region formed by the initial touch point and the ending touch point as the text to be rendered.
6. The method of any one of claims 1-5, further comprising at least one of:
displaying the rendered page;
preloading adjacent pages of the rendered page.
7. A text processing apparatus, the apparatus comprising:
the storage module is used for storing the source text to the temporary file;
the storage module is further used for storing the NDB file corresponding to the source text to a sandbox path;
the analysis module is used for analyzing the NDB file corresponding to the source text to obtain a chapter index corresponding to the source text;
the acquisition module is used for acquiring the text to be rendered in the source text based on the temporary file, and creating a text data item class which is used for storing the text to be rendered;
the acquisition module is further used for acquiring the source text based on the chapter index;
the segmentation module is used for segmenting the source text according to the rows;
the segmentation module is specifically configured to segment the source text into a plurality of rows based on a preset page configuration;
and the rendering module is used for rendering the page corresponding to the text to be rendered based on the line information of the source text.
8. The apparatus of claim 7, wherein the obtaining module is specifically configured to read the temporary file, and determine that a text with a first identifier in the source text is the text to be rendered.
9. The apparatus of claim 8, wherein the obtaining module is further configured to determine a start index, an end index, and a first identification of the text to be rendered corresponding to the text to be rendered.
10. The apparatus of claim 7, wherein the apparatus further comprises:
the filling module is used for filling the source text into the page according to preset page configuration;
the traversing module is used for traversing the source text according to the row and comparing the text to be rendered with the source text;
the rendering module is specifically configured to render, if the text to be rendered in the comparison result has a plurality of texts that overlap continuously with the source text in any line, the plurality of texts that overlap continuously.
11. The apparatus of claim 7, wherein the acquisition module is further configured to determine an initial touch point and an end touch point for the source text;
and the method is also used for determining that the text in the area formed by the initial touch point and the end touch point is the text to be rendered.
12. The apparatus of any of claims 7-11, further comprising at least one of:
the display module is used for displaying the rendered page;
And the preloading module is used for preloading adjacent pages of the rendered page.
13. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the text processing method of any one of claims 1-6.
14. A non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the text processing method according to any one of claims 1-6.
CN202111597032.0A 2021-12-24 2021-12-24 Text processing method and device, electronic equipment and storage medium Active CN114442897B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111597032.0A CN114442897B (en) 2021-12-24 2021-12-24 Text processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111597032.0A CN114442897B (en) 2021-12-24 2021-12-24 Text processing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114442897A CN114442897A (en) 2022-05-06
CN114442897B true CN114442897B (en) 2023-12-15

Family

ID=81364577

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111597032.0A Active CN114442897B (en) 2021-12-24 2021-12-24 Text processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114442897B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8818092B1 (en) * 2011-09-29 2014-08-26 Google, Inc. Multi-threaded text rendering
CN107247691A (en) * 2017-05-24 2017-10-13 腾讯科技(深圳)有限公司 A kind of display methods of text message, device, mobile terminal and storage medium
CN110738050A (en) * 2019-10-16 2020-01-31 北京小米智能科技有限公司 Text recombination method, device and medium based on word segmentation and named entity recognition
CN111460345A (en) * 2020-03-30 2020-07-28 掌阅科技股份有限公司 Electronic book loading display method, electronic equipment and storage medium
CN112256993A (en) * 2020-09-22 2021-01-22 恒鸿达科技有限公司 Picture accelerated display method, system, equipment and medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8818092B1 (en) * 2011-09-29 2014-08-26 Google, Inc. Multi-threaded text rendering
CN107247691A (en) * 2017-05-24 2017-10-13 腾讯科技(深圳)有限公司 A kind of display methods of text message, device, mobile terminal and storage medium
CN110738050A (en) * 2019-10-16 2020-01-31 北京小米智能科技有限公司 Text recombination method, device and medium based on word segmentation and named entity recognition
CN111460345A (en) * 2020-03-30 2020-07-28 掌阅科技股份有限公司 Electronic book loading display method, electronic equipment and storage medium
CN112256993A (en) * 2020-09-22 2021-01-22 恒鸿达科技有限公司 Picture accelerated display method, system, equipment and medium

Also Published As

Publication number Publication date
CN114442897A (en) 2022-05-06

Similar Documents

Publication Publication Date Title
KR102197501B1 (en) Detection and reconstruction of east asian layout features in a fixed format document
CN110377376B (en) Interface message refreshing method and device, computer device and readable storage medium
US10620803B2 (en) Selecting at least one graphical user interface item
CN113050808A (en) Method and device for highlighting target text in input box
CN114218890A (en) Page rendering method and device, electronic equipment and storage medium
CN112198998A (en) Text input control method, related device, equipment and medium
CN113392660B (en) Page translation method and device, electronic equipment and storage medium
CN110609981A (en) Text processing method and device, electronic equipment and computer readable storage medium
CN114885202A (en) Character string display processing method, device, terminal and storage medium
CN113836462A (en) Page description file generation method, device, equipment and storage medium
US10254959B2 (en) Method of inputting a character into a text string using a sliding touch gesture, and electronic device therefor
EP2637109A1 (en) Method for improving rendering speed of browser page
CN114442897B (en) Text processing method and device, electronic equipment and storage medium
CN106776527B (en) Electronic book data display method and device and terminal equipment
CN107797736A (en) Method for information display and device
CN111522610A (en) Information display method, device and equipment
CN112052647A (en) Document editing method and device, electronic equipment and readable storage medium
EP4379596A1 (en) Text typesetting
CN115329720A (en) Document display method, device, equipment and storage medium
CN115546345A (en) Gantt chart drawing method, apparatus, device, storage medium and program product
CN113268949B (en) Form display method and device based on dynamic fields, computer equipment and medium
CN114296852A (en) Method and device for displaying target page, electronic equipment and storage medium
CN114239562A (en) Method, device and equipment for identifying program code blocks in document
CN112861504A (en) Text interaction method, device, equipment, storage medium and program product
CN111626045A (en) Character length calculation method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant