Sentence comparison method and apparatus, and related product

By configuring a word similarity table and comparing semantic role information, the problem of low efficiency and insufficient accuracy of sentence comparison in existing technologies is solved, achieving efficient and accurate sentence similarity calculation and adapting to the needs of different task scenarios.

WO2026158327A1PCT designated stage Publication Date: 2026-07-30HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2026-01-21
Publication Date
2026-07-30

AI Technical Summary

Technical Problem

The word mapping process in existing sentence comparison methods is an iterative and serial calculation, which leads to high computational complexity, affects efficiency, and results in insufficient accuracy.

Method used

By configuring a word similarity table and comparing semantic role information, the mapping relationship between words is determined. The similarity table is queried to quickly determine the similarity of sentences. By combining the weight and hierarchical weight of semantic role information, the accuracy and efficiency of the mapping relationship are improved.

Benefits of technology

It improves the efficiency and accuracy of sentence comparison, and refines the semantic function of words in sentences through parallel querying and processing of multi-level nested sentence structures, adapting to the user needs of different task scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2026073824_30072026_PF_FP_ABST
    Figure CN2026073824_30072026_PF_FP_ABST
Patent Text Reader

Abstract

A sentence comparison method and apparatus, and a related product, which can improve the efficiency of sentence comparison. The sentence comparison method can be applied to a sentence comparison apparatus. The apparatus is configured with a first word similarity table, wherein the first word similarity table comprises similarities between a plurality of words. In a specific implementation, the sentence comparison apparatus acquires a first sentence and a second sentence which are to be compared, and then compares semantic role information of words in the two sentences, so as to determine mapping relationships between the words in the two sentences, wherein a semantic role of a word is used for describing a semantic function borne by the word in a sentence, and the words having a mapping relationship include words having matched semantic role information; and the sentence comparison apparatus then queries a first word similarity table to obtain the similarity between the words having the mapping relationship, and then determines, on the basis of the similarity between the words having the mapping relationship, the similarity between the first sentence and the second sentence, so as to obtain a sentence comparison result.
Need to check novelty before this filing date? Find Prior Art

Description

A statement comparison method, apparatus and related products

[0001] This application claims priority to Chinese Patent Application No. 202510117240.8, filed with the State Intellectual Property Office of China on January 23, 2025, entitled "A Sentence Comparison Method, Apparatus and Related Products", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of natural language processing (NLP), and more particularly to a sentence comparison method, apparatus, and related products. Background Technology

[0003] Sentence comparison refers to the process of measuring the similarity between different sentences. By comparing sentences, the similarity between sentences can be determined. It can be applied to a variety of natural language processing tasks, such as finding the answer to a question in a question-answering system, finding the best translation result in a machine translation system, and recommending similar books to users based on their reading history in a recommendation system.

[0004] Currently, sentence comparison can be achieved as follows: Assuming the sentences to be compared include sentence A and sentence B, word segmentation can be performed on sentences A and B to obtain multiple words in sentence A and sentence B. Then, these words are converted into vectors. Next, the distance between the vector corresponding to each word in sentence A and the vector corresponding to each word in sentence B is calculated. This maps the words in sentence A to the most similar words in sentence B (i.e., words with the smallest vector distance). Based on the similarity between these mapped words, the similarity between sentences A and B is determined, thus completing the comparison process. However, the word mapping process in this method is an iterative and sequential computational process with high computational complexity, which affects the efficiency of sentence comparison. Summary of the Invention

[0005] This application provides a sentence comparison method, apparatus, and related products that can improve the efficiency of sentence comparison.

[0006] Firstly, this application provides a sentence comparison method. This method can be applied to a sentence comparison device. The sentence comparison device is equipped with a first word similarity table, which includes the similarity of multiple words. Specifically, the sentence comparison device acquires a first sentence and a second sentence to be compared, then compares the semantic role information of words in the first sentence and the semantic role information of words in the second sentence to determine the mapping relationship between the words in the first sentence and the words in the second sentence. The semantic role of a word describes the semantic function of the word in the sentence, and words with a mapping relationship include words whose semantic role information matches. Then, the first word similarity table is queried to obtain the similarity between the words with the mapping relationship. Based on the similarity between the words with the mapping relationship, the similarity between the first sentence and the second sentence is determined. Finally, based on the similarity between the first sentence and the second sentence, the sentence comparison result is obtained.

[0007] In the technical solution provided in this application, the sentence comparison device can determine the similarity between words with a mapping relationship in the first and second sentences by querying a word similarity table. Therefore, it can quickly determine the similarity between words in the first and second sentences, improving the efficiency of sentence comparison. Furthermore, since the semantic role information of words can describe the semantic function of words in a sentence, the mapping relationship between words in the first and second sentences determined by comparing semantic role information is more accurate, thereby improving the accuracy of sentence comparison.

[0008] In one possible implementation, before comparing the semantic role information of words in the first sentence and the semantic role information of words in the second sentence, the sentence comparison device further performs the following steps: based on the semantic relationship between words in the first sentence, it determines the multi-layered nested sentence structure contained in the first sentence, and determines the semantic role and corresponding level of the words in the first sentence, wherein the semantic role of a word is used to indicate the semantic function undertaken by the word in the sentence structure to which it belongs, and the level corresponding to the semantic role of a word is used to indicate the level corresponding to the sentence structure to which the word belongs.

[0009] In one possible implementation, the sentence comparison device can compare the semantic role information of words in the first sentence and the semantic role information of words in the second sentence to determine the mapping relationship between the words in the first sentence and the words in the second sentence: the sentence comparison device compares the semantic roles and corresponding levels of words in the first sentence and the semantic roles and corresponding levels of words in the second sentence to determine the mapping relationship between the words in the first sentence and the words in the second sentence, wherein words with a mapping relationship include words whose semantic roles and corresponding levels are matched.

[0010] Through the above implementation, the sentence comparison device can identify the multi-layered semantic roles of words in the first sentence, thereby refining the semantic functions that words perform in the first sentence. Therefore, the mapping relationships between words determined through this implementation are more accurate, improving the accuracy of sentence comparison.

[0011] In one possible implementation, the sentence comparison device also provides a configuration interface through which it receives user configurations. The user configurations include weights for multiple semantic roles and weights for multiple levels. The weights of semantic roles that the user is interested in are greater than the weights of other semantic roles, and the weights of the levels corresponding to the upper-level sentence structures are greater than the weights of the levels corresponding to the lower-level sentence structures.

[0012] In one possible implementation, the sentence comparison device determines the similarity between the first sentence and the second sentence based on the similarity between words with a mapping relationship, including the following steps: the sentence comparison device determines the similarity between the first sentence and the second sentence based on the similarity between words with a mapping relationship, the weight of the semantic role of the words, and the weight of the level corresponding to the sentence structure to which the words belong.

[0013] It is understandable that users may be interested in different semantic roles in different task scenarios. For example, in a scenario distinguishing interests, the semantic role of interest is the recipient, while in a scenario distinguishing whether or not someone likes something, the semantic role of interest is the predicate. Therefore, determining the semantic roles of interest based on specific task scenarios and assigning greater weight values ​​to these roles allows the sentence comparison device to focus its attention on the content that interests the user, thus improving the accuracy of the sentence comparison. Furthermore, it also enhances the applicability of the technical solution provided in this application.

[0014] In one possible implementation, the words with the mapping relationship mentioned above include one or more words in the first statement and one or more words in the second statement. The statement comparison device queries a first word similarity table to obtain the similarity between the words with the mapping relationship, including the following steps: performing a parallel query operation on the first word similarity table to obtain the similarity between each pair of words in the first statement and one or more words in the second statement; then determining the target mapping relationship between the one or more words in the first statement and one or more words in the second statement based on the query results, wherein the sum of the similarities between the words corresponding to the target mapping relationship is less than the sum of the similarities between the words corresponding to other mapping relationships, and the similarity between the one or more words in the first statement and one or more words in the second statement is the similarity corresponding to the target mapping relationship.

[0015] It is understandable that by querying the first word similarity table in parallel, the similarity between multiple words can be determined in parallel, thereby determining the target mapping relationship and the similarity corresponding to the target mapping relationship more quickly, thus improving the efficiency of sentence comparison.

[0016] In one possible implementation, the sentence comparison device is further configured with a second word similarity table, which includes the similarity of multiple words. The similarity of the words in the first and second word similarity tables can be calculated using different word embedding algorithms. Then, the sentence comparison device queries the first word similarity table to obtain the similarity between the words with the aforementioned mapping relationship, including the following steps: the sentence comparison device queries the first and second word similarity tables to obtain the similarity between the words with the aforementioned mapping relationship.

[0017] It's understandable that since the similarity between words in different word similarity tables is calculated using different word embedding algorithms, the similarity for the same pair of words may differ across different tables. Therefore, using multiple word similarity tables will result in higher accuracy in determining the similarity between words, thereby improving the accuracy of sentence comparison.

[0018] In one possible implementation, the sentence comparison device is further configured with a corpus, which includes multiple historical sample sentences and the semantic role information of the words in each historical sample sentence. Before comparing the semantic role information of the words in the first sentence and the semantic role information of the words in the second sentence, the sentence comparison device further performs the following step: obtaining the semantic role information of the words in the second sentence from the corpus.

[0019] Through the above implementation method, the sentence comparison device can directly obtain the semantic role information of words in the second sentence from the corpus. In other words, it is not necessary to obtain the semantic role information of words in the second sentence through online analysis, which improves the efficiency of sentence comparison.

[0020] Secondly, this application provides a sentence comparison device. The device is equipped with a first word similarity table, which includes the similarity of multiple words. The device includes an acquisition module, a comparison module, a query module, and a determination module. The acquisition module acquires a first sentence and a second sentence to be compared. The comparison module compares the semantic role information of words in the first sentence and the semantic role information of words in the second sentence to determine the mapping relationship between the words in the first sentence and the words in the second sentence. The semantic role of a word describes the semantic function of the word in the sentence, and words with a mapping relationship include words whose semantic role information matches. The query module queries the first word similarity table to obtain the similarity between the words with the mapping relationship. The determination module determines the similarity between the first sentence and the second sentence based on the similarity between the words with the mapping relationship, and obtains the sentence comparison result based on the similarity between the first sentence and the second sentence.

[0021] In one possible implementation, the comparison module is further used to determine the multi-layered nested sentence structure contained in the first sentence based on the semantic relationship between the words in the first sentence, and to determine the semantic roles and corresponding levels of the words in the first sentence. The semantic roles of the words are used to indicate the semantic functions undertaken by the words in the sentence structure to which they belong, and the levels corresponding to the semantic roles of the words are used to indicate the levels corresponding to the sentence structure to which the words belong.

[0022] In one possible implementation, the comparison module is used to compare the semantic roles and corresponding levels of words in the first statement and the semantic roles and corresponding levels of words in the second statement to determine the mapping relationship between the words in the first statement and the words in the second statement. The words with the mapping relationship include words whose semantic roles and corresponding levels are matched.

