WO2016095502A1 - Mathematical formula processing method, device, apparatus and computer storage medium - Google Patents

Mathematical formula processing method, device, apparatus and computer storage medium Download PDF

Info

Publication number
WO2016095502A1
WO2016095502A1 PCT/CN2015/083534 CN2015083534W WO2016095502A1 WO 2016095502 A1 WO2016095502 A1 WO 2016095502A1 CN 2015083534 W CN2015083534 W CN 2015083534W WO 2016095502 A1 WO2016095502 A1 WO 2016095502A1
Authority
WO
WIPO (PCT)
Prior art keywords
formula
graphic
operand
graphic object
user
Prior art date
Application number
PCT/CN2015/083534
Other languages
French (fr)
Chinese (zh)
Inventor
韩聪
Original Assignee
百度在线网络技术(北京)有限公司
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 百度在线网络技术(北京)有限公司 filed Critical 百度在线网络技术(北京)有限公司
Priority to KR1020177013186A priority Critical patent/KR101950126B1/en
Priority to JP2017526093A priority patent/JP6866551B2/en
Publication of WO2016095502A1 publication Critical patent/WO2016095502A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations

Definitions

  • the present invention relates to the field of Internet technologies, and in particular, to a mathematical formula processing method, apparatus, device, and computer storage medium.
  • the user enters the formula content according to the prescribed "formula representation", and the browser uses HyperText Mark-up Language (HTML) and Cascading Style Sheets (CSS) to render the user input into a mathematical formula.
  • HTML HyperText Mark-up Language
  • CSS Cascading Style Sheets
  • the server saves the content input by the user as it is.
  • the server returns the previously saved content to the browser, and the browser renders the content returned by the server into a mathematical formula using HTML and CSS.
  • aspects of the present invention provide a mathematical formula processing method, apparatus, device, and computer storage medium for overcoming the problem that a mathematical formula is affected by a page CSS style, and improving the display stability of the mathematical formula.
  • a mathematical formula processing method comprising:
  • Obtaining a body object corresponding to the formula content where the body object includes a hierarchical relationship between the graphic object and the image object, and the hierarchical relationship between the graphic objects represents an operation sequence corresponding to the formula content, and the graphic object includes Operation type attribute and operand attribute;
  • the mathematical expression corresponding to the graphic object is drawn into the page to obtain a mathematical formula corresponding to the formula content.
  • a mathematical formula processing apparatus comprising:
  • An acquiring module configured to acquire a body object corresponding to the formula content, where the body object includes a hierarchical relationship between the graphic object and the image object, and the hierarchical relationship between the graphic objects represents an operation sequence corresponding to the formula content,
  • the graphic object includes an operation type attribute and an operand attribute;
  • a processing module configured to obtain a mathematical expression corresponding to the graphic object according to a hierarchical relationship between the graphic objects, an operation type attribute of the graphic object, and an operand attribute of the graphic object;
  • a drawing module configured to draw a mathematical expression corresponding to the graphic object into a page according to a hierarchical relationship between the graphic objects, to obtain a mathematical formula corresponding to the formula content.
  • the formula content is represented by the body object
  • the operation order corresponding to the formula content is represented by the hierarchical relationship between the graphic objects included in the body object, and the graphic object includes the operation type attribute and the operand attribute;
  • the hierarchical relationship between the hierarchical relationship, the operation type attribute of the graphic object, and the operand attribute of the graphic object obtain the mathematical expression corresponding to the graphic object, and further correspond to the graphic object according to the hierarchical relationship between the graphic objects.
  • the mathematical expression is drawn into the page to obtain the mathematical formula corresponding to the formula content.
  • the invention realizes the generation of a mathematical formula in the page by the drawing technology based on the main body object, which is different from the HTML label used in the prior art, which makes the mathematical formula generated by the invention completely independent of the page and becomes an independent whole. Therefore, it is not easy to be interfered or affected by the CSS style in the page, and the display effect is relatively stable.
  • FIG. 1 is a schematic flowchart diagram of a mathematical formula processing method according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of an embodiment of the present invention for explaining how to correctly decompose a public content into a reference expression
  • FIG. 3 is a schematic diagram of an editing interface according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a process for generating a formula syntax tree according to an embodiment of the present invention
  • FIG. 10 to FIG. 12 are schematic diagrams showing a process of changing a content of a formula by a user through a selection operation according to an embodiment of the present invention
  • FIG. 13 is a schematic structural diagram of a mathematical formula processing apparatus according to an embodiment of the present invention.
  • FIG. 1 is a schematic flowchart diagram of a mathematical formula processing method according to an embodiment of the present invention. As shown in Figure 1, the method includes:
  • the mathematical expression corresponding to the graphic object is drawn into the page to obtain a mathematical formula corresponding to the formula content.
  • the embodiment provides a mathematical formula processing method, which can be performed by a mathematical formula processing device.
  • the mathematical formula processing device may be a mathematical formula processing engine or a tool library, for example, may be applied to a browser environment for implementing web-based mathematical formula processing; or the data formula processing device may be implemented as a separate formula editor.
  • the content of the formula is the content required to generate the mathematical formula, and generally includes information such as operands, operators, and operation order in the mathematical formula.
  • the formula content can be input by the user, but is not limited thereto.
  • the embodiment does not limit the representation of the formula content.
  • the user can enter the formula content in a "formula representation" supported by the browser.
  • the subject object corresponding to the formula content is actually an object having a hierarchical structure, and specifically includes: a hierarchical relationship between the graphic object and the graphic object, and the graphic object includes an operation type attribute and an operand attribute;
  • the hierarchical relationship between the graphic objects, the hierarchical relationship between the graphic objects embodies the hierarchical structure of the main object, and the hierarchical relationship between the graphic objects represents the operation sequence corresponding to the formula content, that is, between the operands in the formula content. The order of operations.
  • the operation type attribute of the graphic object can be recorded as the "name” attribute, which mainly represents the operation type in the mathematical formula, such as "+", "-", " ⁇ ", and the like.
  • the operand property of a graphic object can be written as an "operand” property, which can be represented by an array, for example, the array can be recorded in order of the "operands" list contained in the hierarchy of the graphic object.
  • Each of these operands can be a "simple object” or a "composite object”. If the operand is a "composite object", the operand can continue to be decomposed to form a subgraphic object under the graphical object.
  • the hierarchical body object may be a formula syntax tree, which is actually a syntax tree for identifying mathematical formulas.
  • the subject object corresponding to the formula content may be pre-generated and stored in the specified storage space.
  • the mathematical formula processing device may directly obtain the specified storage space. The subject object.
  • the formula content may be pre-acquired and stored in a specified storage space.
  • the mathematical formula processing device may obtain the formula content from the specified storage space, and The contents of the formula are processed to generate the body object.
  • the mathematical formula processing device can acquire the formula content; according to the preset decomposition rule, the formula content is decomposed into non-resolvable reference expressions; according to the hierarchical relationship between the reference expressions, the type of the reference expression, and the reference expression The operands included, generating the body object.
  • each reference expression is mapped to a graphic object in the body object, and the type of the reference expression and the included operand are respectively mapped into the operation type attribute and the operand attribute of the graphic object; the level between the reference expressions Relationships are mapped to hierarchical relationships between graphical objects.
  • the above reference expression will relatively locate the elements contained inside according to its display effect in the mathematical formula.
  • a text expression will linearly arrange its internal symbols;
  • a square root expression will generate a proper size root number according to its content, and arrange its contents;
  • the integral expression will adjust its upper and lower limits, so that The upper and lower limits are in a relatively correct position.
  • Figure 2 is used to illustrate how to correctly decompose the public content into a reference expression.
  • the downward arrow indicates the content of the formula.
  • the process of decomposing to obtain a reference expression, the upward arrow is the process of obtaining a mathematical formula by combining the decomposed reference expressions, which are mutually reciprocal.
  • the formula (x+a) 2 is decomposed, and finally a sub-expression with the label 1 and a sub-expression with the label 2 are obtained, and at this time, if the decomposition is obtained
  • the subexpression is not a text expression (TextExpression), and the subexpression of label 1 or label 2 is decomposed again according to the requirements of the subexpression until all the expressions are finally decomposed into text expressions.
  • a two-text expression is obtained by decomposing the expression with the number 3, that is, two sub-expressions labeled 1 and 2.
  • the decomposition process ends. It is worth noting that the expression labeled 3 in Figure 2 corresponds to the subject object, and the two sub-expressions labeled 1 and 2 correspond to one of the subject objects, respectively.
  • the "restore” process is performed based on the resulting set of text expressions.
  • the process of "restore” is actually a process of recursing the "decomposition”. The whole process is merged upwards from the end of the text expression. Each merge will get a new "composite expression”, for example: square root expression , superscript expressions, etc. The whole process continues to recursively until there is only one unique expression left, and the expression is the final mathematical formula.
  • the formula content is not obtained in advance, but is entered by the user when a mathematical formula needs to be displayed on the page.
  • the mathematical formula processing device can provide an editing interface to the user on the page, and sequentially acquire the operation symbol or the operand in the formula content input by the user through the editing interface to generate the formula content. Corresponding subject object.
  • the above editing interface may include a visible editing area and a hidden editing area.
  • the visible editing area is mainly used for the user to issue an input instruction and display the formula content to the user according to the manner desired by the user, and the hidden editing area is used to activate the input capturing event and input the formula content for the user.
  • the hidden editing area is hidden.
  • the editing interface may further include: inputting a tool area.
  • An implementation of the editing interface is shown in FIG. 3.
  • the area labeled 1 in FIG. 3 is a hidden editing area, which is hidden in the actual environment, and is explicitly displayed here to visually describe subsequent acquisition. The process of the operand entered by the user.
  • the area labeled 2 in Fig. 3 is a visible editing area in which the user can select the entered formula by the mouse.
  • the area labeled 3 in Figure 3 is the input tool area, which presets some symbols and formulas in advance to facilitate the user to directly select the input, reducing the complexity of the user inputting special characters and common formulas.
  • the area labeled 4 in Figure 3 is an analog cursor to Indicates the location where the user currently inputs the cursor.
  • the mathematical formula processing device sequentially acquires the operation symbols or operands in the formula content input by the user through the editing interface, and the implementation process of generating the body object corresponding to the formula content includes:
  • an analog cursor indicating the current input position is displayed in the visible editing area, the simulated cursor moves following the user's input, and the system cursor associated with the simulated cursor is positioned to the hidden editing area.
  • the capture event is activated by an activation; for example, the user can click on the visible edit area labeled 2 to issue an edit instruction.
  • the user can input directly through the keyboard, or click on the character or formula predetermined by the input tool area 3.
  • an input capture event with the label 1 hidden edit area will be triggered.
  • the operand or operand in the formula content entered by the user in the hidden edit area labeled 1 will be sequentially captured, and the graphic object will be added to the initial empty object according to the current position of the system cursor and the captured arithmetic symbol or operand. And/or operands in the graphic object to get the body object.
  • the subject object corresponding to the above formula content is generated in the process of the user inputting the formula content.
  • the user inputs the formula content a+b ⁇ c-b/a, and takes the subject object as the formula syntax tree as an example to illustrate the process of generating the formula syntax tree.
  • the user needs to input the “ ⁇ ” symbol. Since the key for directly inputting the “ ⁇ ” symbol is not provided on the keyboard, the user can input “ ⁇ ” by the preset symbol of the tool input area included in the editing interface, and the user clicks the corresponding button. After the symbol, the " ⁇ ” symbol is entered into the hidden editing area, and the formula syntax tree is obtained as shown in Fig. 7.
  • the new " ⁇ div ⁇ ” in Fig. 7 is the representation of the " ⁇ ” symbol inside the syntax tree of the formula in this embodiment.
  • the fraction should be input: b/a. Since the fraction cannot be directly input through the keyboard, the user needs to input using the preset formula provided in the tool input area of the editing interface, when the user clicks the corresponding button and inputs After the data, the resulting syntax tree is shown in Figure 9. At this point, the entire formula syntax tree is obtained.
  • the mathematical formula processing device can identify the user's selection operation, and the selection operation refers to the operation of selecting a part of the operands in the formula content by the user; marking the main object according to some operands in the formula content selected by the user; The operand re-entered by the user in the selected area of the selection operation, replacing the marked operand on the subject object with the re-entered operand.
  • the user presses the left mouse button at the position marked with 1, and continues to hold, at this time, the mathematical formula processing device will capture the event, and obtain the mouse pointer at this time from the incidental information of the event. Location information and record the information.
  • the mathematical formula processing device will capture the "mouse moving" event, from The attached information of the event obtains the position of the mouse pointer at this moment, and calculates the selection according to the mouse pointer position at the moment and the previously recorded mouse pointer position information. After the selection is calculated, the selection "flag" is inserted in the corresponding position in the "Formula Syntax Tree” to mark the selection information.
  • the user continues to move the mouse and will continue to trigger the "Mouse Move” event, causing the process of the previous step to be repeated to update the selection.
  • the position between the two solid lines in Fig. 12 is the position of the original selection area in Fig. 11.
  • the original selection area is "closed"
  • the content contained in the original selection area is deleted
  • the new closed area is closed.
  • the new content was inserted before the selection, which is "-".
  • the user can perform an operation of updating the cursor position in addition to editing the formula. Since the update of the cursor position is actually a special case of the selection of the selection, the essence is a selection operation with a selection length of zero.
  • the description of the selection may refer to the description of the operation of the selection change by the user above, and will not be described again.
  • each set of "name” and "operand” constitutes a graphic object, and all the graphic objects and the hierarchical relationship between the graphic objects constitute a main object.
  • the entire content shown in FIG. 9 constitutes a main object; the main object shown in FIG. 9 includes two graphic objects, and the operation type attribute of one graphic object is "combination", and the operand attribute is ["a", "+”, “b", “ ⁇ div ⁇ ", "c", "-”]; another graphic object has the operation type attribute "fraction” and the operand attribute is ["b", "a” ].
  • the present embodiment is provided to the user in a very intuitive manner, which greatly improves the editing and reading experience of the formula and reduces the threshold for the user to use.
  • it is not necessary to communicate with the server, and the user can quickly edit the formula and see the editing effect in an environment where the network is poor.
  • this embodiment has no additional requirements for the user, and the user does not need to understand the professional formula representation - TeX as in the prior art, because the WYSIWYG editing method is adopted, the user can see immediately after inputting.
  • the rendering effect does not require a rendering request to the server, which greatly improves the process of the user's editing process and reduces the threshold for users to participate in editing.
  • the graphic object after obtaining the body object corresponding to the formula content, the graphic object may be obtained according to the hierarchical relationship between the graphic objects included in the body object, the operation type attribute of the graphic object, and the operand attribute of the graphic object. Mathematical expressions.
  • the mathematical formula processing device can draw the mathematical expression corresponding to the graphic object into the page according to the hierarchical relationship between the graphic objects, to obtain a mathematical formula corresponding to the formula content.
  • the mathematical formula processing device can copy a formula syntax tree and call it a mapping tree, and directly replace the graphic object on the mapping tree with the corresponding graphic object.
  • a mathematical expression which in turn obtains a mapping tree composed of mathematical expressions, which is a drawable tree; then, in the order from top to bottom, the mapping tree is drawn into the page, thereby obtaining a Complete mathematical formula.
  • drawing technology used in this embodiment may be an SVG drawing technology, but is not limited thereto.
  • the present embodiment expresses the formula content by the body object, and specifically represents the operation order corresponding to the formula content by the hierarchical relationship between the graphic objects included in the body object, and the graphic object includes the operation type attribute and the operand attribute;
  • the hierarchical relationship between the objects, the operation type attribute of the graphic object, and the operand attribute of the graphic object obtain the mathematical expression corresponding to the graphic object, and further draw the mathematical expression corresponding to the graphic object according to the hierarchical relationship between the graphic objects. In the page, get the mathematical formula corresponding to the formula content.
  • the present embodiment implements a mathematical formula generated in a page by a drawing technique based on a main body object, which is different from the HTML label used in the prior art, which makes the generated mathematical formula completely independent of the page and becomes an independent whole. It is not easy to be interfered or affected by the CSS style in the page, and the display effect is relatively stable.
  • the technical solution of the present invention can support IE browsers of IE9 and above, chrome, firefox, Main browsers such as safari and opera, users can edit and read math formulas in most browsers.
  • FIG. 13 is a schematic structural diagram of a mathematical formula processing apparatus according to an embodiment of the present application. As shown in FIG. 13, the apparatus includes: an obtaining module 1301, a processing module 1302, and a drawing module 1303.
  • the obtaining module 1301 is configured to obtain a body object corresponding to the formula content, where the body object includes a hierarchical relationship between the graphic object and the image object, the hierarchical relationship between the graphic objects represents an operation sequence corresponding to the formula content, and the graphic object includes the operation type attribute and Operand attribute.
  • the processing module 1302 is connected to the obtaining module 1301, and is configured to obtain a mathematical expression corresponding to the graphic object according to the hierarchical relationship between the graphic objects, the operation type attribute of the graphic object, and the operand attribute of the graphic object.
  • the drawing module 1303 is connected to the processing module 1302, and is configured to draw a mathematical expression corresponding to the graphic object obtained by the processing module 1302 into the page according to the hierarchical relationship between the graphic objects, to obtain a mathematical formula corresponding to the formula content.
  • the obtaining module 1301 is specifically configured to:
  • a principal object is generated based on the hierarchical relationship between the reference expressions, the type of the reference expression, and the operands included in the reference expression.
  • the obtaining module 1301 is specifically configured to:
  • the operands or operands in the formula content entered by the user through the editing interface are sequentially acquired to generate a subject object.
  • the editing interface includes: a visible editing area and a hidden editing area.
  • the obtaining module 1301 can be specifically used to:
  • an analog cursor indicating the current input position is displayed in the visible editing area, the simulated cursor moves following the user's input, and the system cursor associated with the simulated cursor is positioned to the hidden editing area. Capture the event with an activation input;
  • the operands or operands in the formula content entered by the user in the hidden edit area are sequentially captured, and the graphic object and/or the graphic object are added to the initial empty object according to the current position of the system cursor and the captured arithmetic symbol or operand.
  • the operands to get the body object are sequentially captured, and the graphic object and/or the graphic object are added to the initial empty object according to the current position of the system cursor and the captured arithmetic symbol or operand.
  • the mathematical formula processing apparatus may further include: an identification module, a marking module, and an updating module.
  • An identification module for identifying a user's selection operation, and the selection operation refers to an operation of the user selecting a part of the operands in the formula content
  • a marking module configured to mark in the main body object according to a part of the operands in the formula content selected by the user
  • the update module is configured to obtain an operand that is re-entered by the user in the selected area of the selection operation, and replaces the marked operand on the subject object with the re-entered operand.
  • processing module 1302 is specifically configured to:
  • the graphic objects are determined one by one according to the hierarchical relationship between the graphic objects from bottom to top;
  • the graphics are drawn according to the operation type attribute and the operand attribute of the graphic object to obtain a mathematical expression corresponding to the graphic object.
  • the subject object corresponding to the content of the formula is a formula syntax tree corresponding to the formula content.
  • the mathematical formula processing apparatus expresses the formula content by the main body object, and specifically represents the operation order corresponding to the formula content by the hierarchical relationship between the graphic objects included in the main body object, and the graphic object includes the operation type attribute and the operand attribute. According to the hierarchical relationship between the graphic objects, the operation type attribute of the graphic object, and the operand attribute of the graphic object, the mathematical expression corresponding to the graphic object is obtained, and the mathematical expression corresponding to the graphic object is further determined according to the hierarchical relationship between the graphic objects. Draw into the page to get the mathematical formula corresponding to the formula content.
  • the mathematical formula processing apparatus implements a mathematical formula generated in a page by a drawing technique based on a main body object, which is different from the HTML label used in the prior art, which makes the generated mathematical formula completely independent of the page and becomes An independent whole, so it is not easy to be interfered or affected by the CSS style in the page, and the display effect is relatively stable.
  • the disclosed system, apparatus, and method may be implemented in other manners.
  • the device embodiment described above For example, the division of the unit is only a logical function division, and the actual implementation may have another division manner, for example, multiple units or components may be combined or may be integrated into another system, or some Features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
  • the above-described integrated unit implemented in the form of a software functional unit can be stored in a computer readable storage medium.
  • the above software functional unit is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to perform the methods of the various embodiments of the present invention. Part of the steps.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store program codes. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • Pure & Applied Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Algebra (AREA)
  • Computational Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Analysis (AREA)
  • User Interface Of Digital Computer (AREA)
  • Document Processing Apparatus (AREA)

