Text parsing method and apparatus, and device and medium

By combining and parsing the lightweight markup language text output in streaming mode multiple times, parsing errors in streaming scenarios are resolved, ensuring the accuracy of text display and reading aloud.

WO2026040708A1PCT designated stage Publication Date: 2026-02-26BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/108666
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-08-21
Filing Date
2025-07-15
Publication Date
2026-02-26

AI Technical Summary

Technical Problem

In existing technologies, lightweight markup languages ​​suffer from parsing errors due to incomplete text in streaming scenarios, leading to errors in text display or reading aloud.

Method used

By acquiring the unit text from the streaming output, combining it with the prefix text, and using streaming parsing rules and backtracking operations, along with non-streaming parsing rules, incomplete text is removed to ensure the integrity of the text parsing.

Benefits of technology

It achieves accurate parsing of lightweight markup language text in streaming scenarios, ensuring the accuracy of text display and reading aloud, and avoiding errors caused by incomplete text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025108666_26022026_PF_FP_ABST
    Figure CN2025108666_26022026_PF_FP_ABST
Patent Text Reader

Abstract

The embodiments of the present disclosure relate to a text parsing method and apparatus, and a device and a medium. The text parsing method comprises: acquiring a unit text that is output in a streaming manner for a target text, wherein the target text is a text in a lightweight markup language; combining the unit text with a prefix text preceding the unit text, so as to obtain a first text; and parsing the first text by means of a streaming parsing rule, so as to obtain a second text from which an incomplete text has been removed. In the present disclosure, for a unit text that is output in a streaming manner for a target text in a lightweight markup language, the unit text can be combined with a preceding prefix text, so as to obtain a first text, and the first text is parsed by means of a streaming parsing rule, so as to obtain a second text from which an incomplete text has been removed. Since the incomplete text is removed during the streaming parsing of the target text in the lightweight markup language, it can be ensured that a text that is output by means of parsing is a complete text, thereby ensuring the accuracy of parsing, and thus ensuring the accuracy of text displaying or reading.
Need to check novelty before this filing date? Find Prior Art

Description

Text analysis method, device, equipment and medium

[0001] Cross-reference to Related Applications

[0002] This application claims priority to Chinese Patent Application No. 202411155140.6, filed on August 21, 2024, the disclosure of which is incorporated herein in its entirety as part of the present application. TECHNICAL FIELD

[0003] The present disclosure relates to a text analysis method, device, equipment and medium. BACKGROUND

[0004] The way of outputting text by a large model is usually word-by-word streaming output, and the text can be output in a lightweight markup language, such as Markdown, in order to enhance readability. In the related art, the text analysis of the lightweight markup language usually only supports the analysis mode of the non-streaming scenario of the complete text, and when the text in the lightweight markup language is output in the streaming scenario, it may cause analysis errors due to incomplete text, resulting in text display errors or reading errors. SUMMARY

[0005] To solve the above technical problems, the present disclosure provides a text analysis method, device, equipment and medium.

[0006] The present disclosure provides a text analysis method, which comprises:

[0007] obtaining unit text for streaming output of target text, wherein the target text is text in a lightweight markup language;

[0008] combining the unit text and prefix text before the unit text to obtain first text;

[0009] analyzing the first text by a streaming analysis rule to obtain second text with incomplete text removed.

[0010] The present disclosure also provides a text analysis device, which comprises:

[0011] an obtaining module configured to obtain unit text for streaming output of target text, wherein the target text is text in a lightweight markup language;

[0012] a combining module configured to combine the unit text and prefix text before the unit text to obtain first text;

[0013] an analyzing module configured to analyze the first text by a streaming analysis rule to obtain second text with incomplete text removed.

[0014] The electronic device includes a processor, a memory for storing instructions executable by the processor, and the processor is configured to read the executable instructions from the memory and execute the instructions to implement the text analysis method provided by the embodiments of the present disclosure.

[0015] The embodiments of the present disclosure also provide a computer readable storage medium, which stores a computer program for executing the text analysis method provided by the embodiments of the present disclosure. BRIEF DESCRIPTION OF DRAWINGS