[0023] In one possible implementation, the sentence comparison device further includes a configuration module. The configuration module provides a configuration interface and receives user configurations through this interface. The user's configuration includes weights for multiple semantic roles and weights for multiple levels, wherein the weight of semantic roles of interest to the user is greater than the weights of other semantic roles, and the weight of the level corresponding to the upper-level sentence structure is greater than the weight of the level corresponding to the lower-level sentence structure.

[0024] In one possible implementation, the determining module is used to determine the similarity between the first and second statements based on the similarity between words with mapping relationships, the weight of the semantic roles of the words, and the weight of the level corresponding to the sentence structure to which the words belong.

[0025] In one possible implementation, the words with the mapping relationship mentioned above include one or more words in the first statement and one or more words in the second statement. The query module performs parallel query operations on the first word similarity table to obtain the similarity between each pair of words in the first statement and one or more words in the second statement. Then, based on the query results, it determines the target mapping relationship between the one or more words in the first statement and one or more words in the second statement. The sum of the similarities between words corresponding to the target mapping relationship is less than the sum of the similarities between words corresponding to other mapping relationships. The similarity between one or more words in the first statement and one or more words in the second statement is the similarity corresponding to the target mapping relationship.

[0026] In one possible implementation, the sentence comparison device is further configured with a second word similarity table, which includes the similarity of multiple words. The similarity of multiple words in the first and second word similarity tables is calculated using different word embedding algorithms. The query module is used to query the first word similarity table to obtain the similarity between the words with the above-mentioned mapping relationship, including the following steps: the sentence comparison device queries the first and second similarity tables to obtain the similarity between the words with the above-mentioned mapping relationship.

[0027] In one possible implementation, the sentence comparison device is further configured with a corpus, which includes multiple historical sample sentences and semantic role information of words in each historical sample sentence. The comparison module is also used to obtain semantic role information of words in a second sentence from the corpus.

[0028] Thirdly, this application provides a computing device. The computing device includes a processor and a memory, the processor executing instructions stored in the memory to cause the computing device to perform some or all of the methods described in the first aspect and any implementation thereof.

[0029] Fourthly, this application provides a computing device cluster. The computing device cluster includes at least one computing device, each computing device including a processor and a memory. The processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, causing the computing device cluster to perform some or all of the methods described in the first aspect and any implementation thereof.

[0030] Fifthly, this application provides a computer program product containing instructions. This computer program product may be a software or program product containing instructions that can run on a computing device or be stored on any usable medium. When the computer program product is run on a computing device, it causes the computing device to perform some or all of the methods described in the first aspect and any implementation thereof.

[0031] Sixthly, this application provides a computer-readable storage medium. The computer storage medium includes computer program instructions that, when executed by a computing device, cause the computing device to perform some or all of the methods described in the first aspect and any implementation thereof. Attached Figure Description

[0032] Figure 1 is a schematic diagram of a sentence comparison scenario provided in this application;

[0033] Figure 2 is a schematic diagram of an application scenario provided in this application;

[0034] Figure 3 is a flowchart illustrating a sentence comparison method provided in this application;

[0035] Figure 4 is a schematic diagram illustrating an example of determining the mapping relationship between words provided in this application;

[0036] Figure 5 is a schematic diagram of another example of determining the mapping relationship between words provided in this application;

[0037] Figure 6 is a schematic diagram of another example of determining the mapping relationship between words provided in this application;

[0038] Figure 7 is a schematic diagram of another example of determining the mapping relationship between words provided in this application;

[0039] Figure 8 is a structural schematic diagram of a sentence comparison device provided in this application;

[0040] Figure 9 is a schematic diagram of the structure of a computing device provided in this application;

[0041] Figure 10 is a schematic diagram of the structure of a computing device cluster provided in this application;

[0042] Figure 11 is a schematic diagram of another computing device cluster provided in this application. Detailed Implementation

[0043] To address the problem of low efficiency in sentence comparison, this application provides a sentence comparison method. This method can be applied to a sentence comparison device. Specifically, for a first sentence and a second sentence to be compared, the sentence comparison device can determine the semantic role information of multiple words in the first sentence and multiple words in the second sentence. By comparing the semantic role information of words in the first sentence and the second sentence, the mapping relationship between the words in the first sentence and the words in the second sentence is determined. Words with a mapping relationship include words with matching semantic role information. Then, by querying a word similarity table configured in the sentence comparison device, the similarity between the aforementioned words with a mapping relationship is determined, thereby obtaining the similarity between the first sentence and the second sentence, thus completing the comparison of the first and second sentences. In the above scheme, the sentence comparison device can complete the comparison between sentences without performing word embedding calculations and vector similarity calculations, improving the efficiency of sentence comparison. On the other hand, since the semantic role of a word describes the semantic function of the word in a sentence, the mapping relationship between words can be accurately determined through the comparison of semantic roles, improving the accuracy of sentence comparison.

[0044] The technical solution provided in this application will be described below with reference to the accompanying drawings.

[0045] Referring to Figure 1, Figure 1 shows a schematic diagram of a sentence comparison scenario to which this application applies. As shown in Figure 1, the scenario includes a client 100 and a sentence comparison device 200, wherein the client 100 and the sentence comparison device 200 can be connected via a network, which can be a wide area network or a local area network.

[0046] Client 100 is used to realize human-computer interaction. It can be deployed on terminal devices, which can include smartphones, tablets, laptops, desktops, augmented reality (AR) devices, virtual reality (VR) devices, wearable devices, handheld devices, all-in-one handheld consoles, smart conferencing devices, smart advertising devices, smart home appliances, etc.

[0047] In a specific implementation, client 100 can be software or application (APP) running on a terminal device controlled by the user, such as a personal computer (PC) client, APP client, etc., or a World Wide Web (web) client accessed through a browser, or a console of a cloud management platform, etc.

[0048] The statement comparison device 200 is used to compare statements. Specifically, a user can initiate a statement comparison request to the statement comparison device 200 through the client 100. Accordingly, the statement comparison device 200 determines the first and second statements to be compared based on the received statement comparison request. The statement comparison device 200 also performs semantic role labeling (SRL) on the first and second statements to obtain the semantic role information of multiple words in the first and second statements. The semantic role information of the words describes the semantic function of the words in the statement. Then, based on the semantic role information of multiple words in the first and second statements, the statement comparison device 200 determines the mapping relationship between the words in the first and second statements. Words with a mapping relationship include words whose semantic role information matches. Subsequently, the sentence comparison device 200 determines the similarity between the words with the mapping relationship by querying at least one word similarity table configured locally, and then determines the similarity between the first sentence and the second sentence based on the similarity between the words with the mapping relationship, thereby obtaining the sentence comparison result.

[0049] In practice, the statement comparison device 200 can be deployed on a single computing device or a cluster of computing devices consisting of multiple computing devices. The computing device can be a server, such as a central server or edge server in a cloud data center or a local server in a local data center, or it can be a desktop computer, laptop computer or other terminal device.

[0050] As one possible implementation, as shown in Figure 2, the client 100 is deployed on the user's terminal device, and the statement comparison device 200 is deployed on a server in a data center. In this case, the statement comparison device 200 can be provided to the user as a cloud service based on the basic resources (including computing resources, storage resources, network resources, etc.) provided by the data center. Accordingly, the user can purchase the aforementioned cloud service on a cloud management platform. After successful purchase, the user can request the statement comparison device 200 to perform comparisons of multiple statements through the client 100. Furthermore, the statement comparison device 200 can also present the statement comparison results to the user through the client 100.

[0051] Next, referring to the flowchart of the statement comparison method shown in Figure 3, the process of statement comparison by the above-mentioned statement comparison device 200 is described in more detail.

[0052] Step 301: Client 100 sends a statement comparison request to statement comparison device 200. Correspondingly, statement comparison device 200 receives the statement comparison request sent by client 100.

[0053] A statement comparison request is used to instruct a comparison operation to be performed on at least two statements, where the at least two statements include the first statement and the second statement. It is worth noting that the statements to be compared may include other statements besides the first and second statements. For ease of description, the following embodiment uses the comparison of the first and second statements as an example.

[0054] Step 302: The statement comparison device 200 obtains the first statement and the second statement according to the statement comparison request.

[0055] In its specific implementation, the sentence comparison device 200 is equipped with a corpus, which includes multiple historical sample sentences, including a second sentence. The sentence comparison request can include a first sentence and an identifier for the second sentence. The identifier for the second sentence includes the identifier of the corpus, which can be the name, number, or other information indicating the corpus. Optionally, the identifier for the second sentence can also include filtering conditions. Therefore, the sentence comparison device 200 can obtain the identifiers of the first and second sentences by parsing the sentence comparison request. Then, based on the identifier of the second sentence, it filters the second sentence from the multiple historical sample sentences contained in the corpus. The second sentence can be a randomly selected historical sample sentence or a historical sample sentence queried based on the filtering conditions. Thus, the sentence comparison device 200 can obtain both the first and second sentences.

[0056] It is worth noting that, in addition to the above methods, the sentence comparison device 200 can also obtain the first sentence and the second sentence in other ways. For example, when the sentence comparison request includes the first sentence and the second sentence, the sentence comparison device 200 can directly obtain the first sentence and the second sentence by parsing the sentence comparison request. This application does not limit this, but for ease of description, the following embodiments will be described using the example that the second sentence is a historical sample sentence obtained from the corpus.

[0057] Step 303: The sentence comparison device 200 determines the semantic role information of multiple words in the first sentence and the semantic role information of multiple words in the second sentence.

[0058] Semantic role information of words describes the semantic function that a word performs in a sentence. For the sake of brevity, we will take a word from the first sentence (hereinafter referred to as the "target word") as an example to introduce the semantic role information of a word.

[0059] The semantic role information of the target word includes one or more semantic roles of the target word. Optionally, the semantic role information of the target word may also include the hierarchy corresponding to each semantic role of the target word. Each semantic role of the target word indicates the semantic function undertaken by the target word within a sentence structure, and the hierarchy corresponding to each semantic role of the target word indicates the hierarchy of the sentence structure to which the target word belongs. Here, sentence structure refers to the hierarchical relationship and structural construction between words in a sentence.

[0060] For example, the above sentence structure can be a "predicate-argument" structure, where the predicate is a word in the sentence that expresses an action, state, or relationship, and the argument is a word in the sentence that is associated with the predicate. For example, it can include one or more of the following categories: agent, patient, time, place, instrument, etc. Here, the agent is a word in the sentence that expresses the entity that performs the action, causes a change in state, or plays a dominant role in the relationship; the patient is a word in the sentence that expresses the entity that receives the action, experiences a change in state, or is in a passive position in the relationship; time is a word in the sentence that expresses the time when the action, state, or relationship occurs; place is a word in the sentence that expresses the location where the action, state, or relationship occurs; and instrument is a word in the sentence that expresses the tool used to perform the action.