Abstract

A mathematical formula processing method, device, apparatus and computer storage medium, the method comprising: acquiring an object corresponding to the content of a formula, the object comprising image objects and a hierarchical relationship between the image objects, the hierarchical relationship between the image objects representing a calculating sequence corresponding to the content of the formula, and the image objects comprising a calculation type attribute and an operand attribute (101); according to the hierarchical relationship between the image objects, and the calculation type attribute and the operand attribute of the image objects, acquiring a mathematical expression corresponding to the image objects (102); and according to the hierarchical relationship between the image objects, drawing the mathematical expression corresponding to the image objects into a page to obtain a mathematical formula corresponding to the content of the formula (103), thus addressing the problem that the mathematical formula is effected by the CSS style of the page, and improving the display stability of the mathematical formula.

Description

数学公式处理方法、装置、设备和计算机存储介质Mathematical formula processing method, device, device and computer storage medium
本申请要求了申请日为2014年12月17日,申请号为201410790497.1发明名称为“数学公式处理方法及装置”的中国专利申请的优先权。The present application claims priority to Chinese Patent Application No. 201410790497.1, entitled "Mathematical Formula Processing Method and Apparatus", filed on December 17, 2014.
技术领域Technical field
本发明涉及互联网技术领域,尤其涉及一种数学公式处理方法、装置、设备和计算机存储介质。The present invention relates to the field of Internet technologies, and in particular, to a mathematical formula processing method, apparatus, device, and computer storage medium.
背景技术Background technique
随着互联网技术的发展,在浏览器上展示数学公式的需求越来越迫切。目前业内主要采用以下方式在浏览器上编辑和呈现数学公式:With the development of Internet technology, the need to display mathematical formulas on browsers is becoming more and more urgent. Currently, the industry mainly uses the following methods to edit and present mathematical formulas on the browser:
用户根据规定的“公式表示法”输入公式内容,浏览器使用超文本标记语言(HyperText Mark-up Language,HTML)和级联样式表(Cascading Style Sheets,CSS)将用户输入的内容渲染成数学公式以供用户预览,用户在提交后,服务器按原样保存用户输入的内容。当用户需要阅读该数学公式时,服务器将之前保存的内容返回给浏览器,浏览器利用HTML和CSS将服务器返回的内容渲染成数学公式。The user enters the formula content according to the prescribed "formula representation", and the browser uses HyperText Mark-up Language (HTML) and Cascading Style Sheets (CSS) to render the user input into a mathematical formula. For the user to preview, after the user submits, the server saves the content input by the user as it is. When the user needs to read the math formula, the server returns the previously saved content to the browser, and the browser renders the content returned by the server into a mathematical formula using HTML and CSS.
上述基于HTML呈现数学公式的方案,在呈现数学公式时,非常容易被宿主页面内的CSS样式影响,显示效果不稳定。The above-mentioned scheme for presenting a mathematical formula based on HTML is very easy to be influenced by the CSS style in the host page when presenting the mathematical formula, and the display effect is unstable.
发明内容Summary of the invention
本发明的多个方面提供一种数学公式处理方法、装置、设备及计算机存储介质,用以克服数学公式受页面CSS样式影响的问题,提高数学公式的显示稳定性。Aspects of the present invention provide a mathematical formula processing method, apparatus, device, and computer storage medium for overcoming the problem that a mathematical formula is affected by a page CSS style, and improving the display stability of the mathematical formula.
本发明的一方面,提供一种数学公式处理方法,包括: In one aspect of the invention, a mathematical formula processing method is provided, comprising:
获取公式内容对应的主体对象,所述主体对象包括图形对象和所述图像对象之间的层次关系,所述图形对象之间的层次关系表示所述公式内容对应的运算顺序,所述图形对象包括运算类型属性和操作数属性;Obtaining a body object corresponding to the formula content, where the body object includes a hierarchical relationship between the graphic object and the image object, and the hierarchical relationship between the graphic objects represents an operation sequence corresponding to the formula content, and the graphic object includes Operation type attribute and operand attribute;
根据所述图形对象之间的层次关系、所述图形对象的运算类型属性和所述图形对象的操作数属性,获得所述图形对象对应的数学表达式;Obtaining a mathematical expression corresponding to the graphic object according to a hierarchical relationship between the graphic objects, an operation type attribute of the graphic object, and an operand attribute of the graphic object;
按照所述图形对象之间的层次关系,将所述图形对象对应的数学表达式绘制到页面中,以获得所述公式内容对应的数学公式。And according to the hierarchical relationship between the graphic objects, the mathematical expression corresponding to the graphic object is drawn into the page to obtain a mathematical formula corresponding to the formula content.
本发明的另一方面,提供一种数学公式处理装置,包括:In another aspect of the invention, a mathematical formula processing apparatus is provided, comprising:
获取模块,用于获取公式内容对应的主体对象,所述主体对象包括图形对象和所述图像对象之间的层次关系,所述图形对象之间的层次关系表示所述公式内容对应的运算顺序,所述图形对象包括运算类型属性和操作数属性;An acquiring module, configured to acquire a body object corresponding to the formula content, where the body object includes a hierarchical relationship between the graphic object and the image object, and the hierarchical relationship between the graphic objects represents an operation sequence corresponding to the formula content, The graphic object includes an operation type attribute and an operand attribute;
处理模块,用于根据所述图形对象之间的层次关系、所述图形对象的运算类型属性和所述图形对象的操作数属性,获得所述图形对象对应的数学表达式;a processing module, configured to obtain a mathematical expression corresponding to the graphic object according to a hierarchical relationship between the graphic objects, an operation type attribute of the graphic object, and an operand attribute of the graphic object;
绘制模块,用于按照所述图形对象之间的层次关系,将所述图形对象对应的数学表达式绘制到页面中,以获得所述公式内容对应的数学公式。And a drawing module, configured to draw a mathematical expression corresponding to the graphic object into a page according to a hierarchical relationship between the graphic objects, to obtain a mathematical formula corresponding to the formula content.
在本发明中,通过主体对象来表示公式内容,具体通过主体对象包括的图形对象之间的层次关系表示公式内容对应的运算顺序,而图形对象包括运算类型属性和操作数属性;根据图形对象之间的层次关系、图形对象的运算类型属性和图形对象的操作数属性,获得图形对象对应的数学表达式,进一步按照图形对象之间的层次关系,将图形对象对应的 数学表达式绘制到页面中,以获得公式内容对应的数学公式。本发明基于主体对象实现了通过绘图技术在页面中生成数学公式,不同于现有技术所使用的HTML标签,这使得本发明所生成的数学公式可以完全独立于页面,而成为一个独立的整体,因此不容易受到页面内CSS样式的干扰或影响,显示效果比较稳定。In the present invention, the formula content is represented by the body object, and the operation order corresponding to the formula content is represented by the hierarchical relationship between the graphic objects included in the body object, and the graphic object includes the operation type attribute and the operand attribute; The hierarchical relationship between the hierarchical relationship, the operation type attribute of the graphic object, and the operand attribute of the graphic object obtain the mathematical expression corresponding to the graphic object, and further correspond to the graphic object according to the hierarchical relationship between the graphic objects. The mathematical expression is drawn into the page to obtain the mathematical formula corresponding to the formula content. The invention realizes the generation of a mathematical formula in the page by the drawing technology based on the main body object, which is different from the HTML label used in the prior art, which makes the mathematical formula generated by the invention completely independent of the page and becomes an independent whole. Therefore, it is not easy to be interfered or affected by the CSS style in the page, and the display effect is relatively stable.
附图说明DRAWINGS
图1为本发明一实施例提供的数学公式处理方法的流程示意图;FIG. 1 is a schematic flowchart diagram of a mathematical formula processing method according to an embodiment of the present invention;
图2为本发明一实施例提供的用以说明如何正确地将公示内容分解成基准表达式的示意图;2 is a schematic diagram of an embodiment of the present invention for explaining how to correctly decompose a public content into a reference expression;
图3为本发明一实施例提供的编辑界面的示意图;FIG. 3 is a schematic diagram of an editing interface according to an embodiment of the present invention; FIG.
图4-图9为本发明一实施例提供的生成公式语法树的过程示意图;FIG. 4 is a schematic diagram of a process for generating a formula syntax tree according to an embodiment of the present invention; FIG.
图10-图12为本发明一实施例提供的用户通过选区操作更改公式内容的过程示意图;10 to FIG. 12 are schematic diagrams showing a process of changing a content of a formula by a user through a selection operation according to an embodiment of the present invention;
图13为本发明一实施例提供的数学公式处理装置的结构示意图。FIG. 13 is a schematic structural diagram of a mathematical formula processing apparatus according to an embodiment of the present invention.
具体实施方式detailed description
为了使本发明的目的、技术方案和优点更加清楚,下面结合附图和具体实施例对本发明进行详细描述。The present invention will be described in detail below with reference to the drawings and specific embodiments.
图1为本发明一实施例提供的数学公式处理方法的流程示意图。如图1所示,该方法包括:FIG. 1 is a schematic flowchart diagram of a mathematical formula processing method according to an embodiment of the present invention. As shown in Figure 1, the method includes:
101、获取公式内容对应的主体对象,该主体对象包括图形对象和图像对象之间的层次关系,图形对象之间的层次关系表示公式内容对应的运算顺序,图形对象包括运算类型属性和操作数属性。101. Acquire a subject object corresponding to the formula content, where the subject object includes a hierarchical relationship between the graphic object and the image object, and the hierarchical relationship between the graphic objects represents an operation sequence corresponding to the formula content, and the graphic object includes the operation type attribute and the operand attribute. .
102、根据上述图形对象之间的层次关系、图形对象的运算类型属性 和图形对象的操作数属性,获得图形对象对应的数学表达式。102. According to the hierarchical relationship between the graphic objects and the operation type attribute of the graphic object And the operand property of the graphic object to obtain the mathematical expression corresponding to the graphic object.
103、按照图形对象之间的层次关系,将图形对象对应的数学表达式绘制到页面中,以获得公式内容对应的数学公式。103. According to the hierarchical relationship between the graphic objects, the mathematical expression corresponding to the graphic object is drawn into the page to obtain a mathematical formula corresponding to the formula content.
本实施例提供一种数学公式处理方法,该方法可由数学公式处理装置来执行。数学公式处理装置可以是数学公式处理引擎或工具库,例如可以应用于浏览器环境中,用于实现基于web的数学公式处理;或者数据公式处理装置也可以作为独立的公式编辑器实现。The embodiment provides a mathematical formula processing method, which can be performed by a mathematical formula processing device. The mathematical formula processing device may be a mathematical formula processing engine or a tool library, for example, may be applied to a browser environment for implementing web-based mathematical formula processing; or the data formula processing device may be implemented as a separate formula editor.
具体的,当需要在页面上展示数学公式时,获取公式内容对应的主体对象。公式内容是生成数学公式所需的内容,一般包括数学公式中的操作数、运算符以及运算顺序等信息。一般来说,公式内容可由用户输入,但不限于此。Specifically, when a mathematical formula needs to be displayed on the page, the subject object corresponding to the formula content is obtained. The content of the formula is the content required to generate the mathematical formula, and generally includes information such as operands, operators, and operation order in the mathematical formula. In general, the formula content can be input by the user, but is not limited thereto.
值得说明的是,本实施例并不限定公式内容的表示方式。例如,用户可以以浏览器所支持的“公式表示法”输入公式内容。It should be noted that the embodiment does not limit the representation of the formula content. For example, the user can enter the formula content in a "formula representation" supported by the browser.
在本实施例中,公式内容对应的主体对象实际上是一具有层次结构的对象(object),具体包括:图形对象和图形对象之间的层次关系,图形对象包括运算类型属性和操作数属性;图形对象之间具有层次关系,图形对象之间的层次关系体现了该主体对象的层次结构,图形对象之间的层次关系表示公式内容对应的运算顺序,也就是公式内容中各操作数之间的运算顺序。In this embodiment, the subject object corresponding to the formula content is actually an object having a hierarchical structure, and specifically includes: a hierarchical relationship between the graphic object and the graphic object, and the graphic object includes an operation type attribute and an operand attribute; The hierarchical relationship between the graphic objects, the hierarchical relationship between the graphic objects embodies the hierarchical structure of the main object, and the hierarchical relationship between the graphic objects represents the operation sequence corresponding to the formula content, that is, between the operands in the formula content. The order of operations.
图形对象的运算类型属性可以记为“name”属性,主要表示数学公式中的运算类型,例如“+”、“-”、“×”等。图形对象的操作数属性可以记为“operand”属性,该属性可以通过一个数组来表示,例如该数组可以按顺序记录在图形对象所在层次上所包含的“操作数”列表, 其中每一个操作数可以是一个“简单对象”,也可以是一个“复合对象”。如果操作数是一个“复合对象”,则该操作数可以继续分解,以形成该图形对象下的子图形对象。The operation type attribute of the graphic object can be recorded as the "name" attribute, which mainly represents the operation type in the mathematical formula, such as "+", "-", "×", and the like. The operand property of a graphic object can be written as an "operand" property, which can be represented by an array, for example, the array can be recorded in order of the "operands" list contained in the hierarchy of the graphic object. Each of these operands can be a "simple object" or a "composite object". If the operand is a "composite object", the operand can continue to be decomposed to form a subgraphic object under the graphical object.
从整体来看,整个公式内容被分解成带有更简单语义的不同基准表达式,并转换成一具有层次结构的主体对象被存储起来。On the whole, the entire formula content is broken down into different benchmark expressions with simpler semantics, and converted into a hierarchical body object is stored.
可选的,具有层次结构的主体对象可以是一公式语法树,该公式语法树实际上是一颗用于标识数学公式的语法树。Alternatively, the hierarchical body object may be a formula syntax tree, which is actually a syntax tree for identifying mathematical formulas.
在一种获取主体对象的实施方式中,公式内容对应的主体对象可以预先生成并存储到指定存储空间中,当需要在页面上展示数学公式时,数学公式处理装置可以直接从指定存储空间中获取主体对象。In an implementation manner of acquiring a subject object, the subject object corresponding to the formula content may be pre-generated and stored in the specified storage space. When the mathematical formula needs to be displayed on the page, the mathematical formula processing device may directly obtain the specified storage space. The subject object.
在另一种获取主体对象的实施方式中,公式内容可以预先获取并存储到指定存储空间,当需要在页面上展示数学公式时,数学公式处理装置可以从指定存储空间中获取公式内容,通过对公式内容进行处理生成主体对象。例如,数学公式处理装置可以获取公式内容;按照预设的分解规则,将公式内容分解成不可再分解的基准表达式;根据基准表达式之间的层次关系、基准表达式的类型以及基准表达式包括的操作数,生成主体对象。其中,每个基准表达式映射成主体对象中的一个图形对象,基准表达式的类型和所包括的操作数分别被映射成图形对象的运算类型属性和操作数属性;基准表达式之间的层次关系被映射成图形对象之间的层次关系。In another implementation manner of acquiring a subject object, the formula content may be pre-acquired and stored in a specified storage space. When a mathematical formula needs to be displayed on the page, the mathematical formula processing device may obtain the formula content from the specified storage space, and The contents of the formula are processed to generate the body object. For example, the mathematical formula processing device can acquire the formula content; according to the preset decomposition rule, the formula content is decomposed into non-resolvable reference expressions; according to the hierarchical relationship between the reference expressions, the type of the reference expression, and the reference expression The operands included, generating the body object. Wherein each reference expression is mapped to a graphic object in the body object, and the type of the reference expression and the included operand are respectively mapped into the operation type attribute and the operand attribute of the graphic object; the level between the reference expressions Relationships are mapped to hierarchical relationships between graphical objects.
在上述实施方式中,把数学公式中出现的所有内容都看作操作数(包括数字和运算符号),再通过对操作数进行预处理,获取不可分解的基准表达式,例如:文本表达式、方根表达式、积分表达式等,以到达在 呈现数学公式时可以复用这些基准表达式的目的,这样可以通过对这些基准表达式的组合以及相对位置的调整获得各种数学公式。In the above embodiment, all the contents appearing in the mathematical formula are regarded as operands (including numbers and arithmetic symbols), and then the inseparable reference expressions are obtained by preprocessing the operands, for example, text expressions, Square root expression, integral expression, etc. to arrive at The purpose of these benchmark expressions can be reused when presenting mathematical formulas, so that various mathematical formulas can be obtained by combining these benchmark expressions and adjusting relative positions.
其中,上述基准表达式将根据其在数学公式中的显示效果对内部包含的元素进行相对定位。例如:文本表达式会对其内部的符号做线性排列;方根表达式则会根据其内容生成合适大小的根号,并排列其内容;积分表达式则会调整其包含的上下限,以使上下限处于相对正确的位置。Among them, the above reference expression will relatively locate the elements contained inside according to its display effect in the mathematical formula. For example, a text expression will linearly arrange its internal symbols; a square root expression will generate a proper size root number according to its content, and arrange its contents; the integral expression will adjust its upper and lower limits, so that The upper and lower limits are in a relatively correct position.
图2用以说明如何正确地将公示内容分解成基准表达式。如图2所示,向下的箭头表示对公式内容
Figure PCTCN2015083534-appb-000001
进行分解,以获得基准表达式的过程,向上的箭头则是通过组合分解出来的基准表达式来获得数学公式的过程,这两个过程是互逆的。
Figure 2 is used to illustrate how to correctly decompose the public content into a reference expression. As shown in Figure 2, the downward arrow indicates the content of the formula.
Figure PCTCN2015083534-appb-000001
The process of decomposing to obtain a reference expression, the upward arrow is the process of obtaining a mathematical formula by combining the decomposed reference expressions, which are mutually reciprocal.
为了帮助理解上述分解和组合过程,下面以公式:
Figure PCTCN2015083534-appb-000002
的一个子部分(x+a)2进行说明:
To help understand the above decomposition and combination process, the following formula:
Figure PCTCN2015083534-appb-000002
A subsection of (x+a) 2 is described:
首先,如图2中标号③所示的公式(x+a)2,其在数学上是一个平方式,在本实施例中,可以使用“上标表达式”(SuperscriptExpression)来表示。First, the formula (x+a) 2 shown by reference numeral 3 in Fig. 2 is mathematically a flat mode, and in the present embodiment, it can be expressed using a "superscript expression".
然后,根据本实施例中上标表达式的要求对公式(x+a)2进行分解,最终得出标号为①的子表达式和标号为②的子表达式,此时,如果分解得到的子表达式不是一个文本表达式(TextExpression),则再次根据子表达式的要求对标号为①或者标号为②的子表达式进行分解,直到最终所有的表达式都分解为文本表达式为止。在这个例子中,对标号为③的表达式进行一次分解就可以得到两个文本表达式,即标号为①和②的两个子表达式,到此,分解过程结束。值得说明的是,图2中标号为③的表 达式对应于主体对象,而标号为①和②的两个子表达式分别对应于主体对象中的一个图形对象。Then, according to the requirement of the superscript expression in the embodiment, the formula (x+a) 2 is decomposed, and finally a sub-expression with the label 1 and a sub-expression with the label 2 are obtained, and at this time, if the decomposition is obtained The subexpression is not a text expression (TextExpression), and the subexpression of label 1 or label 2 is decomposed again according to the requirements of the subexpression until all the expressions are finally decomposed into text expressions. In this example, a two-text expression is obtained by decomposing the expression with the number 3, that is, two sub-expressions labeled 1 and 2. At this point, the decomposition process ends. It is worth noting that the expression labeled 3 in Figure 2 corresponds to the subject object, and the two sub-expressions labeled 1 and 2 correspond to one of the subject objects, respectively.
最后,根据最终得到的文本表达式集合执行“还原”过程。“还原”的过程实际上是对“分解”进行逆序递归的过程,整个过程从最末端的文本表达式向上合并,每一次合并都会得到一个新的“复合表达式”,例如:方根表达式、上标表达式等。整个过程持续递归进行,直到最终仅剩下唯一的一个表达式,则该表达式就是最终所要的数学公式。Finally, the "restore" process is performed based on the resulting set of text expressions. The process of "restore" is actually a process of recursing the "decomposition". The whole process is merged upwards from the end of the text expression. Each merge will get a new "composite expression", for example: square root expression , superscript expressions, etc. The whole process continues to recursively until there is only one unique expression left, and the expression is the final mathematical formula.
在又一种获取主体对象的实施方式中,公式内容未预先获得,而是在需要在页面上展示数学公式时由用户输入。基于此,当需要在页面上展示数学公式时,数学公式处理装置可以在页面上向用户提供一编辑界面,依次获取用户通过编辑界面输入的公式内容中的运算符号或操作数,以生成公式内容对应的主体对象。In yet another embodiment of obtaining a subject object, the formula content is not obtained in advance, but is entered by the user when a mathematical formula needs to be displayed on the page. Based on this, when the mathematical formula needs to be displayed on the page, the mathematical formula processing device can provide an editing interface to the user on the page, and sequentially acquire the operation symbol or the operand in the formula content input by the user through the editing interface to generate the formula content. Corresponding subject object.
例如,上述编辑界面可以包括可见编辑区域和隐藏编辑区域。其中,可见编辑区域主要用于供用户发出输入指令以及根据用户期望的方式向用户显示公式内容,隐藏编辑区域用于激活输入捕获事件并供用户输入公式内容。可选的,隐藏编辑区域是隐藏的。进一步,该编辑界面还可以包括:输入工具区域。该编辑界面的一种实现方式如图3所示,图3中标号为①区域是隐藏编辑区域,该区域在实际环境中是隐藏的,在这里显式地表现出来是为了直观地描述后续获取用户输入的操作数的过程。图3中标号为②的区域是可见编辑区域,用户可以在该区域内通过鼠标选中输入的公式。图3中标号为③的区域是输入工具区域,该区域提前预设了一些符号和公式,以方便用户直接选中输入,降低用户输入特殊字符和常用公式的复杂度。图3中标号为④的区域是模拟光标,用以提 示用户当前输入光标所在的位置。For example, the above editing interface may include a visible editing area and a hidden editing area. The visible editing area is mainly used for the user to issue an input instruction and display the formula content to the user according to the manner desired by the user, and the hidden editing area is used to activate the input capturing event and input the formula content for the user. Optionally, the hidden editing area is hidden. Further, the editing interface may further include: inputting a tool area. An implementation of the editing interface is shown in FIG. 3. The area labeled 1 in FIG. 3 is a hidden editing area, which is hidden in the actual environment, and is explicitly displayed here to visually describe subsequent acquisition. The process of the operand entered by the user. The area labeled 2 in Fig. 3 is a visible editing area in which the user can select the entered formula by the mouse. The area labeled 3 in Figure 3 is the input tool area, which presets some symbols and formulas in advance to facilitate the user to directly select the input, reducing the complexity of the user inputting special characters and common formulas. The area labeled 4 in Figure 3 is an analog cursor to Indicates the location where the user currently inputs the cursor.
基于上述编辑界面,数学公式处理装置依次获取用户通过编辑界面输入的公式内容中的运算符号或操作数,以生成公式内容对应的主体对象的实施过程包括:Based on the above-mentioned editing interface, the mathematical formula processing device sequentially acquires the operation symbols or operands in the formula content input by the user through the editing interface, and the implementation process of generating the body object corresponding to the formula content includes:
根据用户在可见编辑区域发出的编辑指令,在可见编辑区域显示指示当前输入位置的模拟光标,模拟光标会跟随用户的输入而移动,并将与模拟光标相关联的系统光标定位到隐藏编辑区域,以激活输入捕获事件;例如,用户可以点击标号为②的可见编辑区域从而发出编辑指令。According to an editing instruction issued by the user in the visible editing area, an analog cursor indicating the current input position is displayed in the visible editing area, the simulated cursor moves following the user's input, and the system cursor associated with the simulated cursor is positioned to the hidden editing area. The capture event is activated by an activation; for example, the user can click on the visible edit area labeled 2 to issue an edit instruction.
用户可以通过键盘直接输入,也可以单击输入工具区域③所预定的字符或公式进行输入。当用户执行以上任一操作时,将会触发标号为①隐藏编辑区域的输入捕获事件。于是,将依次捕获用户在标号为①隐藏编辑区域输入的公式内容中的运算符号或操作数,并根据系统光标的当前位置和所捕获到的运算符号或操作数在初始空对象中添加图形对象和/或图形对象中的操作数,以获得主体对象。The user can input directly through the keyboard, or click on the character or formula predetermined by the input tool area 3. When the user performs any of the above operations, an input capture event with the label 1 hidden edit area will be triggered. Thus, the operand or operand in the formula content entered by the user in the hidden edit area labeled 1 will be sequentially captured, and the graphic object will be added to the initial empty object according to the current position of the system cursor and the captured arithmetic symbol or operand. And/or operands in the graphic object to get the body object.
上述公式内容对应的主体对象是在用户输入公式内容的过程中生成的。The subject object corresponding to the above formula content is generated in the process of the user inputting the formula content.
下面以用户输入公式内容a+b÷c-b/a,并以主体对象为公式语法树为例,说明生成公式语法树的过程。In the following, the user inputs the formula content a+b÷c-b/a, and takes the subject object as the formula syntax tree as an example to illustrate the process of generating the formula syntax tree.
当用户第一次输入时,此时内容为空,用户通过键盘输入第一个字符:“a”,此时得到公式语法树如图4所示。When the user inputs for the first time, the content is empty at this time, and the user inputs the first character through the keyboard: “a”, and the formula syntax tree is obtained as shown in FIG. 4 .
用户继续通过键盘输入字符:“+”,此时得到公式语法树如图5所示。The user continues to input characters through the keyboard: "+", and the formula syntax tree is obtained as shown in FIG.
用户继续通过键盘输入字符:“b”,此时得到公式语法树如图6 所示。The user continues to input characters through the keyboard: "b", and the formula syntax tree is obtained as shown in Fig. 6. Shown.
接下来,用户需要输入“÷”符号,由于键盘上未提供直接输入“÷”符号的键,则用户可以通过编辑界面所包含的工具输入区域预设的符号输入“÷”,用户在点击相应的符号后,“÷”符号被输入到隐藏编辑区域中,此时得到公式语法树如图7。图7中新增的“\\div\\”是“÷”符号在本实施例公式语法树内部的表示方式。Next, the user needs to input the “÷” symbol. Since the key for directly inputting the “÷” symbol is not provided on the keyboard, the user can input “÷” by the preset symbol of the tool input area included in the editing interface, and the user clicks the corresponding button. After the symbol, the "÷" symbol is entered into the hidden editing area, and the formula syntax tree is obtained as shown in Fig. 7. The new "\\div\\" in Fig. 7 is the representation of the "÷" symbol inside the syntax tree of the formula in this embodiment.
用户继续通过键盘输入字符“c”和“-”,此时得到公式语法树如图8。The user continues to input the characters "c" and "-" through the keyboard, and the formula syntax tree is obtained as shown in FIG.
用户继续输入,此时应该输入分式:b/a,由于分式不能通过键盘直接输入,则用户需使用编辑界面中工具输入区域提供的预设公式进行输入,当用户点击相应的按钮并输入数据后,最终形成的语法树如图9。至此,获得了整个公式语法树。The user continues to input. At this time, the fraction should be input: b/a. Since the fraction cannot be directly input through the keyboard, the user needs to input using the preset formula provided in the tool input area of the editing interface, when the user clicks the corresponding button and inputs After the data, the resulting syntax tree is shown in Figure 9. At this point, the entire formula syntax tree is obtained.
值得说明的是,上述通过编辑界面输入公式内容的过程可以看做是编辑公式内容的过程。在实际应用中,用户在编辑公式内容时,会对公式内容的某一部分进行选区操作,以达到对公式内容中部分内容进行编辑的目的。It is worth noting that the above process of inputting the formula content through the editing interface can be regarded as the process of editing the content of the formula. In practical applications, when editing the content of a formula, the user performs a selection operation on a certain part of the formula content to achieve the purpose of editing part of the content of the formula.
具体的,数学公式处理装置可以识别用户的选区操作,选区操作是指用户选中公式内容中的部分操作数的操作;根据用户选中的公式内容中的部分操作数,在主体对象中进行标记;获取用户在选区操作所选中的区域内重新输入的操作数,用重新输入的操作数替换主体对象上被标记的操作数。Specifically, the mathematical formula processing device can identify the user's selection operation, and the selection operation refers to the operation of selecting a part of the operands in the formula content by the user; marking the main object according to some operands in the formula content selected by the user; The operand re-entered by the user in the selected area of the selection operation, replacing the marked operand on the subject object with the re-entered operand.
下面将以一个简单的公式a+b÷c为例,说明用户通过选区操作,将公式:a+b÷c更改为新的公式:a+b-c的过程。 In the following, a simple formula a+b÷c will be taken as an example to illustrate the process in which the user changes the formula: a+b÷c to the new formula: a+b-c through the selection operation.
如图10所示,用户在标号为①的位置处按下鼠标左键,并持续不放,此时数学公式处理装置将捕获到该事件,从事件的附带信息中获取到此时的鼠标指针位置信息,并记录该信息。As shown in FIG. 10, the user presses the left mouse button at the position marked with 1, and continues to hold, at this time, the mathematical formula processing device will capture the event, and obtain the mouse pointer at this time from the incidental information of the event. Location information and record the information.
用户在按住鼠标左键的情况下移动鼠标,其移动的轨迹如图10中标号为②的灰度框所示部分,此时,数学公式处理装置将捕获到该“鼠标移动”事件,从事件的附带信息中获取此刻鼠标指针的位置,并根据此刻的鼠标指针位置和之前记录的鼠标指针位置信息计算出选区。计算出选区后,将在“公式语法树”中相应位置插入选区“标志位”以标记该选区信息。The user moves the mouse while holding down the left mouse button, and the moving track is as shown in the gray box labeled 2 in FIG. 10, at this time, the mathematical formula processing device will capture the "mouse moving" event, from The attached information of the event obtains the position of the mouse pointer at this moment, and calculates the selection according to the mouse pointer position at the moment and the previously recorded mouse pointer position information. After the selection is calculated, the selection "flag" is inserted in the corresponding position in the "Formula Syntax Tree" to mark the selection information.
用户继续移动鼠标,将持续触发“鼠标移动”事件,使上一步的过程重复执行以更新选区。The user continues to move the mouse and will continue to trigger the "Mouse Move" event, causing the process of the previous step to be repeated to update the selection.
用户在图10中标号为③的位置处释放左键,此时数学公式处理装置将收到一个“鼠标按键弹起”的事件通知,以更新选区,并停止获取位置信息,选区将保持不变,直到用户重复上述各步骤的过程时,才会重新启动对选区的更新。此时,公式内部的语法树表示如图11所示,其中两条实线表示选区的起点和终点。值得说明的是,实线仅是标记方式的一种示例,并不限于此。The user releases the left button at the position marked 3 in FIG. 10, at which time the mathematical formula processing device will receive an event notification of "mouse button pop up" to update the selection and stop acquiring the location information, and the selection will remain unchanged. The update to the selection will not be restarted until the user repeats the process of the above steps. At this time, the syntax tree inside the formula is shown in Fig. 11, where two solid lines indicate the start and end points of the selection. It is worth noting that the solid line is only an example of the marking method and is not limited thereto.
此时用户通过键盘键入字符:“-”,公式语法树将会首先移除掉图11中两条实线之间的内容,然后再插入新的内容,更新后的语法树如图12所示。At this point, the user types the character through the keyboard: "-", the formula syntax tree will first remove the content between the two solid lines in Figure 11, and then insert the new content, the updated syntax tree is shown in Figure 12. .
图12中两条实线间的位置是图11中原来选区所在的位置,用户输入新的数据后,原有的选区被“闭合”,原选区包含的内容被删除,且在新的闭合的选区之前被插入了新的内容,即“-”。 The position between the two solid lines in Fig. 12 is the position of the original selection area in Fig. 11. After the user inputs the new data, the original selection area is "closed", the content contained in the original selection area is deleted, and the new closed area is closed. The new content was inserted before the selection, which is "-".
在此说明,用户除了编辑公式之外,还可以进行更新光标位置的操作。由于光标位置的更新实际上是选区更新的一个特例,其本质是一个选区长度为零的一个选区操作,其描述可以参考上面用户更改选区操作的描述,不再赘述。Here, the user can perform an operation of updating the cursor position in addition to editing the formula. Since the update of the cursor position is actually a special case of the selection of the selection, the essence is a selection operation with a selection length of zero. The description of the selection may refer to the description of the operation of the selection change by the user above, and will not be described again.
值得说明的是,在图4-图9以及图11-图12中,每组“name”和“operand”组合构成一个图形对象,所有图形对象以及图形对象之间的层次关系构成主体对象。以图9为例,整个图9所示内容构成一主体对象;图9所示主体对象包括两个图形对象,一个图形对象的运算类型属性为“combination”,操作数属性为[“a”,“+”,“b”,“\\div\\”,“c”,“-”];另一个图形对象的运算类型属性为“fraction”,操作数属性为[“b”,“a”]。It should be noted that in FIG. 4-9 and FIG. 11-12, each set of "name" and "operand" constitutes a graphic object, and all the graphic objects and the hierarchical relationship between the graphic objects constitute a main object. Taking FIG. 9 as an example, the entire content shown in FIG. 9 constitutes a main object; the main object shown in FIG. 9 includes two graphic objects, and the operation type attribute of one graphic object is "combination", and the operand attribute is ["a", "+", "b", "\\div\\", "c", "-"]; another graphic object has the operation type attribute "fraction" and the operand attribute is ["b", "a" ].
由上述可见,本实施方式以非常直观的方式提供给用户使用,大大提升了公式的编辑和阅读体验,降低用户使用的门槛。另外,在本实施方式中,不需要与服务器通信,用户在网络较差的环境下,也可以很快进行公式编辑并看到编辑效果。还有,该实施方式对用户没有额外要求,用户不需要像现有技术那样必须了解专业的公式表示法-TeX,由于采用的是所见即所得的编辑方式,用户可以在输入后立即看到渲染的效果,不需要向服务器发出渲染请求,极大地提高了用户编辑过程的流程、降低了用户参与编辑的门槛。It can be seen from the above that the present embodiment is provided to the user in a very intuitive manner, which greatly improves the editing and reading experience of the formula and reduces the threshold for the user to use. In addition, in the present embodiment, it is not necessary to communicate with the server, and the user can quickly edit the formula and see the editing effect in an environment where the network is poor. Also, this embodiment has no additional requirements for the user, and the user does not need to understand the professional formula representation - TeX as in the prior art, because the WYSIWYG editing method is adopted, the user can see immediately after inputting. The rendering effect does not require a rendering request to the server, which greatly improves the process of the user's editing process and reduces the threshold for users to participate in editing.
基于上述各实施方式,在获得公式内容对应的主体对象之后,可以根据该主体对象包括的图形对象之间的层次关系、图形对象的运算类型属性和图形对象的操作数属性,获得图形对象对应的数学表达式。Based on the foregoing embodiments, after obtaining the body object corresponding to the formula content, the graphic object may be obtained according to the hierarchical relationship between the graphic objects included in the body object, the operation type attribute of the graphic object, and the operand attribute of the graphic object. Mathematical expressions.
例如,可以按照图形对象之间的层次关系由下往上的顺序,逐一确 定图形对象;根据图形对象的运算类型属性和操作数属性进行图形绘制,以获得图形对象对应的数学表达式。For example, you can follow the hierarchical relationship between graphic objects from bottom to top, one by one. The graphic object is drawn; the graphic is drawn according to the operation type attribute and the operand attribute of the graphic object to obtain a mathematical expression corresponding to the graphic object.
之后,数学公式处理装置可以按照图形对象之间的层次关系,将图形对象对应的数学表达式绘制到页面中,以获得公式内容对应的数学公式。After that, the mathematical formula processing device can draw the mathematical expression corresponding to the graphic object into the page according to the hierarchical relationship between the graphic objects, to obtain a mathematical formula corresponding to the formula content.
例如,以主体对象是一棵公式语法树为例,则数学公式处理装置可以复制一棵公式语法树,并将其称之为映射树,将映射树上的图形对象直接替换为图形对象对应的数学表达式,进而获得一棵由数学表达式构成的映射树,该映射树是一棵可绘制的树;之后,按照从上到下的顺序,将该映射树绘制到页面中,从而获得一个完整的数学公式。For example, taking the main object object as a formula syntax tree as an example, the mathematical formula processing device can copy a formula syntax tree and call it a mapping tree, and directly replace the graphic object on the mapping tree with the corresponding graphic object. A mathematical expression, which in turn obtains a mapping tree composed of mathematical expressions, which is a drawable tree; then, in the order from top to bottom, the mapping tree is drawn into the page, thereby obtaining a Complete mathematical formula.
值得说明的是,本实施例采用的绘制技术可以是SVG绘图技术,但不限于此。It should be noted that the drawing technology used in this embodiment may be an SVG drawing technology, but is not limited thereto.
由上述可见,本实施例通过主体对象来表示公式内容,具体通过主体对象包括的图形对象之间的层次关系表示公式内容对应的运算顺序,而图形对象包括运算类型属性和操作数属性;根据图形对象之间的层次关系、图形对象的运算类型属性和图形对象的操作数属性,获得图形对象对应的数学表达式,进一步按照图形对象之间的层次关系,将图形对象对应的数学表达式绘制到页面中,以获得公式内容对应的数学公式。本实施例基于主体对象实现了通过绘图技术在页面中生成数学公式,不同于现有技术所使用的HTML标签,这使得所生成的数学公式可以完全独立于页面,而成为一个独立的整体,因此不容易受到页面内CSS样式的干扰或影响,显示效果比较稳定。It can be seen from the above that the present embodiment expresses the formula content by the body object, and specifically represents the operation order corresponding to the formula content by the hierarchical relationship between the graphic objects included in the body object, and the graphic object includes the operation type attribute and the operand attribute; The hierarchical relationship between the objects, the operation type attribute of the graphic object, and the operand attribute of the graphic object obtain the mathematical expression corresponding to the graphic object, and further draw the mathematical expression corresponding to the graphic object according to the hierarchical relationship between the graphic objects. In the page, get the mathematical formula corresponding to the formula content. The present embodiment implements a mathematical formula generated in a page by a drawing technique based on a main body object, which is different from the HTML label used in the prior art, which makes the generated mathematical formula completely independent of the page and becomes an independent whole. It is not easy to be interfered or affected by the CSS style in the page, and the display effect is relatively stable.
本发明技术方案可以支持IE9及以上的IE浏览器、chrome、firefox、 safari、opera等主流浏览器,用户可以在绝大多数的浏览器下编辑和阅读数学公式。The technical solution of the present invention can support IE browsers of IE9 and above, chrome, firefox, Main browsers such as safari and opera, users can edit and read math formulas in most browsers.
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本发明所必须的。It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should understand that the present invention is not limited by the described action sequence. Because certain steps may be performed in other sequences or concurrently in accordance with the present invention. In addition, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above embodiments, the descriptions of the various embodiments are different, and the details that are not detailed in a certain embodiment can be referred to the related descriptions of other embodiments.
图13为本申请一实施例提供的数学公式处理装置的结构示意图。如图13所示,该装置包括:获取模块1301、处理模块1302和绘制模块1303。FIG. 13 is a schematic structural diagram of a mathematical formula processing apparatus according to an embodiment of the present application. As shown in FIG. 13, the apparatus includes: an obtaining module 1301, a processing module 1302, and a drawing module 1303.
获取模块1301,用于获取公式内容对应的主体对象,主体对象包括图形对象和图像对象之间的层次关系,图形对象之间的层次关系表示公式内容对应的运算顺序,图形对象包括运算类型属性和操作数属性。The obtaining module 1301 is configured to obtain a body object corresponding to the formula content, where the body object includes a hierarchical relationship between the graphic object and the image object, the hierarchical relationship between the graphic objects represents an operation sequence corresponding to the formula content, and the graphic object includes the operation type attribute and Operand attribute.
处理模块1302,与获取模块1301连接,用于根据图形对象之间的层次关系、图形对象的运算类型属性和图形对象的操作数属性,获得图形对象对应的数学表达式。The processing module 1302 is connected to the obtaining module 1301, and is configured to obtain a mathematical expression corresponding to the graphic object according to the hierarchical relationship between the graphic objects, the operation type attribute of the graphic object, and the operand attribute of the graphic object.
绘制模块1303,与处理模块1302连接,用于按照图形对象之间的层次关系,将处理模块1302获得的图形对象对应的数学表达式绘制到页面中,以获得公式内容对应的数学公式。The drawing module 1303 is connected to the processing module 1302, and is configured to draw a mathematical expression corresponding to the graphic object obtained by the processing module 1302 into the page according to the hierarchical relationship between the graphic objects, to obtain a mathematical formula corresponding to the formula content.
在一可选实施方式中,获取模块1301具体可用于:In an optional implementation, the obtaining module 1301 is specifically configured to:
获取公式内容; Get the formula content;
按照预设的分解规则,将公式内容分解成不可再分解的基准表达式;Decompose the formula content into a non-resolvable reference expression according to a preset decomposition rule;
根据基准表达式之间的层次关系、基准表达式的类型以及基准表达式包括的操作数,生成主体对象。A principal object is generated based on the hierarchical relationship between the reference expressions, the type of the reference expression, and the operands included in the reference expression.
在另一可选实施方式中,获取模块1301具体可用于:In another optional implementation, the obtaining module 1301 is specifically configured to:
在页面中向用户提供一编辑界面;Providing an editing interface to the user in the page;
依次获取用户通过编辑界面输入的公式内容中的运算符号或操作数,以生成主体对象。The operands or operands in the formula content entered by the user through the editing interface are sequentially acquired to generate a subject object.
进一步可选的,上述编辑界面包括:可见编辑区域和隐藏编辑区域。Further optionally, the editing interface includes: a visible editing area and a hidden editing area.
基于此,获取模块1301具体可用于:Based on this, the obtaining module 1301 can be specifically used to:
在页面中向用户提供编辑界面;Providing an editing interface to the user in the page;
根据用户在可见编辑区域发出的编辑指令,在可见编辑区域显示指示当前输入位置的模拟光标,模拟光标会跟随用户的输入而移动,并将与模拟光标相关联的系统光标定位到隐藏编辑区域,以激活输入捕获事件;According to an editing instruction issued by the user in the visible editing area, an analog cursor indicating the current input position is displayed in the visible editing area, the simulated cursor moves following the user's input, and the system cursor associated with the simulated cursor is positioned to the hidden editing area. Capture the event with an activation input;
依次捕获用户在隐藏编辑区域输入的公式内容中的运算符号或操作数,并根据系统光标的当前位置和所捕获到的运算符号或操作数在初始空对象中添加图形对象和/或图形对象中的操作数,以获得主体对象。The operands or operands in the formula content entered by the user in the hidden edit area are sequentially captured, and the graphic object and/or the graphic object are added to the initial empty object according to the current position of the system cursor and the captured arithmetic symbol or operand. The operands to get the body object.
进一步,本实施例提供的数学公式处理装置还可以包括:识别模块、标记模块和更新模块。Further, the mathematical formula processing apparatus provided in this embodiment may further include: an identification module, a marking module, and an updating module.
识别模块,用于识别用户的选区操作,选区操作是指用户选中公式内容中的部分操作数的操作;An identification module for identifying a user's selection operation, and the selection operation refers to an operation of the user selecting a part of the operands in the formula content;
标记模块,用于根据用户选中的公式内容中的部分操作数,在主体对象中进行标记; a marking module, configured to mark in the main body object according to a part of the operands in the formula content selected by the user;
更新模块,用于获取用户在选区操作所选中的区域内重新输入的操作数,用重新输入的操作数替换主体对象上被标记的操作数。The update module is configured to obtain an operand that is re-entered by the user in the selected area of the selection operation, and replaces the marked operand on the subject object with the re-entered operand.
在一可选实施方式中,处理模块1302具体可用于:In an optional implementation, the processing module 1302 is specifically configured to:
按照图形对象之间的层次关系由下往上的顺序,逐一确定图形对象;The graphic objects are determined one by one according to the hierarchical relationship between the graphic objects from bottom to top;
根据图形对象的运算类型属性和操作数属性进行图形绘制,以获得图形对象对应的数学表达式。The graphics are drawn according to the operation type attribute and the operand attribute of the graphic object to obtain a mathematical expression corresponding to the graphic object.
可选的,上述公式内容对应的主体对象为公式内容对应的公式语法树。Optionally, the subject object corresponding to the content of the formula is a formula syntax tree corresponding to the formula content.
本实施例提供的数学公式处理装置,通过主体对象来表示公式内容,具体通过主体对象包括的图形对象之间的层次关系表示公式内容对应的运算顺序,而图形对象包括运算类型属性和操作数属性;根据图形对象之间的层次关系、图形对象的运算类型属性和图形对象的操作数属性,获得图形对象对应的数学表达式,进一步按照图形对象之间的层次关系,将图形对象对应的数学表达式绘制到页面中,以获得公式内容对应的数学公式。本实施例提供的数学公式处理装置基于主体对象实现了通过绘图技术在页面中生成数学公式,不同于现有技术所使用的HTML标签,这使得所生成的数学公式可以完全独立于页面,而成为一个独立的整体,因此不容易受到页面内CSS样式的干扰或影响,显示效果比较稳定。The mathematical formula processing apparatus provided in this embodiment expresses the formula content by the main body object, and specifically represents the operation order corresponding to the formula content by the hierarchical relationship between the graphic objects included in the main body object, and the graphic object includes the operation type attribute and the operand attribute. According to the hierarchical relationship between the graphic objects, the operation type attribute of the graphic object, and the operand attribute of the graphic object, the mathematical expression corresponding to the graphic object is obtained, and the mathematical expression corresponding to the graphic object is further determined according to the hierarchical relationship between the graphic objects. Draw into the page to get the mathematical formula corresponding to the formula content. The mathematical formula processing apparatus provided in this embodiment implements a mathematical formula generated in a page by a drawing technique based on a main body object, which is different from the HTML label used in the prior art, which makes the generated mathematical formula completely independent of the page and becomes An independent whole, so it is not easy to be interfered or affected by the CSS style in the page, and the display effect is relatively stable.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。A person skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the system, the device and the unit described above can refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
在本发明所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例 仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided by the present invention, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the device embodiment described above For example, the division of the unit is only a logical function division, and the actual implementation may have another division manner, for example, multiple units or components may be combined or may be integrated into another system, or some Features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
上述以软件功能单元的形式实现的集成的单元,可以存储在一个计算机可读取存储介质中。上述软件功能单元存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本发明各个实施例所述方法的部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The above-described integrated unit implemented in the form of a software functional unit can be stored in a computer readable storage medium. The above software functional unit is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to perform the methods of the various embodiments of the present invention. Part of the steps. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store program codes. .
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均 应包含在本发明保护的范围之内。 The above description is only the preferred embodiment of the present invention, and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention are It should be included in the scope of protection of the present invention.