[0016] The above and other features, aspects, and advantages of the present disclosure will become more apparent with reference to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or like reference numerals are used to represent the same or similar elements. It is to be understood that the drawings are schematically showing the elements and features, which are not necessarily drawn to scale.

[0017] FIG. 1 is a flow diagram of a text analysis method according to an embodiment of the present disclosure;

[0018] FIG. 2 is a flow diagram of another text analysis method according to an embodiment of the present disclosure;

[0019] FIG. 3 is a schematic diagram of a text analysis process according to an embodiment of the present disclosure;

[0020] FIG. 4 is a schematic diagram of a backtracking process according to an embodiment of the present disclosure;

[0021] FIG. 5 is a structural diagram of a text analysis apparatus according to an embodiment of the present disclosure; and

[0022] FIG. 6 is a structural diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] Embodiments of the present disclosure will be described in more detail by referring to the drawings. Although certain embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein, but rather the embodiments are provided to more thoroughly and completely understand the present disclosure. It is understood that the drawings and embodiments of the present disclosure are for exemplary purposes only and are not intended to limit the scope of the present disclosure.

[0024] It is understood that each of the steps described in the method embodiments of the present disclosure can be executed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit the execution of the steps shown. The scope of the present disclosure is not limited in this respect.

[0025] The term "include" and variations thereof, used in this disclosure, is an open term, meaning "including, but not limited to". The term "based on" means "based, at least in part, on". The term "one embodiment" means "at least one embodiment". The term "another embodiment" means "at least one additional embodiment". The term "some embodiments" means "at least some embodiments". Related terms have corresponding meanings.

[0026] It should be noted that the terms "first", "second", and the like in the present disclosure are used only to distinguish different devices, modules or units, and do not imply the order or interdependence of the functions performed by these devices, modules or units.

[0027] It should be noted that the terms "one", "multiple" in the present disclosure are illustrative and not restrictive, and those skilled in the art should understand that "one" or "multiple" should be understood as "one or more" unless otherwise explicitly indicated in the context.

[0028] The names of the messages or information exchanged between the plurality of devices in the embodiments of the present disclosure are only for illustrative purposes, and are not used to limit the scope of the messages or information.

[0029] In the related art, the functional components related to the parsing of lightweight markup language text, such as Markdown text, usually only support non-streaming parsing mode, that is, the input is a complete piece of text, and cannot well solve the problem in the streaming scenario. For example, assuming that the complete text is "[A's official website](https: / / www.A.com", the text output at a certain moment in the streaming scenario may be "[A's official website](http: / / www", which is not a Markdown syntax element that conforms to the grammar rules, so in the non-streaming scenario, the Markdown parsing module will output it as a whole as pure text. If such a parsing result is sent to a speech synthesis module, the part of the hyperlink "http: / / www" that would not have been displayed on the client will be read out. In addition, for the client interface display, the error parsing caused by the incomplete text at a certain moment will be displayed incorrectly, but since they can refresh the entire displayed interface in real time, the correct display can be achieved after the complete text arrives. However, for speech synthesis, any error parsing at any moment may cause text that should not be read to be read, which cannot be recovered. In summary, when outputting lightweight markup language text in a streaming scenario, parsing errors caused by incomplete text may cause text display errors or reading errors.

[0030] To solve the above problem, the embodiments of the present disclosure provide a text parsing method, which will be introduced below in combination with specific embodiments.

[0031] FIG. 1 is a flowchart of a text parsing method provided by an embodiment of the present disclosure, which can be executed by a text parsing device. The device can be implemented by software and / or hardware, and can be integrated in an electronic device. As shown in FIG. 1, the method comprises the following steps:

[0032] In step 101, a unit text output in a streaming manner for a target text is obtained, wherein the target text is a text in a lightweight markup language.