[0061] When the sentence structure is a "predicate-argument" structure, the sentence structure contained in the first sentence depends on the number of predicates in the first sentence. Specifically, when the first sentence includes only one predicate, it includes only one sentence structure; when the first sentence includes multiple predicates, it includes multiple sentence structures, which may have nested and / or parallel relationships. Nesting refers to a sentence structure (hereinafter referred to as the "upper-level sentence structure") containing another sentence structure (hereinafter referred to as the "lower-level sentence structure"), where the lower-level sentence structure can be the sentence structure corresponding to a certain argument in the upper-level sentence structure. Parallel relationships mean that the sentence structures are independent of each other. Sentence structures with nested relationships have different levels, while sentence structures with parallel relationships have the same level.

[0062] It is worth noting that, in addition to the "predicate-argument" structure, the above sentence structure can also have other forms, such as the common sentence structure of "subject-verb-object" or "subject-linking verb-complement", or the sentence structure customized by the user based on the needs of the sentence comparison task. This application does not limit this, but for ease of description, the following embodiments will all be introduced using the "predicate-argument" structure as an example.

[0063] It is understandable that the semantic role information of other words in the first sentence and the semantic role information of multiple words in the second sentence can be understood by referring to the relevant description of the semantic role information of the target word mentioned above. For the sake of brevity, it will not be elaborated here.

[0064] In its specific implementation, the sentence comparison device 200 can determine the semantic role information of multiple words in the first sentence through the following sub-steps:

[0065] Step 1): The sentence comparison device 200 performs word segmentation processing on the first sentence to obtain the word segmentation result.

[0066] Specifically, the sentence comparison device 200 has a built-in word segmentation tool. This word segmentation tool can be an existing tool in the industry that can perform word segmentation well, such as JieBa or spaCy. Therefore, the sentence comparison device 200 can input the first sentence into the word segmentation tool, which will then analyze the grammatical structure of the first sentence and the contextual information of the words in the first sentence. Based on the analysis results, the tool will perform word segmentation processing on the first sentence to divide it into multiple words, obtaining the word segmentation result. The word segmentation result includes multiple words obtained from the segmentation, and each word can be composed of one or more characters.

[0067] Step 2) The sentence comparison device 200 performs stop word removal processing on the word segmentation results to obtain the filtering results.

[0068] Specifically, the sentence comparison device 200 calculates the term frequency (TF) and inverse document frequency (IDF) of each word in the segmentation result. The TF reflects the frequency of the word's occurrence in the first sentence, while the IDF reflects the rarity of the word's occurrence in the corpus. Next, the sentence comparison device 200 calculates the product of the TF and IDF for each word to obtain its TF-IDF value. Then, based on the TF-IDF value of each word, it performs stop word removal processing on the segmentation result to obtain a filtered result. This filtered result includes multiple words, each with a TF-IDF value greater than a first threshold, which can be set by the user or by the sentence comparison device 200.

[0069] It's understandable that a smaller TF value indicates that the word appears infrequently in the first sentence; a smaller IDF value indicates that the word appears more frequently in other sentences. Therefore, a smaller TF-IDF value indicates that the word is less important in the first sentence, meaning it's a stop word, and removing it has less impact on the comparison between the first and second sentences.

[0070] In addition to the above methods, the sentence comparison device 200 can also remove stop words from the word segmentation results in other ways, such as removing stop words based on a predefined stop word list or based on word frequency, etc., which are not limited in this application.

[0071] Step 3) The sentence comparison device 200 performs semantic role labeling on multiple words contained in the filtering result to obtain the semantic role information of the above multiple words.

[0072] Specifically, the sentence comparison device 200 performs semantic role labeling on the multiple words contained in the filtering result based on their semantic relationships, obtaining a semantic role label for each word. The semantic role label indicates the semantic role information of the word and can be represented using one or more of numbers, characters, and text. It should be noted that each word can have one or more semantic role labels, and each label indicates a semantic role for that word. Optionally, it can also indicate the level corresponding to that semantic role.

[0073] More specifically, the sentence comparison device 200 identifies at least one predicate in the filtering result, and then determines a first predicate and at least one first argument associated with the first predicate based on the semantic relationship between the identified predicate and other words in the filtering result. The first predicate is the core predicate in the filtering result, i.e., the action, state, or relationship that the first sentence mainly intends to express. Any one of the at least one first argument can include one or more words. Next, the sentence comparison device 200 determines the first semantic role label of the first predicate and the words in each first argument based on the semantic relationship between the first predicate and at least one first argument. The first semantic role label is used to indicate the semantic role of the word in the first-level sentence structure (i.e., the sentence structure corresponding to the filtering result). When the filtering result includes only one predicate, the above steps can complete the semantic role labeling of multiple words contained in the filtering result. Conversely, when the filtering result includes multiple predicates, the sentence comparison device 200 also needs to determine the first argument containing the predicate, and then perform semantic role labeling on the words in the first argument containing the predicate again to obtain the second semantic role label of the words in the first argument. The second semantic role label is used to indicate the semantic role of the word in the second-level sentence structure (i.e., the sentence structure corresponding to the first argument). This process continues until the sentence comparison device 200 performs semantic role labeling on all words in the sentence structure containing all predicates in the filtering result. Thus, the semantic role information of each word in the filtering result can be obtained.

[0074] Taking a first argument containing a predicate as an example, the process of "performing semantic role labeling on words in the first argument containing a predicate" involved in the above steps will be described in more detail: The statement comparison device 200 determines at least one predicate contained in the first argument, and then, based on the semantic relationship between the determined predicate and other words in the first argument, determines the second predicate and at least one second argument associated with the second predicate. The second predicate is the core predicate in the first argument, that is, the action, state, or relationship that the first argument mainly intends to express. Any second argument in the at least one second argument can include one or more words. Afterwards, the statement comparison device 200 determines the second semantic role label of the second predicate and the words in each second argument based on the semantic relationship between the second predicate and the at least one second argument. When the first argument contains only one predicate, the semantic role labeling of the words in the first argument can be completed through the above steps. Conversely, when the first argument contains multiple predicates, the statement comparison device 200 also needs to determine the second arguments containing the predicates, and then perform semantic role labeling on the words in the second arguments containing the predicates again. This process continues until the sentence comparison device 200 performs semantic role labeling on all words in the sentence structure containing all predicates in the first argument.

[0075] It is understandable that the specific implementation process of "performing semantic role labeling on words in the second argument containing the predicate" can refer to the specific implementation process of "performing semantic role labeling on words in the first argument containing the predicate". For the sake of brevity, it will not be described in detail here.

[0076] As one possible implementation, the statement comparison device 200 can use a neural network model to perform step 3) above, that is: the statement comparison device 200 inputs the filtering results into the neural network model, and after processing by the neural network model, obtains the semantic role information of the first statement. The aforementioned neural network model can be an existing neural network model capable of accurately implementing semantic role labeling, such as a bidirectional long short-term memory network (BiLSTM) or a graph neural network (GNN). Alternatively, the aforementioned neural network model can be a neural network model trained based on a user-configured semantic role labeling template, and the specific training process is as follows:

[0077] The sentence comparison device 200 provides a configuration interface, which can be implemented through an application programming interface (API) or a graphical user interface (GUI). The configuration interface displays multiple candidate semantic role annotation templates, each corresponding to a semantic role annotation method. The semantic role annotation method defines which words in the sentence need to be annotated with semantic roles and the specific annotation content. The configuration interface also displays multiple training sentences, which can include historical sample sentences from a corpus or sentences uploaded by the user; this application does not impose any limitations on this. Through the configuration interface, the user can determine a suitable semantic role annotation template according to business needs and add semantic role labels to the words in each training sentence based on the template, obtaining the semantic role information of each training sentence, and thus obtaining a training dataset. The training dataset includes multiple training data sets, each including a training sentence and its semantic role information. Correspondingly, the sentence comparison device 200 receives the user's configuration operation through the configuration interface and obtains the training dataset based on the user's configuration operation.

[0078] Subsequently, the sentence comparison device 200 trains the initial neural network model using the aforementioned training dataset. This initial neural network model can be a convolutional neural network (CNN) model, a recurrent neural network (RNN) model, or a deep learning model based on a self-attention mechanism. During training, the sentence comparison device 200 can input training sentences into the initial neural network model in batches. After acquiring the training sentences, the initial neural network model performs semantic role labeling on the words in the training sentences to obtain predicted semantic role information for the training sentences. Then, it updates the parameters of the initial neural network model based on the difference between the predicted semantic role information and the actual semantic role information of the training sentences (i.e., the loss value). The training of the aforementioned neural network model is a repetitive iterative process. Each iteration performs semantic role labeling on the words in different training sentences and obtains the corresponding loss value. The goal of multiple iterations is to continuously update the parameters of the neural network model, finding the parameter configuration that minimizes the loss value or approaches stability, thereby completing the training of the neural network model.

[0079] To facilitate understanding of steps 1) to 3) above, three more examples will be provided below:

[0080] Example 1) Suppose the first statement is "I liked football when I was a child". After performing word segmentation and stop word removal on this statement, the filtered result includes the following words: "I", "when I was a child", "like", and "football". In the above filtered result, the first predicate is "like", the first arguments include "I", "when I was a child", and "football", and the sentence structure formed by the first predicate and the first arguments (hereinafter referred to as "sentence structure a") is the sentence structure corresponding to "I liked football when I was a child". Since the semantic relationship between "like" and "I" is the relationship between the predicate and the agent, the semantic relationship between "like" and "when I was a child" is the relationship between the predicate and the time when the action it indicates occurs, and the semantic relationship between "like" and "football" is the relationship between the predicate and the patient, the first semantic role label of "I" is used to indicate that the word is the agent in sentence structure a, the first semantic role label of "when I was a child" is used to indicate that the word is the word indicating the time when the action occurs in sentence structure a, the first semantic role label of "like" is used to indicate that the word is the predicate in sentence structure a, and the first semantic role label of "football" is used to indicate that the word is the patient in sentence structure a. Since the above filtering results only include one predicate, each word in the filtering results has only one semantic role label, namely: the first semantic role label of "I", the first semantic role label of "when I was a child", the first semantic role label of "like", and the first semantic role label of "football".