Claims (16)

  1. 一种数学公式处理方法,其特征在于,包括:A mathematical formula processing method, comprising:
    获取公式内容对应的主体对象,所述主体对象包括图形对象和所述图形对象之间的层次关系,所述图形对象之间的层次关系表示所述公式内容对应的运算顺序,所述图形对象包括运算类型属性和操作数属性;Obtaining a main body object corresponding to the formula content, where the main body object includes a hierarchical relationship between the graphic object and the graphic object, and the hierarchical relationship between the graphic objects represents an operation sequence corresponding to the formula content, and the graphic object includes Operation type attribute and operand attribute;
    根据所述图形对象之间的层次关系、所述图形对象的运算类型属性和所述图形对象的操作数属性,获得所述图形对象对应的数学表达式;Obtaining a mathematical expression corresponding to the graphic object according to a hierarchical relationship between the graphic objects, an operation type attribute of the graphic object, and an operand attribute of the graphic object;
    按照所述图形对象之间的层次关系,将所述图形对象对应的数学表达式绘制到页面中,以获得所述公式内容对应的数学公式。And according to the hierarchical relationship between the graphic objects, the mathematical expression corresponding to the graphic object is drawn into the page to obtain a mathematical formula corresponding to the formula content.
  2. 根据权利要求1所述的方法,其特征在于,所述获取公式内容对应的主体对象,包括:The method according to claim 1, wherein the obtaining the subject object corresponding to the formula content comprises:
    获取所述公式内容;Obtaining the content of the formula;
    按照预设的分解规则,将所述公式内容分解成不可再分解的基准表达式;Decomposing the formula content into a non-redecomposable reference expression according to a preset decomposition rule;
    根据所述基准表达式之间的层次关系、所述基准表达式的类型以及所述基准表达式包括的操作数,生成所述主体对象。The subject object is generated according to a hierarchical relationship between the reference expressions, a type of the reference expression, and an operand included by the reference expression.
  3. 根据权利要求1所述的方法,其特征在于,所述获取所述公式内容对应的主体对象,包括:The method according to claim 1, wherein the acquiring the subject object corresponding to the formula content comprises:
    在所述页面中向用户提供一编辑界面;Providing an editing interface to the user in the page;
    依次获取所述用户通过所述编辑界面输入的所述公式内容中的运算符号或操作数,以生成所述主体对象。Acquiring an operation symbol or an operand in the formula content input by the user through the editing interface to generate the subject object.
  4. 根据权利要求3所述的方法,其特征在于,所述编辑界面包括:可见编辑区域和隐藏编辑区域; The method according to claim 3, wherein the editing interface comprises: a visible editing area and a hidden editing area;
    所述依次获取所述用户通过所述编辑界面输入的所述公式内容中的运算符号或操作数,以生成所述主体对象,包括:And acquiring the operation symbol or the operand in the formula content that is input by the user through the editing interface to generate the subject object, including:
    根据所述用户在所述可见编辑区域发出的编辑指令,在所述可见编辑区域显示指示当前输入位置的模拟光标,所述模拟光标会跟随用户的输入而移动,并将与所述模拟光标相关联的系统光标定位到所述隐藏编辑区域,以激活输入捕获事件;And displaying an analog cursor indicating a current input position in the visible editing area according to an editing instruction issued by the user in the visible editing area, the simulated cursor moving along with a user input, and is related to the simulated cursor The associated system cursor is positioned to the hidden editing area to activate an input capture event;
    依次捕获所述用户在所述隐藏编辑区域输入的所述公式内容中的运算符号或操作数,并根据所述系统光标的当前位置和所述捕获到的运算符号或操作数在初始空对象中添加图形对象和/或图形对象中的操作数,以获得所述主体对象。And sequentially capturing an operation symbol or an operand in the formula content input by the user in the hidden editing area, and according to the current position of the system cursor and the captured operation symbol or operand in the initial empty object An operand in a graphic object and/or a graphic object is added to obtain the subject object.
  5. 根据权利要求4所述的方法,其特征在于,在获得所述主体对象之后,还包括:The method according to claim 4, further comprising: after obtaining the subject object, further comprising:
    识别所述用户的选区操作,所述选区操作是指用户选中所述公式内容中的部分操作数的操作;Identifying a selection operation of the user, the selection operation refers to an operation of selecting a part of operands in the content of the formula;
    根据所述用户选中的所述公式内容中的部分操作数,在所述主体对象中进行标记;Marking in the subject object according to a part of the operands in the formula content selected by the user;
    获取所述用户在所述选区操作所选中的区域内重新输入的操作数,用所述重新输入的操作数替换所述主体对象上被标记的操作数。Obtaining an operand that is re-entered by the user in an area selected by the selection operation, and replacing the marked operand on the subject object with the re-entered operand.
  6. 根据权利要求1-5任一项所述的方法,其特征在于,所述根据所述图形对象之间的层次关系、所述图形对象的运算类型属性和所述图形对象的操作数属性,获得所述图形对象对应的数学表达式,包括:The method according to any one of claims 1 to 5, wherein the obtaining is based on a hierarchical relationship between the graphic objects, an operation type attribute of the graphic object, and an operand attribute of the graphic object. The mathematical expression corresponding to the graphic object includes:
    按照所述图形对象之间的层次关系由下往上的顺序,逐一确定所述图形对象; Determining the graphic object one by one according to a hierarchical relationship between the graphic objects from bottom to top;
    根据所述图形对象的运算类型属性和操作数属性进行图形绘制,以获得所述图形对象对应的数学表达式。Graphic drawing is performed according to the operation type attribute and the operand attribute of the graphic object to obtain a mathematical expression corresponding to the graphic object.
  7. 根据权利要求1-5任一项所述的方法,其特征在于,所述公式内容对应的主体对象为所述公式内容对应的公式语法树。The method according to any one of claims 1-5, wherein the subject object corresponding to the formula content is a formula syntax tree corresponding to the formula content.
  8. 一种数学公式处理装置,其特征在于,包括:A mathematical formula processing device, comprising:
    获取模块,用于获取公式内容对应的主体对象,所述主体对象包括图形对象和所述图像对象之间的层次关系,所述图形对象之间的层次关系表示所述公式内容对应的运算顺序,所述图形对象包括运算类型属性和操作数属性;An acquiring module, configured to acquire a body object corresponding to the formula content, where the body object includes a hierarchical relationship between the graphic object and the image object, and the hierarchical relationship between the graphic objects represents an operation sequence corresponding to the formula content, The graphic object includes an operation type attribute and an operand attribute;
    处理模块,用于根据所述图形对象之间的层次关系、所述图形对象的运算类型属性和所述图形对象的操作数属性,获得所述图形对象对应的数学表达式;a processing module, configured to obtain a mathematical expression corresponding to the graphic object according to a hierarchical relationship between the graphic objects, an operation type attribute of the graphic object, and an operand attribute of the graphic object;
    绘制模块,用于按照所述图形对象之间的层次关系,将所述图形对象对应的数学表达式绘制到页面中,以获得所述公式内容对应的数学公式。And a drawing module, configured to draw a mathematical expression corresponding to the graphic object into a page according to a hierarchical relationship between the graphic objects, to obtain a mathematical formula corresponding to the formula content.
  9. 根据权利要求8所述的装置,其特征在于,所述获取模块具体用于:The device according to claim 8, wherein the obtaining module is specifically configured to:
    获取所述公式内容;Obtaining the content of the formula;
    按照预设的分解规则,将所述公式内容分解成不可再分解的基准表达式;Decomposing the formula content into a non-redecomposable reference expression according to a preset decomposition rule;
    根据所述基准表达式之间的层次关系、所述基准表达式的类型以及所述基准表达式包括的操作数,生成所述主体对象。The subject object is generated according to a hierarchical relationship between the reference expressions, a type of the reference expression, and an operand included by the reference expression.
  10. 根据权利要求8所述的装置,其特征在于,所述获取模块具体 用于:The apparatus according to claim 8, wherein said acquisition module is specific Used for:
    在所述页面中向用户提供一编辑界面;Providing an editing interface to the user in the page;
    依次获取所述用户通过所述编辑界面输入的所述公式内容中的运算符号或操作数,以生成所述主体对象。Acquiring an operation symbol or an operand in the formula content input by the user through the editing interface to generate the subject object.
  11. 根据权利要求10所述的装置,其特征在于,所述编辑界面包括:可见编辑区域和隐藏编辑区域;The device according to claim 10, wherein the editing interface comprises: a visible editing area and a hidden editing area;
    所述获取模块具体用于:The obtaining module is specifically configured to:
    在所述页面中向所述用户提供所述编辑界面;Providing the editing interface to the user in the page;
    根据所述用户在所述可见编辑区域发出的编辑指令,在所述可见编辑区域显示指示当前输入位置的模拟光标,所述模拟光标会跟随用户的输入而移动,并将与所述模拟光标相关联的系统光标定位到所述隐藏编辑区域,以激活输入捕获事件;And displaying an analog cursor indicating a current input position in the visible editing area according to an editing instruction issued by the user in the visible editing area, the simulated cursor moving along with a user input, and is related to the simulated cursor The associated system cursor is positioned to the hidden editing area to activate an input capture event;
    依次捕获所述用户在所述隐藏编辑区域输入的所述公式内容中的运算符号或操作数,并根据所述系统光标的当前位置和所述捕获到的运算符号或操作数在初始空对象中添加图形对象和/或图形对象中的操作数,以获得所述主体对象。And sequentially capturing an operation symbol or an operand in the formula content input by the user in the hidden editing area, and according to the current position of the system cursor and the captured operation symbol or operand in the initial empty object An operand in a graphic object and/or a graphic object is added to obtain the subject object.
  12. 根据权利要求11所述的装置,其特征在于,还包括:The device according to claim 11, further comprising:
    识别模块,用于识别所述用户的选区操作,所述选区操作是指用户选中所述公式内容中的部分操作数的操作;An identification module, configured to identify a selection operation of the user, where the selection operation refers to an operation of selecting a part of operands in the content of the formula;
    标记模块,用于根据所述用户选中的所述公式内容中的部分操作数,在所述主体对象中进行标记;a marking module, configured to mark in the main body object according to a part of the operands in the formula content selected by the user;
    更新模块,用于获取所述用户在所述选区操作所选中的区域内重新输入的操作数,用所述重新输入的操作数替换所述主体对象上被标记的 操作数。An update module, configured to acquire an operand re-entered by the user in an area selected by the selection operation, and replace the marked object on the subject object with the re-entered operand Operands.
  13. 根据权利要求8-12任一项所述的装置,其特征在于,所述处理模块具体用于:The device according to any one of claims 8 to 12, wherein the processing module is specifically configured to:
    按照所述图形对象之间的层次关系由下往上的顺序,逐一确定所述图形对象;Determining the graphic object one by one according to a hierarchical relationship between the graphic objects from bottom to top;
    根据所述图形对象的运算类型属性和操作数属性进行图形绘制,以获得所述图形对象对应的数学表达式。Graphic drawing is performed according to the operation type attribute and the operand attribute of the graphic object to obtain a mathematical expression corresponding to the graphic object.
  14. 根据权利要求8-12任一项所述的装置,其特征在于,所述公式内容对应的主体对象为所述公式内容对应的公式语法树。The apparatus according to any one of claims 8 to 12, wherein the subject object corresponding to the formula content is a formula syntax tree corresponding to the formula content.
  15. 一种设备,包括a device, including
    一个或者多个处理器;One or more processors;
    存储器;Memory
    一个或者多个程序,所述一个或者多个程序存储在所述存储器中,当被所述一个或者多个处理器执行时:One or more programs, the one or more programs being stored in the memory, when executed by the one or more processors:
    获取公式内容对应的主体对象,所述主体对象包括图形对象和所述图形对象之间的层次关系,所述图形对象之间的层次关系表示所述公式内容对应的运算顺序,所述图形对象包括运算类型属性和操作数属性;Obtaining a main body object corresponding to the formula content, where the main body object includes a hierarchical relationship between the graphic object and the graphic object, and the hierarchical relationship between the graphic objects represents an operation sequence corresponding to the formula content, and the graphic object includes Operation type attribute and operand attribute;
    根据所述图形对象之间的层次关系、所述图形对象的运算类型属性和所述图形对象的操作数属性,获得所述图形对象对应的数学表达式;Obtaining a mathematical expression corresponding to the graphic object according to a hierarchical relationship between the graphic objects, an operation type attribute of the graphic object, and an operand attribute of the graphic object;
    按照所述图形对象之间的层次关系,将所述图形对象对应的数学表达式绘制到页面中,以获得所述公式内容对应的数学公式。And according to the hierarchical relationship between the graphic objects, the mathematical expression corresponding to the graphic object is drawn into the page to obtain a mathematical formula corresponding to the formula content.
  16. 一种非易失性计算机存储介质,所述计算机存储介质存储有一个或者多个程序,当所述一个或者多个程序被一个设备执行时,使得所 述设备:A non-volatile computer storage medium storing one or more programs, when the one or more programs are executed by a device, Description of equipment:
    获取公式内容对应的主体对象,所述主体对象包括图形对象和所述图形对象之间的层次关系,所述图形对象之间的层次关系表示所述公式内容对应的运算顺序,所述图形对象包括运算类型属性和操作数属性;Obtaining a main body object corresponding to the formula content, where the main body object includes a hierarchical relationship between the graphic object and the graphic object, and the hierarchical relationship between the graphic objects represents an operation sequence corresponding to the formula content, and the graphic object includes Operation type attribute and operand attribute;
    根据所述图形对象之间的层次关系、所述图形对象的运算类型属性和所述图形对象的操作数属性,获得所述图形对象对应的数学表达式;Obtaining a mathematical expression corresponding to the graphic object according to a hierarchical relationship between the graphic objects, an operation type attribute of the graphic object, and an operand attribute of the graphic object;
    按照所述图形对象之间的层次关系,将所述图形对象对应的数学表达式绘制到页面中,以获得所述公式内容对应的数学公式。 And according to the hierarchical relationship between the graphic objects, the mathematical expression corresponding to the graphic object is drawn into the page to obtain a mathematical formula corresponding to the formula content.
