CN113268960B - Formula processing method and device - Google Patents

Formula processing method and device Download PDF

Info

Publication number
CN113268960B
CN113268960B CN202110580698.9A CN202110580698A CN113268960B CN 113268960 B CN113268960 B CN 113268960B CN 202110580698 A CN202110580698 A CN 202110580698A CN 113268960 B CN113268960 B CN 113268960B
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.)
Active
Application number
CN202110580698.9A
Other languages
Chinese (zh)
Other versions
CN113268960A (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

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)
  • Processing Or Creating Images (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application provides a formula processing method and a formula processing device, wherein when a deleting 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; wherein the formula to be processed comprises a second landmark element paired with the first landmark element; performing deleting operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the types of target elements include landmark types or non-landmark types; outputting a target formula. In this way, by determining the target element in the formula to be processed and performing the deleting operation on the first landmark element according to the type of the target element, the integrity of the output target formula can be improved to a certain extent by retaining other parts in the formula to be processed under the condition of deleting the first landmark element.

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
A large number of formulas may be used in the editing process of the document, each formula may be regarded as a multi-tree structure, and landmarks in the formulas, such as brackets, integrals, sums, etc., are subtrees of the multi-tree structure, typically an integral structure. For example, when a landmark is a bracket, the left and right brackets are in their entirety, where 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 formulas. Since landmark elements in the same landmark are displayed as a whole in the document. Thus, when any one of the landmark elements is deleted, both the landmark element in the landmark and the data in the landmark element are deleted, thereby destroying the integrity of the formula.
Disclosure of Invention
The embodiment of the application provides a formula processing method and a formula processing device, which realize that the integrity of an output target formula can be improved to a certain extent by reserving other parts in the formula to be processed under the condition of deleting a first landmark element.
In a first aspect, an embodiment of the present application provides a formula processing method, where the formula processing method includes:
When detecting the deleting 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.
Performing a deleting 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.
Outputting the target formula.
In one possible implementation manner, the performing a deletion operation on the first landmark element according to the type of the target element, to obtain a target formula includes:
if the type of the target element is a landmark type, determining the second landmark element paired with the first landmark element in the pending formula.
Deleting the first landmark element and the second landmark element from the pending formula to obtain the target formula.
In one possible implementation manner, 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.
Deleting the first landmark element from the formula to be processed to obtain the target formula.
In a possible implementation manner, the determining a target element in the formula to be processed according to the attribute information of the first landmark element includes:
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.
The target element is determined in the pending formula according to the position of the first landmark element relative to the second landmark element.
In a possible implementation manner, the determining the target element in the pending formula according to the position of the first landmark element relative to the second landmark element includes:
If the first landmark element is to the left of the second landmark element, the target element is determined to the right of the first landmark element.
If the first landmark element is to the right of the second landmark element, the target element is determined to the left of the first landmark element.
In one possible implementation, the first landmark element includes N landmark elements, and the determining the target element on the right side of the first landmark element includes:
Determining an N-th element on the right side of each landmark element as the target element aiming at each landmark element in the first landmark elements; wherein N is a positive integer.
In one possible implementation, the first landmark element includes N landmark elements, and the determining the target element on the left side of the first landmark element includes:
determining an N-th element on the left side of each landmark element as the target element aiming at each landmark element in the first landmark elements; wherein N is a positive integer.
In a second aspect, an embodiment of the present application provides a formula processing apparatus, including:
A determining unit, 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; wherein the formula to be processed comprises a second landmark element paired with the first landmark element.
The processing unit is used for executing deleting 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; deleting the first landmark element and the second landmark element from the pending formula to obtain the target formula.
In a possible implementation manner, the processing unit is specifically configured to assign attribute information of the first landmark element to the target element when the type of the target element is a non-landmark type; 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 a position of the first landmark element relative to the second landmark element according to attribute information of the first landmark element and attribute information of the second landmark element; the target element is determined in the pending formula 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; the target element is determined to the left of the first landmark element when the first landmark element is to the right 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 a 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 a 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, embodiments of the present application further provide a formula processing apparatus, where the formula processing apparatus may include a memory and a processor; wherein,
The memory is used for storing a computer program.
The processor is configured to read the computer program stored in the memory, and execute the formula processing method according to 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 computer executable instructions are stored, and when executed by a processor, implement a formula processing method as described in any one of the possible implementation manners of the first aspect.
In a fifth aspect, embodiments of the present application further provide a computer program product, including a computer program, which when executed by a processor implements a formula processing method as described in any one of the possible implementations of the first aspect.
Therefore, the embodiment of the application provides a formula processing method and device, when the deleting operation of the first landmark element in the formula to be processed is detected, determining the 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; performing deleting operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the types of target elements include landmark types or non-landmark types; outputting a target formula. In this way, by determining the target element in the formula to be processed and performing the deleting operation on the first landmark element according to the type of the target element, the integrity of the output target formula can be improved to a certain extent by retaining other parts in the formula to be processed under the condition of deleting the first landmark element.
Drawings
Fig. 1 is a schematic diagram of an application scenario of a formula processing method according to an embodiment of the present application;
FIG. 2 is a flowchart of another formula processing method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a nested structure of landmarks in a formula provided by an embodiment of the present application;
fig. 4 is a schematic structural diagram of a split formula according to an embodiment of the present application;
Fig. 5 is a schematic structural diagram of a landmark element to be deleted in a formula according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a target formula according to an embodiment of the present application;
FIG. 7 is a schematic diagram of a nested structure of landmarks in a target formula according to an embodiment of the present application;
FIG. 8 is a schematic diagram of a formula processing device according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of another formula processing device according to an embodiment of the present application.
Specific embodiments of the present disclosure have been shown by way of the above drawings and will be described in more detail below. These drawings and the written description are not intended to limit the scope of the disclosed concepts in any way, but rather to illustrate the disclosed concepts to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
In embodiments of the present application, "at least one" means one or more, and "a plurality" means two or more. "and/or", describes an association relationship of an association object, and indicates that there may be three relationships, for example, a and/or B, and may indicate: there are three cases, a alone, a and B together, and B alone, wherein a, B may be singular or plural. In the text description of the present application, the character "/" generally indicates that the front-rear associated object is an or relationship.
A large number of formulas may be used in the editing process of the document, each formula may be regarded as a multi-tree structure, and landmarks in the formulas, such as brackets, integrals, sums, etc., are subtrees of the multi-tree structure, typically an integral structure. For example, when a landmark is a bracket, the landmark element is left-hand bracket, the landmark element is right-hand bracket, and the non-landmark elements within the bracket make up a whole. The technical scheme provided by the embodiment of the application can be applied to the typesetting scene of the formula. For example, in interactive science and technology typesetting software, a large number of formulas and text may need to be typeset. If a large amount of characters exist in a certain line, the formula is long, so that the formula and the characters in the line cannot be displayed in the same line, and the typesetting effect is poor.
In order to improve typesetting effect, when editing some formulas in a document, part of landmark elements of some landmarks in the formulas may need to be deleted, and the speech speed that cannot be displayed in the same line in the formulas is transferred to the next line to continue displaying. Since landmark elements in the same landmark are displayed as a whole in the document. Thus, when any one of the landmark elements is deleted, both the landmark elements in the landmark and the non-landmark elements are deleted, thereby destroying the integrity of the formula.
In order to avoid the problem that when any landmark element in the landmarks is deleted because the landmarks in the formula are an integer, other parts of the landmarks are deleted, 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 other parts in the formula are reserved.
Based on the above conception, the embodiment of the application provides a formula processing method, when detecting the deleting 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; performing deleting operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the types of target elements include landmark types or non-landmark types; outputting a target formula.
In the present 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 the formula, for example, a bracket, an integral symbol, a summation symbol, etc. Where the operators "+", "-", "=" etc. 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 a left bracket, the second landmark element is a right bracket, whereas when the first landmark element is a right bracket, the second landmark element is a left bracket. The attribute information of the landmark element may be understood as attributes describing the landmark element. For example, if the landmark element is a left bracket, the attribute information of the landmark element is a left bracket; if the landmark element is a right bracket, the attribute information of the landmark element is a 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; the deleting operation is carried out 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 that the first landmark element in the formula to be processed is deleted and other parts in the formula to be processed are reserved.
The formula processing method provided by the application will be described in detail by specific examples. It is to be understood that the following embodiments may be combined with each other and that some embodiments may not be repeated for the same or similar concepts or processes.
Fig. 1 is a flow chart of a formula processing method according to an embodiment of the present application. The formulation method may be performed by software and/or hardware means, for example, the hardware means may be a formulation means, which may 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 deleting 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 pending formula comprises a second landmark element paired with the first landmark element. And the first landmark element may include a plurality of landmark elements, the embodiment of the present application does not make any limitation on the number of the first landmark elements.
For example, before detecting the deletion operation of the first landmark element in the equation to be processed, the landmarks in the equation to be processed may be split, i.e., the landmarks are split into multiple independent portions of landmark elements and non-landmark elements. When a landmark is split, each landmark element in the landmark is assigned corresponding attribute information. Wherein the attribute information is used to represent information of its corresponding landmark element. For example, when "(a+b)" is split into "(", ")", and "a+b", landmark elements "(" and landmark elements ")" have their corresponding attribute information, respectively. After splitting the formula to be processed, each landmark in the formula to be processed is not existed as a whole, so that the deleting operation can be executed 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 further checked to determine whether each landmark element in the formula has a landmark element paired with the landmark element, and specifically, the verification may be performed according to attribute information of the landmark element. If there is a landmark element that cannot be paired, the landmark element is automatically deleted to ensure the integrity of the formula.
When the deleting operation of the first landmark element in the formula to be processed is detected, the attribute information of the first landmark element can be acquired, and the target element is determined in the formula to be processed according to the attribute information of the first landmark element. 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; a target element is determined in the equation to be processed based on the position of the first landmark element relative to the second landmark element. For example, if the first landmark element is left-bracketed and the second landmark element is right-bracketed, that is, it can be determined that the first landmark element is to the left of the second landmark element, then the target element can be determined from the location 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 respectively corresponding to the first landmark element and the second landmark element; and determining the target element according to the position, so that the determined position of the target element is more accurate.
For example, when determining a target element in the pending formula based on the position of the first landmark element relative to the second landmark element, if the first landmark element is to the left of the second landmark element, then determining the target element to the right of the first landmark element; if the first landmark element is to the right of the second landmark element, a target element is determined to the left of the first landmark element. For example, deleting a landmark element "(", knowing that the landmark element paired with it is ")" in the formula a=b (a+c)/D, and the landmark element is located on the left side of the paired landmark element, the target element is determined on the right side of the landmark element "(").
In the embodiment of the application, the target element is determined at 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 at 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 determining the target element 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, the landmark element "{" 3 rd element on the right "+" is taken as its corresponding target element, the landmark element "[" third element on the right "a" is taken as its corresponding target element, and the landmark element "(" third element on the right "b" is taken as its corresponding target element).
For example, the first landmark element includes N landmark elements, and when determining the target element on the left side of the first landmark element, for each landmark element in the first landmark element, the nth element on the left side of the landmark element may be determined as the target 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 is ") ] }", i.e., the first landmark element includes ")", "]" and "}"3 landmark elements, i.e., N is 3, the 3 rd element "b" on the left of the landmark element "}" is taken as its corresponding target element; taking the third element "+" on the left side of the landmark element "]" as the corresponding target element; landmark element ")" third element on the left "as its corresponding target element.
In the embodiment of the application, when the first landmark element comprises N landmark elements, the N elements on the right side or the left side of each landmark element are determined as the corresponding target elements, so that the problem that when a plurality of landmark elements are included in the first landmark element, the same target elements determined by two landmark elements possibly exist can be avoided, and the determined target elements are more accurate.
For example, when determining the target element in the formula to be processed according to the attribute information of the first landmark element, when detecting the deletion operation of the first landmark element in the formula to be processed, an array may be built by using the attribute information of the first landmark element as an element, and the target element may be determined according to the information of the element in the array. Wherein the array includes attribute information of each landmark element in the first landmark element, and the number of elements in the array is the same as the number of attribute information. Of course, a table may be established 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 embodiment of the present application is only described by taking the creation of an array as an example, but the embodiment of the present application is not limited thereto.
When determining the target element, the target element can be determined directly according to the number of the elements in the array and the attribute information. Determining the left side or the right side of the target element according to the attribute information of each landmark element in the array, and determining the number of elements of the landmark information, which are positioned on the left side or the right side, according to the number of elements in the array. 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, 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 certain landmark element is located on the right side of the landmark element paired with the landmark element, then the target element corresponding to the landmark element is the fifth element on the left side of the landmark element in the pending formula.
After determining the target element in the pending formula, the following S102 may be performed:
S102, deleting the first landmark element according to the type of the target element to obtain a target formula.
Wherein the types of target elements include landmark types or non-landmark types. Illustratively, the target element being of the landmark type means that the target element is a landmark element, i.e., the target element has attribute information; a target element being of a non-landmark type means that the target element is not a landmark element, i.e. the target element does not have attribute information.
When a target formula is obtained by executing deleting operation on the 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 paired with the first landmark element in the formula to be processed; 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 element corresponding to the current target element in the formula to be processed may be determined to be a new target element by stacking the first landmark element as a center. For example, for the integration and difference formula in the trigonometric function, cos αsin β=1/2 [ sin (α+β) -sin (α - β) ], if the first landmark element is "]", then according to the above method, 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 ")" the first landmark element "]" and the second landmark element "[" paired therewith are both deleted, i.e., the formula becomes cosαsinβ=1/2 sin (α+β) -sin (α - β).
For 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 comprises 3 landmark elements, which respectively correspond to the target elements "(", "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 deleted in the formula to be processed, so that the problem that the output target formula is incomplete 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 in the landmark is judged to be error data when the output target formula in other editing software is output is avoided, and the integrity of the output target formula can be effectively improved.
It can be understood that when the deleting 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, attribute information of the first landmark element is assigned to the target element; 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, the attribute information of the first landmark element is assigned to the target element, and the first landmark element is deleted, namely, after the first landmark element is deleted, the attribute information of the first landmark element is still in a 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 other parts of the landmark can be reserved under the condition of deleting the first landmark element in the output target formula.
S103, outputting a target formula.
For example, in outputting the formulas, the target formulas may be output in a common format such as word or mathML. Because the attribute information of each landmark element in the target formula is matched with the attribute information, when the target formula is output in a common format such as word or mathML, other parts of the deleted first landmark information are not deleted by mistake as error data, so that the integrity of the output target formula is ensured.
Therefore, according to the formula processing method provided by the embodiment of the application, when the deleting 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; wherein the formula to be processed comprises a second landmark element paired with the first landmark element; performing deleting operation on the first landmark element according to the type of the target element to obtain a target formula; wherein the types of target elements include landmark types or non-landmark types; outputting a target formula. In this way, by determining the target element in the formula to be processed and performing the deleting operation on the first landmark element according to the type of the target element, the integrity of the output target formula can be improved to a certain extent by retaining other parts in the formula to be processed under the condition of deleting the first landmark element.
In order to facilitate understanding of the formula processing method provided by the embodiment of the present application, the technical solution provided by the embodiment of the present application will be described in detail below by taking the formula to be processed as an integrated sum and difference formula in the trigonometric function as an example, and the determining formula processing method may be executed by a software and/or hardware device. Referring specifically to fig. 2, fig. 2 is a schematic flow chart of another formula processing method according to an embodiment of the present application. The formula text processing method can comprise the following steps:
S201, receiving a deleting operation.
Wherein the deleting operation is for indicating deletion of at least one landmark element in the pending formula.
For example, the formula to be processed is the integrated sum-difference formula cos αsin β=1/2 [ sin (α+β) -sin (α - β) ] in the trigonometric function, and can be seen in fig. 3, and fig. 3 is a schematic diagram of the nested structure of landmarks in the formula provided in the embodiment of the present application. In fig. 3, landmarks 301, 302, and 303 are brackets type landmarks, each comprising two landmark elements that can be paired with each other. Wherein, the landmarks 301, 302 and 303 are all integral, and when deleting the part thereof, other elements in the landmarks are deleted.
According to the method of the above embodiment, the formulas to be processed may be split such that landmarks 301, 302, and 303 are no longer displayed as a whole. Referring to fig. 4, fig. 4 is a schematic structural diagram of a split formula according to an embodiment of the present application. In fig. 4, the individual elements in the formula to be processed are distinguished by different shapes. Wherein the elements in the square of the dotted line are two paired landmark elements, the elements in the circle of the dotted line are two paired landmark elements, and the elements in the pentagon of the dotted line are two paired elements; the elements within the circles of the other solid lines are all elements of non-landmark types.
In this embodiment, the landmark elements to be deleted may be shown in fig. 5, and fig. 5 is a schematic structural diagram of the landmark elements to be deleted in the formula provided in the embodiment of the present application. Wherein the landmark element 501 to be deleted comprises two landmark elements, one of the landmark 301 and the landmark 303 in fig. 3, respectively. That is, in an embodiment of the present application, the received delete operation is used to indicate that two of the landmark elements 501 in fig. 5 are deleted.
S202, acquiring attribute information of each landmark element to be deleted.
When the attribute information of each landmark element to be deleted is acquired, each landmark element in the formula to be processed can be checked to be matched with the other landmark element, so that the integrity of the formula to be processed is ensured before the landmark elements in the formula to be processed are deleted.
When the attribute information of the landmark element to be deleted is acquired, an array may be further established according to the acquired 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 embodiment of the present application is only described by taking the creation of an array as an example, but the embodiment of the present application is not limited thereto.
S203, determining target elements corresponding to the landmark elements to be deleted according to the attribute information of the landmark elements 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 be described with reference to the above embodiment, which is not limited in any way. According to the method of the above embodiment, it may be determined that, among the landmark elements 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, that is, 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, that is, the element "β" in the circle of the solid line.
S204, deleting the landmark elements to be deleted according to the types of the target elements to obtain a target formula.
When the deleting operation is performed on each landmark element to be deleted according to the type of the target element to obtain the target formula, the type of the target element needs to be determined first, and according to the method described in the above embodiment, it is known that, if the types of the target element "-" and the target element "β" are both non-landmark types, the attribute information of the landmark element in the pentagon of the dotted line can be assigned to the corresponding target element "-", the attribute information of the landmark element in the square of the dotted line can be assigned to the corresponding target element "β" thereof, and the deleting operation is 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 according to an embodiment of the present application. According to fig. 6, the shape of the target element "-" changes from the original solid-line circle to the dotted-line pentagon, and the shape of the target element "β" changes from the original solid-line circle to the dotted-line square, and the target element "-" and the target element "β" each have attribute information of different landmark elements.
S205, outputting a target formula.
For example, the output formula may be shown in fig. 7, and fig. 7 is a schematic diagram of a nested structure of landmarks in a target formula according to an embodiment of the present application. As can be seen from fig. 7, the landmark structure of the target formula varies according to the location where the attribute information of the landmark element thereof is located.
In summary, according to the formula processing method provided by the embodiment of the 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 reserved under the condition that the landmark element to be deleted is deleted, and each landmark element in the output target formula can be ensured to have the landmark element corresponding to the landmark element. So that in the case of deleting the landmark element to be deleted, other parts of the equation to be processed are preserved, thereby providing the integrity of the output target equation to a certain extent
Fig. 8 is a schematic structural diagram of a formula processing device 80 according to an embodiment of the present application, for example, please refer to fig. 8, the formula processing device 80 may include:
A determining unit 801, 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; wherein the formula to be processed comprises a second landmark element paired with the first landmark element;
A processing unit 802, 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 types of target elements include landmark types or non-landmark types;
and an output unit 803 for outputting 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 a landmark type; 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 attribute information of the first landmark element to the target element when the type of the target element is a non-landmark type; 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 a 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; a target element is determined in the equation to be processed based on the position of the first landmark element relative to the second landmark element.
Optionally, the determining unit 801 is specifically configured to determine, when the first landmark element is located on the left side of the second landmark element, a target element on the right side of the first landmark element; a target element is determined to the left of the first landmark element when the first landmark element is to the right 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 a 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 a 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 device provided by the embodiment of the application can execute the technical scheme of the formula processing method in any embodiment, and the implementation principle and beneficial effects of the formula processing device are similar to those of the formula processing method, and can be referred to the implementation principle and beneficial effects of the formula processing method, and are not repeated here.
Fig. 9 is a schematic structural diagram of another formula processing device 90 according to an embodiment of the present application, for example, please refer to fig. 9, the formula processing device 90 may include a processor 901 and a memory 902; wherein,
The memory 902 is configured to store a computer program.
The processor 901 is configured to read a computer program stored in the memory 902, and execute the technical solution of the formula processing method in any one of the foregoing 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 separate from the processor 901, the formula processing apparatus 90 may further include: a bus for connecting the memory 902 and the processor 901.
Optionally, the present embodiment further includes: a communication interface, which 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-described formula processing device 90.
The formula processing device 90 in the embodiment of the present application may execute the technical scheme of the formula processing method in any of the foregoing embodiments, and the implementation principle and beneficial effects of the formula processing method are similar to those of the formula processing method, and may refer to the implementation principle and beneficial effects of the formula processing method, which are not described herein.
The embodiment of the application also provides a computer readable storage medium, in which computer executing instructions are stored, when a processor executes the computer executing instructions, the technical scheme of the formula processing method in any embodiment is realized, and the implementation principle and the beneficial effects are similar to those of the formula processing method, and can be seen in the implementation principle and the beneficial effects of the formula processing method, and the description is omitted here.
The embodiment of the application also provides a computer program product, which comprises a computer program, when the computer program is executed by a processor, the technical scheme of the formula processing method in any of the above embodiments is realized, and the realization principle and the beneficial effects are similar to those of the formula processing method, and can be seen from the realization principle and the beneficial effects of the formula processing method, and the description is omitted here.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection illustrated or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in hardware plus software functional units.
The integrated modules, which are implemented in the form of software functional modules, may be stored in a computer readable storage medium. The software functional module is stored in a storage medium, and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (english: processor) to perform some steps of the methods of the embodiments of the application.
It should be understood that the above processor may be a central processing unit (english: central Processing Unit, abbreviated as CPU), or may be other general purpose processors, digital signal processors (english: DIGITAL SIGNAL processor, abbreviated as DSP), application specific integrated circuits (english: application SPECIFIC INTEGRATED circuit, abbreviated as ASIC), or the like. 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 for execution, or in a combination of hardware and software modules in a processor for execution.
The memory may comprise a high-speed RAM memory, and may further comprise a non-volatile memory NVM, such as at least one magnetic disk memory, and may also be a U-disk, a removable hard disk, a read-only memory, a magnetic disk or optical disk, etc.
The bus may be an industry standard architecture (Industry Standard Architecture, ISA) bus, an external device interconnect (PERIPHERAL COMPONENT, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, the buses in the drawings of the present application are not limited to only one bus or to one type of bus.
The computer-readable storage medium described above 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 disk. 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 for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the application.

Claims (5)

1. A method of formula processing, comprising:
when detecting the deleting 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 landmark elements are brackets; the formula to be processed includes a second landmark element paired with the first landmark element;
performing a deleting 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;
Outputting the target formula;
And performing a deleting operation on the first landmark element according to the type of the target element to obtain a target formula, wherein the deleting operation comprises the following steps:
If the type of the target element is a landmark type, determining the second landmark element paired with the first landmark element in the pending formula;
deleting the first landmark element and the second landmark element from the formula to be processed to obtain the target formula;
If the type of the target element is a non-landmark type, attribute information of the first landmark element is assigned to the target element;
deleting the first landmark element from the formula to be processed to obtain the target formula;
The first landmark element comprises N landmark elements, N is a positive integer, and the determining the target element in the pending formula according to the attribute information of the first landmark element comprises the following steps:
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;
If the first landmark element is positioned on the left side of the second landmark element, determining the Nth element on the right side of each landmark element in the first landmark element as the target element;
And if the first landmark element is positioned on the right side of the second landmark element, determining the Nth element on the left side of each landmark element in the first landmark element as the target element.
2. A formula processing apparatus, comprising:
A determining unit, 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; wherein the landmark elements are brackets; the formula to be processed includes a second landmark element paired with the first landmark element;
The processing unit is used for executing deleting 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 configured to output the target formula;
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; deleting the first landmark element and the second landmark element from the formula to be processed to obtain the target formula; when the type of the target element is a non-landmark type, attribute information of the first landmark element is assigned to the target element; deleting the first landmark element from the formula to be processed to obtain the target formula;
The first landmark element comprises N landmark elements, N is a positive integer, and the determining unit is specifically used for 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; if the first landmark element is positioned on the left side of the second landmark element, determining the Nth element on the right side of each landmark element in the first landmark element as the target element; and if the first landmark element is positioned on the right side of the second landmark element, determining the Nth element on the left side of each landmark element in the first landmark element as the target element.
3. A formula processing device, comprising a memory and a processor; wherein,
The memory is used for storing a computer program;
The processor is configured to read the computer program stored in the memory, and execute a formula processing method according to the computer program stored in the memory.
4. A computer readable storage medium having stored therein computer executable instructions which when executed by a processor implement a formula processing method as claimed in claim 1.
5. A computer program product comprising a computer program which, when executed by a processor, implements a formula processing method as claimed in claim 1.
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 CN113268960A (en) 2021-08-17
CN113268960B true 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
CN113268960A (en) 2021-08-17

Similar Documents

Publication Publication Date Title
CN111159329B (en) Sensitive word detection method, device, terminal equipment and computer readable storage medium
CN113505580A (en) Method and device for analyzing table file
CN111460098B (en) Text matching method and device and terminal equipment
CN113268960B (en) Formula processing method and device
CN111930363B (en) Block interface code generation method and device
CN110955545A (en) Data integrity checking method, system and related equipment
CN110377276B (en) Source code file management method and device
CN111553847B (en) Image processing method and device
CN113177045A (en) Data extraction method and device, computable storage equipment and data request equipment
CN113434251B (en) Cross-platform deployment method, device and equipment for service modules
CN113126981B (en) Medical data processing method and device based on Excel
CN113590581B (en) Data transmission method, device, equipment and storage medium
CN114116958A (en) Auditing method, auditing device, electronic equipment and storage medium
US11729246B2 (en) Apparatus and method for determining types of uniform resource locator
CN109242984B (en) Virtual three-dimensional scene construction method, device and equipment
CN112508526A (en) Data auditing method and device
CN109840080B (en) Character attribute comparison method and device, storage medium and electronic equipment
EP3842936A1 (en) Multi-language scheduling method and apparatus, and embedded device
CN110609988A (en) Form verification method and equipment
CN111381977A (en) Message processing method and device
CN113568578B (en) Picture processing method and device, electronic equipment and readable storage medium
CN107835990A (en) Control device
CN117079703B (en) Method and device for testing embedded memory of chip and electronic equipment
CN115114240A (en) Data processing method and device
CN116049155A (en) Method, device and storage medium for processing data

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