[0081] Example 2) Suppose the first statement is "I liked playing football when I was a child". After performing word segmentation and stop word removal on this statement, the filtered result includes the following words: "I", "when I was a child", "like", "play", and "football". In the above filtered result, the first predicate is "like", and the first arguments include "I", "when I was a child", and "play football". The sentence structure formed by the first predicate and the first arguments (hereinafter referred to as "sentence structure b") is the sentence structure corresponding to "I liked playing football when I was a child". Since the semantic relationship between "like" and "I" is the relationship between the predicate and the agent, the semantic relationship between "like" and "when I was a child" is the relationship between the predicate and the time when the action it indicates occurs, and the semantic relationship between "like" and "play football" is the relationship between the predicate and the patient. Therefore, the first semantic role label of "I" indicates that the word is the agent in sentence structure b; the first semantic role label of "when I was a child" indicates that the word is the word indicating the time of the action in sentence structure b; the first semantic role label of "like" indicates that the word is the predicate in sentence structure b; the first semantic role label of "kick" indicates that the word is the patient in sentence structure b; and the first semantic role label of "football" indicates that the word is the patient in sentence structure b. Furthermore, since the predicates in the above filtering results include not only "like" but also "kick," analyzing the above three first arguments determines that "kicking football" includes the predicate "kick," and thus determines that the second predicate is "kick," the second argument is "football," and the sentence structure formed by the second predicate and the second argument (hereinafter referred to as "sentence structure c") is the sentence structure corresponding to "kicking football." In the above sentence structure, the semantic relationship between "kick" and "football" is that of a predicate and its object. Therefore, the second semantic role label of "kick" indicates that it is the predicate in sentence structure c, and the second semantic role label of "football" indicates that it is the object in sentence structure c. In summary, the semantic role information of the words in the first sentence includes: the first semantic role label of "I", the first semantic role label of "when I was little", the first semantic role label of "like", the first and second semantic role labels of "kick", and the first and second semantic role labels of "football".

[0082] Example 3) Suppose the first statement is "When I was a child, I liked to play football and basketball." After performing word segmentation and stop word removal on this statement, the filtered result includes the following words: "I," "when I was a child," "like," "kick," "football," "play," and "basketball." In the above filtered result, the first predicate is "like," and the first arguments include "I," "when I was a child," "kick football," and "play basketball." The sentence structure formed by the first predicate and the first arguments (hereinafter referred to as "sentence structure d") is the sentence structure corresponding to "When I was a child, I liked to kick football and play basketball." Since the semantic relationship between "like" and "I" is the relationship between the predicate and the agent, the semantic relationship between "like" and "when I was a child" is the relationship between the predicate and the time when the action it indicates occurs, the semantic relationship between "like" and "kick football" is the relationship between the predicate and the patient, and the semantic relationship between "like" and "play basketball" is the relationship between the predicate and the patient. Therefore, the first semantic role label of "I" indicates that the word is the agent in sentence structure d; the first semantic role label of "when I was a child" indicates that the word is the word indicating the time of the action in sentence structure d; the first semantic role label of "like" indicates that the word is the predicate in sentence structure d; and the first semantic role labels of "kick," "football," "hit," and "basketball" all indicate that the above words are the objects in sentence structure d. Furthermore, since the predicates in the above filtering results include not only "like" but also "kick" and "hit," analyzing the above four first arguments determines that "kicking football" includes the predicate "kick," and "playing basketball" includes the predicate "hit." For the sentence "play football", the second predicate is "kick", and the second argument is "football". The sentence structure formed by the second predicate and the second argument (hereinafter referred to as "sentence structure e") is the sentence structure corresponding to "play football". In this sentence structure, the semantic relationship between "kick" and "football" is the relationship between predicate and object. Therefore, the second semantic role label of "kick" is used to indicate that this word is the predicate in sentence structure e, and the second semantic role label of "football" is used to indicate that this word is the object in sentence structure e. For the sentence "play basketball", the second predicate is "play", and the second argument is "basketball". The sentence structure formed by the second predicate and the second argument (hereinafter referred to as "sentence structure f") is the sentence structure corresponding to "play basketball". In this sentence structure, the semantic relationship between "play" and "basketball" is the relationship between predicate and object. Therefore, the second semantic role label of "play" is used to indicate that this word is the predicate in sentence structure f, and the second semantic role label of "basketball" is used to indicate that this word is the object in sentence structure f.In summary, the semantic role information of words in the first sentence includes: the first semantic role label of "I", the first semantic role label of "when I was a child", the first semantic role label of "like", the first and second semantic role labels of "kick", the first and second semantic role labels of "football", the first and second semantic role labels of "hit", and the first and second semantic role labels of "basketball".

[0083] The above text details the process by which the sentence comparison device 200 determines the semantic role information of multiple words in the first sentence. Similarly, the process by which the sentence comparison device 200 determines the semantic role information of multiple words in the second sentence is similar to the process by which the sentence comparison device 200 determines the semantic role information of multiple words in the first sentence. For details, please refer to steps 1) to 3) above. For the sake of brevity, it will not be elaborated here.

[0084] As one possible implementation, the aforementioned corpus, in addition to including multiple historical example sentences, may also include semantic role information for each historical example sentence. The process of determining the semantic role information for each historical example sentence in the corpus is similar to the process of determining the semantic role information for the first sentence, and for simplicity, it will not be described in detail here. Furthermore, the process of determining the semantic role information for each historical example sentence in the corpus can be completed offline by the sentence comparison device 200. In this way, the sentence comparison device 200 can directly obtain the semantic role information of the second sentence from the corpus, improving the comparison efficiency between the first and second sentences.

[0085] Step 304: The sentence comparison device 200 determines the mapping relationship between the words in the first sentence and the words in the second sentence based on the semantic role information of multiple words in the first sentence and the semantic role information of multiple words in the second sentence.

[0086] Among them, words with mapping relationships include words whose semantic role information is matched. Since the semantic role information of a word includes the word's semantic role and its corresponding level, words with semantic role information matched refer to words whose semantic role and corresponding level are both matched. In other words, words with mapping relationships include words whose semantic role and corresponding level are both matched.

[0087] In a specific implementation, the sentence comparison device 200 can determine the level corresponding to the semantic role of multiple words in the first sentence based on the semantic role information of multiple words in the first sentence, and determine the level corresponding to the semantic role of multiple words in the second sentence based on the semantic role information of multiple words in the second sentence. The sentence comparison device 200 compares the semantic roles and corresponding levels of multiple words in the first sentence and the semantic roles and corresponding levels of multiple words in the second sentence to determine the mapping relationship between the words in the first sentence and the words in the second sentence.

[0088] As one possible implementation, since the semantic role information of words can be represented by semantic role tags, the sentence comparison device 200 can directly determine the mapping relationship between words in the first sentence and words in the second sentence by comparing the semantic role tags of multiple words in the first sentence and the semantic role tags of multiple words in the second sentence. The specific process is as follows:

[0089] Step 1): The sentence comparison device 200 compares the first semantic role labels of words in the first sentence with the first semantic role labels of words in the second sentence, and determines the words that match the first semantic role labels. There is a mapping relationship between the words that match the first semantic role labels.

[0090] Specifically, taking the first semantic role label of a word in the first sentence (hereinafter referred to as "word a") as an example, the sentence comparison device can compare the first semantic role label of word a with the first semantic role labels of multiple words in the second sentence. If the first semantic role label of one or more words in the second sentence (hereinafter referred to as "word b") matches the first semantic role label of word a, it indicates that there is a mapping relationship between word a and the aforementioned one or more words b. Here, matching of first semantic role labels means that the similarity between the first semantic role labels is greater than a similarity threshold, which can be set by the user or by the sentence comparison device 200. Conversely, if the first semantic role labels of all words in the second sentence do not match the first semantic role label of word a, it indicates that there is no word in the second sentence that has a mapping relationship with word a.

[0091] As mentioned above, semantic role labels for words can be represented using one or more of numbers, characters, and text. Therefore, the sentence comparison device 200 can also implement the "comparison between first semantic role labels" involved in the above steps in various ways. For example, when the first semantic role labels are represented using numbers and / or characters, the sentence comparison device 200 can use string comparison to compare the first semantic role labels. When the first semantic role labels are represented using one or more methods including text, the sentence comparison device 200 can first convert the first semantic role labels into vectors, and then calculate the distance between the vectors to achieve the comparison between the first semantic role labels.

[0092] The first semantic role labels of other words in the first statement can also be compared with the first semantic role labels of multiple words in the second statement in the same way as described above. This way, the words that match the first semantic role labels in the first and second statements can be obtained.

[0093] Furthermore, considering that multiple words in the first statement may have the same first semantic role label, after obtaining the matching relationship between the first semantic role label of each word in the first statement and the first semantic role label of each word in the second statement, the statement comparison device 200 can also determine the words in the first statement that have the same first semantic role label by comparing the first semantic role labels of multiple words in the first statement. This determines that the words matched by the first semantic role label include multiple words in the first statement and one or more words in the second statement. In other words, there is a mapping relationship between the words determined above. For example, assuming that words a and c in the first statement have the same first semantic role label, the statement comparison device 200 can determine that the first semantic role label of word b in the second statement matches the first semantic role labels of words a and c by performing a first semantic role label comparison operation. Therefore, for this first semantic role label, the matched words include words a, b, and c. In other words, there is a mapping relationship between words a, b, and c.

[0094] Step 2): The sentence comparison device 200 determines whether the words matched by the first semantic role tag meet the target conditions. If the target conditions are met, then step 3 is executed.

[0095] The target condition is: including at least one first word and at least one second word, wherein the first word is a word in the first statement that has a second semantic role label, and the second word is a word in the second statement that has a second semantic role label.

[0096] Step 3) The sentence comparison device 200 compares the second semantic role tags of at least one first word and at least one second word to determine the words that match the second semantic role tags, wherein there is a mapping relationship between the words that match the second semantic role tags.

[0097] It is understandable that the specific implementation process of this step can be found in step 1) above, and for the sake of brevity, it will not be described in detail here. In addition, it should be noted that there may be one or more words in the first and second sentences that have three or more semantic role tags. If the first and second semantic role tags of the above words match, then the other semantic role tags of the above words can be compared to determine the words with mapping relationships in the first and second sentences in a more granular way. The specific process is similar to step 3) above, and for the sake of brevity, it will not be described in detail here either.

[0098] To better understand the process of "identifying the words with a mapping relationship between the first and second statements" described in steps 1) to 3) above, four more examples will be provided below:

[0099] Example 1) The first statement is "I like football", and the second statement is "I like basketball".

[0100] As shown in Figure 4, the first statement includes "I", "like", and "football". These three words only have first semantic role labels, which indicate that they are the agent, predicate, and patient in the sentence structure corresponding to "I like football". The second statement includes "I", "like", and "basketball". These three words only have first semantic role labels, which indicate that they are the agent, predicate, and patient in the sentence structure corresponding to "I like basketball".

[0101] By comparing the first semantic role labels of three words in the first statement and the first semantic role labels of three words in the second statement, it can be determined that there are three pairs of words with a mapping relationship between the first statement and the second statement: "I" in the first statement and "I" in the second statement, "like" in the first statement and "like" in the second statement, and "football" in the first statement and "basketball" in the second statement.

[0102] Example 2) The first statement is "I like football, basketball and badminton", and the second statement is "I like basketball and badminton".