PCT/CN2015/083534 2014-12-17 2015-07-08 Mathematical formula processing method, device, apparatus and computer storage medium WO2016095502A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
KR1020177013186A KR101950126B1 (en) 2014-12-17 2015-07-08 Mathematical formula processing method, device, apparatus and computer storage medium
JP2017526093A JP6866551B2 (en) 2014-12-17 2015-07-08 Computer algebra methods, devices, devices and programs

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410790497.1A CN104572577B (en) 2014-12-17 2014-12-17 Mathematical formulae processing method and processing device
CN201410790497.1 2014-12-17

Publications (1)

Publication Number Publication Date
WO2016095502A1 true WO2016095502A1 (en) 2016-06-23

Family

ID=53088684

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/083534 WO2016095502A1 (en) 2014-12-17 2015-07-08 Mathematical formula processing method, device, apparatus and computer storage medium

Country Status (4)

Country Link
JP (1) JP6866551B2 (en)
KR (1) KR101950126B1 (en)
CN (1) CN104572577B (en)
WO (1) WO2016095502A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111309302A (en) * 2020-02-06 2020-06-19 杭州电子科技大学 Method for converting Verilog code based on LaTeX four-principle operation and trigonometric function mixed operation formula
CN112269476A (en) * 2020-10-28 2021-01-26 维沃移动通信有限公司 Formula display method and device and electronic equipment
CN112269476B (en) * 2020-10-28 2024-05-31 维沃移动通信有限公司 Formula display method and device and electronic equipment

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572577B (en) * 2014-12-17 2018-09-04 百度在线网络技术(北京)有限公司 Mathematical formulae processing method and processing device
CN106802749A (en) * 2015-11-25 2017-06-06 阿里巴巴集团控股有限公司 Numerical value input method and device
CN107390978B (en) * 2017-07-27 2020-11-03 广州视源电子科技股份有限公司 Formula display method and device, terminal and computer readable storage medium
CN107832271B (en) * 2017-10-31 2021-08-31 广州视睿电子科技有限公司 Function image drawing method, device, equipment and computer storage medium
CN109992121B (en) * 2017-12-29 2023-02-03 北京搜狗科技发展有限公司 Input method, input device and input device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040114258A1 (en) * 2002-12-17 2004-06-17 Harris Richard Alexander Device and method for combining dynamic mathematical expressions and other multimedia objects within a document
CN102663138A (en) * 2012-05-03 2012-09-12 北京大学 Method and device for inputting formula query terms
CN103176954A (en) * 2013-03-27 2013-06-26 重庆市科学技术研究院 Mathematical formula display method and mathematical formula display system based on hypertext markup language (HTML) 5 canvas
CN103425634A (en) * 2012-05-17 2013-12-04 北大方正集团有限公司 Method and device for generating streaming documents
CN103425773A (en) * 2013-08-02 2013-12-04 深圳市菁优网络科技有限公司 Method for rapidly displaying mathematical formula in web page by utilizing native Html (Hypertext Markup Language)
CN104572577A (en) * 2014-12-17 2015-04-29 百度在线网络技术(北京)有限公司 Mathematical formula processing method and device

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01108673A (en) * 1987-10-21 1989-04-25 Hitachi Ltd Mathematical formula input and edit system
JP2000148738A (en) * 1998-11-16 2000-05-30 Suuken Shuppan Kk Device and method for mathematical expression input and display, and recording medium where mathematical input and display program is recorded
JP4956757B2 (en) * 2006-03-15 2012-06-20 国立大学法人大阪大学 Formula description structured language object search system and search method
KR100963976B1 (en) * 2007-12-24 2010-06-15 엔에이치엔(주) Method, apparatus, system and computer-readable recording medium for arithmetical operation based on image information
CN101436309B (en) * 2008-12-15 2011-03-30 北大方正集团有限公司 Method and apparatus for modifying formula operator
MX2014008560A (en) * 2012-01-23 2014-09-26 Microsoft Corp Formula detection engine.
CN102693303B (en) * 2012-05-18 2017-06-06 上海极值信息技术有限公司 The searching method and device of a kind of formulation data

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040114258A1 (en) * 2002-12-17 2004-06-17 Harris Richard Alexander Device and method for combining dynamic mathematical expressions and other multimedia objects within a document
CN102663138A (en) * 2012-05-03 2012-09-12 北京大学 Method and device for inputting formula query terms
CN103425634A (en) * 2012-05-17 2013-12-04 北大方正集团有限公司 Method and device for generating streaming documents
CN103176954A (en) * 2013-03-27 2013-06-26 重庆市科学技术研究院 Mathematical formula display method and mathematical formula display system based on hypertext markup language (HTML) 5 canvas
CN103425773A (en) * 2013-08-02 2013-12-04 深圳市菁优网络科技有限公司 Method for rapidly displaying mathematical formula in web page by utilizing native Html (Hypertext Markup Language)
CN104572577A (en) * 2014-12-17 2015-04-29 百度在线网络技术(北京)有限公司 Mathematical formula processing method and device

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111309302A (en) * 2020-02-06 2020-06-19 杭州电子科技大学 Method for converting Verilog code based on LaTeX four-principle operation and trigonometric function mixed operation formula
CN111309302B (en) * 2020-02-06 2023-04-18 杭州电子科技大学 Method for converting Verilog code based on LaTeX four-principle operation and trigonometric function mixed operation formula
CN112269476A (en) * 2020-10-28 2021-01-26 维沃移动通信有限公司 Formula display method and device and electronic equipment
CN112269476B (en) * 2020-10-28 2024-05-31 维沃移动通信有限公司 Formula display method and device and electronic equipment