[0033] The target text can be a text output in a streaming manner, for example, a text output by a large model. The streaming manner refers to outputting unit texts one by one. The unit text can be the smallest unit (Token) output by the model. In the embodiment of the present disclosure, the unit text can be a character, a word or a phrase, which can be set according to actual conditions. The format of the target text is a lightweight markup language. In the embodiment of the present disclosure, the lightweight markup language is taken as Markdown for example. Markdown can be used to add formatting elements to a plain text document. The format is plain text, easy to read and write.

[0034] Specifically, the text parsing device obtains the unit text output in the streaming manner for the target text. The target text comprises a plurality of unit texts. The unit texts are obtained one by one and then subjected to subsequent text parsing processing. The text parsing of the embodiment of the present disclosure is to parse the unit text output in the streaming manner for the target text into a text in a preset format for display or reading. The preset format can be determined according to the requirements of the current use scenario.

[0035] In step 102, a first text is obtained by combining the unit text and prefix text before the unit text.

[0036] The prefix text can be part of the text before the text. In the embodiment of the present disclosure, the prefix text refers to all the text before the unit text. The first text can be the text obtained by combining the unit text and the prefix text before the unit text.

[0037] Specifically, after obtaining the current unit text, the text parsing device can combine the unit text and the prefix text before the unit text to obtain the first text, and use the first text as the input for subsequent text parsing.

[0038] In step 103, the first text is parsed according to a streaming parsing rule to obtain a second text with incomplete texts removed.

[0039] The stream parsing rule can be a rule for realizing text parsing in a stream scenario by twice parsing based on a backtracking operation and a non-stream parsing rule. The backtracking can be used to return to a previous complete text to continue parsing when parsing fails in the parsing process, so as to avoid parsing errors caused by incomplete texts. The incomplete text can be a unit text that fails to be parsed by using the non-stream parsing rule. The second text can be a text obtained by parsing the first text by using the stream parsing rule, and the second text does not include the incomplete text.

[0040] Specifically, the text parsing apparatus can input the first text into the stream parsing rule to perform parsing. The first parsing removes the incomplete text in the first text by using backtracking. The second parsing obtains the second text by using the non-stream rule to parse the first text after the removal.

[0041] For example, FIG. 2 is a flowchart of another text parsing method provided by an embodiment of the present disclosure. As shown in FIG. 2, in a possible implementation, the first text is parsed by using a stream text parsing rule to obtain a second text in which the incomplete text is removed, and the method can include the following steps.

[0042] In step 201, the first text is backtracked to obtain a third text in which the incomplete text is removed.

[0043] The backtracking can be an algorithm for finding all solutions or optimal solutions by exploring all possible candidate solutions. When the algorithm tries to construct a solution by trying all possible steps, and finds that the current step cannot lead to a valid solution, it returns to a certain step before the last step to try another possibility. This process is called backtracking. In the embodiment of the present disclosure, the backtracking can be used to return to a previous complete text to continue parsing when parsing fails in the parsing process, so as to avoid parsing errors caused by incomplete texts. The third text can be a text obtained by backtracking the first text, and the third text does not include the incomplete text.

[0044] In some embodiments, the first text is backtracked to obtain a third text in which the incomplete text is removed, which can include: parsing the first text by using a non-stream parsing rule to extract a unit text that fails to be parsed as the incomplete text; determining a start position of the incomplete text in the first text as a backtracking position; and obtaining the third text by cutting off the text before the backtracking position in the first text.

[0045] The non-stream parsing rule can be a rule for parsing texts in a non-stream scenario of a lightweight markup language. The non-stream parsing rule can filter out elements constituting a syntax and only retain text elements when parsing. The parsing of the non-stream parsing rule can be implemented by using various libraries, tools or components. The backtracking position can be a specific position returned in the parsing process of the first text.

[0046] Specifically, when backtracking the first text, the text analysis device can parse the first text using a non-streaming parsing rule, and can record the current text position before parsing. When the current unit text fails to be parsed during the parsing process, it is determined to be an incomplete text. At this time, the recorded text position can be used as the backtracking position, that is, the start position of the incomplete text. The text before the backtracking position of the first text is extracted to obtain the third text.