[0103] As shown in Figure 5, the first statement includes "I", "like", "football", "basketball", and "badminton". The first semantic role label of each of these words indicates that they are the agent, predicate, patient, and object in the sentence structure corresponding to "I like football, basketball, and badminton". The second statement includes "I", "like", "basketball", and "badminton". The semantic role label of each of these words indicates that they are the agent, predicate, patient, and object in the sentence structure corresponding to "I like basketball and badminton".

[0104] By comparing the first semantic role labels of the five words in the first statement with the first semantic role labels of the four words in the second statement, it can be determined that there are three pairs of words with a mapping relationship between the first statement and the second statement: "I" in the first statement and "I" in the second statement, "like" in the first statement and "like" in the second statement, and "football", "basketball", and "badminton" in the first statement and "basketball" and "badminton" in the second statement.

[0105] Example 3) The first statement is "I like football", and the second statement is "I like playing basketball".

[0106] As shown in Figure 6, the first sentence includes three words: "I", "like", and "football". The first semantic role labels of these three words are used to indicate that they are the agent, predicate, and patient in the sentence structure corresponding to "I like football".

[0107] The second sentence includes "I", "like", "play", and "basketball". The words "I" and "like" each have one semantic role label, while "play" and "basketball" each have two semantic role labels. Specifically, the first semantic role labels for "I" and "like" indicate that they are the agent and predicate in the sentence structure corresponding to "I like playing basketball", respectively. The first semantic role labels for "play" and "basketball" indicate that they are the patient in the sentence structure corresponding to "I like playing basketball", respectively. The second semantic role labels indicate that they are the predicate and patient in the sentence structure corresponding to "play basketball", respectively.

[0108] By comparing the first semantic role tags of the three words in the first statement with the first semantic role tags of the four words in the second statement, it can be determined that the words matching the first semantic role tags include three pairs: "I" in the first statement and "I" in the second statement; "like" in the first statement and "like" in the second statement; "football" in the first statement and "play" and "basketball" in the second statement. Furthermore, since none of the above three pairs of words matching the first semantic role tags satisfy the target conditions, it can be determined that the words with a mapping relationship between the first statement and the second statement include: "I" in the first statement and "I" in the second statement; "like" in the first statement and "like" in the second statement; "football" in the first statement and "play" and "basketball" in the second statement.

[0109] Example 4) The first statement is "I like playing basketball", and the second statement is "I like eating apples".

[0110] As shown in Figure 7, the first sentence includes "I", "like", "play", and "basketball". The words "I" and "like" each have one semantic role label, while "play" and "basketball" each have two semantic role labels. Specifically, the first semantic role labels for "I" and "like" indicate that they are the agent and predicate in the sentence structure corresponding to "I like playing basketball", respectively. The first semantic role labels for "play" and "basketball" indicate that they are the patient in the sentence structure corresponding to "I like playing basketball", respectively. The second semantic role labels indicate that they are the predicate and patient in the sentence structure corresponding to "play basketball", respectively.

[0111] The second sentence includes "I", "like", "eat", and "apple". The words "I" and "like" each have one semantic role label, while "eat" and "apple" each have two semantic role labels. Specifically, the first semantic role labels for "I" and "like" indicate that they are the agent and predicate in the sentence structure corresponding to "I like to eat apples", respectively. The first semantic role labels for "eat" and "apple" indicate that they are the patient in the sentence structure corresponding to "I like to eat apples", respectively. The second semantic role labels indicate that they are the predicate and patient in the sentence structure corresponding to "eat apples", respectively.

[0112] By comparing the first semantic role tags of the four words in the first sentence with the first semantic role tags of the four words in the second sentence, it can be determined that the words matching the first semantic role tags include three pairs: "I" in the first sentence and "I" in the second sentence; "like" in the first sentence and "like" in the second sentence; "play" and "basketball" in the first sentence and "eat" and "apple" in the second sentence. Furthermore, since "play" and "basketball" in the first sentence and "eat" and "apple" in the second sentence all have second semantic role tags, by comparing the second semantic role tags of these four words, it can be determined that the words matching the second semantic role tags include two pairs: "play" in the first sentence and "eat" in the second sentence; "basketball" in the first sentence and "apple" in the second sentence. In summary, the words with a mapping relationship between the first and second sentences include: "I" in the first sentence and "I" in the second sentence; "like" in the first sentence and "like" in the second sentence; "play" in the first sentence and "eat" in the second sentence; "basketball" in the first sentence and "apple" in the second sentence.

[0113] Step 305: The sentence comparison device 200 determines the similarity between words with mapping relationships by querying one or more word similarity tables.

[0114] In its specific implementation, the sentence comparison device 200 is configured with at least one word similarity table. For the sake of brevity, the following description will use one of the at least one word similarity tables (hereinafter referred to as the "first word similarity table") as an example. It can be understood that when the sentence comparison device 200 is configured with multiple word similarity tables, the other word similarity tables can be understood by referring to the relevant description of the first word similarity table.

[0115] The first word similarity table comprises multiple rows and columns, where each row and column corresponds to a single word. The elements in the table represent the similarity between the word in the row and the word in the column. In this application, the first word similarity table includes the similarity between word p and word q.

[0116] The sentence comparison device 200 obtains the first word similarity table in the following way: The sentence comparison device 200 acquires multiple words, which may include words from an existing dictionary (such as the JieBa dictionary), or words obtained by segmenting sentences in a corpus and removing stop words. Then, the sentence comparison device 200 converts these multiple words into vectors, and calculates the similarity between the vectors corresponding to these multiple words, obtaining the similarity between every two words and the similarity between each word and itself. Here, the similarity between words is represented by the similarity between the vectors corresponding to the words. Thus, the sentence comparison device 200 can obtain the first word similarity table.

[0117] Regarding the step of "converting the above-mentioned multiple words into vectors" involved in the above implementation method, the sentence comparison device 200 can use existing word embedding algorithms that can accurately convert words into vectors. The word embedding algorithm here may include word to vector (Word2Vec) model, global vectors for word representation (GloVe) model, or bidirectional encoder representations from transformers (BERT) model, etc., and this application does not limit it.

[0118] For the step of "calculating the similarity between vectors corresponding to the above-mentioned multiple words" involved in the above implementation method, the sentence comparison device 200 can use an existing similarity measurement algorithm that can accurately calculate the similarity between vectors. The similarity measurement algorithm can include cosine similarity algorithm, Euclidean distance algorithm, Manhattan distance algorithm, etc., and this application does not limit it.

[0119] It is understandable that when the sentence comparison device 200 is configured with multiple word similarity tables, these multiple word similarity tables can be calculated by the sentence comparison device 200 using multiple word embedding algorithms and / or multiple similarity measurement methods. For the specific process, please refer to the process by which the sentence comparison device 200 obtains the first word similarity table. For the sake of brevity, it will not be described in detail here.

[0120] Therefore, the sentence comparison device 200 can select one or more word similarity tables from at least one locally configured word similarity table, and then determine the similarity between words with mapping relationship by querying the selected one or more word similarity tables.

[0121] The one or more word similarity tables selected above can be randomly selected by the sentence comparison device 200 from at least one word similarity table, or they can be selected by the sentence comparison device 200 according to the user's configuration. Specifically, when the one or more word similarity tables are selected according to the user's configuration, this can be implemented as follows: the sentence comparison device 200 provides a configuration interface, which can be implemented via API or GUI. The configuration interface displays at least one candidate word similarity table. Through the configuration interface, the user can select one or more word similarity tables according to business needs. Correspondingly, the sentence comparison device 200 can receive the user's selection operation through the configuration interface and determine the one or more word similarity tables specified by the user based on the user's selection operation.

[0122] As can be seen from step 304 above, the words with a mapping relationship include one or more of the following: one word in the first statement and one word in the second statement; multiple words in the first statement and multiple words in the second statement; one word in the first statement and multiple words in the second statement; multiple words in the first statement and one word in the second statement.

[0123] Depending on the specific circumstances, the process by which the sentence comparison device 200 determines the similarity between words with a mapping relationship based on one or more word similarity tables varies slightly. This will be described in more detail below:

[0124] 1) When the words with a mapping relationship include a word in the first sentence (let's say "word p") and a word in the second sentence (let's say "word q"), the sentence comparison device 200 can determine the similarity between word p and word q in any of the following ways:

[0125] Method ①: The sentence comparison device 200 selects a word similarity table from at least one locally configured word similarity table, and then queries the word similarity table to obtain the similarity between word p and word q.

[0126] In its specific implementation, the sentence comparison device 200 pre-stores the correspondence between each row and the corresponding word in the word similarity table, as well as the correspondence between each column and the corresponding word. Therefore, the sentence comparison device 200 can determine which row and column in the word similarity table each word p and word q correspond to based on the above correspondence, and then query the word similarity between word p and word q from the word similarity table based on the determined row and column.

[0127] Method ②: The sentence comparison device 200 selects multiple word similarity tables from at least one locally configured word similarity table, then queries these multiple word similarity tables to obtain multiple similarities between word p and word q, and then determines the similarity between word p and word q based on the multiple similarities obtained from the query.

[0128] In its implementation, for each word similarity table, the sentence comparison device 200 queries the word similarity table to obtain the similarity between word p and word q. The specific process can be found in the description of method ① above. Thus, the sentence comparison device 200 can obtain multiple similarities between word p and word q. Then, the sentence comparison device 200 performs a weighted average calculation on the multiple similarities obtained from the query, and the calculated value is the similarity between word p and word q.

[0129] It is understandable that after obtaining multiple similarities between word p and word q, the sentence comparison device 200 can not only perform a weighted average calculation on the multiple similarities, but also perform other operations on the multiple similarities, such as determining the maximum value among the multiple similarities and taking the maximum value as the similarity between word p and word q.

[0130] As one possible implementation, the sentence comparison device 200 can perform parallel query operations on multiple word similarity tables. This improves the efficiency of the sentence comparison device 200 in determining the similarity between word p and word q.

[0131] 2) When the words with a mapping relationship include multiple words in the first sentence (assumed to be "u words", where u is an integer greater than 1) and multiple words in the second sentence (assumed to be "v words", where v is an integer greater than 1), the sentence comparison device 200 can determine the similarity between the above u words and v words in any of the following ways:

[0132] Method 1: The sentence comparison device 200 selects a word similarity table from at least one locally configured word similarity table, then queries the selected word similarity table to determine the similarity between each word in u words and each word in v words. Based on the query results, it determines the target mapping relationship between u words and v words. The target mapping relationship is a mapping relationship between u words and v words. The similarity between u words and v words indicated by the target mapping relationship (hereinafter referred to as "first similarity") is less than the similarity between u words and v words indicated by other mapping relationships. Therefore, the similarity between u words and v words is determined as the first similarity.