Also Published As

Publication number Publication date
JP2018501551A (en) 2018-01-18
CN104572577B (en) 2018-09-04
CN104572577A (en) 2015-04-29
KR101950126B1 (en) 2019-02-19
KR20170071553A (en) 2017-06-23
JP6866551B2 (en) 2021-04-28

Similar Documents

Publication Publication Date Title
WO2016095502A1 (en) Mathematical formula processing method, device, apparatus and computer storage medium
US10318628B2 (en) System and method for creation of templates
US9047261B2 (en) Document editing method
US10078709B2 (en) Managing a display of results of a keyword search on a web page by modifying attributes of a DOM tree structure
US9753699B2 (en) Live browser tooling in an integrated development environment
US8887089B2 (en) System and method for generating a file peek ahead user interface
CN102779114B (en) It is supported using the unstructured data of automatically rule generation
CN108762743B (en) Data table operation code generation method and device
JP6606304B2 (en) Fixed native document comments in preview
US20150309993A1 (en) Agile Enterprise Globalization
CN105580384A (en) Actionable content displayed on a touch screen
CN102428461A (en) Web translation with display replacement
JP2011159284A (en) Website font previewing
US9852117B1 (en) Text-fragment based content editing and publishing
CN109213480B (en) Method, storage medium, equipment and system for developing background management page
CN104679642A (en) Language independent processing of logs in a log analytics system
CA2714228C (en) Complex input to image transformation for distribution
TW201308108A (en) System and method for integrating menus and toolbars
US10671801B2 (en) Markup code generator
CN109445900B (en) Translation method and device for picture display
WO2017049715A1 (en) Page construction method, apparatus and device, and nonvolatile computer storage medium
JP7438769B2 (en) Sentence structure drawing device
CN116541120B (en) Webpage rendering mode identification method, system and computer equipment
AU2021106041A4 (en) Methods and systems for obtaining and storing web pages
Gärtner et al. NLATool: An Application for Enhanced Deep Text Understanding

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15869013

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2017526093

Country of ref document: JP

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 20177013186

Country of ref document: KR

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15869013

Country of ref document: EP

Kind code of ref document: A1