[0047] For example, if the first character of the current unit text is an asterisk, the position of the asterisk can be recorded, and the Markdown bold syntax rule can be used for parsing. It is expected that there will be two asterisks, a piece of text, and then two asterisks. If it does not meet the bold syntax rule and has reached the end of the unit text, the parsing fails, and other rules can be used for parsing. If all rules fail, the unit text parsing fails and is determined to be an incomplete text. The initially recorded position of the asterisk can be determined as the backtracking position.

[0048] Optionally, if the backtracking position includes multiple positions, the position closest to the front can be retained, and the other backtracking positions can be removed. Here, when the unit text has a nested condition, the backtracking position can include multiple positions. For example, a table with bold text can be a nested condition. If a cell in the table is incomplete, it is not necessary to backtrack to the table before the cell. Therefore, the position closest to the front is retained. In the above scheme, only the position closest to the front is retained when backtracking the first text, which avoids errors caused by multiple backtracking positions due to the nested condition or other conditions of some syntax elements. The backtracking position is as far forward as possible, thereby improving the accuracy of backtracking.

[0049] Step 202, parsing the third text using a non-streaming parsing rule to obtain the second text.

[0050] Specifically, after the text analysis device obtains the third text by removing the incomplete text, the third text does not include the incomplete text. The third text can be input into a non-streaming parsing rule tool for parsing to obtain the second text. At this time, the second text does not include the incomplete text, and the accuracy of the output text is ensured when the second text is output.

[0051] The text analysis scheme provided by the embodiments of the present disclosure obtains unit texts output in a streaming manner for target texts, wherein the target texts are texts in a lightweight markup language; combines the unit texts and prefix texts before the unit texts to obtain first texts; and analyzes the first texts through a streaming analysis rule to obtain second texts from which incomplete texts are removed. By using the above technical solution, the unit texts output in a streaming manner for the target texts in the lightweight markup language can be combined with the prefix texts before the unit texts to obtain the first texts, and the first texts are analyzed through the streaming analysis rule to obtain the second texts from which the incomplete texts are removed. Since the incomplete texts are removed in the streaming analysis process of the target texts in the lightweight markup language, it can be ensured that the analyzed output texts are complete texts, the accuracy of the analysis is ensured, and the accuracy of text display or reading is further ensured.

[0052] In some embodiments, the text analysis method can further include: displaying the second texts; and / or deleting a last analyzed text in the second texts to obtain fourth texts, and playing voice data of the fourth texts.

[0053] The last analyzed text can be a text obtained by analyzing a last unit text of the current unit text in the target texts through the streaming analysis rule. The fourth texts can be understood as texts obtained by subtracting the last analyzed text from the current second texts. If the current unit text is a complete text, the fourth texts are the analyzed text of the current unit text. If the current unit text is an incomplete text, the fourth texts are empty. Until the current unit text and at least one subsequent unit text are combined into a complete text, the analyzed text is the fourth texts. The voice data can be data converted by using a text-to-speech (TTS) technology on the fourth texts. The text-to-speech technology is a technology for converting text information into spoken voice output.

[0054] After the text analysis device analyzes the first texts through the streaming analysis rule to obtain the second texts from which the incomplete texts are removed, the second texts can be displayed, for example, the content displayed in the past is replaced with the second texts in the output scenario of a large model; or a last analyzed text in the second texts can be deleted to obtain fourth texts, and voice data of the fourth texts is played to realize reading of the fourth texts, for example, the complete fourth texts output at this time are read in the output scenario of a large model. In the above scheme, the analysis of incomplete lightweight markup language texts is supported in the scenario of streaming output of texts, and the incomplete texts will not be analyzed and output, the content that should be displayed or read is effectively identified, the accuracy of the displayed texts at any moment of the streaming output of the texts is ensured, and the accuracy of the texts when the streaming output of the texts is read is ensured.

[0055] In some embodiments, the text parsing method can further include: obtaining a verification text; parsing the verification text using the non-streaming parsing rule to obtain a first result; parsing the verification text according to a streaming output manner, incrementally extracting a prefix text for each unit text, and using the streaming parsing rule to obtain a second result; and comparing the first result and the second result to determine a verification result. The second result includes a plurality of sub-results obtained by parsing a plurality of prefix texts corresponding to a plurality of unit texts in the verification text using the streaming parsing rule.