[0133] As one possible implementation, the sentence comparison device 200 can perform parallel query operations on the word similarity table to obtain the similarity between each word in the u words and each word in the v words. This improves the efficiency of the sentence comparison device 200 in determining the similarity between the u words and the v words.

[0134] To facilitate understanding, the following explanation uses the example in Figure 5 as an example:

[0135] In this example, there is a mapping relationship between "football," "basketball," and "badminton" in the first sentence and "basketball" and "badminton" in the second sentence. Therefore, the sentence comparison device 200 can query the word similarity table in parallel to determine the similarity between "football" in the first sentence and "basketball" and "badminton" in the second sentence, the similarity between "basketball" in the first sentence and "basketball" and "badminton" in the second sentence, and the similarity between "badminton" in the first sentence and "basketball" and "badminton" in the second sentence. This determines the target mapping relationship as "basketball" in the first sentence mapping to "basketball" in the second sentence, and "badminton" in the first sentence mapping to "badminton" in the second sentence. Therefore, the similarity between the words with the mapping relationship (i.e., "football," "basketball," and "badminton" in the first sentence and "basketball," "badminton" in the second sentence) is the sum of the similarity between "basketball" in the first sentence and "basketball" in the second sentence, and the similarity between "badminton" in the first sentence and "badminton" in the second sentence.

[0136] It is worth noting that in the example above, since no word in the second sentence can be found that maps to "football" in the first sentence, the similarity between that word and the word in the second sentence can be considered as 0.

[0137] Method ②: The sentence comparison device 200 selects multiple word similarity tables from at least one locally configured word similarity table. For each word similarity table, the sentence comparison device 200 performs the following steps: querying the word similarity table, determining the similarity between each word in u words and each word in v words, determining the target mapping relationship between u words and v words based on the query results, and then obtaining the similarity between u words and v words indicated by the target mapping relationship (i.e., the first similarity). By performing the above steps on multiple word similarity tables, the sentence comparison device 200 will obtain multiple first similarities. Then, the sentence comparison device 200 performs a weighted average calculation (or maximum value calculation, etc.) on the multiple first similarities obtained above, and the calculated value is the similarity between u words and v words.

[0138] As one possible implementation, the sentence comparison device 200 can perform parallel query operations for each word similarity table. Furthermore, the sentence comparison device 200 can also perform parallel query operations on multiple word similarity tables. This improves the efficiency of the sentence comparison device 200 in determining the similarity between u words and v words.

[0139] 3) When the words with a mapping relationship include one word in the first sentence (hereinafter referred to as word m) and multiple words in the second sentence (assumed to be "n words", where n is an integer greater than 1), the sentence comparison device 200 can determine the similarity between the above word m and the n words in any of the following ways:

[0140] Method ①: The sentence comparison device 200 determines the similarity between word m and n words based on the word mover's distance (WMD) between word m and n words.

[0141] In its specific implementation, the sentence comparison device 200 can obtain the word shift distance between word m and n words using the following formula:

[0142] Next, we will introduce each part of the above formula:

[0143] ① WMD min This represents the minimum word shift distance between word m and n other words.

[0144] ② c(i,m) represents the similarity between word i and word m.

[0145] For example, c(i,m) can be calculated using the following formula:

[0146] Where x represents the vector corresponding to word i, and y represents the vector corresponding to word m, both x and y are k-dimensional vectors, where k is an integer greater than 1. x and y can be obtained by the sentence comparison device 200 processing words i and m based on a word embedding algorithm. The word embedding algorithm used here can be the same as or different from the word embedding algorithm required for the word similarity table used above, and this application does not limit it in this regard.

[0147] ③, T i T represents the weight of word i transitioning to word m. i The following conditions must be met:

[0148] Where, d m The normalized bag-of-words (nBOW) frequency of word m, ci This indicates the number of times word i appears among the above n words.

[0149] It can be seen that when T i When the following conditions are met, Minimum:

[0150] In other words, WMD min =d m *min{c(1,m),…,c(n,m)}.

[0151] After the sentence comparison device 200 obtains the minimum word shift distance between word m and n words, the similarity between word m and n words can be calculated using the following formula:

[0152] Among them, WMD min sim represents the minimum word shift distance between word m and n words, and sim represents the similarity between word m and n words.

[0153] It is understood that the above formula is merely an example of one possible way to convert word-shift distance into word-to-word similarity. In practical applications, other methods can also be used to convert word-shift distance into word-to-word similarity, and this application does not limit this.

[0154] To facilitate understanding, the following explanation uses the example in Figure 6 as an example:

[0155] In this example, there is a mapping relationship between "football" in the first sentence and "play" and "basketball" in the second sentence. The word shift distance between "football" and "play" and "basketball" can be calculated using the following formula: WMD min =min[T1*‖x1-y‖2+T2*‖x2-y‖2] T1+T2=d

[0156] Among them, WMD min Let y represent the minimum word shift distance between "football" and "play" and "basketball", y represent the vector corresponding to "football", x1 represent the vector corresponding to "play", x2 represent the vector corresponding to "basketball", T1 represent the weight when "football" is shifted to "play", T2 represent the weight when "football" is shifted to "basketball", and d represent the normalized word frequency of "football", which is equal to 1 / 2.

[0157] Since ||x1-y||2>||x2-y||2, in order to ensure that [T1*||x1-y||2+T2*||x2-y||2] is minimized, T1 should be equal to 0, and T2 should be equal to d. That is to say, WMD min=T2*‖x2-y‖2. Therefore, the similarity between the words with the mapping relationship (i.e., "football" in the first sentence and "play" and "basketball" in the second sentence) is 1 / (1+WMD). min ).

[0158] Method ②: The sentence comparison device 200 selects a word similarity table from at least one locally configured word similarity table, queries the word similarity table, obtains the similarity between word m and each of the n words, determines the second similarity based on the query results, wherein the second similarity is the minimum value of the similarity between word m and each of the n words, and thus determines the similarity between word m and the n words as the second similarity.

[0159] As one possible implementation, the sentence comparison device 200 can perform parallel query operations on the word similarity table to obtain the similarity between word m and each of the n words. This improves the efficiency of the sentence comparison device 200 in determining the similarity between word m and the n words.

[0160] Method 3: The sentence comparison device 200 selects multiple word similarity tables from at least one locally configured word similarity table. For each selected word similarity table, the sentence comparison device 200 performs the following steps: querying the word similarity table to obtain the similarity between word m and each of the n words; determining the minimum similarity value (i.e., the second similarity) between word m and each of the n words based on the query results. By performing the above steps on multiple word similarity tables, the sentence comparison device 200 obtains multiple second similarities, and then performs a weighted average calculation (or maximum value calculation, etc.) on the multiple second similarities. The calculated value is the similarity between word m and the n words.

[0161] As one possible implementation, the sentence comparison device 200 can perform parallel query operations for each word similarity table. Furthermore, the sentence comparison device 200 can also perform parallel query operations on multiple word similarity tables. This improves the efficiency of the sentence comparison device 200 in determining the similarity between word m and n words.

[0162] 4) When the words with a mapping relationship include multiple words in the first sentence and one word in the second sentence, the sentence comparison device 200 can determine the similarity between the words with the mapping relationship based on the word shift distance between the words or one or more word similarity tables. The specific implementation process can be found in the relevant introduction described in 3) above. For the sake of brevity, it will not be described in detail here.

[0163] Step 306: The sentence comparison device 200 determines the similarity between the first sentence and the second sentence based on the similarity between words with a mapping relationship.

[0164] In its specific implementation, the sentence comparison device 200 pre-stores the weights of multiple semantic roles and the weights of multiple levels. The weights of the levels are used to indicate the weights of the levels corresponding to the sentence structures to which the words belong.

[0165] The sentence comparison device 200 can obtain the weights of multiple semantic roles and the weights of multiple levels in the following way: The sentence comparison device 200 provides a configuration interface, which can be implemented through API or GUI. The sentence comparison device 200 can receive user configuration through the above configuration interface. The user configuration includes the weights of multiple semantic roles and the weights of multiple levels. Among them, the weight of the semantic role that the user is interested in is greater than the weight of other semantic roles, and the weight of the level corresponding to the upper-level sentence structure is greater than the weight of the level corresponding to the lower-level sentence structure.

[0166] Optionally, the sum of the weights of multiple semantic roles is 1, the weight of the level corresponding to the first-level sentence structure is equal to 1, and the weight of the level corresponding to other sentence structures (such as the second sentence structure) is less than 1.

[0167] Optionally, the semantic roles that users are interested in can depend on the requirements of the sentence comparison task. For example, if the sentence comparison task is to distinguish interests, then when configuring the weights of semantic roles, the weight of "patient" can be made greater than the weights of other semantic roles (such as the weight of "predicate", the weight of "agent", the weight of "time", etc.).

[0168] It is understandable that the higher the weight of the semantic roles that users are interested in, the greater the similarity between the words corresponding to these semantic roles will be when calculating the similarity between the first and second sentences. In other words, in this way, the sentence comparison device 200 can focus its attention on the content that users are interested in, reduce the impact of content that users are not interested in on the sentence comparison, and improve the accuracy of the sentence comparison.

[0169] For example, suppose the first statement is "I liked football when I was a child," and the second statement is "I like football when I grew up." The first statement includes three words: "I," "when I was a child," "like," and "football." The first semantic role labels of these three words indicate that they are the agent, time, predicate, and patient in the sentence structure corresponding to "I liked football when I was a child," respectively. The second statement includes four words: "I," "when I grew up," "like," and "football." The first semantic role labels of these four words indicate that they are the agent, time, predicate, and patient in the sentence structure corresponding to "I like football when I grew up," respectively. By comparing the first semantic role labels of the four words in the first statement with the first semantic role labels of the four words in the second statement, we can determine that there are four pairs of words with a mapping relationship between the first and second statements: "I" in the first statement and "I" in the second statement; "when I was a child" in the first statement and "when I grew up" in the second statement; "like" in the first statement and "like" in the second statement; and "football" in the first statement and "football" in the second statement. If the sentence comparison task is to distinguish interests and hobbies, then the weight of "time" can be set to 0. In this case, the similarity of words corresponding to this role ("when I was a child" in the first sentence and "when I grew up" in the second sentence) will not affect the sentence similarity judgment. Conversely, if the sentence comparison task is to distinguish the age group at which a user likes football, then the weight of "time" can be set to be greater than the weight of other semantic roles. In this case, the similarity of words corresponding to this role ("when I was a child" in the first sentence and "when I grew up" in the second sentence) will have a greater impact on the sentence similarity judgment.

[0170] Based on the weights of multiple semantic roles and multiple levels configured by the user, the sentence comparison device 200 can determine the semantic roles and corresponding levels of words with mapping relationships. Then, based on the similarity between words with mapping relationships, the weights of the semantic roles of words, and the weights of the levels of the sentence structures to which the words belong, the similarity between the first sentence and the second sentence can be determined.

