Grammar analysis method and device, intelligent equipment and storage medium
By entering the sentences to be parsed into a pre-trained grammar model, obtaining part-of-speech, dependent syntax and morphological features, performing grammatical analysis and generating descriptions, the problem that existing dictionary pens cannot parse grammar is solved, and the effect of learning non-native languages is improved.
Patent Information
- Application Number
- CN202311270707.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-27
- Publication Date
- 2025-03-28
AI Technical Summary
Existing dictionary pens cannot perform grammatical analysis of scanned text and cannot extract grammatical knowledge points, which limits users' ability to obtain grammatical information when learning non-native languages.
By obtaining the statement to be parsed, inputting it into the pre-trained grammar model, obtaining the grammatical results including part of speech, dependent syntax and morphological features, performing grammatical analysis based on these results, and generating a grammatical analysis description.
It realizes accurate grammatical analysis of sentences, effectively extracts grammatical knowledge points, generates easy-to-understand grammatical analysis descriptions, and improves the learning effect of users when learning non-native languages.
Smart Images

Figure CN119721018A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information processing technology, and in particular to a syntax parsing method, apparatus, intelligent device and storage medium. Background Art
[0002] As the most popular language in the world, English has attracted more and more people's attention. The education of foreign languages such as English in China has also become more popular and in-depth. Compared with learning a mother tongue, learning a non-native language will inevitably increase the difficulty. At present, in order to help users learn non-native languages, various dictionary pens have been launched on the market. Users can quickly learn the meaning of unfamiliar words by scanning them with dictionary pens.
[0003] To learn a non-native language well, it is far from enough to just learn words. However, existing dictionary pens can only translate scanned texts but cannot perform grammatical analysis, which means that users can only simply understand the meaning of words through dictionary pens but cannot learn grammatical knowledge points.
[0004] It can be seen from this that how to accurately parse the grammar in the sentence and effectively extract grammatical knowledge points is a problem that needs to be considered at present. Summary of the invention
[0005] The embodiments of the present application provide a grammar parsing method, apparatus, intelligent device and storage medium, which can accurately parse the grammar in a sentence and effectively extract grammar knowledge points.
[0006] In a first aspect, an embodiment of the present application provides a syntax parsing method, the method comprising:
[0007] Get the statement to be parsed;
[0008] Inputting the sentence to be parsed into a pre-trained grammar model to obtain a grammar result, wherein the grammar result includes the part of speech, dependency syntax and morphological features of the sentence to be parsed;
[0009] Performing grammatical analysis on the sentence to be parsed according to the part of speech, the dependency syntax and the morphological features;
[0010] Based on the parsing result, a grammatical parsing description of the sentence to be parsed is generated and output.
[0011] In a possible implementation manner of the first aspect, the step of inputting the sentence to be parsed into a pre-trained grammar model to obtain a grammar result includes:
[0012] Performing word segmentation processing on the sentence to be parsed to obtain a word segmentation result;
[0013] The word segmentation result is input into the pre-trained grammar model to obtain a grammar result including the part of speech, dependency syntax and morphological features of the sentence to be parsed.
[0014] In a possible implementation manner of the first aspect, the step of performing grammatical parsing on the sentence to be parsed according to the part of speech, the dependency syntax, and the morphological feature includes:
[0015] According to the part of speech, lexical analysis is performed on the sentence to be parsed;
[0016] Parsing the sentence type of the sentence to be parsed according to the dependency syntax;
[0017] According to the morphological features, the tense and voice of the sentence to be parsed are parsed.
[0018] In a possible implementation manner of the first aspect, the grammatical result output by the grammar model is expressed in English, and before the step of performing grammatical parsing on the sentence to be parsed according to the part of speech, the dependency syntax, and the morphological feature, the method further includes:
[0019] Translate the grammatical result into a specified language representation;
[0020] A language comparison table is generated, wherein the language comparison table includes a comparison relationship between the English identifier of the grammatical result and the designated language representation.
[0021] In a possible implementation manner of the first aspect, the grammatical parsing description is classified according to a learning level, and the step of generating and outputting the grammatical parsing description of the sentence to be parsed based on the parsing result includes:
[0022] Get the current user's learning level.
[0023] Based on the parsing result, a target grammatical parsing description of the sentence to be parsed is generated and output, wherein the target grammatical parsing description corresponds to the learning level of the current user.
[0024] In a possible implementation manner of the first aspect, the method further includes:
[0025] Acquire sentence samples, wherein the sentence samples include annotated sample sentences and unannotated sample sentences, wherein the annotated sample sentences include part-of-speech tagging, dependency syntax tagging, and morphological feature tagging of the sample sentences;
[0026] Using the sentence samples to train a multilingual pre-trained model, so that the output of the multilingual pre-trained model includes part of speech, dependency syntax, and morphological features of the sentence;
[0027] When the model loss of the multilingual pre-training model is less than or equal to a preset loss threshold, the trained grammar model is obtained.
[0028] In a second aspect, an embodiment of the present application provides a grammar parsing device, including:
[0029] A statement acquisition unit, used for acquiring the statement to be parsed;
[0030] A grammar acquisition unit, used for inputting the sentence to be parsed into a pre-trained grammar model to obtain a grammar result, wherein the grammar result includes the part of speech, dependency syntax and morphological features of the sentence to be parsed;
[0031] A grammar parsing unit, used for performing grammar parsing on the sentence to be parsed according to the part of speech, the dependency syntax and the morphological features;
[0032] A description output unit is used to generate and output a grammatical parsing description of the sentence to be parsed based on the parsing result.
[0033] In a third aspect, an embodiment of the present application provides an intelligent device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the grammatical parsing method described in the first aspect above is implemented.
[0034] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the grammatical parsing method as described in the first aspect above is implemented.
[0035] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a smart device, the smart device executes the grammatical parsing method described in the first aspect above.
[0036] In an embodiment of the present application, by obtaining a sentence to be parsed, the sentence to be parsed is input into a pre-trained grammar model to quickly obtain a grammatical result, the grammatical result includes the part of speech, dependency syntax and morphological features of the sentence to be parsed, and then the sentence to be parsed is parsed according to the part of speech, the dependency syntax and the morphological features, and then based on the result of the parsing, a grammatical parsing description of the sentence to be parsed is generated and output. The present application scheme uses a pre-trained grammar model to obtain the grammatical result of the sentence, which can improve the accuracy of the grammatical result acquisition, and then parses the sentence according to the part of speech, dependency syntax and morphological features, effectively extracts the grammatical knowledge points in the sentence, generates and outputs the grammatical parsing description for the user's reference and learning, which helps to improve the user's learning effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0038] Figure 1 It is a flow chart of the implementation of the grammar parsing method provided in the embodiment of the present application;
[0039] Figure 2 This is a specific implementation flow chart of obtaining a grammar model in the grammar parsing method provided in the embodiment of the present application;
[0040] Figure 3 It is a specific implementation flow chart of step S102 in the grammar parsing method provided in the embodiment of the present application;
[0041] Figure 4 It is a specific implementation flow chart of step S103 in the grammar parsing method provided in the embodiment of the present application;
[0042] Figure 5 It is a specific implementation flow chart of generating a language comparison table in the grammar parsing method provided in the embodiment of the present application;
[0043] Figure 6 It is a specific implementation flow chart of step S104 in the grammar parsing method provided in the embodiment of the present application;
[0044] Figure 7 is a structural block diagram of a grammar parsing device provided in an embodiment of the present application;
[0045] Figure 8 It is a schematic diagram of a smart device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0047] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0048] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0049] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0050] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0051] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0052] The grammatical parsing method provided in the embodiments of the present application can be applied to various types of smart devices and servers that need to perform grammatical parsing, specifically including mobile phones, tablet computers, wearable devices, smart dictionary pens, high-performance computers, etc.
[0053] In one possible implementation, the smart device that performs grammatical parsing supports offline parsing mode and online parsing mode. In offline parsing mode, the smart device directly implements grammatical parsing of the statement to be parsed based on the lightweight grammar model deployed by itself; while in online parsing mode, the smart device transmits the statement to be parsed to the designated server, implements grammatical parsing based on the high-performance grammar model deployed on the server, and the server then transmits the result of the grammatical parsing back to the smart device. Among them, the lightweight grammar model is a grammar model that has been compressed and simplified in terms of data volume. Deploying a lightweight grammar model on a smart device can reduce the storage space occupied by the grammar model and ensure that basic grammatical parsing can be achieved even in poor network conditions. A high-performance grammar model is a grammar model that contains a large amount of data, has undergone performance expansion, and has model rendering. In comparison, the results of grammatical parsing using a high-performance grammar model are more accurate and effective.
[0054] The switching between the offline analysis mode and the online analysis mode can be determined according to a user instruction, or the offline analysis mode and the online analysis mode can be automatically switched according to the real-time network status.
[0055] For example, in an application scenario, the grammatical parsing method provided in the embodiment of the present application is applied to a dictionary pen that supports offline mode and online mode. In the offline mode of the dictionary pen, the dictionary pen directly implements grammatical parsing based on the lightweight grammatical model deployed by itself. When the dictionary pen switches to online mode, the dictionary pen transmits the sentence to be parsed to the server, and the server implements grammatical parsing based on the high-performance grammatical model deployed by itself, and then the server transmits the result of the grammatical parsing back to the dictionary pen for user reference.
[0056] Figure 1 The implementation process of the grammar parsing method provided in the embodiment of the present application is shown, and the method flow includes steps S101 to S104. The specific implementation principle of each step is as follows:
[0057] Step S101: Obtain the statement to be parsed.
[0058] The sentence to be parsed may be an English sentence. In some implementations, the sentence to be parsed may be a sentence in another language.
[0059] In a possible implementation, text information is obtained by scanning to obtain the sentence to be parsed.
[0060] Exemplarily, a sentence on the current page is scanned using a dictionary pen, and the scanned sentence is determined as the sentence to be parsed.
[0061] In a possible implementation, more than one sentence may be scanned in one scanning process, and text information corresponding to the scanning is obtained, and the text information is segmented into sentences to obtain multiple sentences to be parsed.
[0062] Exemplarily, the dictionary pen is used to scan the current page to obtain text information of the current page, and then the text information is segmented into sentences to obtain multiple sentences to be parsed.
[0063] Step S102: input the sentence to be parsed into a pre-trained grammar model to obtain a grammar result, which includes the part of speech, dependency syntax and morphological features of the sentence to be parsed.
[0064] Among them, part of speech refers to the basis for dividing word classes; dependency syntax is used to describe the dependency relationship between words; morphological features refer to the tense and voice of sentence expression.
[0065] In this embodiment, the pre-trained grammar model is obtained by fine-tuning a multi-language pre-trained model. The multi-language pre-trained model is specifically an XLM-Roberta model. By fine-tuning the XLM-Roberta model, the part of speech, dependency syntax and morphological features of the sentence are obtained.
[0066] As a possible implementation of the present application, Figure 2 As shown, in the grammar parsing method provided in the embodiment of the present application, a specific implementation process of obtaining a grammar model specifically includes:
[0067] A1: Obtain sentence samples, wherein the sentence samples include annotated sample sentences and unannotated sample sentences, wherein the annotated sample sentences include part-of-speech tagging, dependency syntax tagging, and morphological feature tagging of the sample sentences.
[0068] A2: Using the sentence samples to train a multilingual pre-training model, so that the output of the multilingual pre-training model includes part of speech, dependency syntax, and morphological features of the sentence.
[0069] In this embodiment, training the multilingual pre-trained model is based on fine-tuning the network, which means adjusting the model parameters of the multilingual pre-trained model.
[0070] A3: When the model loss of the multilingual pre-training model is less than or equal to a preset loss threshold, the trained grammar model is obtained.
[0071] In this embodiment, the model parameters of the multilingual pre-training model are trained by minimizing the loss function, so as to improve the model training performance.
[0072] In an embodiment of the present application, the model parameters of the multilingual pre-trained model are trained using labeled samples to achieve the part of speech, dependency syntax, and morphological features of the sentences output by the multilingual pre-trained model. At the same time, the model parameters of the multilingual pre-trained model are trained using unlabeled samples to improve the accuracy of the output of the multilingual pre-trained model.
[0073] As a possible implementation of this application, Figure 3 The following is a specific implementation process of inputting the sentence to be parsed into a pre-trained grammar model to obtain a grammar result in the grammar parsing method provided in the embodiment of the present application, which is described in detail as follows:
[0074] B1: Perform word segmentation processing on the sentence to be parsed to obtain a word segmentation result.
[0075] In this embodiment, the sentence to be parsed is segmented, words and symbols are completely separated, and each segmented word corresponds to an id.
[0076] For example, take the sentence to be parsed: Who we should defeat is nobody but ourselves. Perform word segmentation on the sentence, completely separate the words and symbols, and one word segmentation corresponds to one id. The word segmentation result example is as follows:
[0077] [{'id':1,'text':'Who'},{'id':2,'text':'we'},{'id':3,'text':'should'},{'id':4,'text':'defeat'},{'id':5,'te xt':'is'},{'id':6,'text':'nobody'},{'id':7,'text':'but'},{'id':8,'text':'ourselves'},{'id':9,'text':'.'}].
[0078] B2: Input the word segmentation result into the pre-trained grammar model to obtain a grammar result including the part of speech, dependency syntax and morphological features of the sentence to be parsed.
[0079] In an embodiment of the present application, the sentence to be parsed is segmented and then input into the pre-trained grammar model to improve the efficiency of grammar model processing.
[0080] Step S103: performing grammatical analysis on the sentence to be analyzed according to the part of speech, the dependency syntax and the morphological features.
[0081] In the embodiment of the present application, the to-be-parsed sentence can be parsed using preset logical rules. In some implementations, the parsing process is mapped onto an existing syntax tree.
[0082] As a possible implementation of this application, Figure 4 A specific implementation process of performing grammatical parsing on the sentence to be parsed according to the part of speech, the dependency syntax and the morphological features in the grammatical parsing method provided in an embodiment of the present application is shown, and is described in detail as follows:
[0083] C1: performing lexical analysis on the sentence to be analyzed according to the part of speech.
[0084] C2: According to the dependency syntax, the sentence type of the sentence to be parsed is parsed. The sentence type includes clauses and clause types.
[0085] C3: parsing the tense and voice of the sentence to be parsed according to the morphological features.
[0086] In real time, this application performs grammatical analysis from three aspects: part of speech, dependency syntax, and morphological features to ensure the accuracy of the grammatical analysis results.
[0087] For example, for the sentence to be parsed, "Who we should defeat is nobody but ourselves", the dependency syntax gives the deprel result corresponding to the word defeat as "noun clause modifier", indicating that this sentence contains a noun clause. According to the dependency relationship of the modifier, the clause text can be extracted, that is, "Who we should defeat". In addition, noun clauses include subject clauses, object clauses, predicative clauses, and appositive clauses. Then, according to the logical rules, for example, based on the fact that the clause is at the beginning and followed by the be verb, it can be determined to be a "subject clause". For tense analysis, the main clause contains the be verb is, and here is is a copula, not used with gerunds, etc., it can be determined to belong to the "general present tense". For voice analysis, is is followed by a noun, which can be determined to be "active voice".
[0088] As a possible implementation of the present application, the grammatical result output by the grammar model is expressed in English, such as Figure 5 As shown, before the step of performing grammatical parsing on the sentence to be parsed according to the part of speech, the dependency syntax and the morphological features, it also includes:
[0089] D1: Translate the grammatical result into a specified language, for example, translate the grammatical result into Chinese, or translate it into another language other than English.
[0090] In some implementations, the designated language may be preset by a user. The user may set the designated language according to his or her needs.
[0091] D2: Generate a language comparison table, wherein the language comparison table includes a comparison relationship between the English identifier of the grammatical result and the designated language representation.
[0092] In an embodiment of the present application, when the sentence to be parsed is an English sentence, the grammatical result output by the above-mentioned pre-trained grammar model is expressed in English. The grammatical result is translated into a specified language expression, and a language comparison table is generated, which can ensure the accuracy and readability of the subsequent grammatical parsing description.
[0093] Step S104: Based on the parsing result, generate and output a grammatical parsing description of the sentence to be parsed.
[0094] In this embodiment, the grammatical analysis description is used to list the grammatical knowledge points involved in the sentence to be analyzed.
[0095] As a possible implementation of the present application, the grammar parsing description is classified by learning level. Figure 6 A specific implementation method of generating and outputting a grammatical parsing description of the sentence to be parsed based on the parsing result in the grammatical parsing method provided in an embodiment of the present application is shown, and is described in detail as follows:
[0096] E1: Get the learning level of the current user.
[0097] In this embodiment, the current user refers to the user who currently uses the smart device to perform syntax analysis. The learning level of the current user can be determined through the user information of the user logging into the smart device.
[0098] E2: Based on the parsing result, generate and output a target grammar parsing description of the sentence to be parsed, wherein the target grammar parsing description corresponds to the learning level of the current user.
[0099] The grammatical knowledge points to be learned at different learning levels may be different. In this embodiment, the grammatical knowledge points corresponding to each learning level are preset, and after obtaining the user's learning level, a grammatical analysis description including the grammatical knowledge points corresponding to the learning level is generated.
[0100] Taking into account the different grammatical knowledge points involved in different learning levels, this embodiment outputs the corresponding grammatical analysis description in combination with the user's learning level to help the user learn the language step by step, which can enhance the user's interest in language learning, prevent the user from giving up learning due to fear of difficulty, and thus improve the effectiveness of language learning.
[0101] As can be seen from the above, in an embodiment of the present application, by obtaining a sentence to be parsed, the sentence to be parsed is input into a pre-trained grammar model to quickly obtain a grammatical result, the grammatical result includes the part of speech, dependency syntax and morphological features of the sentence to be parsed, and then the sentence to be parsed is parsed according to the part of speech, the dependency syntax and the morphological features, and then based on the result of the parsing, a grammatical parsing description of the sentence to be parsed is generated and output. The present application scheme uses a pre-trained grammar model to obtain the grammatical result of the sentence, which can improve the accuracy of the grammatical result acquisition, and then parses the sentence according to the part of speech, dependency syntax and morphological features, effectively extracts the grammatical knowledge points in the sentence, generates and outputs the grammatical parsing description for the user's reference and learning, which helps to improve the user's learning effect.
[0102] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0103] Corresponding to the syntax parsing method described in the above embodiment, Figure 7 A structural block diagram of a grammatical parsing device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0104] Reference Figure 7 The grammar parsing device comprises: a sentence acquisition unit 71, a grammar acquisition unit 72, a grammar parsing unit 73, and a description output unit 74, wherein:
[0105] A statement acquisition unit 71, used to acquire a statement to be parsed;
[0106] A grammar acquisition unit 72, configured to input the sentence to be parsed into a pre-trained grammar model to obtain a grammar result, wherein the grammar result includes the part of speech, dependency syntax and morphological features of the sentence to be parsed;
[0107] A grammar parsing unit 73, configured to perform grammar parsing on the sentence to be parsed according to the part of speech, the dependency syntax and the morphological features;
[0108] The description output unit 74 is used to generate and output a grammatical parsing description of the sentence to be parsed based on the parsing result.
[0109] As a possible implementation of the present application, the grammar acquisition unit 72 includes:
[0110] A word segmentation processing module, used to perform word segmentation processing on the sentence to be parsed to obtain a word segmentation result;
[0111] The grammar acquisition module is used to input the word segmentation result into the pre-trained grammar model to obtain the grammar result including the part of speech, dependency syntax and morphological features of the sentence to be parsed.
[0112] As a possible implementation of the present application, the grammar parsing unit 73 includes:
[0113] A first parsing module, configured to perform lexical parsing on the sentence to be parsed according to the part of speech;
[0114] A second parsing module, used for parsing the sentence type of the sentence to be parsed according to the dependency syntax;
[0115] The third parsing module is used to parse the tense and voice of the sentence to be parsed according to the morphological features.
[0116] As a possible implementation manner of the present application, the grammatical result output by the grammar model is expressed in English, and the grammar parsing device further includes:
[0117] A language translation unit, used for translating the grammar result into a specified language representation;
[0118] The comparison table generating unit is used to generate a language comparison table, wherein the language comparison table includes a comparison relationship between the English identifier of the grammatical result and the specified language representation.
[0119] As a possible implementation of the present application, the grammatical parsing description is classified according to the learning level, and the description output unit 74 includes:
[0120] The level acquisition module is used to obtain the current user's learning level.
[0121] A description output module is used to generate and output a target grammar parsing description of the sentence to be parsed based on the result of the parsing, wherein the target grammar parsing description corresponds to the learning level of the current user.
[0122] As a possible implementation of the present application, the above-mentioned syntax parsing device further includes:
[0123] A sample acquisition unit, used to acquire sentence samples, wherein the sentence samples include annotated sample sentences and unannotated sample sentences, wherein the annotated sample sentences include part-of-speech tagging, dependency syntax tagging, and morphological feature tagging of the sample sentences;
[0124] A model training unit is used to train a multilingual pre-training model using the sentence samples so that the output of the multilingual pre-training model includes the part of speech, dependency syntax and morphological features of the sentence; when the model loss of the multilingual pre-training model is less than or equal to a preset loss threshold, the trained grammar model is obtained.
[0125] As can be seen from the above, in an embodiment of the present application, by obtaining a sentence to be parsed, the sentence to be parsed is input into a pre-trained grammar model to quickly obtain a grammatical result, the grammatical result includes the part of speech, dependency syntax and morphological features of the sentence to be parsed, and then the sentence to be parsed is parsed according to the part of speech, the dependency syntax and the morphological features, and then based on the result of the parsing, a grammatical parsing description of the sentence to be parsed is generated and output. The present application scheme uses a pre-trained grammar model to obtain the grammatical result of the sentence, which can improve the accuracy of the grammatical result acquisition, and then parses the sentence according to the part of speech, dependency syntax and morphological features, effectively extracts the grammatical knowledge points in the sentence, generates and outputs the grammatical parsing description for the user's reference and learning, which helps to improve the user's learning effect.
[0126] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0127] The present application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, Figures 1 to 6 Represents the steps of any grammar parsing method.
[0128] The embodiment of the present application also provides an intelligent device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, Figures 1 to 6 Represents the steps of any grammar parsing method.
[0129] The present application also provides a computer program product, which, when executed on a smart device, enables the smart device to execute the following Figures 1 to 6 Represents the steps of any grammar parsing method.
[0130] Figure 8 Schematic diagram of a smart device provided by an embodiment of the present application. Figure 8 As shown, the smart device 8 of this embodiment includes: a processor 80, a memory 81, and a computer program 82 stored in the memory 81 and executable on the processor 80. When the processor 80 executes the computer program 82, the steps in the above-mentioned grammar parsing method embodiments are implemented, for example Figure 1 Alternatively, when the processor 80 executes the computer program 82, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 7 The functions of the units 71 to 74 are shown.
[0131] Exemplarily, the computer program 82 may be divided into one or more modules / units, which are stored in the memory 81 and executed by the processor 80 to complete the present application. The one or more modules / units may be a series of computer-readable instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 82 in the smart device 8.
[0132] The smart device 8 may be a dictionary pen. The smart device 8 may include, but is not limited to, a processor 80 and a memory 81. Those skilled in the art will appreciate that Figure 8 It is only an example of the smart device 8 and does not constitute a limitation of the smart device 8. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the smart device 8 may also include input and output devices, network access devices, buses, etc.
[0133] The processor 80 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0134] The memory 81 may be an internal storage unit of the smart device 8, such as a hard disk or memory of the smart device 8. The memory 81 may also be an external storage device of the smart device 8, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the smart device 8. Further, the memory 81 may also include both an internal storage unit and an external storage device of the smart device 8. The memory 81 is used to store the computer program and other programs and data required by the smart device. The memory 81 may also be used to temporarily store data that has been output or is to be output.
[0135] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0136] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0137] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the device / terminal device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0138] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0139] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A syntax parsing method, characterized in that: The method comprises: Get the statement to be parsed; Inputting the sentence to be parsed into a pre-trained grammar model to obtain a grammar result, wherein the grammar result includes the part of speech, dependency syntax and morphological features of the sentence to be parsed; Performing grammatical analysis on the sentence to be parsed according to the part of speech, the dependency syntax and the morphological features; Based on the parsing result, a grammatical parsing description of the sentence to be parsed is generated and output.
2. The method according to claim 1, characterized in that The step of inputting the sentence to be parsed into a pre-trained grammar model to obtain a grammar result includes: Performing word segmentation processing on the sentence to be parsed to obtain a word segmentation result; The word segmentation result is input into the pre-trained grammar model to obtain a grammar result including the part of speech, dependency syntax and morphological features of the sentence to be parsed.
3. The method according to claim 1, characterized in that The step of performing grammatical analysis on the sentence to be analyzed according to the part of speech, the dependency syntax and the morphological features comprises: According to the part of speech, lexical analysis is performed on the sentence to be parsed; Parsing the sentence type of the sentence to be parsed according to the dependency syntax; According to the morphological features, the tense and voice of the sentence to be parsed are parsed.
4. The method according to claim 1, characterized in that: The grammatical result output by the grammatical model is expressed in English. Before the step of performing grammatical analysis on the sentence to be analyzed according to the part of speech, the dependency syntax and the morphological features, the method further includes: Translate the grammatical result into a specified language representation; A language comparison table is generated, wherein the language comparison table includes a comparison relationship between the English identifier of the grammatical result and the designated language representation.
5. The method according to claim 1, characterized in that The grammatical parsing description is classified according to the learning level, and the step of generating and outputting the grammatical parsing description of the sentence to be parsed based on the parsing result includes: Get the current user's learning level. Based on the parsing result, a target grammatical parsing description of the sentence to be parsed is generated and output, wherein the target grammatical parsing description corresponds to the learning level of the current user.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Acquire sentence samples, wherein the sentence samples include annotated sample sentences and unannotated sample sentences, wherein the annotated sample sentences include part-of-speech tagging, dependency syntax tagging, and morphological feature tagging of the sample sentences; Using the sentence samples to train a multilingual pre-trained model, so that the output of the multilingual pre-trained model includes part of speech, dependency syntax, and morphological features of the sentence; When the model loss of the multilingual pre-training model is less than or equal to a preset loss threshold, the trained grammar model is obtained.
7. A grammar analysis device, characterized in that: The device comprises: A statement acquisition unit, used for acquiring the statement to be parsed; A grammar acquisition unit, used for inputting the sentence to be parsed into a pre-trained grammar model to obtain a grammar result, wherein the grammar result includes the part of speech, dependency syntax and morphological features of the sentence to be parsed; A grammar parsing unit, used for performing grammar parsing on the sentence to be parsed according to the part of speech, the dependency syntax and the morphological features; A description output unit is used to generate and output a grammatical parsing description of the sentence to be parsed based on the parsing result.
8. The device according to claim 7, characterized in that The device also includes: A sample acquisition unit, used to acquire sentence samples, wherein the sentence samples include annotated sample sentences and unannotated sample sentences, wherein the annotated sample sentences include part-of-speech tagging, dependency syntax tagging, and morphological feature tagging of the sample sentences; A model training unit is used to train a multilingual pre-training model using the sentence samples so that the output of the multilingual pre-training model includes the part of speech, dependency syntax and morphological features of the sentence; when the model loss of the multilingual pre-training model is less than or equal to a preset loss threshold, the trained grammar model is obtained.
9. An intelligent 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 grammatical parsing method according to any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the grammatical parsing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Grammar analysis method and device, equipment and storage medium
CN113901798A
Text analysis method and device, electronic equipment and storage medium
CN115034209A
Data processing method and device and electronic equipment
CN115828929A
Deep learning creative science and technology text automatic generation method
CN116167344A
Self-adaptive word card example sentence generation method and system
CN116303879A