[0056] The verification text can be a text used to verify the parsing effect of the streaming parsing rule, and the format of the verification text is the same as that of the target text. The verification text and the target text can both be Markdown texts. The first result can be a complete result obtained by parsing the verification text using the non-streaming parsing rule. The second result can be a result obtained by simulating a streaming scenario to parse the verification text using the streaming parsing rule. The second result can include a plurality of sub-results, each of which is obtained by parsing a prefix text corresponding to a unit text in the verification text using the streaming parsing rule. The verification result can include that the streaming parsing rule passes the verification and that the streaming parsing rule fails the verification.

[0057] The text parsing device can obtain a verification text, for example, a large number of rich text passages can be obtained from a network or a log as the verification text. Then, the verification text can be input into a tool of the non-streaming parsing rule to obtain a first result. The verification text can be parsed according to a streaming output manner, and the corresponding prefix text for each unit text can be output and parsed using the streaming parsing rule to obtain a second result. For example, for a verification text including N unit texts and N prefix texts, the Nth prefix text is the verification text, and the corresponding N sub-results are the second result. Each sub-result in the second result is verified based on the first result to determine a verification result.

[0058] Optionally, comparing the first result and the second result to determine the verification result can include: determining whether each sub-result in the second result is a prefix of the first result; if yes, the verification result is that the streaming parsing rule passes the verification; otherwise, the verification result is that the streaming parsing rule fails the verification.

[0059] The prefix of the first result can be any beginning part of the first result, and can be any part of the first result itself. Starting from an empty string (i.e., no characters), the prefix of the first result can be the entire first result itself. The prefix of the string has the same meaning, for example, the first result is “ABCD”, and the prefix of the first result can include an empty string, “A”, “AB”, “ABC”, and “ABCD”.

[0060] When determining the verification result by comparing the first result and the second result, the text analysis module can determine whether each sub result in the second result is a prefix of the first result. If all the sub results are prefixes of the first result, the verification result is that the streaming analysis rule passes the verification. If there is at least one sub result that is not a prefix of the first result, there is an analysis error, the verification result is that the streaming analysis rule fails the verification, and the streaming analysis rule can be adjusted until the streaming analysis rule passes the verification. After that, the streaming analysis rule is applied to the analysis of the target text.

[0061] For example, assuming that the verification text is "**hi**,**hi**", the first result is "hi,hi", and the multiple prefix texts of the verification text streaming output and the multiple sub results corresponding thereto can include: …Input:**hi**; Output: hi; …Input:**hi**,*; Output: hi; …Input:**hi**,**hi; Output: hi; …Input:**hi**,**hi**; Output: hi, hi, Input refers to the prefix text, and Output refers to the corresponding sub result. Since each sub result is a prefix of the first result, the verification result is that the streaming analysis rule passes the verification.

[0062] In the above scheme, by verifying whether the streaming analysis rule can correctly backtrack when the input text is an incomplete text at each time, no additional incomplete text is output, the verification of the streaming analysis rule of the above embodiment is implemented, the streaming analysis of the text of the lightweight markup language can be performed when the verification passes, and the accuracy of the text analysis is further ensured.

[0063] Next, the text analysis method of the embodiments of the present disclosure is further described through a specific example. For example, FIG. 3 is a schematic diagram of a text analysis process provided by the embodiments of the present disclosure. As shown in FIG. 3, the diagram takes Markdown as an example of a lightweight markup language, shows a streaming parsing rule, and a two-pass parsing method based on backtracking is used to parse an incomplete Markdown text in a streaming scenario. In the first pass, the incomplete Markdown text can be input into the streaming parsing rule, complete parts in the incomplete Markdown text are extracted, and incomplete syntax elements are backtracked to obtain backtracked Markdown text. The input is a current unit text, which is an incomplete text. For example, “**B” is input, the unit text is combined with a previous prefix text to obtain a first text, for example, “*Hi*,**B” in the diagram. After backtracking, the incomplete text is removed, the backtracking position is before “**B” in the diagram, and the backtracked Markdown text “*Hi*,” is obtained, which is the third text described above. In the second pass, the backtracked Markdown text, for example, “*Hi*,” in the diagram, can be input into a Markdown parsing module. The Markdown parsing module uses a non-streaming parsing rule to parse the backtracked Markdown text and obtains a parsed pure text, which is the second text described above, for example, “*Hi*,” in the diagram.

