Method, system, medium and electronic device for defining context window text range
By determining the rules of the central sentence and hit sentence in the dialogue text and defining the context window text scope of the dialogue text in the service field, the problem of inaccurate definition of context windows in the prior art is solved, and the accuracy and stability of text semantic analysis are improved.
Patent Information
- Application Number
- CN202111047014.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-07
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2041-09-07
AI Technical Summary
The prior art is difficult to accurately define the context window text range of dialogue text in service fields, resulting in insufficient accuracy and stability of text semantic analysis, and the inability to scientifically train models to improve the accuracy of speech recognition and semantic understanding.
By determining the rules of the central sentence and the hit sentence, traverse the dialogue text, determine the central sentence based on the central sentence judgment rules, and then search the hit sentence based on the hit sentence judgment rules within the preset text search range of the central sentence, and then define the text range of the semantic window and add semantic labels.
It realizes the accurate definition of the text scope of the context window, improves the accuracy and stability of text semantic analysis, and provides a window rule that is universal, easy to use, easy to expand, and trainable and improved.
Smart Images

Figure CN113761939B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of defining a context window text range, and in particular relates to a method, system, medium and electronic device for defining a context window text range. Background Art
[0002] In the service domain, semantic structured analysis of text content is required to achieve data abstraction. The results of word segmentation and matching of a single sentence cannot infer the true semantics. A large amount of semantics requires contextual understanding of continuous conversation content.
[0003] In the service field, due to the uncertainty of the scene, it is difficult for existing text processing programs to find the accurate boundaries of the context of conversation text. Therefore, we need a window rule that is universal, easy to use, easy to expand, and trainable to describe the context semantics, so as to perform structured processing on the conversation text.
[0004] High labor costs and the inability to effectively divide labor and collaborate are the biggest drawbacks of the prior art. In the current technology, the accuracy and stability of text structured processing cannot be guaranteed, and the methodology cannot be continuously reused; therefore, it is impossible to scientifically train the model to improve the accuracy of speech recognition and semantic understanding. The present invention is used to solve the technical problems in the prior art. Summary of the invention
[0005] The embodiments of the present application provide a method, system, medium and electronic device for defining the scope of text in a context window, so as to at least solve the problem that the existing method for defining the scope of text in a context window cannot scientifically train the model to improve the accuracy of text semantic analysis.
[0006] The present invention provides a method for defining a context window text range, which includes:
[0007] Determine the central sentence step: traverse each sentence in the dialogue text and determine the first central sentence according to the central sentence determination rule;
[0008] The step of determining a hit sentence: searching and determining the first hit sentence corresponding to the first central sentence in a preset text search range of the first central sentence based on a hit sentence determination rule;
[0009] Labeling step: defining the text range of the first semantic window according to the positions of the first central sentence and the first hit sentence, and then adding a first semantic label to the entire text within the first semantic window.
[0010] In the above method, the central sentence determination rule and the hit sentence rule include:
[0011] In the dialogue text, if a central sentence label mention word appears in a dialogue text sentence of any dialogue character, and a central sentence label keyword appears or does not appear in the dialogue text sentence according to a preset rule, the dialogue text sentence is determined to be a central sentence; in the dialogue text, if a hit sentence label mention word appears in a dialogue text sentence of any dialogue character, and a hit sentence label keyword appears or does not appear in the dialogue text sentence according to a preset rule, the dialogue text sentence is determined to be a hit sentence.
[0012] In the above method, the text search range includes: a search direction and a search sentence number.
[0013] In the above method, when the hit sentence determination rule searches for the hit sentence, the window boundary is completed; if the central sentence and the hit sentence are the same sentence, the window is the central sentence.
[0014] The present invention also provides a system for defining a context window text range, which includes:
[0015] A central sentence determination module, wherein the central sentence determination module traverses each sentence in the dialogue text and determines the first central sentence according to a central sentence determination rule;
[0016] A hit sentence determination module, wherein the hit sentence determination module searches and determines the first hit sentence corresponding to the first central sentence in a preset text search range of the first central sentence based on a hit sentence determination rule;
[0017] A label marking module defines the text range of a first semantic window according to the positions of the first central sentence and the first hit sentence, and then adds a first semantic label to the entire text within the first semantic window.
[0018] In the above system, the central sentence determination rule and the hit sentence rule include:
[0019] In the dialogue text, if a central sentence label mention word appears in a dialogue text sentence of any dialogue character, and a central sentence label keyword appears or does not appear in the dialogue text sentence according to a preset rule, the dialogue text sentence is determined to be a central sentence; in the dialogue text, if a hit sentence label mention word appears in a dialogue text sentence of any dialogue character, and a hit sentence label keyword appears or does not appear in the dialogue text sentence according to a preset rule, the dialogue text sentence is determined to be a hit sentence.
[0020] In the above system, the text search range includes: a search direction and a search sentence number.
[0021] In the above system, when the hit sentence determination rule searches for the hit sentence, the window boundary is completed; if the central sentence and the hit sentence are the same sentence, the window is the central sentence.
[0022] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above methods when executing the computer program.
[0023] A storage medium stores a computer program, wherein the program, when executed by a processor, implements any of the methods described above.
[0024] The beneficial effects of the present invention are:
[0025] The present invention belongs to the field of artificial intelligence in intelligent device technology and provides a method for defining the scope of context window text by using window rules that are universal, easy to use, easy to expand, and trainable and improveable. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The drawings described herein are used to provide 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 improper limitations on the present application.
[0027] In the attached picture:
[0028] Figure 1 is a flow chart of a method for defining a context window text range of the present invention;
[0029] Figure 2 It is a display diagram showing the determination rules of the present invention;
[0030] Figure 3 It is a schematic diagram of the structure of the system for defining the text range of the context window of the present invention;
[0031] Figure 4 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0032] 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.
[0033] 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.
[0034] 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.
[0035] 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 quantity limitation, and may indicate 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 mean: 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.
[0036] 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.
[0037] Before elaborating on each embodiment of the present invention in detail, the core inventive concept of the present invention is summarized and elaborated in detail through the following several embodiments.
[0038] Embodiment 1:
[0039] Please refer to Figure 1 , Figure 1 is a flowchart of a method for defining the scope of the context window text. Figure 1 As shown, the method for defining the context window text range of the present invention includes:
[0040] Determine the central sentence step S1: traverse each sentence in the dialogue text and determine the first central sentence according to the central sentence determination rule;
[0041] Determine the hit sentence step S2: In the preset text search range of the first central sentence, search and determine the first hit sentence corresponding to the first central sentence based on the hit sentence determination rule;
[0042] Labeling step S3: defining the text range of the first semantic window according to the positions of the first central sentence and the first hit sentence, and then adding a first semantic label to the entire text within the first semantic window.
[0043] The central sentence determination rule and the hit sentence rule include:
[0044] In the dialogue text, if a central sentence label mention word appears in a dialogue text sentence of any dialogue character, and a central sentence label keyword appears or does not appear in the dialogue text sentence according to a preset rule, the dialogue text sentence is determined to be a central sentence; in the dialogue text, if a hit sentence label mention word appears in a dialogue text sentence of any dialogue character, and a hit sentence label keyword appears or does not appear in the dialogue text sentence according to a preset rule, the dialogue text sentence is determined to be a hit sentence.
[0045] The text search range includes: search direction and search sentence number.
[0046] Furthermore, the search scope indicates the scope of contextual search, which is not calculated but pre-set based on big data; search direction: starting from the central sentence according to the order of the conversation, searching upward or downward for the hit sentence; number of sentences to be searched: counting the number of sentences in the conversation text that express a complete semantic text range, and then calculating the average or median of the number of sentences to determine the number of sentences to be searched.
[0047] Furthermore, the number of sentences to be searched in this solution is differentiated according to the speaker. For example, the number of sentences in the following dialogue text is 3:
[0048] Waiter: Hello, what can I order?
[0049] Customer: I want to buy some watermelon frost throat lozenges, do you have any?
[0050] Waiter: Yes, this one, please have a look.
[0051] Furthermore, when the hit sentence determination rule searches for the hit sentence, the window boundary is completed; if the central sentence and the hit sentence are the same sentence, the window is the central sentence.
[0052] Specifically, according to Figure 2 As shown, the specific steps of the present invention are as follows:
[0053] The present invention determines the text range of the window according to the central sentence determination rule, the hit sentence determination rule and the search range.
[0054] Furthermore, setting the central sentence determination rules and the hit sentence determination rules includes:
[0055] Central sentence determination rule: if the central sentence label mention word appears in the dialogue text sentence of the dialogue character and the central sentence label keyword appears or does not appear in the dialogue text sentence according to the preset rules, the dialogue text sentence is determined to be the central sentence;
[0056] Hit sentence determination rules: In the dialogue text, if a hit sentence label mention word appears in the dialogue text sentence of any dialogue character, and the hit sentence label keyword appears or does not appear in the dialogue text sentence according to the preset rules, the dialogue text sentence is determined to be a hit sentence.
[0057] The entire context starts from the central sentence and ends with the hit sentence, which defines the scope of the window and facilitates expansion and training.
[0058] When this solution is used to define the context window text range:
[0059] First, traverse each sentence in the dialogue text and bring it into the judgment rule of the central sentence. If the judgment rule conditions of the central sentence are met, the central sentence is determined, and the hit sentence search is performed on the central sentence according to the preset search range. Within the preset search range, the search is stopped when the hit sentence is found according to the judgment rule of the hit sentence, and the positions of the central sentence and the hit sentence are recorded, that is, the context window range is determined, and then the entire window range is structured and the corresponding semantic tags are added.
[0060] A statement may be in multiple window scopes, that is, there is nesting and overlapping of window scopes.
[0061] Find the central sentence according to the rules, and then search for the hit sentence according to the hit sentence judgment rules within the preset search range based on the upward and / or downward search direction. Finding the hit sentence is equivalent to determining the boundary of a window range. If the central sentence and the hit sentence are the same sentence, then there is only one sentence within the window range.
[0062] In this patent, the central sentence is determined by the central sentence determination rules. Specifically, if a sentence contains multiple groups of roles or the sentence mentions the central sentence keywords, then the sentence will be determined as the central sentence by the central sentence determination rules. In this patent, the hit sentence determination rules are the same as the central sentence determination rules. If a sentence contains multiple groups of roles or the sentence mentions the hit sentence keywords, then the sentence will be determined as the hit sentence by the hit sentence determination rules. However, in actual operation, the determination rules for the central sentence and the hit sentence may be different.
[0063] Embodiment 2:
[0064] Please refer to Figure 3 , Figure 3 Schematic diagram of the system for defining the context window text range of the present invention. Figure 3 A system for defining a context window text range of the present invention, comprising:
[0065] A central sentence determination module 11, wherein the central sentence determination module 11 traverses each sentence in the dialogue text and determines the first central sentence according to a central sentence determination rule;
[0066] A hit sentence determination module 12, wherein the hit sentence determination module 12 searches and determines the first hit sentence corresponding to the first central sentence in a preset text search range of the first central sentence based on a hit sentence determination rule;
[0067] The label marking module 13 defines the text range of the first semantic window according to the positions of the first central sentence and the first hit sentence, and then adds a first semantic label to the entire text within the first semantic window.
[0068] The central sentence determination rule and the hit sentence rule include:
[0069] In the dialogue text, if a central sentence label mention word appears in a dialogue text sentence of any dialogue character, and a central sentence label keyword appears or does not appear in the dialogue text sentence according to a preset rule, the dialogue text sentence is determined to be a central sentence; in the dialogue text, if a hit sentence label mention word appears in a dialogue text sentence of any dialogue character, and a hit sentence label keyword appears or does not appear in the dialogue text sentence according to a preset rule, the dialogue text sentence is determined to be a hit sentence.
[0070] The text search range includes: search direction and search sentence number.
[0071] When the hit sentence determination rule searches for the hit sentence, the window boundary is completed; if the central sentence and the hit sentence are the same sentence, the window is the central sentence.
[0072] Embodiment three:
[0073] Combination Figure 4 As shown, this embodiment discloses a specific implementation of an electronic device. The electronic device may include a processor 81 and a memory 82 storing computer program instructions.
[0074] 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.
[0075] 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 (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically alterable ROM (EAROM) 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.
[0076] 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 .
[0077] The processor 81 implements any one of the methods for defining the context window text range in the above embodiments by reading and executing the computer program instructions stored in the memory 82 .
[0078] In some of the embodiments, the electronic device may further include a communication interface 83 and a bus 80. Figure 4 As shown, the processor 81, the memory 82, and the communication interface 83 are connected via a bus 80 and communicate with each other.
[0079] 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 interface 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.
[0080] The bus 80 includes hardware, software or both, and couples the components of the electronic 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.
[0081] The electronic device can define the context window text range to achieve the combination Figure 1 Describes the method for delimiting the text scope of a context window.
[0082] In addition, in combination with the method for defining the scope of the context window text 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 a processor, any one of the methods for defining the scope of the context window text in the above embodiment is implemented.
[0083] 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.
[0084] In summary, based on the beneficial effects of the present invention, the present invention provides a method for defining the scope of context window text by using window rules that are universal, easy to use, easy to expand, and trainable and improveable.
[0085] The above-described 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 protection of the invention. 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 scope of protection of the present application. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the attached claims.
Claims
1. A method for defining a context window text range, characterized in that: include: Determine the central sentence step: traverse each sentence in the dialogue text and determine the first central sentence according to the central sentence determination rule; The step of determining a hit sentence: searching and determining the first hit sentence corresponding to the first central sentence in a preset text search range of the first central sentence based on a hit sentence determination rule; Labeling step: defining the text range of the first semantic window according to the positions of the first central sentence and the first hit sentence, and then adding a first semantic label to the entire text within the first semantic window; The central sentence determination rule and the hit sentence determination rule include: in the dialogue text, if a central sentence label mention word appears in a dialogue text sentence of any dialogue character, and a central sentence label keyword appears or does not appear in the dialogue text sentence according to a preset rule, the dialogue text sentence is determined to be a central sentence; in the dialogue text, if a hit sentence label mention word appears in a dialogue text sentence of any dialogue character, and a hit sentence label keyword appears or does not appear in the dialogue text sentence according to a preset rule, the dialogue text sentence is determined to be a hit sentence.
2. The method according to claim 1, characterized in that The text search range includes: search direction and search sentence number.
3. The method according to claim 1, characterized in that When the hit sentence determination rule searches for the hit sentence, the window boundary is completed; if the central sentence and the hit sentence are the same sentence, the window is the central sentence.
4. A system for defining a context window text range, characterized in that: include: A central sentence determination module, wherein the central sentence determination module traverses each sentence in the dialogue text and determines the first central sentence according to a central sentence determination rule; A hit sentence determination module, wherein the hit sentence determination module searches and determines a first hit sentence corresponding to the first central sentence in a preset text search range of the first central sentence based on a hit sentence determination rule; A label marking module, wherein the label marking module defines a text range of a first semantic window according to the positions of the first central sentence and the first hit sentence, and then adds a first semantic label to the entire text within the first semantic window; The central sentence determination rule and the hit sentence determination rule include: in the dialogue text, if a central sentence label mention word appears in a dialogue text sentence of any dialogue character, and a central sentence label keyword appears or does not appear in the dialogue text sentence according to a preset rule, the dialogue text sentence is determined to be a central sentence; in the dialogue text, if a hit sentence label mention word appears in a dialogue text sentence of any dialogue character, and a hit sentence label keyword appears or does not appear in the dialogue text sentence according to a preset rule, the dialogue text sentence is determined to be a hit sentence.
5. The system according to claim 4, characterized in that The text search range includes: search direction and search sentence number.
6. The system according to claim 4, characterized in that When the hit sentence determination rule searches for the hit sentence, the window boundary is completed; if the central sentence and the hit sentence are the same sentence, the window is the central sentence.
7. An electronic 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 method according to any one of claims 1 to 3 is implemented.
8. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Intention recognition method and device, electronic equipment and storage medium
CN111339781A