[0171] More specifically, when the first and second sentences contain multi-layered nested sentence structures, the sentence comparison device 200 can first determine the similarity of the lower sentence structure based on the similarity between words with mapping relationships in the lower sentence structure, the weight of the semantic roles of the words, and the weight of the level corresponding to the lower sentence structure. Then, it can determine the similarity of the upper sentence structure based on the similarity of the lower sentence structure, and thus obtain the similarity between the first and second sentences (i.e., the similarity between the first and second sentences regarding the first sentence structure).

[0172] The similarity of the lower-level sentence structures can be calculated using the following formula:

[0173] In the above formula, sim′ represents the similarity of the lower-level sentence structure, t represents the number of words with mapping relationships in the lower-level sentence structure, and sim′ represents the similarity of the lower-level sentence structure. j w represents the j-th pair of words with a mapping relationship in the lower-level sentence structure. j Let α represent the semantic role of the j-th pair of words with a mapping relationship, and let α represent the weight of the level corresponding to the lower-level sentence structure.

[0174] After obtaining the similarity of the lower-level sentence structure, the sentence comparison device 200 can use this similarity as the similarity between words with mapping relationships in the upper-level sentence structure. Then, based on the similarity between words with mapping relationships in the upper-level sentence structure, the weights of the semantic roles of the words, and the weights of the corresponding levels of the upper-level sentence structure, the similarity of the upper-level sentence structure is determined. It can be understood that the process by which the sentence comparison device 200 determines the similarity of the upper-level sentence structure is similar to the process by which the sentence comparison device 200 determines the similarity of the lower-level sentence structure; for the sake of brevity, it will not be elaborated further here.

[0175] To facilitate understanding, the following explanation uses the example in Figure 7 as an example:

[0176] In this example, both the first and second sentences contain two sentence structures. The lower-level sentence structures contain two pairs of words with a mapping relationship: "hit" in the first sentence and "eat" in the second sentence; and "basketball" in the first sentence and "apple" in the second sentence. Therefore, the similarity of the lower-level sentence structures is: (sim1*w1+sim2*w2)*α, where sim1 represents the similarity between "hit" in the first sentence and "eat" in the second sentence, w1 represents the weight of the "predicate," sim2 represents the similarity between "basketball" in the first sentence and "apple" in the second sentence, w2 represents the weight of the "patient," and α represents the weight of the level corresponding to the lower-level sentence structure, where α<1. Based on the similarity of the lower-level sentence structure, the similarity of the upper-level sentence structure (i.e., the first and second sentences) is: sim3*w3 + sim4*w1 + (sim1*w1 + sim2*w2)*α*w2, where sim3 represents the similarity of "I" in the first sentence and "I" in the second sentence, w3 represents the weight of the "agent," and sim4 represents the similarity of "like" in the first sentence and "like" in the second sentence. It is worth noting that the weight of the level corresponding to the upper-level sentence structure is 1, therefore it is not reflected in the above calculation formula.

[0177] It's understandable that in practical applications, besides words with mapping relationships, the first or second statement may contain one or more words with unmatched semantic role labels. To facilitate subsequent calculation of statement similarity, the similarity of these words can be recorded as 0. For example, suppose the first statement is "I like football," and the second statement is "I liked football when I was a child." The first statement includes the words "I," "like," and "football." The first semantic role labels of these three words indicate that they are the agent, predicate, and patient in the sentence structure corresponding to "I like football," respectively. The second statement includes the words "I," "when I was a child," "like," and "basketball." The first semantic role labels of these four words indicate that they are the agent, time, predicate, and patient in the sentence structure corresponding to "I liked football when I was a child," respectively. By comparing the first semantic role labels of the three words in the first statement and the first semantic role labels of the four words in the second statement, it can be determined that there are three pairs of words with mapping relationships in the first and second statements: "I" in the first statement and "I" in the second statement; "like" in the first statement and "like" in the second statement; and "football" in the first statement and "football" in the second statement. Regarding the word "childhood" in the second statement, since no corresponding word can be found in the first statement, the similarity between this word and the words in the first statement can be considered as 0. Therefore, the similarity between the first and second statements is the sum of the products of the similarity between the three pairs of words with mapping relationships and the weights of their corresponding semantic roles.

[0178] Step 307: The sentence comparison device 200 obtains the sentence comparison result based on the similarity between the first sentence and the second sentence.

[0179] The statement comparison result may include the similarity between the first statement and the second statement, and / or information determined based on the similarity between the first statement and the second statement, such as information required for the statement comparison task. For example, when the statement comparison task is to find the answer to a question (i.e., the first statement) in a question-answering system, if the first statement and the second statement have a high similarity, then the statement comparison device 200 can find the answer to the second statement from the question-answering system, and the statement comparison result is the answer to the second statement. Similarly, when the statement comparison task is to find the translation result of the first statement in a machine translation system, if the first statement and the second statement have a high similarity, then the statement comparison device 200 can find the translation result of the second statement from the machine translation system, and the statement comparison result is the translation result of the second statement. Furthermore, when the statement comparison task is to recommend items to users based on their interests in a recommendation system, if the first statement and the second statement have a high similarity, then the statement comparison device 200 can find items associated with the interests expressed in the second statement from the recommendation system, and the statement comparison result is the items found in the second statement.

[0180] In step 308, the statement comparison device 200 sends the statement comparison result to the client 100. Accordingly, the client 100 receives the statement comparison result sent by the statement comparison device 200.

[0181] As can be seen from the descriptions of steps 301 to 308 above, the statement comparison method provided in this application has the following advantages:

[0182] Firstly, the similarity between words with a mapping relationship can be determined directly by querying the word similarity table, thus eliminating the need to perform word embedding calculation and vector similarity calculation, thereby improving the efficiency of sentence comparison.

[0183] Secondly, since the semantic role information of words can describe the semantic function that words perform in a sentence, the mapping relationship between words can be accurately determined by comparing the semantic role information, thus improving the accuracy of sentence comparison.

[0184] Third, the semantic roles and corresponding hierarchical weights of words can be configured according to the specific sentence comparison task, so that the sentence comparison device 200 focuses its attention on the content that users are interested in (especially the identification of vertical subcategories), weakens the impact of content that users are not interested in on the sentence comparison, and improves the accuracy of the sentence comparison.

[0185] The statement comparison method provided in this application has been described in detail above with reference to Figures 1 to 7. The structure of the statement comparison device 200 that performs the above method is described below with reference to Figure 8.

[0186] Referring to Figure 8, Figure 8 shows a schematic diagram of the structure of a statement comparison device 200. As shown in Figure 8, the statement comparison device 200 includes an acquisition module 201, a comparison module 202, a query module 203, and a determination module 204. Optionally, the statement comparison device 200 also includes a configuration module 205.

[0187] The acquisition module 201 is used to perform the step of receiving the statement comparison request sent by the client 100 in step 301 above, as well as step 302 above. The comparison module 202 is used to perform steps 303 and 304 above. The query module 203 is used to perform step 305 above. The determination module 204 is used to perform steps 306 to 308 above. The configuration module 205 is used to perform the related steps of configuring the corpus, at least one word similarity table, the weights of multiple semantic roles, and the weights of multiple levels.

[0188] It is understood that the specific details of any possible implementation of the relevant steps performed by each module of the above statement comparison device 200 can be referred to the relevant content of the foregoing method embodiments, and will not be repeated here.

[0189] In specific implementations, the acquisition module 201, comparison module 202, query module 203, determination module 204, and configuration module 205 can be implemented in software or hardware. For example, the implementation of the acquisition module 201 will be described below. Similarly, the implementation of the comparison module 202, query module 203, determination module 204, and configuration module 205 can refer to the implementation of the acquisition module 201.

[0190] As an example of a software functional unit, the acquisition module 201 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, or a container. Further, the aforementioned computing instance may be one or more. For example, the acquisition module 201 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Further, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one or more geographically proximate data centers. Typically, a region may include multiple AZs.

[0191] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same Virtual Private Cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Communication between two VPCs within the same region, as well as between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.

[0192] As an example of a hardware functional unit, the acquisition module 201 may include at least one computing device, such as a server. The acquisition module 201 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The aforementioned PLD can be implemented using a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof.

[0193] The multiple computing devices included in the acquisition module 201 can be distributed in the same region or in different regions. Similarly, the multiple computing devices included in the acquisition module 201 can be distributed in the same Availability Zone (AZ) or in different AZs. Likewise, the multiple computing devices included in the acquisition module 201 can be distributed in the same Virtual Private Cloud (VPC) or in multiple VPCs. These multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.

[0194] It should be noted that, in other embodiments, the acquisition module 201 can be used to execute any step in the above-described statement comparison method, the comparison module 202 can be used to execute any step in the above-described statement comparison method, the query module 203 can be used to execute any step in the above-described statement comparison method, the determination module 204 can be used to execute any step in the above-described statement comparison method, and the configuration module 205 can be used to execute any step in the above-described statement comparison method. The steps implemented by the acquisition module 201, comparison module 202, query module 203, determination module 204, and configuration module 205 can be specified as needed. By implementing different steps in the above-described statement comparison method through the acquisition module 201, comparison module 202, query module 203, determination module 204, and configuration module 205, all functions of the statement comparison device 200 can be realized.

[0195] This application also provides a computing device. The computing device can be a server, such as a server in a cloud data center, an edge server, or a local server in a local data center, or it can be a terminal device such as a desktop computer, a laptop computer, or a smartphone.

[0196] Referring to Figure 9, which exemplarily illustrates a schematic diagram of a computing device, the computing device 400 includes a bus 401, a processor 402, a memory 403, and a communication interface 404. The processor 402, memory 403, and communication interface 404 communicate via the bus 401. It should be understood that this application does not limit the number of processors 402 and memories 403 in the computing device 400; that is, the computing device 400 may include one or more processors 402 and one or more memories 403. However, for ease of description, Figure 6 only shows one processor 402 and one memory 403. The various parts of the computing device 400 will be described in detail below.

[0197] Bus 401 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, only one line is used in Figure 9, but this does not mean that the computing device 400 has only one bus or one type of bus. Bus 401 can include pathways for transmitting information between various components of the computing device 400 (e.g., processor 402, memory 403, and communication interface 404).

[0198] Processor 402 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0199] Memory 403 may include volatile memory, such as random access memory (RAM). Memory 403 may also include non-volatile memory, such as SSD, flash memory, read-only memory (ROM), or hard disk drive (HDD).

[0200] The memory 403 stores executable code. The processor 402 executes the code stored in the memory 403 to implement the functions of the acquisition module 201, comparison module 202, query module 203, determination module 204, and configuration module 205, respectively, thereby implementing the statement comparison method described above. That is to say, the memory 403 stores instructions for executing the statement comparison method described above.