[0064] For example, FIG. 4 is a schematic diagram of a backtracking process provided by the embodiments of the present disclosure. As shown in FIG. 4, the diagram shows a backtracking process in the first pass of the parsing process in FIG. 3. Specifically, the input unit text is input into a syntax rule, which is one of non-streaming parsing rules. The non-streaming parsing rules can include multiple syntax rules. The current text position is recorded. The next character is expected to satisfy the syntax rule, but it is found that the end of the text has been reached, that is, the current unit text is incomplete and cannot satisfy the current syntax rule. If the unit text cannot satisfy all syntax rules, the unit text is an incomplete text. In a streaming scenario, the recorded text position can be used as a backtracking position. If there is a previous backtracking position, the earlier one is kept as the final backtracking position. Optionally, when in a non-streaming scenario, if a syntax rule fails to parse, the rule can be exited, the text position is restored to the recorded text position, and other syntax rules are tried for parsing.

[0065] The above scheme uses a two-pass parsing method for the streaming parsing rule of the lightweight markup language text. Backtracking and non-streaming parsing ensure that incomplete texts are removed, the parsed output text is complete, the accuracy of the parsing is ensured, and the accuracy of the text display or reading is ensured.

[0066] Fig. 5 is a structural schematic diagram of a text parsing device provided by an embodiment of the present disclosure. The device can be implemented by software and / or hardware, and can be integrated in an electronic device. As shown in Fig. 5, the device comprises:

[0067] The acquisition module 501 is configured to acquire a unit text output in a streaming manner for a target text, wherein the target text is a text in a lightweight markup language;

[0068] The combination module 502 is configured to combine the unit text and prefix text before the unit text to obtain a first text;

[0069] The parsing module 503 is configured to parse the first text by using a streaming parsing rule to obtain a second text in which incomplete texts are removed.

[0070] Optionally, the parsing module 503 comprises:

[0071] The backtracking unit is configured to backtrack the first text to obtain a third text in which incomplete texts are removed;

[0072] The processing unit is configured to parse the third text by using a non-streaming parsing rule to obtain the second text.

[0073] Optionally, the backtracking unit is configured to:

[0074] parse the first text by using the non-streaming parsing rule, and extract a unit text for which parsing fails as an incomplete text;

[0075] determine a start position of the incomplete text as a backtracking position in the first text;

[0076] cut the first text before the backtracking position to obtain the third text.

[0077] Optionally, the device further comprises an output module configured to:

[0078] display the second text;

[0079] and / or delete a last parsed text in the second text to obtain a fourth text, and play voice data of the fourth text.

[0080] Optionally, the device further comprises a verification module comprising:

[0081] The first unit is configured to acquire a verification text;

[0082] The second unit is configured to parse the verification text by using a non-streaming parsing rule to obtain a first result;

[0083] a third unit configured to extract, in a manner of incrementally extracting a prefix text from the verification text according to a streaming output, the prefix text from each unit text of the verification text according to the streaming parsing rule, and obtain a second result;

[0084] a fourth unit configured to compare the first result and the second result, and determine a verification result.

[0085] Optionally, the second result includes a plurality of sub-results obtained by parsing a plurality of prefix texts corresponding to a plurality of unit texts in the verification text according to the streaming parsing rule, and the fourth unit is configured to:

[0086] determine whether each of the sub-results in the second result is a prefix of the first result;

[0087] if yes, the verification result is that the streaming parsing rule passes the verification; otherwise, the verification result is that the streaming parsing rule fails the verification.

