Search

CN-122021555-A - Format conversion method, apparatus, device and storage medium

CN122021555ACN 122021555 ACN122021555 ACN 122021555ACN-122021555-A

Abstract

The application discloses a format conversion method, a format conversion device, format conversion equipment and a storage medium, and relates to the technical field of computers. The method comprises the steps of obtaining a formula text, wherein the formula text is a formula which is expressed in a text form and is constructed based on at least one function, the formula text comprises at least two characters, performing lexical analysis on the formula text to obtain a word list corresponding to the formula text, the word list comprises at least two word information, the word information comprises words and type information of the words, the words comprise at least one character in the formula text, and performing formatting processing on the formula text according to the type information of each word contained in the formula text to obtain a formatting processing result of the formula text, wherein the formatting processing result is used for displaying each word contained in the formula text in a unified format according to semantic logic in a branching mode. According to the application, the formula text is displayed in a multi-line text form, so that the readability of the formula text is improved.

Inventors

  • LIU ZHONGZHENG
  • XU YUE

Assignees

  • 腾讯科技(深圳)有限公司

Dates

Publication Date
20260512
Application Date
20241112

Claims (14)

  1. 1. A method of format conversion, the method comprising: acquiring a formula text, wherein the formula text is a formula which is expressed in a text form and is constructed based on at least one function, and the formula text comprises at least two characters; Performing lexical analysis on the formula text to obtain a word list corresponding to the formula text, wherein the word list comprises at least two word information, the word information comprises words and type information of the words, and the words comprise at least one character in the formula text; According to the arrangement sequence of each word in the formula text, sequentially storing each word in the formula text into a current line list, wherein the current line list has a storage upper limit, the current line list is used for storing the word currently executing formatting, and the word in the current line list is moved out of the current line list after executing the formatting; And executing the formatting processing on the words stored in the current line list according to the type information of the words stored in the current line list to obtain a formatting processing result of the formula text, wherein the formatting processing result is used for displaying each word in the formula text in a unified format according to semantic logic lines.
  2. 2. The method according to claim 1, wherein the step of performing the formatting process on the word stored in the current line list according to the type information of the word stored in the current line list to obtain a formatting process result of the formula text includes: stopping storing words into the current line list under the condition that the number of characters in the current line list meets a threshold value condition, and determining the stored words in the current line list as formula text fragments to be processed; executing the formatting process on the formula text segment according to the type information of each word in the formula text segment to obtain a formatting process result of the formula text segment; after each formatting processing result of a row of words is obtained in the formula text segment, the row of words is moved out of the current row list, and the words in the formula text are continuously stored in the current row list; And obtaining the formatting result of the formula text according to the formatting result of the at least two lines of words removed from the current line list.
  3. 3. The method according to claim 2, wherein stopping the word storing in the current line list in case the number of characters in the current line list satisfies a threshold condition, determining the stored word in the current line list as a formula text segment to be processed, comprises: under the condition that the number of characters in the current line list is smaller than a first threshold value, continuing to store one word in the formula text in the current line list; And stopping storing the words in the current line list under the condition that the number of characters in the current line list is greater than or equal to the first threshold value, and determining the stored words in the current line list as the formula text fragments.
  4. 4. A method according to claim 2 or 3, wherein the formatting process comprises a line feed process for sorting the stored words in the current line list according to semantic logic and a indentation process for adding indentation characters before the sorting the presented words.
  5. 5. The method according to claim 4, wherein the step of performing the formatting process on the formula text segment according to the type information of each word in the formula text segment to obtain the formatting process result of the formula text segment includes: determining a first word and a second word in the formula text fragment according to the type information of each word in the formula text fragment, wherein the first word is a word used for triggering the line feed processing, and the second word is a word used for triggering the indentation processing; And executing the line feed processing and the indentation processing on the formula text fragment according to the first word and the second word to obtain a formatting processing result of the formula text fragment.
  6. 6. The method of claim 5, wherein determining the first word and the second word in the formula text segment based on the type information of each word in the formula text segment comprises: for any word in the formula text fragment, if the type information of the word is right brackets, determining the word as the first word; and if the type information of the word is left brackets, determining the word as the second word.
  7. 7. The method according to claim 5 or 6, wherein the performing the line feed processing and the indentation processing on the formula text segment according to the first word and the second word to obtain a formatting processing result of the formula text segment includes: Executing the line feed processing and the indentation processing on other words located after the second word under the condition that the function corresponding to the second word belongs to a nested function, wherein the function corresponding to the second word refers to a function expressed by a word before the second word; executing the line feed processing on the first word and other words located after the first word under the condition that the second word matched with the first word is subjected to the formatting processing, wherein the number of the indentation characters of the first word is the same as that of the second word matched with the first word; And obtaining the formatting result of the formula text according to the formatting result corresponding to the second word and the formatting result corresponding to the first word.
  8. 8. The method according to claim 7, wherein the performing the line feed processing and the indentation processing on other words located after the second word in a case where the function corresponding to the second word belongs to a nested function includes: Traversing each word in the formula text fragment, storing the ith word into a contracted stack when the ith word is the second word, and moving the second word positioned at the topmost layer in the contracted stack out of the contracted stack when the ith word is the first word, wherein i is a positive integer; Executing the line feed processing on other words positioned behind the second word under the condition that the function corresponding to the second word belongs to a nested function, so as to obtain a word subjected to the line feed processing; Obtaining the number of the contracted characters of the second word according to the length of a stack when the second word is stored in the contracted stack, wherein the length of the stack refers to the total number of the characters contained in each word in the contracted stack; And adding the indentation characters before the word subjected to the line feed processing according to the indentation character number of the second word.
  9. 9. The method according to claim 7 or 8, characterized in that the method further comprises: If the number of functions called inside the function corresponding to the second word is smaller than or equal to a second threshold value under the condition that the function corresponding to the second word belongs to a nested function, not executing the line feed processing and the indentation processing on other words located behind the second word; Or alternatively And if the number of characters in the function corresponding to the second word is smaller than or equal to a third threshold value under the condition that the function corresponding to the second word belongs to a nested function, not executing the line feed processing and the indentation processing on other words positioned behind the second word.
  10. 10. The method according to any one of claims 7 to 9, further comprising: and traversing each word in the formula text fragment, and executing the line feed processing on other words positioned behind the jth word under the condition that the type information of the jth word is comma, wherein the number of the indentation characters of the other words positioned behind the jth word is the same as that of the jth word, and j is a positive integer.
  11. 11. A format conversion apparatus, the apparatus comprising: a formula acquisition module, configured to acquire a formula text, where the formula text is a formula that is expressed in text form and is constructed based on at least one function, and the formula text includes at least two characters; The lexical analysis module is used for performing lexical analysis on the formula text to obtain a word list corresponding to the formula text, wherein the word list comprises at least two word information, the word information comprises words and type information of the words, and the words comprise at least one character in the formula text; the word storage module is used for sequentially storing each word in the formula text into a current line list according to the arrangement sequence of each word in the formula text, the current line list has a storage upper limit, the current line list is used for storing the word currently executing formatting, and the word in the current line list is moved out of the current line list after executing the formatting; the format processing module is used for executing the formatting processing on the words stored in the current line list according to the type information of the words stored in the current line list to obtain a formatting processing result of the formula text, wherein the formatting processing result is used for displaying all the words in the formula text in a unified format according to semantic logic lines.
  12. 12. A computer device comprising a processor and a memory, the memory having stored therein a computer program that is loaded and executed by the processor to implement the format conversion method of any of claims 1 to 10.
  13. 13. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a computer program, which is loaded and executed by a processor to implement the format conversion method according to any one of claims 1 to 10.
  14. 14. A computer program product, characterized in that the computer program product comprises a computer program that is loaded and executed by a processor to implement the format conversion method of any one of claims 1 to 10.