[0201] The communication interface 404 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing device 400 and other devices or communication networks. For example, the computing device 400 can communicate with the client 100 through the communication interface 404 to obtain original video and hairstyle editing requests.

[0202] It should be understood that the computing device 400 provided according to this application can correspond to the statement comparison device 200 described above, and the functions of each component in the computing device 400 are respectively to implement the corresponding process of each step in the method shown in FIG3. For the sake of brevity, they will not be described in detail here.

[0203] This application also provides a computing device cluster. The computing device cluster includes at least one computing device, which may be a server, such as a central server or edge server in a cloud data center, or a local server in a local data center. In some embodiments, the computing device in the computing device cluster may also be a terminal device such as a desktop computer, laptop computer, or smartphone.

[0204] Referring to Figure 10, which exemplarily illustrates a schematic diagram of a computing device cluster, the computing device cluster includes at least one computing device 400. The memory 403 of one or more computing devices 400 in the computing device cluster may store identical instructions for executing the aforementioned statement comparison method.

[0205] In some possible implementations, the memory 403 of one or more computing devices 400 in the computing device cluster may also store partial instructions for executing the statement comparison method described above. In other words, a combination of one or more computing devices 400 can jointly execute the instructions of the statement comparison method described above.

[0206] It should be noted that the memory 403 of different computing devices 400 in the computing device cluster can store different instructions, which are used to execute some functions of the statement comparison device 200. That is, the instructions stored in the memory 403 of different computing devices 400 can realize the function of at least one of the modules: acquisition module 201, comparison module 202, query module 203, determination module 204, and configuration module 205.

[0207] In some possible implementations, one or more computing devices 400 in a computing device cluster can be connected via a network, such as a wide area network (WAN) or a local area network (LAN). Figure 11 illustrates one possible implementation. As shown in Figure 11, computing devices 400A and 400B are connected via a network. Specifically, they are connected to the network through communication interfaces in computing devices 400A and 400B. In this implementation, the memory 403 in computing device 400A stores instructions for implementing the functions of the acquisition module 201, comparison module 202, query module 203, and determination module 204, while the memory 403 in computing device 400B stores instructions for implementing the functions of the configuration module 205.

[0208] The connection method between computing devices 400 in the computing device cluster shown in Figure 11 is based on the consideration that the corpus and word similarity table used in the sentence comparison method provided in this application can be configured offline. Therefore, the function of the configuration module 205 is to be performed by the computing device 400B.

[0209] It should be understood that the functions of computing device 400A shown in Figure 11 can also be performed by multiple computing devices 400. Similarly, the functions of computing device 400B can also be performed by multiple computing devices 400.

[0210] It should also be understood that the computing device cluster provided in this application can correspond to the statement comparison device 200 described above, and the functions of each component in the computing device cluster are respectively to implement the corresponding processes of each step in the method shown in Figure 3. For the sake of brevity, they will not be described in detail here.

[0211] This application also provides a computer program product containing instructions. This computer program product may be a software or program product containing instructions that can run on a computing device or be stored on any available medium. When the computer program product is run on a computing device, it causes the computing device to execute the statement comparison method described above.

[0212] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium capable of being stored by a computing device, or a data storage device such as a data center containing one or more available media. The aforementioned available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives). The computer-readable storage medium includes instructions that instruct the computing device to execute the statement comparison method described above.

[0213] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of this application.

Claims

1. A statement comparison method, characterized in that, The method is applied to a sentence comparison device, which is equipped with a first word similarity table, the first word similarity table including the similarity of multiple words, and includes: Get the first and second statements; By comparing the semantic role information of words in the first statement with the semantic role information of words in the second statement, the mapping relationship between the words in the first statement and the words in the second statement is determined. The semantic role of a word is used to describe the semantic function that the word performs in the statement. Words with a mapping relationship include words whose semantic role information matches. Query the first word similarity table to obtain the similarity between the words with the mapping relationship; The similarity between the first statement and the second statement is determined based on the similarity between the words with the mapping relationship. The statement comparison results are obtained based on the similarity between the first statement and the second statement.

2. The method according to claim 1, characterized in that, Before comparing the semantic role information of words in the first statement with the semantic role information of words in the second statement, the method further includes: Based on the semantic relationships between the words in the first statement, determine the multi-layered nested sentence structure contained in the first statement; Determine the semantic roles and corresponding levels of the words in the first statement, wherein the semantic role of a word is used to indicate the semantic function that the word undertakes in the sentence structure to which it belongs, and the level corresponding to the semantic role of a word is used to indicate the level of the sentence structure to which the word belongs.

3. The method according to claim 2, characterized in that, The step of comparing the semantic role information of words in the first statement and the semantic role information of words in the second statement to determine the mapping relationship between the words in the first statement and the words in the second statement includes: By comparing the semantic roles and corresponding levels of words in the first statement with the semantic roles and corresponding levels of words in the second statement, the mapping relationship between the words in the first statement and the words in the second statement is determined. Words with a mapping relationship include words whose semantic roles and corresponding levels are matched.

4. The method according to claim 3, characterized in that, The method further includes: Provides a configuration interface; The configuration interface receives user configurations, which include weights for multiple semantic roles and weights for multiple levels. The weights of semantic roles that the user is interested in are greater than the weights of other semantic roles, and the weights of the levels corresponding to the upper-level sentence structures are greater than the weights of the levels corresponding to the lower-level sentence structures.

5. The method according to claim 4, characterized in that, Determining the similarity between the first statement and the second statement based on the similarity between the words with the mapping relationship includes: The similarity between the first statement and the second statement is determined based on the similarity between the words with the mapping relationship, the weight of the semantic role of the words, and the weight of the level corresponding to the sentence structure to which the words belong.

6. The method according to any one of claims 1 to 5, characterized in that, The words with a mapping relationship include one or more words in the first statement and one or more words in the second statement; The step of querying the first word similarity table to obtain the similarity between the words with the mapping relationship includes: Perform a parallel query operation on the first word similarity table to obtain the similarity between one or more words in the first statement and each pair of words in one or more words in the second statement; Based on the query results, a target mapping relationship is determined between one or more words in the first statement and one or more words in the second statement. The sum of similarities between words corresponding to the target mapping relationship is less than the sum of similarities between words corresponding to other mapping relationships. The similarity between one or more words in the first statement and one or more words in the second statement is the similarity corresponding to the target mapping relationship.

7. The method according to any one of claims 1 to 6, characterized in that, The sentence comparison device is also equipped with a second word similarity table, which includes the similarity of multiple words. The similarity of multiple words in the first word similarity table and the second word similarity table is calculated using different word embedding algorithms. The query of the first word similarity table to obtain the similarity between the words with the mapping relationship includes: The similarity between the words with the mapping relationship is obtained by querying the first word similarity table and the second word similarity table.

8. The method according to any one of claims 2 to 7, characterized in that, The sentence comparison device is equipped with a corpus, which includes multiple historical sample sentences and semantic role information of words in each historical sample sentence; Before comparing the semantic role information of words in the first statement with the semantic role information of words in the second statement, the method further includes: Obtain semantic role information of words in the second statement from the corpus.

9. A sentence comparison device, characterized in that, The device is equipped with a first word similarity table, which includes the similarity of multiple words. The device includes: The acquisition module is used to acquire the first and second statements; The comparison module is used to compare the semantic role information of words in the first statement and the semantic role information of words in the second statement to determine the mapping relationship between the words in the first statement and the words in the second statement. The semantic role of a word is used to describe the semantic function that the word performs in the statement. Words with a mapping relationship include words whose semantic role information is matched. The query module is used to query the first word similarity table to obtain the similarity between the words with the mapping relationship; The determining module is used to determine the similarity between the first statement and the second statement based on the similarity between the words with the mapping relationship; and to obtain the statement comparison result based on the similarity between the first statement and the second statement.

10. The apparatus according to claim 9, characterized in that, The comparison module is further configured to determine the multi-layered nested sentence structure contained in the first statement based on the semantic relationship between the words in the first statement, and to determine the semantic roles and corresponding levels of the words in the first statement. The semantic roles of the words are used to indicate the semantic functions undertaken by the words in the sentence structure to which they belong, and the levels corresponding to the semantic roles of the words are used to indicate the levels corresponding to the sentence structure to which the words belong.

11. The apparatus according to claim 10, characterized in that, The comparison module is used to compare the semantic roles and corresponding levels of words in the first statement with the semantic roles and corresponding levels of words in the second statement to determine the mapping relationship between the words in the first statement and the words in the second statement. The words with the mapping relationship include words whose semantic roles and corresponding levels are matched.

12. The apparatus according to claim 11, characterized in that, The device further includes: A configuration module is used to provide a configuration interface; through the configuration interface, the user's configuration includes the weights of multiple semantic roles and the weights of multiple levels, wherein the weight of the semantic role that the user is interested in is greater than the weight of other semantic roles, and the weight of the level corresponding to the upper-level sentence structure is greater than the weight of the level corresponding to the lower-level sentence structure.

13. The apparatus according to claim 12, characterized in that, The determining module is used to determine the similarity between the first statement and the second statement based on the similarity between the words with the mapping relationship, the weight of the semantic role of the words, and the weight of the level corresponding to the sentence structure to which the words belong.

14. The apparatus according to any one of claims 9 to 13, characterized in that, The words with a mapping relationship include one or more words in the first statement and one or more words in the second statement; The query module is used to perform a parallel query operation on the first word similarity table to obtain the similarity between one or more words in the first statement and pairs of words in one or more words in the second statement; Based on the query results, a target mapping relationship is determined between one or more words in the first statement and one or more words in the second statement. The sum of similarities between words corresponding to the target mapping relationship is less than the sum of similarities between words corresponding to other mapping relationships. The similarity between one or more words in the first statement and one or more words in the second statement is the similarity corresponding to the target mapping relationship.

15. The apparatus according to any one of claims 9 to 14, characterized in that, The device is also equipped with a second word similarity table, which includes the similarity of multiple words. The similarity of multiple words in the first word similarity table and the second word similarity table is calculated using different word embedding algorithms. The query module is used to query the first word similarity table and the second word similarity table to obtain the similarity between the words with the mapping relationship.

16. The apparatus according to any one of claims 10 to 15, characterized in that, The device is equipped with a corpus, which includes multiple historical sample sentences and semantic role information of words in each historical sample sentence; The comparison module is also used to obtain semantic role information of words in the second statement from the corpus.

17. A computing device cluster, characterized in that, It includes at least one computing device, each computing device including a processor and memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device to cause the cluster of computing devices to perform the method as described in any one of claims 1 to 8.

18. A computer program product containing instructions, characterized in that, When the instruction is executed by the computing device cluster, the computing device cluster causes the computing device cluster to perform the method as described in any one of claims 1 to 8.

19. A computer-readable storage medium, characterized in that, Includes computer program instructions, which, when executed by a cluster of computing devices, perform the method as described in any one of claims 1 to 8.