[0088] Optionally, the unit text is a character, a word, or a term, and the lightweight markup language is Markdown.

[0089] The text parsing apparatus provided in the embodiments of the present disclosure can perform the text parsing method provided in any of the embodiments of the present disclosure, and has the corresponding function modules and beneficial effects of the execution method.

[0090] The embodiments of the present disclosure further provide a computer program product, which includes computer programs / instructions, and the computer programs / instructions are executed by a processor to implement the text parsing method provided in any of the embodiments of the present disclosure.

[0091] FIG. 6 is a structural schematic diagram of an electronic device provided in an embodiment of the present disclosure. Hereinafter, specific reference will be made to FIG. 6, which shows a structural schematic diagram of an electronic device 600 suitable for implementing the electronic device in the embodiments of the present disclosure. The electronic device 600 in the embodiments of the present disclosure can include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (Personal Digital Assistant), a PAD (Tablet Personal Computer), a PMP (Portable Multimedia Player), a vehicle terminal (for example, a vehicle navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in FIG. 6 is only an example, and should not bring any limitation to the functions and use range of the embodiments of the present disclosure.

[0092] As shown in FIG. 6, the electronic device 600 can include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601 that can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 602 or loaded into a random access memory (RAM) 603 from a storage device 608. Various programs and data required for the operation of the electronic device 600 are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0093] In general, the following devices can be connected to the I / O interface 605: input devices 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 608 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 609. The communication devices 609 can allow the electronic device 600 to communicate wirelessly or wired with other devices to exchange data. Although FIG. 6 shows the electronic device 600 with various devices, it should be understood that all of the illustrated devices are not required to be implemented or possessed. More or less devices can be alternatively implemented or possessed.

[0094] According to embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product including a computer program carried on a non-transitory computer-readable medium, the computer program containing program codes for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network through the communication devices 609, or installed from the storage devices 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-described functions defined in the text analysis method of embodiments of the present disclosure are performed.

[0095] It should be noted that the computer-readable medium described above can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any suitable combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having 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 above. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program used by or in connection with an instruction execution system, apparatus or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in baseband or propagated as a carrier wave in a propagated data signal, in which the computer-readable program code is contained. Such a propagated data signal can take any of a variety of forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium that is not a storage medium and that can communicate, propagate or transport a program for use by or in connection with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wire, cable, optical fiber, RF, etc., or any suitable combination of the above.

[0096] In some embodiments, the client, server, or both can communicate using any current known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet, and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any current known or future developed networks.

[0097] The computer-readable medium described above can be included in the electronic device described above; or can exist separately from the electronic device, and not be assembled into the electronic device.

[0098] The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to acquire a unit text streamed for a target text, wherein the target text is a text in a lightweight markup language; combine the unit text and a prefix text before the unit text to obtain a first text; and parse the first text according to a streaming parsing rule to obtain a second text from which an incomplete text is removed.

[0099] Computer program code for carrying out operations of the present disclosure can be written in any of one or more programming languages, including object oriented programming languages such as Java, Smalltalk, C++ or conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0100] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of present disclosure. In this regard, each block in the flow diagrams or block diagrams can represent a module, a procedure, or a part of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in a different order than that noted in the figures. For example, two blocks noted in succession can in fact be executed substantially concurrently or in the opposite order, depending on the functionality involved. It should also be noted that each block in the block diagrams and / or flow diagrams, and combinations of blocks in the block diagrams and / or flow diagrams, can be implemented by dedicated hardware-based systems that perform the specified functions or operations, or can be implemented by a combination of dedicated hardware-based systems and computer instructions.

[0101] The units described in the embodiments of the present disclosure can be implemented by software, or by hardware. In some cases, the names of the units do not constitute a limitation on the units themselves.

[0102] The functions described above in the present disclosure can be performed, at least in part, by one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Application-specific Integrated Circuits (ASICs), Application-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.

[0103] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can 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 the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0104] It can be understood that, before using the technical solutions disclosed by the embodiments of the present disclosure, the type of information involved in the present disclosure, the use range, the use scenario, etc. should be informed to the user and the authorization of the user should be obtained through appropriate means according to relevant laws and regulations.

