CN113268960A - Formula processing method and device - Google Patents

Formula processing method and device Download PDF

Info

Publication number
CN113268960A
CN113268960A CN202110580698.9A CN202110580698A CN113268960A CN 113268960 A CN113268960 A CN 113268960A CN 202110580698 A CN202110580698 A CN 202110580698A CN 113268960 A CN113268960 A CN 113268960A
Authority
CN
China
Prior art keywords
landmark
formula
target
processed
type
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.)
Granted
Application number
CN202110580698.9A
Other languages
Chinese (zh)
Other versions
CN113268960B (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 Founder Electronics Co Ltd
Original Assignee
Beijing Founder Electronics 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 Founder Electronics Co Ltd filed Critical Beijing Founder Electronics Co Ltd
Priority to CN202110580698.9A priority Critical patent/CN113268960B/en
Publication of CN113268960A publication Critical patent/CN113268960A/en
Application granted granted Critical
Publication of CN113268960B publication Critical patent/CN113268960B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The embodiment of the application provides a formula processing method and a formula processing device, wherein when deletion operation of a first landmark element in a formula to be processed is detected, a target element is determined in the formula to be processed according to attribute information of the first landmark element; the formula to be processed comprises a second landmark element paired with the first landmark element; executing deletion operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the type of the target element comprises a landmark type or a non-landmark type; and outputting the target formula. Therefore, the target element is determined in the formula to be processed, and the deleting operation is performed on the first landmark element according to the type of the target element, so that the other parts in the formula to be processed are reserved under the condition of deleting the first landmark element, and the integrity of the output target formula can be improved to a certain extent.

Description

Formula processing method and device
Technical Field
The present application relates to the field of computer software technologies, and in particular, to a formula processing method and apparatus.
Background
During the document editing process, a large number of formulas may be applied, each formula may be regarded as a multi-way tree structure, and landmarks in the formulas, such as brackets, integrals, sums, etc., are taken as sub-trees of the multi-way tree structure, and are usually an integral structure. For example, when the landmark is a bracket, the left and right brackets are a whole, wherein both the left and right brackets are landmark elements.
When editing certain formulas in a document, it may be necessary to delete some landmark elements of certain landmarks in the formula. Since landmark elements in the same landmark are displayed in the document as a whole. Therefore, when any one of the landmark elements in the landmark is deleted, the landmark element in the landmark and the data in the landmark element are both deleted, thereby destroying the integrity of the formula.
Disclosure of Invention
The embodiment of the application provides a formula processing method and device, which realize that under the condition of deleting a first landmark element, other parts in a formula to be processed are reserved, and the integrity of an output target formula can be improved to a certain extent.
In a first aspect, an embodiment of the present application provides a formula processing method, where the formula processing method includes:
when detecting the deletion operation of a first landmark element in a formula to be processed, determining a target element in the formula to be processed according to the attribute information of the first landmark element; wherein the formula to be processed comprises a second landmark element paired with the first landmark element.
Executing deletion operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the type of the target element comprises a landmark type or a non-landmark type.
And outputting the target formula.
In one possible implementation, the performing a deletion operation on the first landmark element according to the type of the target element to obtain a target formula includes:
and if the type of the target element is the landmark type, determining the second landmark element paired with the first landmark element in the formula to be processed.
And deleting the first landmark element and the second landmark element from the formula to be processed to obtain the target formula.
In one possible implementation, the performing a deletion operation on the first landmark element according to the type of the target element to obtain a target formula includes:
and if the type of the target element is a non-landmark type, assigning the attribute information of the first landmark element to the target element.
And deleting the first landmark element from the formula to be processed to obtain the target formula.
In one possible implementation, the determining a target element in the formula to be processed according to the attribute information of the first landmark element includes:
and determining the position of the first landmark element relative to the second landmark element according to the attribute information of the first landmark element and the attribute information of the second landmark element.
And determining the target element in the formula to be processed according to the position of the first landmark element relative to the second landmark element.
In one possible implementation, the determining the target element in the formula to be processed according to the position of the first landmark element relative to the second landmark element includes:
determining the target element on the right side of the first landmark element if the first landmark element is located on the left side of the second landmark element.
Determining the target element on the left side of the first landmark element if the first landmark element is located on the right side of the second landmark element.
In one possible implementation, if the first landmark element includes N landmark elements, the determining the target element on the right side of the first landmark element includes:
for each landmark element in the first landmark elements, determining the Nth element on the right side of the landmark element as the target element; wherein N is a positive integer.
In one possible implementation, if the first landmark element includes N landmark elements, the determining the target element on the left side of the first landmark element includes:
for each landmark element in the first landmark elements, determining the Nth element on the left side of the landmark element as the target element; wherein N is a positive integer.
In a second aspect, an embodiment of the present application provides a formula processing apparatus, where the formula processing apparatus includes:
the determining unit is used for determining a target element in the formula to be processed according to the attribute information of a first landmark element when the deleting operation of the first landmark element in the formula to be processed is detected; wherein the formula to be processed comprises a second landmark element paired with the first landmark element.
The processing unit is used for executing deletion operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the type of the target element comprises a landmark type or a non-landmark type.
And the output unit is used for outputting the target formula.
In a possible implementation manner, the processing unit is specifically configured to determine, in the formula to be processed, the second landmark element paired with the first landmark element when the type of the target element is a landmark type; and deleting the first landmark element and the second landmark element from the formula to be processed to obtain the target formula.
In a possible implementation manner, the processing unit is specifically configured to assign the attribute information of the first landmark element to the target element when the type of the target element is a non-landmark type; and deleting the first landmark element from the formula to be processed to obtain the target formula.
In a possible implementation manner, the determining unit is specifically configured to determine, according to the attribute information of the first landmark element and the attribute information of the second landmark element, a position of the first landmark element relative to the second landmark element; and determining the target element in the formula to be processed according to the position of the first landmark element relative to the second landmark element.
In a possible implementation, the determining unit is specifically configured to determine the target element on the right side of the first landmark element when the first landmark element is located on the left side of the second landmark element; determining the target element on a left side of the first landmark element when the first landmark element is located on a right side of the second landmark element.
In a possible implementation manner, the determining unit is specifically configured to determine, for each landmark element in the first landmark elements, an nth element on the right side of the landmark element as the target element; wherein N is a positive integer; the first landmark element includes N landmark elements.
In a possible implementation manner, the determining unit is specifically configured to determine, for each landmark element in the first landmark elements, an nth element on the left side of the landmark element as the target element; wherein N is a positive integer; the first landmark element includes N landmark elements.
In a third aspect, an embodiment of the present application further provides a formula processing apparatus, where the formula processing apparatus may include a memory and a processor; wherein the content of the first and second substances,
the memory is used for storing the computer program.
The processor is configured to read the computer program stored in the memory, and execute the formula processing method in any one of the possible implementation manners of the first aspect according to the computer program in the memory.
In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, where a computer-executable instruction is stored in the computer-readable storage medium, and when a processor executes the computer-executable instruction, the formula processing method described in any one of the foregoing possible implementation manners of the first aspect is implemented.
In a fifth aspect, an embodiment of the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the method for processing a formula in any one of the possible implementation manners of the first aspect is implemented.
Therefore, the embodiment of the application provides a formula processing method and device, when deletion operation of a first landmark element in a formula to be processed is detected, a target element is determined in the formula to be processed according to attribute information of the first landmark element; the formula to be processed comprises a second landmark element paired with the first landmark element; executing deletion operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the type of the target element comprises a landmark type or a non-landmark type; and outputting the target formula. Therefore, the target element is determined in the formula to be processed, and the deleting operation is performed on the first landmark element according to the type of the target element, so that the other parts in the formula to be processed are reserved under the condition of deleting the first landmark element, and the integrity of the output target formula can be improved to a certain extent.
Drawings
Fig. 1 is a schematic view of an application scenario of a formula processing method according to an embodiment of the present application;
FIG. 2 is a schematic flow chart diagram illustrating another method for processing formulas according to an embodiment of the present disclosure;
FIG. 3 is a diagram illustrating a nested structure of landmarks in a formula according to an embodiment of the present application;
fig. 4 is a schematic structural diagram after a formula is split according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of a landmark element to be deleted in a formula provided in an embodiment of the present application;
FIG. 6 is a schematic structural diagram of a target formula provided in an embodiment of the present application;
FIG. 7 is a diagram illustrating a nested structure of landmarks in a target formula according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a formula processing apparatus according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of another formula processing apparatus according to an embodiment of the present application.
With the foregoing drawings in mind, certain embodiments of the disclosure have been shown and described in more detail below. These drawings and written description are not intended to limit the scope of the disclosed concepts in any way, but rather to illustrate the concepts of the disclosure to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
In the embodiments of the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone, wherein A and B can be singular or plural. In the description of the text of the present application, the character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
During the document editing process, a large number of formulas may be applied, each formula may be regarded as a multi-way tree structure, and landmarks in the formulas, such as brackets, integrals, sums, etc., are taken as sub-trees of the multi-way tree structure, and are usually an integral structure. For example, when a landmark is a bracket, the landmark element left bracket, the landmark element right bracket, and the non-landmark elements within the brackets constitute a whole. The technical scheme provided by the embodiment of the application can be applied to a formula typesetting scene. For example, in interactive technical typesetting software, a large number of formulas and words may need to be typeset. If a large number of characters exist in a certain row, it may happen that the formula and the characters in the row cannot be displayed in the same row due to the long formula, resulting in poor typesetting effect.
In order to improve the typesetting effect, when some formulas in the document are edited, some landmark elements of some landmarks in the formulas may need to be deleted, and the speech speed which cannot be displayed in the same line in the formulas is transferred to the next line for continuous display. Since landmark elements in the same landmark are displayed in the document as a whole. Therefore, when any one of the landmark elements in the landmark is deleted, the landmark element and the non-landmark element in the landmark are all deleted, thereby destroying the integrity of the formula.
In order to avoid the problem that when any one of the landmark elements in the landmark is deleted, the other part of the landmark is deleted because the landmark in the formula is a whole, a target element can be determined according to the attribute information of the landmark element to be deleted in the formula, so that the landmark element to be deleted can be deleted according to the type of the target element, and the other part of the formula is reserved.
Based on the above concept, an embodiment of the present application provides a formula processing method, where when a deletion operation of a first landmark element in a formula to be processed is detected, a target element is determined in the formula to be processed according to attribute information of the first landmark element; the formula to be processed comprises a second landmark element paired with the first landmark element; executing deletion operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the type of the target element comprises a landmark type or a non-landmark type; and outputting the target formula.
In this application, the first landmark element and the second landmark element are two landmark elements paired with each other in the same landmark, and the landmark is a special operator in a formula, such as a bracket, an integral symbol, a summation symbol, and the like. Here, operators such as "+", "-", "═ and the like are not landmarks. For example, if the landmark is a bracket, the first landmark element may be a left bracket or a right bracket, and when the first landmark element is the left bracket, the second landmark element is the right bracket, and vice versa, when the first landmark element is the right bracket, the second landmark element is the left bracket. The attribute information of the landmark element may be understood as an attribute for describing the landmark element. For example, if the landmark element is a left bracket, the attribute information of the landmark element is the left bracket; if the landmark element is a right bracket, the attribute information of the landmark element is the right bracket.
Therefore, in the embodiment of the application, when the formula text is processed, the target element is determined in the formula to be processed according to the attribute information of the first landmark element; and executing deletion operation on the first landmark element according to the type of the target element, so that the completeness of the output target formula can be improved to a certain extent under the condition of deleting the first landmark element in the formula to be processed and reserving other parts in the formula to be processed.
Hereinafter, the formula processing method provided in the present application will be described in detail by specific examples. It is to be understood that the following detailed description may be combined with other embodiments, and that the same or similar concepts or processes may not be repeated in some embodiments.
Fig. 1 is a schematic flow chart of a formula processing method according to an embodiment of the present disclosure. The formula processing method can be executed by software and/or hardware device, for example, the hardware device can be a formula processing device, and the formula processing device can be a terminal or a processing chip in the terminal. For example, referring to fig. 1, the formula processing method may include:
s101, when the deletion operation of the first landmark element in the formula to be processed is detected, determining a target element in the formula to be processed according to the attribute information of the first landmark element.
Wherein the formula to be processed includes a second landmark element paired with the first landmark element. And the first landmark element may include a plurality of landmark elements, and the number of the first landmark elements is not limited in this embodiment.
For example, before detecting the deletion operation of the first landmark element in the formula to be processed, each of the plurality of landmarks in the formula to be processed may be split, that is, the landmark may be split into a plurality of independent parts of the landmark element and the non-landmark element. When a landmark is split, each landmark element in the landmark is assigned corresponding attribute information. The attribute information is information indicating a landmark element corresponding to the attribute information. For example, when "(a + b)" is split into "(", ")", and "a + b", the landmark elements "(" and landmark elements ")" have their corresponding attribute information, respectively. After the formula to be processed is split, each landmark in the formula to be processed does not exist as a whole, and therefore deletion operation can be performed on part of landmark elements in the formula to be processed.
For example, before detecting the deletion operation of the first landmark element in the formula to be processed, the split formula may be checked to determine whether each landmark element in the formula has a landmark element paired with the split formula, and specifically, the checking may be performed according to the attribute information of the landmark element. If the landmark elements which cannot be matched exist, the landmark elements are automatically deleted so as to ensure the integrity of the formula.
When the deletion operation of the first landmark element in the formula to be processed is detected, the attribute information of the first landmark element can be obtained, and the target element is determined in the formula to be processed according to the attribute information of the first landmark element. Determining a position of the first landmark element relative to the second landmark element based on the attribute information of the first landmark element and the attribute information of the second landmark element; and determining the target element in the formula to be processed according to the position of the first landmark element relative to the second landmark element. For example, if the first landmark element is a left bracket and the second landmark element is a right bracket, it may be determined that the first landmark element is located on the left side of the second landmark element, and the target element may be determined according to the position information.
In the embodiment of the application, the position of the first landmark element relative to the second landmark element is determined through the attribute information corresponding to the first landmark element and the second landmark element respectively; and the target element is determined according to the position, so that the determined position of the target element is more accurate.
For example, when a target element is determined in a formula to be processed according to the position of a first landmark element relative to a second landmark element, if the first landmark element is located on the left side of the second landmark element, the target element is determined on the right side of the first landmark element; if the first landmark element is located on the right side of the second landmark element, the target element is determined on the left side of the first landmark element. For example, if a landmark element "(" to which a paired landmark element is "is known") in formula a ═ B (a + c)/D is deleted and the landmark element is located on the left side of the paired landmark element, a target element is determined on the right side of the landmark element "(").
In the embodiment of the application, the target element is determined on the left side or the right side of the first landmark element according to the position of the first landmark element relative to the second landmark element, so that the problem that the target elements respectively determined by the two landmark elements are the same element when two unpaired landmark elements on the left side and the right side are deleted simultaneously can be avoided, and the determined position of the target element is more accurate.
For example, the first landmark element includes N landmark elements, and when the target element is determined on the right side of the first landmark element, the nth element on the right side of the landmark element may be determined as the target element for each of the landmark elements in the first landmark element; wherein N is a positive integer. For example, the formula to be processed is a { BC + D [ cos (a + b) ] }/E, the first landmark element includes "{", "[" and "(" 3 landmark elements, i.e., N is 3, then the landmark element "{" the 3 rd element on the right side "+" is taken as its corresponding target element, the landmark element "[" the third element on the right side "a" is taken as its corresponding target element, and the landmark element "(" the third element on the right side "b" is taken as its corresponding target element.
For example, the first landmark element includes N landmark elements, and when the target element is determined on the left side of the first landmark element, the nth element on the left side of the landmark element may be determined as the target element for each of the landmark elements in the first landmark element; wherein N is a positive integer. For example, if the formula to be processed is a ═ BC + D [ cos (a + b) ] }/E, and the first landmark element is ") ] }", that is, the first landmark element includes ")", "]" and "}" 3 landmark elements, that is, N is 3, the 3 rd element "b" on the left side of the landmark element "}" is taken as its corresponding target element; taking the third element on the left side of the landmark element "]" + "as a corresponding target element; landmark element ")" the third left element "a" as its corresponding target element.
In the embodiment of the application, when the first landmark element includes N landmark elements, the nth element on the right side or the left side of each landmark element is determined as the corresponding target element, so that the problem that the target elements determined by two landmark elements are the same when the first landmark element includes a plurality of landmark elements can be avoided, and the determined target elements are more accurate.
For example, when a target element is determined in a formula to be processed according to attribute information of a first landmark element, an array may be established by using the attribute information of the first landmark element as an element when a deletion operation of the first landmark element in the formula to be processed is detected, and the target element is determined according to information of the element in the array. The array comprises attribute information of each landmark element in the first landmark elements, and the number of the elements in the array is the same as that of the attribute information. Of course, a table may be created according to the attribute information of the first landmark element, and the target element may be determined according to each data in the table. The embodiments of the present application are only described by taking the creation of an array as an example, but the embodiments of the present application are not limited thereto.
When determining the target element, the target element may be determined directly according to the number of elements in the array and the attribute information. And determining that the target element is positioned on the left side or the right side of the landmark element according to the attribute information of each landmark element in the array, and determining the number of the left or right elements of the target element of the landmark information according to the number of the elements in the array. And if the attribute information indicates that the landmark element is positioned on the right side of the landmark element matched with the landmark element, the target element corresponding to the landmark element is positioned on the left side of the landmark element, and otherwise, the target element corresponding to the landmark element is positioned on the right side of the landmark element. For example, there are 5 elements in the array, and a landmark element is located at the right side of the landmark element paired with the landmark element, then the target element corresponding to the landmark element is in the fifth element at the left side of the landmark element in the formula to be processed.
After determining the target element in the pending formula, the following S102 may be performed:
and S102, deleting the first landmark element according to the type of the target element to obtain a target formula.
Wherein the type of the target element comprises a landmark type or a non-landmark type. As an example, the target element being a landmark type indicates that the target element is a landmark element, that is, the target element has attribute information; the target element being of a non-landmark type indicates that the target element is not a landmark element, i.e. the target element has no attribute information.
When a target formula is obtained by executing deletion operation on a first landmark element according to the type of the target element, if the type of the target element is the landmark type, determining a second landmark element matched with the first landmark element in the formula to be processed; and deleting the first landmark element and the second landmark element from the formula to be processed to obtain a target formula. For example, if the type of the target element is a landmark element, the first landmark element may be stacked as a center, and an element corresponding to the current target element in the to-be-processed formula is determined as a new target element. For example, for the sum-of-products and difference formula in the trigonometric function, cos α sin β is 1/2[ sin (α + β) -sin (α - β) ], and if the first landmark element is "]", the target element can be determined to be the first element to the left of the first landmark element, i.e., the target element is ")". Since the type of the target element ")" is a landmark type, and there is no element corresponding to the target element ")", both the first landmark element "]" and the second landmark element "[" paired therewith are deleted, i.e., the formula becomes cos α sin β ═ 1/2sin (α + β) -sin (α - β).
As another example, the formula to be processed is (d + (c- (ab))), the first landmark element to be deleted is "))". Wherein the first landmark element to be deleted includes 3 landmark elements, which respectively correspond to target elements of "(", "a" and "b" according to the above method, and thus the formula becomes (d + (c-ab).
In the embodiment of the application, if the type of the target element is the landmark type, the first landmark element and the second landmark element corresponding to the first landmark element are both deleted in the formula to be processed, so that the problem that when the target formula is output in other editing software, other parts of the landmark are deleted except the first landmark element due to the fact that the first landmark element does not have the second landmark element matched with the first landmark element and other landmark information except the first landmark element is judged to be wrong data when the target formula is output is avoided, and the integrity of the output target formula can be effectively improved.
It can be understood that, when the deletion operation is performed on the first landmark element according to the type of the target element to obtain the target formula, if the type of the target element is a non-landmark type, the attribute information of the first landmark element is assigned to the target element; and deleting the first landmark element from the formula to be processed to obtain a target formula.
In the embodiment of the application, when the target element is a non-landmark element, attribute information of the first landmark element is assigned to the target element, and the first landmark element is deleted, that is, after the first landmark element is deleted, the attribute information of the first landmark element is still in the formula to be processed, so that the second landmark element can be paired with the target element containing the attribute information of the first landmark element, the integrity of the attribute information of the landmark is ensured, and in the output target formula, under the condition that the first landmark element is deleted, other parts of the landmark can be reserved.
And S103, outputting a target formula.
For example, when outputting the formula, the target formula may be output in a common format such as word or mathML. Because the attribute information of each landmark element in the target formula has the attribute information matched with the landmark element, when the target formula is output in a common format such as word or mathML, other deleted parts of the first landmark information cannot be mistakenly deleted as error data, so that the integrity of the output target formula is ensured.
Therefore, in the formula processing method provided by the embodiment of the application, when the deletion operation of the first landmark element in the formula to be processed is detected, the target element is determined in the formula to be processed according to the attribute information of the first landmark element; the formula to be processed comprises a second landmark element paired with the first landmark element; executing deletion operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the type of the target element comprises a landmark type or a non-landmark type; and outputting the target formula. Therefore, the target element is determined in the formula to be processed, and the deleting operation is performed on the first landmark element according to the type of the target element, so that the other parts in the formula to be processed are reserved under the condition of deleting the first landmark element, and the integrity of the output target formula can be improved to a certain extent.
In order to facilitate understanding of the formula processing method provided in the embodiment of the present application, the following will describe in detail the technical solution provided in the embodiment of the present application by taking the formula to be processed as the product and difference formula in the trigonometric function as an example, and the determined formula processing method may be executed by software and/or a hardware device. Specifically, as shown in fig. 2, fig. 2 is a schematic flow chart of another formula processing method provided in the embodiment of the present application. The processing method of the formula text can comprise the following steps:
s201, receiving a deleting operation.
Wherein the deletion operation is used for indicating to delete at least one landmark element in the formula to be processed.
For example, the formula to be processed is a sum-product and difference formula cos α sin β in a trigonometric function, which is 1/2[ sin (α + β) -sin (α - β) ], and as shown in fig. 3, fig. 3 is a schematic diagram of a nested structure of landmarks in a formula provided in an embodiment of the present application. In fig. 3, landmark 301, landmark 302, and landmark 303 are all bracket-type landmarks, each including two landmark elements that may be paired with each other. The landmark 301, the landmark 302, and the landmark 303 are all an integral body, and when a part of the integral body is deleted, other elements in the landmark are all deleted.
According to the method described in the above embodiment, the formula to be processed may be split such that the landmarks 301, 302, and 303 are no longer displayed as a whole. Referring to fig. 4, fig. 4 is a schematic structural diagram after a formula is split according to an embodiment of the present disclosure. In fig. 4, the elements in the formula to be processed are distinguished by different shapes. The elements in the square of the dotted line are two landmark elements matched with each other, the elements in the circle of the dotted line are two landmark elements matched with each other, and the elements in the pentagon of the dotted line are two elements matched with each other; the elements within the other solid circles are all non-landmark type elements.
In this embodiment, the landmark element to be deleted may be as shown in fig. 5, and fig. 5 is a schematic structural diagram of the landmark element to be deleted in a formula provided in the embodiment of the present application. The landmark element 501 to be deleted includes two landmark elements, each of which is one of the landmarks 301 and 303 in fig. 3. That is, in the embodiment of the present application, the received deletion operation is used to indicate deletion of two landmark elements of the landmark elements 501 in fig. 5.
S202, acquiring attribute information of each landmark element to be deleted.
When obtaining the attribute information of each landmark element to be deleted, each landmark element in the formula to be processed can be checked to have another landmark element paired with the landmark element, so that the integrity of the formula to be processed is ensured before the landmark element in the formula to be processed is deleted.
When obtaining the attribute information of the landmark element to be deleted, an array may also be established according to the obtained attribute information, and according to the above embodiment, if the landmark element to be deleted is the landmark element 501 in fig. 5, the established array includes 2 different attribute information. The embodiments of the present application are only described by taking the creation of an array as an example, but the embodiments of the present application are not limited thereto.
And S203, determining a target element corresponding to each landmark element to be deleted according to the attribute information of each landmark element to be deleted.
For example, the method for determining the target element corresponding to each landmark element to be deleted according to the attribute information of each landmark element to be deleted may refer to the foregoing embodiment, which is not limited in this embodiment of the present application. According to the method described in the above embodiment, it may be determined that, in the landmark element 501 to be deleted, the target element corresponding to the landmark element in the pentagon of the dotted line is the second element on the left side thereof, i.e. the element "-" in the circle of the solid line, and the target element corresponding to the landmark element in the square of the dotted line is the second element on the left side thereof, i.e. the element "β" in the circle of the solid line.
And S204, executing deletion operation on each landmark element to be deleted according to the type of the target element to obtain a target formula.
According to the method described in the above embodiment, it is known that the types of the target element "-" and the target element "β" are both non-landmark types, and then the attribute information of the landmark element in the dotted line pentagon may be assigned to the corresponding target element "-" and the attribute information of the landmark element in the dotted line square may be assigned to the corresponding target element "β", and the deletion operation may be performed on each landmark element to be deleted. The formula to be processed shown in fig. 6 can be obtained, and fig. 6 is a schematic structural diagram of a target formula provided in the embodiment of the present application. As shown in fig. 6, the shape of the target element "-" is changed from the original circle of the solid line to the pentagon of the broken line, and the shape of the target element "β" is changed from the original circle of the solid line to the square of the broken line, indicating that both the target element "-" and the target element "β" carry attribute information of different landmark elements.
And S205, outputting a target formula.
For an example, the output formula can be shown in fig. 7, and fig. 7 is a schematic diagram of a nested structure of landmarks in a target formula provided in an embodiment of the present application. As can be seen from fig. 7, the landmark structure of the target formula varies depending on the position where the attribute information of the landmark element is located.
In summary, in the formula processing method provided in the embodiment of the present application, the attribute information of the landmark element to be deleted is obtained, and the target element is determined according to the attribute information; and assigning the attribute information of the landmark element to be deleted to the corresponding target element, so that the attribute information of the landmark element to be deleted is kept under the condition that the landmark element to be deleted is deleted, and therefore, the landmark element corresponding to each landmark element in the output target formula can be ensured to exist. So that the integrity of the output target formula is provided to a certain extent by reserving other parts in the formula to be processed under the condition that the landmark element to be deleted is deleted
Fig. 8 is a schematic structural diagram of a formula processing apparatus 80 according to an embodiment of the present application, for example, please refer to fig. 8, where the formula processing apparatus 80 may include:
the determining unit 801 is configured to determine, when a deletion operation of a first landmark element in a formula to be processed is detected, a target element in the formula to be processed according to attribute information of the first landmark element; the formula to be processed comprises a second landmark element paired with the first landmark element;
the processing unit 802 is configured to perform a deletion operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the type of the target element comprises a landmark type or a non-landmark type;
an output unit 803, configured to output the target formula.
Optionally, the processing unit 802 is specifically configured to determine, in the formula to be processed, a second landmark element paired with the first landmark element when the type of the target element is the landmark type; and deleting the first landmark element and the second landmark element from the formula to be processed to obtain a target formula.
Optionally, the processing unit 802 is specifically configured to assign the attribute information of the first landmark element to the target element when the type of the target element is a non-landmark type; and deleting the first landmark element from the formula to be processed to obtain a target formula.
Optionally, the determining unit 801 is specifically configured to determine, according to the attribute information of the first landmark element and the attribute information of the second landmark element, a position of the first landmark element relative to the second landmark element; and determining the target element in the formula to be processed according to the position of the first landmark element relative to the second landmark element.
Optionally, the determining unit 801 is specifically configured to determine the target element on the right side of the first landmark element when the first landmark element is located on the left side of the second landmark element; the target element is determined on the left side of the first landmark element when the first landmark element is located on the right side of the second landmark element.
Optionally, the determining unit 801 is specifically configured to determine, for each landmark element in the first landmark elements, an nth element on the right side of the landmark element as a target element; wherein N is a positive integer; the first landmark element includes N landmark elements.
Optionally, the determining unit 801 is specifically configured to determine, for each landmark element in the first landmark elements, an nth element on the left side of the landmark element as a target element; wherein N is a positive integer; the first landmark element includes N landmark elements.
The formula processing apparatus provided in the embodiment of the present application can execute the technical solution of the formula processing method in any of the above embodiments, and the implementation principle and the beneficial effect of the formula processing apparatus are similar to those of the formula processing method, which can be referred to as the implementation principle and the beneficial effect of the formula processing method, and are not described herein again.
Fig. 9 is a schematic structural diagram of another formula processing apparatus 90 provided in the embodiment of the present application, for example, please refer to fig. 9, where the formula processing apparatus 90 may include a processor 901 and a memory 902; wherein the content of the first and second substances,
the memory 902 is used for storing computer programs.
The processor 901 is configured to read the computer program stored in the memory 902, and execute the technical solution of the formula processing method in any of the embodiments according to the computer program in the memory 902.
Alternatively, the memory 902 may be separate or integrated with the processor 901. When the memory 902 is a device independent from the processor 901, the formula processing apparatus 90 may further include: a bus for connecting the memory 902 and the processor 901.
Optionally, this embodiment further includes: a communication interface that may be connected to the processor 901 via a bus. The processor 901 may control the communication interface to implement the functions of receiving and transmitting of the above equation processing apparatus 90.
The formula processing apparatus 90 shown in this embodiment of the application can execute the technical solution of the formula processing method in any embodiment, and its implementation principle and beneficial effect are similar to those of the formula processing method, and reference may be made to the implementation principle and beneficial effect of the formula processing method, which is not described herein again.
An embodiment of the present application further provides a computer-readable storage medium, where a computer execution instruction is stored in the computer-readable storage medium, and when a processor executes the computer execution instruction, the technical solution of the formula processing method in any of the above embodiments is implemented, and an implementation principle and beneficial effects of the formula processing method are similar to those of the formula processing method, which can be referred to as the implementation principle and beneficial effects of the formula processing method, and are not described herein again.
The embodiment of the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the technical solution of the formula processing method in any of the above embodiments is implemented, and the implementation principle and the beneficial effect of the computer program are similar to those of the formula processing method, which can be referred to as the implementation principle and the beneficial effect of the formula processing method, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts shown as units may or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment. In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated module implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present application.
It should be understood that the Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor, or in a combination of the hardware and software modules within the processor.
The memory may comprise a high-speed RAM memory, and may further comprise a non-volatile storage NVM, such as at least one disk memory, and may also be a usb disk, a removable hard disk, a read-only memory, a magnetic or optical disk, etc.
The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the buses in the figures of the present application are not limited to only one bus or one type of bus.
The computer-readable storage medium may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (11)

1. A method of formula processing, comprising:
when detecting the deletion operation of a first landmark element in a formula to be processed, determining a target element in the formula to be processed according to the attribute information of the first landmark element; wherein the formula to be processed comprises a second landmark element paired with the first landmark element;
executing deletion operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the type of the target element comprises a landmark type or a non-landmark type;
and outputting the target formula.
2. The method of claim 1, wherein the performing a deletion operation on the first landmark element according to the type of the target element, resulting in a target formula, comprises:
if the type of the target element is a landmark type, determining the second landmark element matched with the first landmark element in the formula to be processed;
and deleting the first landmark element and the second landmark element from the formula to be processed to obtain the target formula.
3. The method of claim 1, wherein the performing a deletion operation on the first landmark element according to the type of the target element, resulting in a target formula, comprises:
if the type of the target element is a non-landmark type, assigning the attribute information of the first landmark element to the target element;
and deleting the first landmark element from the formula to be processed to obtain the target formula.
4. The method according to any of claims 1-3, wherein said determining a target element in said formula to be processed from attribute information of said first landmark element comprises:
determining the position of the first landmark element relative to the second landmark element according to the attribute information of the first landmark element and the attribute information of the second landmark element;
and determining the target element in the formula to be processed according to the position of the first landmark element relative to the second landmark element.
5. The method of claim 4, wherein determining the target element in the formula to be processed based on the position of the first landmark element relative to the second landmark element comprises:
determining the target element on the right side of the first landmark element if the first landmark element is located on the left side of the second landmark element;
determining the target element on the left side of the first landmark element if the first landmark element is located on the right side of the second landmark element.
6. The method of claim 5, wherein the first landmark element comprises N landmark elements, and wherein the determining the target element to the right of the first landmark element comprises:
for each landmark element in the first landmark elements, determining the Nth element on the right side of the landmark element as the target element; wherein N is a positive integer.
7. The method of claim 5, wherein the first landmark element comprises N landmark elements, and wherein the determining the target element on the left side of the first landmark element comprises:
for each landmark element in the first landmark elements, determining the Nth element on the left side of the landmark element as the target element; wherein N is a positive integer.
8. An equation processing apparatus, comprising:
the determining unit is used for determining a target element in the formula to be processed according to the attribute information of a first landmark element when the deleting operation of the first landmark element in the formula to be processed is detected; wherein the formula to be processed comprises a second landmark element paired with the first landmark element;
the processing unit is used for executing deletion operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the type of the target element comprises a landmark type or a non-landmark type;
and the output unit is used for outputting the target formula.
9. An equation processing apparatus, comprising a memory and a processor; wherein the content of the first and second substances,
the memory for storing a computer program;
the processor is used for reading the computer program stored in the memory and executing a formula processing method of any one of the claims 1-7 according to the computer program in the memory.
10. A computer-readable storage medium having computer-executable instructions stored thereon which, when executed by a processor, implement a formula processing method as recited in any one of claims 1-7.
11. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, carries out a method of formula processing according to any one of the preceding claims 1-7.
CN202110580698.9A 2021-05-26 2021-05-26 Formula processing method and device Active CN113268960B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110580698.9A CN113268960B (en) 2021-05-26 2021-05-26 Formula processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110580698.9A CN113268960B (en) 2021-05-26 2021-05-26 Formula processing method and device

Publications (2)

Publication Number Publication Date
CN113268960A true CN113268960A (en) 2021-08-17
CN113268960B CN113268960B (en) 2024-04-19

Family

ID=77233064

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110580698.9A Active CN113268960B (en) 2021-05-26 2021-05-26 Formula processing method and device

Country Status (1)

Country Link
CN (1) CN113268960B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4852057A (en) * 1986-10-27 1989-07-25 Hewlett-Packard Company Algebraic expression manipulation method and implementation for an electronic data processing apparatus
JPH03260766A (en) * 1990-03-09 1991-11-20 Mitsubishi Electric Corp Translating device with parenthesis generation deciding function
JPH05181804A (en) * 1991-12-27 1993-07-23 Sharp Corp Information processor
JP2003256417A (en) * 2002-03-05 2003-09-12 Nec Soft Ltd Review document correcting device
CN106874243A (en) * 2016-12-21 2017-06-20 武汉斗鱼网络科技有限公司 Formula processing method and device based on character string

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4852057A (en) * 1986-10-27 1989-07-25 Hewlett-Packard Company Algebraic expression manipulation method and implementation for an electronic data processing apparatus
JPH03260766A (en) * 1990-03-09 1991-11-20 Mitsubishi Electric Corp Translating device with parenthesis generation deciding function
JPH05181804A (en) * 1991-12-27 1993-07-23 Sharp Corp Information processor
JP2003256417A (en) * 2002-03-05 2003-09-12 Nec Soft Ltd Review document correcting device
CN106874243A (en) * 2016-12-21 2017-06-20 武汉斗鱼网络科技有限公司 Formula processing method and device based on character string

Also Published As

Publication number Publication date
CN113268960B (en) 2024-04-19

Similar Documents

Publication Publication Date Title
EP3796182A1 (en) Data processing method and apparatus, and computer-readable storage medium
CN110442308B (en) Data block storage method, device, equipment and storage medium
CN110888922B (en) Method and device for creating target table during data synchronization
CN112712014A (en) Table picture structure analysis method, system, equipment and readable storage medium
CN112199268A (en) Software compatibility testing method and electronic equipment
CN110866382A (en) Document generation method, device, terminal equipment and medium
CN113268960B (en) Formula processing method and device
CN111553847B (en) Image processing method and device
CN110955545A (en) Data integrity checking method, system and related equipment
CN113177045A (en) Data extraction method and device, computable storage equipment and data request equipment
CN111753812A (en) Text recognition method and equipment
CN113434251B (en) Cross-platform deployment method, device and equipment for service modules
CN114116958A (en) Auditing method, auditing device, electronic equipment and storage medium
CN112216333B (en) Chip testing method and device
CN112508526A (en) Data auditing method and device
CN108334394B (en) Multi-language processing method and device for basic data of multi-language software system
CN113642398A (en) Method and device for identifying space region
CN109242984B (en) Virtual three-dimensional scene construction method, device and equipment
CN114743203A (en) Document processing method, device, equipment and storage medium
CN113568578B (en) Picture processing method and device, electronic equipment and readable storage medium
CN117271440B (en) File information storage method, reading method and related equipment based on freeRTOS
CN107835990A (en) Control device
CN111859871A (en) Data processing method, device, equipment and computer readable storage medium
CN115757201A (en) SG instruction implementation method, device, equipment and storage medium based on DMA framework
CN115114240A (en) Data processing method and device

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