Description

Format conversion method, apparatus, device and storage medium Technical Field The present application relates to the field of computer technologies, and in particular, to a format conversion method, apparatus, device, and storage medium. Background The intelligent table is a novel database electronic table, has rich column types and multidimensional view display, and limits each column to be only one fixed column type, so that the operation is simpler and more convenient, and the situation of data misreading and random writing can be reduced in cooperation. In the related art, a list of formulas may be set in the intelligent table, and the formulas may be automatically calculated according to parameters of other columns required by the formulas to obtain data of the formulas by configuring one formula, where the formulas allow the user to calculate the formula result using different function methods and referring to fields of the intelligent table. The user rapidly configures each element of the formula through a formula editor in a formula column, through clicking or keyboard operation and the like. However, the formula written in the above method is shown in only one paragraph, and the readability of the formula is poor when the formula is long or the nested relationship is relatively complex. Disclosure of Invention The embodiment of the application provides a format conversion method, a format conversion device, format conversion equipment and a storage medium. The technical scheme provided by the embodiment of the application is as follows: according to an aspect of an embodiment of the present application, there is provided a format conversion method, including: acquiring a formula text, wherein the formula text is a formula which is expressed in a text form and is constructed based on at least one function, and the formula text comprises at least two characters; Performing lexical analysis on the formula text to obtain a word list corresponding to the formula text, wherein the word list comprises at least two word information, the word information comprises words and type information of the words, and the words comprise at least one character in the formula text; According to the arrangement sequence of each word in the formula text, sequentially storing each word in the formula text into a current line list, wherein the current line list has a storage upper limit, the current line list is used for storing the word currently executing formatting, and the word in the current line list is moved out of the current line list after executing the formatting; And executing the formatting processing on the words stored in the current line list according to the type information of the words stored in the current line list to obtain a formatting processing result of the formula text, wherein the formatting processing result is used for displaying each word in the formula text in a unified format according to semantic logic lines. According to an aspect of an embodiment of the present application, there is provided a format conversion apparatus including: a formula acquisition module, configured to acquire a formula text, where the formula text is a formula that is expressed in text form and is constructed based on at least one function, and the formula text includes at least two characters; The lexical analysis module is used for performing lexical analysis on the formula text to obtain a word list corresponding to the formula text, wherein the word list comprises at least two word information, the word information comprises words and type information of the words, and the words comprise at least one character in the formula text; the word storage module is used for sequentially storing each word in the formula text into a current line list according to the arrangement sequence of each word in the formula text, the current line list has a storage upper limit, the current line list is used for storing the word currently executing formatting, and the word in the current line list is moved out of the current line list after executing the formatting; the format processing module is used for executing the formatting processing on the words stored in the current line list according to the type information of the words stored in the current line list to obtain a formatting processing result of the formula text, wherein the formatting processing result is used for displaying all the words in the formula text in a unified format according to semantic logic lines. According to an aspect of an embodiment of the present application, there is provided a computer apparatus including a processor and a memory in which a computer program is stored, the computer program being loaded and executed by the processor to implement the above-described format conversion method. According to an aspect of an embodiment of the present application, there is provided a computer-readable storage medium having stored therein a computer progr