[0105] The above description is merely illustrative of the embodiments of the present disclosure and the explanation of the principles of the technology used. Those skilled in the art should understand that the disclosure range involved in the present disclosure is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by replacing the above features with the technical features disclosed in the present disclosure (but not limited to) having similar functions.

[0106] Furthermore, while operations are depicted in a particular, sequential order, this should not be understood as requiring or implying that the operations are performed in the order depicted or in sequential order, and that other operations were not intervening. It will be appreciated that in some circumstances, multitasking and parallel processing can be advantageous. Likewise, while specific implementations are discussed, this should not be understood as implying that these are the only implementations. The description is not to be limited to the specific details given herein. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in subcombination or as separate embodiments.

[0107] Although the present disclosure has been described in some specific detail, it is understood that modifications or alterations can be made to the above description by those skilled in the art without departing from the spirit and scope of the application. Accordingly, the above description is intended for the purposes of illustration only and should not be taken in a restrictive sense.

Claims

1. A text parsing method, comprising: obtaining unit texts that are streamed out for a target text, wherein the target text is a text in a lightweight markup language; combining the unit texts and prefix texts before the unit texts to obtain a first text; parsing the first text by a streaming parsing rule to obtain a second text in which incomplete texts are removed.

2. The method of claim 1, wherein, parsing the first text by a streaming text parsing rule to obtain a second text in which incomplete texts are removed, comprising: backtracking the first text to obtain a third text in which incomplete texts are removed; parsing the third text by a non-streaming parsing rule to obtain the second text.

3. The method of claim 2, wherein, backtracking the first text to obtain a third text in which incomplete texts are removed, comprising: parsing the first text by the non-streaming parsing rule to extract unit texts that fail to be parsed as incomplete texts; determining a start position of the incomplete texts as a backtracking position in the first text; cutting the first text before the backtracking position to obtain the third text. 4.The method of any one of claims 1-3, further comprising: displaying the second text; and / or deleting a last parsed text in the second text to obtain a fourth text, and playing voice data of the fourth text. 5.The method of any one of claims 1-4, further comprising: obtaining a verification text; parsing the verification text by a non-streaming parsing rule to obtain a first result; parsing the verification text by the streaming parsing rule to obtain a second result, wherein the verification text is incrementally extracted by unit texts and prefix texts before the unit texts are streamed out; comparing the first result and the second result to determine a verification result.

6. The method of claim 5, wherein, The second result comprises a plurality of sub-results obtained by parsing a plurality of prefix texts corresponding to a plurality of unit texts in the verification text by the streaming parsing rule, and comparing the first result and the second result to determine a verification result comprises: determining whether each of the sub-results in the second result is a prefix of the first result; if yes, the verification result is that the streaming parsing rule passes the verification; otherwise, the verification result is that the streaming parsing rule fails the verification.

7. The method of any one of claims 1-6, wherein, The unit text is a character, a word, or a term, and the lightweight markup language is Markdown. 8.A text parsing apparatus, comprising: an obtaining module configured to obtain unit texts that are streamed out for a target text, wherein the target text is a text in a lightweight markup language; a combining module configured to combine the unit texts and prefix texts before the unit texts to obtain a first text; a parsing module configured to parse the first text by a streaming parsing rule to obtain a second text in which incomplete texts are removed. 9.An electronic device, comprising: a processor; a memory for storing executable instructions of the processor; wherein the processor is configured to read the executable instructions from the memory and execute the instructions to implement the text parsing method of any one of claims 1-7.

10. A computer readable storage medium storing a computer program, wherein, The computer program is used for executing the text analysis method in any one of claims 1-7.

Citation Information

Patent Citations

  • Streaming data processing method and system, computer equipment and readable storage medium

    CN113535783A

  • Streaming question and answer illustration method and system

    CN118035416A

  • Method for reading streaming Markdown text and tracking and displaying reading progress

    CN118280342A

  • Semantics processing method, electronic device, and medium

    US20210209309A1