Lightweight text annotation method, system, device and storage medium based on javascript
Lightweight text annotation is implemented through JavaScript, which solves the problem of difficult to parse table name positions in long SQL statements, provides a simple and scalable solution, and improves user experience and business efficiency.
Patent Information
- Application Number
- CN202110153364.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-04
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2041-02-04
AI Technical Summary
When processing long SQL statements, it is difficult for the server to parse the location of the table name accurately, resulting in difficulty in carrying out the business.
Using a lightweight text annotation method based on JavaScript, the table name array is obtained by parsing SQL statements, and adding span tags to each table name, obtaining label location information, creating custom labels and result lists, and implementing table names in SQL statements position label in.
It simplifies the search for table name locations, improves business scalability and user experience, and is especially suitable for parsing ultra-long SQL statements.
Smart Images

Figure CN112800078B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a lightweight text annotation method. More specifically, the present invention mainly relates to a lightweight text annotation method, system, device and storage medium based on javascript. Background Art
[0002] In actual business, companies often need to let the server parse some tables in SQL (Structured Query Language) statements and then perform some operations on these tables. However, when encountering particularly long SQL statements, such as SQL statements with dozens or hundreds of lines, it is usually impossible to accurately find the position of the table parsed by the server in the SQL statement, resulting in the company's business being unable to proceed well.
[0003] JavaScript ("JS" for short) is a lightweight, interpreted or just-in-time compiled programming language with function-first approach. Although JavaScript is famous as a scripting language for developing web pages, JavaScript is also used in many non-browser environments. JavaScript is a dynamic scripting language based on prototype programming and multiple paradigms, and supports object-oriented, imperative and declarative (such as functional programming) styles. Summary of the invention
[0004] The embodiment of the present application provides a lightweight text annotation method based on javascript to at least solve the problem of subjective factors in the related art.
[0005] The present invention provides a lightweight text annotation method based on javascript, the method comprising the following steps:
[0006] Parsing steps: Parsing SQL statements;
[0007] Table name acquisition step: acquiring a table name array according to the parsing result of the SQL statement;
[0008] Span tag adding step: adding a span tag to each table name in the table name array;
[0009] Position acquisition step: acquiring the tag position information of the span tag, and acquiring the position of the table name in the SQL statement according to the tag position information.
[0010] In the above-mentioned lightweight text annotation method based on javascript, the span tag adding step specifically includes the following steps:
[0011] Matching step: matching the position of each table name in the table name array by using a regular expression;
[0012] Adding step: adding the span tag before and after the table name;
[0013] ID adding step: add an ID to the span tag.
[0014] In the above-mentioned lightweight text annotation method based on javascript, the position acquisition step specifically includes the following steps:
[0015] Distance acquisition step: acquiring the position of each span tag from the top and the left of the SQL statement, obtaining the tag position information, and saving the tag position information into the table name array;
[0016] Label creation step: creating a custom label according to the label position information;
[0017] List creation step: creating a result list based on the table name array to which the ID and the tag position information are added, and obtaining the position of the table name in the SQL statement;
[0018] Interaction adding step: adding interaction between the result list and the custom tag.
[0019] In the above-mentioned lightweight text annotation method based on JavaScript, the tag position information is obtained using document.getElementById().
[0020] Based on the same inventive concept, the present invention also discloses a lightweight text annotation system based on javascript based on the lightweight text annotation method disclosed by any invention creation.
[0021] The lightweight text annotation system based on javascript includes:
[0022] Parsing module, parsing SQL statements;
[0023] A table name acquisition module, which acquires a table name array according to the parsing result of the SQL statement;
[0024] A span tag adding module is used to add a span tag to each table name in the table name array;
[0025] A position acquisition module is used to acquire the tag position information of the span tag, and acquire the position of the table name in the SQL statement according to the tag position information.
[0026] In the above-mentioned lightweight text annotation system based on javascript, the span tag adding module specifically includes:
[0027] A matching unit, which matches the position of each table name in the table name array through a regular expression;
[0028] Add a unit, adding the span tags before and after the table name;
[0029] The ID adding unit adds an ID to the span tag.
[0030] In the above-mentioned lightweight text annotation system based on javascript, the location acquisition module specifically includes:
[0031] A distance acquisition unit is used to acquire the position of each span tag from the top and the left of the SQL statement, obtain the tag position information, and save the tag position information into the table name array;
[0032] A label creation unit, which creates a custom label according to the label position information;
[0033] A list creation unit, which creates a result list based on the table name array to which the ID and the tag position information are added, and obtains the position of the table name in the SQL statement;
[0034] An interaction adding unit adds interaction between the result list and the custom tag.
[0035] In the above-mentioned lightweight text annotation system based on JavaScript, the tag position information is obtained using document.getElementById().
[0036] In addition, to achieve the above-mentioned purpose, the present invention also provides a device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements a lightweight text annotation method based on JavaScript when executing the computer program.
[0037] In addition, to achieve the above-mentioned purpose, the present invention also provides a storage medium on which a computer program is stored, and when the program is executed by a processor, a lightweight text annotation method based on JavaScript is implemented.
[0038] Compared with the prior art, the present invention has the following beneficial effects:
[0039] 1. A lightweight text annotation method based on JavaScript is proposed for very long SQL statements. After the SQL statement is parsed, some annotations are made to help find the location of the table name in the SQL statement;
[0040] 2. Easy to use, highly scalable, and convenient for business development;
[0041] 3. Use js to implement lightweight annotation to improve user experience.
[0042] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0044] Figure 1 This is an overall flow chart of a lightweight text annotation method based on javascript provided by an embodiment of the present invention;
[0045] Figure 2 It is an overall flow chart of the technical solution disclosed in this embodiment;
[0046] Figure 3 is a table name array format diagram disclosed in this embodiment;
[0047] Figure 4 yes Figure 1 The disclosed overall flow chart of step S3;
[0048] Figure 5 This is a diagram of the table name array format after adding ID disclosed in this embodiment;
[0049] Figure 6 yes Figure 1 The overall flow chart of step S4 disclosed;
[0050] Figure 7 is a diagram of the table name array format after adding the distance disclosed in this embodiment;
[0051] Figure 8 is a diagram of the software interface disclosed in this embodiment;
[0052] Fig. 9 This is a structural framework diagram of a lightweight text annotation system based on javascript provided in this embodiment;
[0053] Fig.10is a framework diagram of a computer device according to an embodiment of the present invention.
[0054] In the above picture:
[0055] 1. Parsing module; 2. Table name acquisition module; 3. Span tag adding module; 4. Location acquisition module; 31. Matching unit; 32. Adding unit; 33. ID adding unit; 41. Distance acquisition unit; 42. Tag creation unit; 43. List creation unit; 44. Interaction adding unit; 80. Bus; 81. Processor; 82. Memory; 83. Communication interface. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0057] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.
[0058] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0059] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects, and do not represent a specific ordering of the objects.
[0060] The present invention is described in detail below in conjunction with the various embodiments shown in the accompanying drawings, but it should be noted that these embodiments are not limitations of the present invention, and any equivalent transformations or substitutions in functions, methods, or structures made by ordinary technicians in the field based on these embodiments are all within the scope of protection of the present invention.
[0061] Before describing in detail various embodiments of the present invention, the core inventive concept of the present invention is summarized and described in detail through the following several embodiments.
[0062] The present invention can realize lightweight text annotation based on javascript, and through label annotation, it is convenient to find the position of the table after the SQL statement is parsed. It is simple to use and has strong expansibility.
[0063] Embodiment 1:
[0064] Reference Figures 1 to 8 As shown, this example discloses a specific implementation method of a lightweight text annotation method based on javascript (hereinafter referred to as "method").
[0065] Specifically, refer to Figure 1 and Figure 2 As shown, the method disclosed in this embodiment includes the following steps:
[0066] Step S1, parsing SQL statements.
[0067] Then, step S2 is executed to obtain a table name array according to the parsing result of the SQL statement.
[0068] Specifically, in some embodiments, the parsing result of the SQL statement is obtained from the server, and the data type returned is usually an array, and each item of the array is a table name in the form of Figure 3 It should be noted that the present invention does not limit the form of the table name array.
[0069] Then, step S3 is executed to add a span tag to each table name in the table name array.
[0070] Specifically, in some of the embodiments, reference is made to Figure 4 As shown, step S3 specifically includes the following steps:
[0071] S31, matching the position of each table name in the table name array by using a regular expression;
[0072] S32, adding the span tag before and after the table name;
[0073] S33. Add an ID to the span tag.
[0074] Specifically, in some of the embodiments, the position of each table name in the parsing result is matched by a regular expression, and then the table name is preceded and followed by label, and for each Add an ID to the tag, and finally process the ID and the parsing result (table name array) and save it for later use. For example: the table name array after adding the ID can be as follows Figure 5 shown.
[0075] Then, step S4 is executed to obtain the tag position information of the span tag, and the position of the table name in the SQL statement is obtained according to the tag position information.
[0076] Specifically, in some of the embodiments, reference is made to Figure 6 As shown, step S4 specifically includes the following steps:
[0077] S41, obtaining the position of each span tag from the top and the left of the SQL statement, obtaining the tag position information, and saving the tag position information into the table name array;
[0078] S42, creating a custom tag according to the tag location information;
[0079] S43, creating a result list based on the table name array with the ID and the tag position information added, and obtaining the position of the table name in the SQL statement;
[0080] S44: Add interaction between the result list and the custom tag.
[0081] Specifically, use the js native method document.getElementById() to get the position of each span tag from the top and left of the SQL statement text, and then save it to the result data. For example, the table name array after adding the distance can be as follows: Figure 7 shown.
[0082] Specifically, in some of the embodiments, a custom label is created according to the position information of the array table, and the style is arbitrary. Then, a result list is created according to the table name array data after adding the ID and label position information. At the same time, a mouse click event is added. When a table name in the result list is clicked, the text automatically jumps to the position of the table name in the text.
[0083] Specifically, in some of the embodiments, the software interface is as follows: Figure 8 As shown, the software also adds other functions. Clicking the label under the SQL can also realize automatic jump to the result location.
[0084] A lightweight text annotation method based on javascript disclosed in the embodiment of the present application is aimed at ultra-long SQL statements. After the SQL statement is parsed, some annotations are made to help find the position of the table name in the SQL statement. It is simple to use, highly scalable, and convenient for work and business development. Lightweight annotation is implemented using js to improve user experience.
[0085] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent.
[0086] Embodiment 2:
[0087] In combination with the lightweight text annotation method based on javascript disclosed in Example 1, this embodiment discloses a specific implementation example of a lightweight text annotation system based on javascript (hereinafter referred to as "system").
[0088] Reference Fig. 9 As shown, the system comprises:
[0089] Parsing module 1, parsing SQL statements;
[0090] Table name acquisition module 2, acquiring a table name array according to the parsing result of the SQL statement;
[0091] Span tag adding module 3, adding a span tag to each table name in the table name array;
[0092] The position acquisition module 4 acquires the tag position information of the span tag, and acquires the position of the table name in the SQL statement according to the tag position information.
[0093] Specifically, in some embodiments, the span tag adding module 3 specifically includes:
[0094] A matching unit 31 matches the position of each table name in the table name array through a regular expression;
[0095] An adding unit 32, adding the span tag before and after the table name;
[0096] The ID adding unit 33 adds an ID to the span tag.
[0097] Specifically, in some embodiments, the location acquisition module 4 specifically includes:
[0098] The distance obtaining unit 41 obtains the position of each span tag from the top and the left of the SQL statement, obtains the tag position information, and saves the tag position information into the table name array;
[0099] A label creation unit 42, which creates a custom label according to the label position information;
[0100] A list creation unit 43 creates a result list based on the table name array to which the ID and the tag position information are added, and obtains the position of the table name in the SQL statement;
[0101] The interaction adding unit 44 adds the interaction between the result list and the custom tag.
[0102] For the technical solutions of the lightweight text annotation system based on javascript disclosed in this embodiment and the lightweight text annotation method based on javascript disclosed in embodiment one, please refer to embodiment one and will not be repeated here.
[0103] Embodiment three:
[0104] Combination Fig.10 As shown, this embodiment discloses a specific implementation of a computer device. The computer device may include a processor 81 and a memory 82 storing computer program instructions.
[0105] Specifically, the processor 81 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0106] Among them, the memory 82 may include a large-capacity memory for data or instructions. By way of example and not limitation, the memory 82 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 82 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 82 may be inside or outside the data processing device. In a specific embodiment, the memory 82 is a non-volatile memory. In a specific embodiment, the memory 82 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-Only Memory, PROM for short), an erasable PROM (Erasable ProgrammableRead-Only Memory, EPROM for short), an electrically erasable PROM (Electrically Erasable ProgrammableRead-Only Memory, EEPROM for short), an electrically alterable ROM (Electrically Alterable Read-Only Memory, EAROM for short) or a flash memory (FLASH) or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0107] The memory 82 may be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 81 .
[0108] The processor 81 reads and executes the computer program instructions stored in the memory 82 to implement any one of the lightweight text annotation methods based on JavaScript in the above embodiments.
[0109] In some of these embodiments, the computer device may further include a communication interface 83 and a bus 80. Fig.10 As shown, the processor 81, the memory 82, and the communication interface 83 are connected via a bus 80 and communicate with each other.
[0110] The communication interface 83 is used to implement communication between the modules, devices, units and / or equipment in the embodiment of the present application. The communication port 83 can also implement data communication with other components such as: external devices, image / data acquisition equipment, databases, external storage, and image / data processing workstations.
[0111] The bus 80 includes hardware, software or both, and couples the components of the computer device to each other. The bus 80 includes but is not limited to at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not limitation, bus 80 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, bus 80 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
[0112] The computer device can realize lightweight text annotation based on javascript, thereby realizing the combination of Figure 1 Describe the method.
[0113] In addition, in combination with the lightweight text annotation method based on javascript in the above embodiment, the embodiment of the present application can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by the processor, any lightweight text annotation method based on javascript in the above embodiment is implemented.
[0114] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0115] In summary, the beneficial effect of the present invention lies in that a lightweight text annotation method based on javascript is proposed, which is aimed at ultra-long SQL statements. After the SQL statement is parsed, some annotations are made to help find the position of the table name in the SQL statement; it is simple to use, has strong scalability, and is convenient for work and business development; lightweight annotation is implemented using js to improve user experience.
[0116] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A lightweight text annotation method based on JavaScript, characterized in that , including the following steps: Parsing steps: Parsing SQL statements; Table name acquisition step: acquiring a table name array according to the parsing result of the SQL statement; Span tag adding step: adding a span tag to each table name in the table name array; Position acquisition step: acquiring tag position information of the span tag, and acquiring the position of the table name in the SQL statement according to the tag position information; The span tag adding step specifically includes the following steps: Matching step: matching the position of each table name in the table name array by using a regular expression; Adding step: adding the span tag before and after the table name; ID adding step: adding an ID to the span tag; The location acquisition step specifically includes the following steps: Distance acquisition step: acquiring the position of each span tag from the top and the left of the SQL statement, obtaining the tag position information, and saving the tag position information into the table name array. The tag position information is acquired using document.getElementById(); Label creation step: creating a custom label according to the label position information; List creation step: creating a result list based on the table name array to which the ID and the tag position information are added, and obtaining the position of the table name in the SQL statement; Interaction adding step: adding interaction between the result list and the custom tag; Among them, a custom label is created according to the position information of the array table, a result list is created according to the table name array data after adding the ID and label position information, and a mouse click event is added. When a table name in the result list is clicked, the text will automatically jump to the position of the table name in the text.
2. A lightweight text annotation system based on JavaScript, characterized by ,include: Parsing module, parsing SQL statements; A table name acquisition module, which acquires a table name array according to the parsing result of the SQL statement; A span tag adding module is used to add a span tag to each table name in the table name array; A position acquisition module is used to acquire the tag position information of the span tag, and acquire the position of the table name in the SQL statement according to the tag position information; The span tag adding module specifically includes: A matching unit, which matches the position of each table name in the table name array through a regular expression; Add a unit, adding the span tags before and after the table name; ID adding unit, adding ID to the span tag; Wherein, the location acquisition module specifically includes: A distance acquisition unit acquires the position of each span tag from the top and the left of the SQL statement, obtains the tag position information, and saves the tag position information into the table name array. The tag position information is acquired using document.getElementById(); A label creation unit, which creates a custom label according to the label position information; A list creation unit, which creates a result list based on the table name array to which the ID and the tag position information are added, and obtains the position of the table name in the SQL statement; An interaction adding unit, adding the interaction between the result list and the custom tag; Among them, a custom label is created according to the position information of the array table, a result list is created according to the table name array data after adding the ID and label position information, and a mouse click event is added. When a table name in the result list is clicked, the text will automatically jump to the position of the table name in the text.
3. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the lightweight text annotation method based on JavaScript as claimed in claim 1 is implemented.
4. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the lightweight text annotation method based on javascript as claimed in claim 1 is implemented.
