Text label labeling method, device and system
By using label generation model and multiple similarity calculation methods in text annotation, automatically matching and labeling labels in text, the problem of time-consuming and inconsistent traditional manual label classification is solved, and the comprehensiveness of labels and the accuracy of retrieval is improved.
Patent Information
- Application Number
- CN202411679015.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-11-21
AI Technical Summary
The traditional manual tag classification method is time-consuming and labor-intensive, and it is difficult to ensure the consistency and comprehensiveness of tags, which limits the effective utilization and sharing of knowledge resources.
By obtaining the target word segmentation from the text to be marked, using the label generation model to generate the initial label based on the label library, and using a variety of similarity calculation methods to match the candidate labels in the synonym database until the target candidate label is obtained, the label is performed.
It improves the efficiency and comprehensiveness of text labeling, improves the accuracy of searching or querying text, and makes full use of knowledge resources.
Smart Images

Figure CN119646215A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a text labeling method, device and system. Background Art
[0002] In related technologies, stored knowledge resources such as scientific research reports or technical materials need to be labeled and classified to facilitate query and retrieval, so that the knowledge resources can be effectively utilized and shared. However, the traditional manual label classification method is not only time-consuming and labor-intensive, but also difficult to ensure the consistency and comprehensiveness of the labels, thus limiting the effective utilization and sharing of knowledge resources. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present disclosure provides a text labeling method, device and system.
[0004] According to a first aspect of an embodiment of the present disclosure, a method for marking a text label is provided, comprising:
[0005] Obtain target word segmentation from the text to be annotated;
[0006] Using a label generation model, generating an initial label of the target word segmentation according to a label library; the label library is a label library associated with the field to which the text to be annotated belongs;
[0007] Using multiple similarity calculation methods to calculate the similarity value between the initial tag and each candidate tag in the synonym library to obtain multiple similarity values;
[0008] Normalizing the multiple similarity values, and sorting the normalized multiple similarity values to obtain a first order;
[0009] According to the first order, determining a second order of the plurality of matching methods;
[0010] Matching the initial tag with the candidate tags in the synonym library in sequence according to the matching method corresponding to the second sequence until at least one target candidate tag is obtained;
[0011] The target word segment is labeled using the initial label and the at least one target candidate label.
[0012] In some embodiments of the present disclosure, the normalizing the multiple similarity values includes:
[0013] When the multiple similarity calculation methods include the first method, the similarity value corresponding to the first method is normalized using the following formula:
[0014]
[0015] Wherein, tf_idf_h(Test[n] is the similarity value obtained by calculating the similarity of the nth candidate tag in the synonym library using the first method, and a is the normalized similarity value corresponding to the first method; the first method is to calculate the similarity value using the term frequency-inverse document frequency TF-IDF algorithm;
[0016] When the multiple similarity calculation methods include the second method, the similarity value corresponding to the first method is normalized using the following formula:
[0017]
[0018] Among them, levenshtein_hash(Test[n]) is the similarity value obtained by calculating the similarity of the nth candidate tag in the synonym library using the second method, b is the normalized similarity value corresponding to the second method, and length(n) is the length of the nth candidate tag; the second method is to calculate the similarity value using the edit distance algorithm.
[0019] In some embodiments of the present disclosure, determining a second order of the plurality of matching methods according to the first order includes:
[0020] Acquire a mapping relationship between the multiple similarity calculation methods and the multiple matching methods;
[0021] According to the mapping relationship and the first order, a second order of the multiple matching methods is determined; wherein the multiple similarity calculation methods include TF-IDF algorithm, edit distance algorithm, cosine similarity algorithm and Jaccard similarity algorithm; the matching methods include synonym matching, exact matching, fuzzy matching and semantic matching; the mapping relationship is that TF-IDF algorithm corresponds to synonym matching, edit distance algorithm corresponds to exact matching, cosine similarity algorithm corresponds to fuzzy matching, and Jaccard similarity algorithm corresponds to semantic matching.
[0022] In some embodiments of the present disclosure, matching the initial tag with the candidate tags in the synonym library in the matching manner corresponding to the second order in sequence until at least one target candidate tag is obtained includes:
[0023] Determine a current matching mode from the plurality of matching modes according to the second order;
[0024] Matching the initial tag with the candidate tags in the synonym library according to the current matching method to obtain a matching result; the matching result includes whether the match is successful and the matched candidate tags;
[0025] If the matching result is that no match is successful, and the current matching method is not the last matching method in the second order, the next matching method is determined as the current matching method according to the second order, and the step of matching the initial tag with the candidate tags in the synonym library according to the current matching method to obtain a matching result is returned to the execution;
[0026] When the matching result is a successful match, determining the matched candidate tag as the target candidate tag;
[0027] When the matching result is that no matching is successful and the current matching mode is the last matching mode in the second sequence, it is determined that the matching fails.
[0028] In some embodiments of the present disclosure, the multiple matching methods include fuzzy matching, and matching the initial tag with the candidate tags in the synonym library according to the current matching method to obtain a matching result includes:
[0029] When the current matching method is fuzzy matching, for each candidate tag in the synonym library, the comprehensive similarity value between the initial tag and the candidate tag is calculated by the following formula:
[0030]
[0031] Wherein, Target is the comprehensive similarity value, a is the similarity value calculated by the first method, b is the similarity value calculated by the second method, c is the similarity value calculated by the third method, d is the similarity value calculated by the fourth method, λ1 is the weight value corresponding to the first method, λ2 is the weight value corresponding to the second method, λ3 is the weight value corresponding to the third method, and λ4 is the weight value corresponding to the fourth method;
[0032] When the comprehensive similarity value satisfies the first preset condition, the candidate tag is determined as the target candidate tag.
[0033] In some embodiments of the present disclosure, when the comprehensive similarity value satisfies the first preset condition, determining the candidate tag as the target candidate tag includes:
[0034] The similarity mean x is calculated by the following formula:
[0035]
[0036] Wherein, n is the number of candidate tags in the synonym library;
[0037] In the case of Target<=x, a plurality of first intervals are used to determine the similarity level of the candidate tags;
[0038] In the case of Target>x, multiple second intervals are used to determine the similarity level of the candidate tags;
[0039] When the similarity level meets the second preset condition, the candidate tag is determined as the target candidate tag; wherein the interval range corresponding to the first interval whose similarity level meets the second preset condition is larger than the interval range corresponding to the second interval whose similarity level meets the second preset condition.
[0040] According to a second aspect of an embodiment of the present disclosure, a text label marking device is provided, including:
[0041] An acquisition unit, used to acquire target word segments from the text to be annotated;
[0042] A generating unit, configured to generate an initial label of the target word segmentation according to a label library using a label generation model; the label library is a label library associated with the field to which the text to be annotated belongs;
[0043] A calculation unit, used to calculate the similarity value between the initial tag and each candidate tag in the synonym library by using multiple similarity calculation methods to obtain multiple similarity values;
[0044] A sorting unit, configured to normalize the plurality of similarity values, and sort the plurality of similarity values after the normalization process to obtain a first order;
[0045] A determining unit, configured to determine a second order of the plurality of matching modes according to the first order;
[0046] a matching unit, configured to match the initial tag with the candidate tags in the synonym library in sequence according to the matching method corresponding to the second sequence until at least one target candidate tag is obtained;
[0047] A labeling unit is used to label the target word segmentation using the initial label and the at least one target candidate label.
[0048] According to a third aspect of an embodiment of the present disclosure, an electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method described in any one of the first aspects is implemented.
[0049] According to a fourth aspect of an embodiment of the present disclosure, there is provided a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method according to any one of the first aspects is implemented.
[0050] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program implements the method as described in any one of the first aspects when executed by a processor.
[0051] The technical solution provided by the embodiment of the present disclosure may include the following beneficial effects: by obtaining a target word segment from the text to be annotated, using a label generation model, generating an initial label of the target word segment according to a label library, using multiple similarity calculation methods to calculate the similarity value between the initial label and each candidate label in the synonym library, obtaining multiple similarity values, normalizing the multiple similarity values, sorting the normalized multiple similarity values, obtaining a first order, determining a second order of multiple matching methods according to the first order, matching the initial label with the candidate labels in the synonym library in turn according to the matching methods corresponding to the second order, until at least one target candidate label is obtained, and annotating the target word segment using the initial label and at least one target candidate label. The label of the text is expanded by a secondary generation identifier, thereby improving the efficiency of labeling the text while improving the comprehensiveness of the text label, thereby improving the accuracy of retrieving or querying the text, and making full use of knowledge resources.
[0052] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0054] Figure 1 The present invention is a flowchart of a text label marking method according to an exemplary embodiment.
[0055] Figure 2 The figure is a block diagram of a text label marking device according to an exemplary embodiment.
[0056] Figure 3 The invention is a block diagram showing a device for a method for marking text labels according to an exemplary embodiment. DETAILED DESCRIPTION
[0057] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0058] The terms used in the disclosed embodiments are only for the purpose of describing specific embodiments, and are not intended to limit the disclosed embodiments. The singular forms "a", "an" and "the" used in the disclosed embodiments and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0059] It should be understood that although the terms first, second, third, etc. may be used to describe various information in the disclosed embodiments, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the disclosed embodiments, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein may be interpreted as "at" or "when" or "in response to determination".
[0060] In addition, various forms of processes shown in the embodiments of the present disclosure may be used to reorder, add or delete steps. For example, the steps described in the present application may be performed in parallel, sequentially or in different orders, as long as the desired results of the technical solution disclosed in the present disclosure can be achieved, and this document does not limit this.
[0061] In related technologies, stored knowledge resources such as scientific research reports or technical materials need to be labeled and classified to facilitate query and retrieval, so that the knowledge resources can be effectively utilized and shared. However, the traditional manual label classification method is not only time-consuming and labor-intensive, but also difficult to ensure the consistency and comprehensiveness of the labels, thus limiting the effective utilization and sharing of knowledge resources.
[0062] In order to solve the above problems, the present invention provides a method, device and system for labeling text labels, which obtains a target word segmentation from a text to be labeled, generates an initial label of the target word segmentation according to a label library using a label generation model, calculates the similarity value between the initial label and each candidate label in a synonym library using multiple similarity calculation methods, obtains multiple similarity values, normalizes the multiple similarity values, sorts the normalized multiple similarity values, obtains a first order, determines a second order of multiple matching methods according to the first order, matches the initial label with the candidate labels in the synonym library in turn according to the matching methods corresponding to the second order, until at least one target candidate label is obtained, and labels the target word segmentation using the initial label and at least one target candidate label. The label of the text is expanded by generating a secondary identifier, thereby improving the efficiency of labeling the text and improving the comprehensiveness of the text label, thereby improving the accuracy of retrieving or querying the text, and making full use of knowledge resources.
[0063] Figure 1 is a flowchart of a text label marking method according to an exemplary embodiment. Figure 1 As shown, it should be noted that the text label marking method of the embodiment of the present disclosure is applied to the text label marking device. Figure 1 As shown, the method may include the following steps:
[0064] Step 101: Obtain target word segments from the text to be annotated.
[0065] In some embodiments of the present disclosure, the knowledge resources that need to be labeled can be converted into plain text format in advance, and pre-processing operations such as denoising, word segmentation, and stop word filtering can be performed to provide high-quality text data for subsequent processing. Natural language processing (NLP) technology, such as TF-IDF, Word2Vec, or BERT models, is used to extract features from the pre-processed text to capture key information in the text, including keywords, phrases, and sentence-level semantic features, and obtain multiple word segments.
[0066] In one embodiment, natural language processing (NLP) technology can be used for text preprocessing, document cleaning, removal of useless special characters, and word segmentation (for Chinese or other non-space-delimited languages) and stop word filtering (referring to words that appear frequently in the text but usually do not have much meaning) to reduce the complexity of subsequent processing. Word embedding (such as Word2Vec, BERT) is used to convert text into numerical vectors for computer processing. In addition, keywords or phrases can be extracted as feature representations of documents through algorithms such as TF-IDF and TextRank.
[0067] It is understandable that each of the above-mentioned multiple segmented words can be used as the above-mentioned target segmented word to execute the text labeling method proposed in the present disclosure to complete the labeling of the entire text.
[0068] Step 102: Generate an initial tag for the target word segmentation based on the tag library using the tag generation model.
[0069] The tag library is a tag library associated with the field to which the text to be annotated belongs.
[0070] In one embodiment, a tag library may be constructed in advance based on professional knowledge representing the field to which the text belongs, and an association network between tags may be constructed in the tag library, such as constructing a tag-based knowledge graph, thereby improving the comprehensiveness and logic of tag annotation.
[0071] As an example, a pre-trained machine learning or deep learning algorithm (such as K-means clustering, LDA topic model, sequence labeling model, etc.) can be used as a label generation model to automatically generate a set of initial labels. Since they are generated based on a label library that includes domain expertise, the initial labels not only cover the main content of the text, but also reflect the characteristics of the domain.
[0072] In some embodiments of the present disclosure, since the automatically generated initial tags may contain redundant, irrelevant or erroneous tags, the initial tags may be optimized and selected to further improve the quality of the tags, such as deduplication and screening of the initial tags, removal of duplicate tags, and filtering out obviously irrelevant tags based on statistics or rules.
[0073] Step 103: multiple similarity calculation methods are used to calculate the similarity value between the initial tag and each candidate tag in the synonym database to obtain multiple similarity values.
[0074] In some embodiments, the above-mentioned multiple similarity calculation methods may include any of the following:
[0075] TF-IDF algorithm, edit distance algorithm, cosine similarity algorithm and Jaccard similarity algorithm.
[0076] Step 104 , normalizing the multiple similarity values, and sorting the normalized multiple similarity values to obtain a first order.
[0077] In one embodiment, the normalized similarity values may be sorted in descending order.
[0078] In some embodiments of the present disclosure, the normalization process of the multiple similarity values in step 104 may include the following steps:
[0079] Step a1: when the multiple similarity calculation methods include the first method, the similarity value corresponding to the first method is normalized using the following formula:
[0080]
[0081] Wherein, tf_idf_h(Test[n] is the similarity value obtained by calculating the similarity of the nth candidate tag in the synonym library using the first method, and a is the normalized similarity value corresponding to the first method; the first method is to calculate the similarity value using the term frequency-inverse document frequency TF-IDF algorithm;
[0082] Step a2: when the multiple similarity calculation methods include the second method, the similarity value corresponding to the first method is normalized using the following formula:
[0083]
[0084] Among them, levenshtein_hash(Test[n]) is the similarity value obtained by calculating the similarity of the nth candidate tag in the synonym library using the second method, b is the normalized similarity value corresponding to the second method, and length(n) is the length of the nth candidate tag; the second method is to calculate the similarity value using the edit distance algorithm.
[0085] Step 105: Determine a second order of the plurality of matching methods according to the first order.
[0086] It is understandable that the larger the similarity value is, the higher the priority of the corresponding matching method is.
[0087] In some embodiments of the present disclosure, step 105 may specifically include the following steps:
[0088] Obtain mapping relationships between multiple similarity calculation methods and multiple matching methods;
[0089] According to the mapping relationship and the first order, the second order of the plurality of matching modes is determined.
[0090] Among them, the various similarity calculation methods include TF-IDF algorithm, edit distance algorithm, cosine similarity algorithm and Jaccard similarity algorithm; the matching methods include synonym matching, exact matching, fuzzy matching and semantic matching; the mapping relationship is that TF-IDF algorithm corresponds to synonym matching, edit distance algorithm corresponds to exact matching, cosine similarity algorithm corresponds to fuzzy matching, and Jaccard similarity algorithm corresponds to semantic matching.
[0091] It should be noted that exact matching refers to directly comparing the generated initial label with each synonym in the synonym library. If they are exactly the same, it is considered a successful match; fuzzy matching refers to using fuzzy matching algorithms (such as edit distance, Jaccard similarity, etc.) to compare the similarity between the initial label and synonyms in order to take into account the diversity and flexibility of the language. If the similarity exceeds a certain threshold, it is considered a successful match; semantic matching refers to using natural language processing technology (such as word embedding, semantic role labeling, etc.) to capture the semantic relationship between the initial label and synonyms. If the initial label and the synonym are semantically similar or related, it is considered a successful match.
[0092] It is understood that the TF-IDF (Term Frequency–Inverse Document Frequency) algorithm is used to evaluate the importance of a word to a document set or one of the documents in a corpus. The importance of a word increases in direct proportion to the number of times it appears in a document, but it decreases in inverse proportion to the frequency of its occurrence in the corpus. Various forms of TF-IDF weighting are often used by search engines as a measure or rating of the relevance between documents and user queries. Based on this feature, TF-IDF values are more likely to detect synonyms.
[0093] In addition, the edit distance algorithm calculates the edit distance between two texts to measure their similarity and is used to calculate the minimum number of edit operations between two strings, including insertion, deletion, and substitution. Based on this feature, it is easier to detect exact matches.
[0094] In addition, the cosine similarity algorithm represents the text tag phrase as a vector and calculates the cosine similarity between two vectors. Cosine similarity is a method used to measure the cosine value of the angle between two non-zero vectors, and is usually used to compare document similarity. The value of cosine similarity is between -1 and 1, where 1 means exactly the same, 0 means dissimilar, and -1 means completely opposite. Based on this feature, it is more suitable to use fuzzy matching for matching.
[0095] In addition, the Jaccard similarity algorithm is based on the vocabulary sets of two text phrases, and calculates the ratio of their intersection and union. It is used to measure the similarity between two sets, which is defined as the size of the intersection of the two sets divided by the size of the union. The Jaccard similarity value is between 0 and 1, 1 means that the two sets are exactly the same, and 0 means that they are completely different. Based on this feature, it is more suitable to use semantic matching for matching.
[0096] In one embodiment, the similarity values calculated using the TF-IDF algorithm can be stored in the Hash table tf_idf_hash in the form of a key-value pair; the similarity values calculated using the edit distance algorithm can be stored in the Hash table levenshteind_hash in the form of a key-value pair; the similarity values calculated using the cosine similarity algorithm can be stored in the Hash table cosine_similaritycos_hash in the form of a key-value pair; the similarity values calculated using the Jaccard similarity algorithm can be stored in the Hash table Jaccardjac_hash in the form of a key-value pair.
[0097] In one embodiment, the four values of a, b, c, and d can be sorted to obtain the above first sorting. The method with the larger value is preferred to match words with each other. a is the similarity value calculated by the first method, b is the similarity value calculated by the second method, c is the similarity value calculated by the third method, and d is the similarity value calculated by the fourth method. c = consine_similarity_hash (Test[n]), d = jaccard_hash (Test[n]).
[0098] Step 106 , matching the initial tag with the candidate tags in the synonym library in sequence according to the matching method corresponding to the second order until at least one target candidate tag is obtained.
[0099] In one embodiment, a synonym library can be created in advance, and the synonym library can contain multiple meanings of a word and multiple synonyms of multiple words, thereby enhancing the accuracy and richness of the search. The initial tag is matched with the synonyms (i.e., candidate tags) in the tag library to select the most appropriate tag as the target candidate tag.
[0100] It is understandable that in order to improve the efficiency of label matching, the most suitable matching method can be selected for matching according to the second order. If the target candidate label is not matched, the next matching method can be used for matching until the current matching method can match the target candidate label.
[0101] It should be noted that the target candidate tag can be one or more. In addition, the initial tag can be one or more. In the case where the target word segmentation has multiple initial tags, at least one target candidate tag can be matched for each initial tag.
[0102] In some embodiments of the present disclosure, step 106 may specifically include the following steps:
[0103] Step b1, determining a current matching method from multiple matching methods according to a second order.
[0104] Step b2: Match the initial tag with the candidate tags in the synonym library according to the current matching method to obtain a matching result.
[0105] The matching result includes whether the match is successful and the matched candidate tags.
[0106] Step b3: If the matching result is that no match is successful and the current matching method is not the last matching method in the second order, the next matching method is determined as the current matching method according to the second order, and the process returns to step b2.
[0107] Step b4: when the matching result is successful, the matched candidate tag is determined as the target candidate tag.
[0108] Step b5: When the matching result is that no matching is successful and the current matching mode is the last matching mode in the second order, it is determined that the matching fails.
[0109] In one embodiment, if it is determined that the match fails, the initial tag may be stored in a synonym library for future use.
[0110] In some embodiments of the present disclosure, step b2 may specifically include the following steps:
[0111] Step b21, when the current matching mode is fuzzy matching, for each candidate tag in the synonym library, the comprehensive similarity value between the initial tag and the candidate tag is calculated by the following formula:
[0112]
[0113] Wherein, Target is the comprehensive similarity value, a is the similarity value calculated by the first method, b is the similarity value calculated by the second method, c is the similarity value calculated by the third method, d is the similarity value calculated by the fourth method, λ1 is the weight value corresponding to the first method, λ2 is the weight value corresponding to the second method, λ3 is the weight value corresponding to the third method, and λ4 is the weight value corresponding to the fourth method;
[0114] Step b22: when the comprehensive similarity value satisfies the first preset condition, the candidate tag is determined as the target candidate tag.
[0115] In some embodiments of the present disclosure, step b22 may specifically include the following steps:
[0116] The similarity mean x is calculated by the following formula:
[0117]
[0118] Where n is the number of candidate tags in the synonym library;
[0119] In the case of Target<=x, multiple first intervals are used to determine the similarity level of the candidate tags;
[0120] In the case of Target>x, multiple second intervals are used to determine the similarity level of the candidate tags;
[0121] When the similarity level satisfies the second preset condition, the candidate tag is determined as the target candidate tag.
[0122] The interval range corresponding to the first interval whose similarity level meets the second preset condition is greater than the interval range corresponding to the second interval whose similarity level meets the second preset condition.
[0123] In one embodiment, the second preset condition may be that the similarity level is greater than or equal to a preset level.
[0124] It is understood that the larger the x is, the higher the overall similarity between the initial tag and the synonym library is, and it is easier to match the target candidate tag. The smaller the x is, the lower the overall similarity between the initial tag and the synonym library is, and it is more difficult to match the target candidate tag. Therefore, when the comprehensive similarity value Target<=x between the initial tag and the candidate tag, it means that the match is more difficult, and the screening criteria can be relaxed, that is, multiple first intervals are used to determine the similarity level of the candidate tag, so as to use the similarity level to determine whether the candidate tag can be used as the target candidate tag; when the comprehensive similarity value Target>x between the initial tag and the candidate tag, it means that the match is easier, and the screening criteria can be tightened, thereby improving the matching accuracy while ensuring a successful match, that is, multiple second intervals are used to determine the similarity level of the candidate tag, so as to use the similarity level to determine whether the candidate tag can be used as the target candidate tag.
[0125] For example, when Target<=x, the multiple first intervals used are shown in Table 1:
[0126] Table 1 Mapping relationship between the first interval and the similarity level
[0127] Rating level 1Low similarity 2. Low similarity 3. High similarity 4. High similarity First interval [0,0.3) [0.3,0.5) [0.5,0.7) [0.7,1.0]
[0128] When Target>x, the multiple first intervals used are shown in Table 2:
[0129] Table 2 Mapping relationship between the first interval and the similarity level
[0130] Rating level 1Low similarity 2. Low similarity 3. High similarity 4. High similarity Second interval [0,0.4) [0.4,0.6) [0.6,0.85) [0.85,1.0]
[0131] When the similarity level is determined to be 3, the tag similarity is high, and when the similarity level is determined to be 4, the similarity is high. The threshold can be set to a, 0.6<=a<=1, and is set by the knowledge base system within this range. If Value>=a, the fuzzy match is considered successful.
[0132] Step 107: label the target word segmentation using the initial label and at least one target candidate label.
[0133] In some embodiments of the present disclosure, after step 107, the initial tag and at least one target candidate tag may also be displayed on the terminal device, and the user may provide real-time feedback, wherein the feedback on the tag may include "correct", "wrong", "useful", "irrelevant", etc.
[0134] According to the text label annotation method proposed in the embodiment of the present disclosure, the target word segmentation is obtained from the text to be annotated, the label generation model is used to generate the initial label of the target word segmentation according to the label library, and multiple similarity calculation methods are used to calculate the similarity value between the initial label and each candidate label in the synonym library to obtain multiple similarity values, and the multiple similarity values are normalized. The multiple similarity values after normalization are sorted to obtain a first order, and according to the first order, the second order of multiple matching methods is determined, and the initial label is matched with the candidate labels in the synonym library in turn according to the matching method corresponding to the second order until at least one target candidate label is obtained, and the target word segmentation is annotated using the initial label and at least one target candidate label. The label of the text is expanded by the secondary generation of the identifier, thereby improving the efficiency of labeling the text while improving the comprehensiveness of the text label, thereby improving the accuracy of the retrieval or query text, and making full use of knowledge resources.
[0135] Figure 2 is a block diagram of a text label marking device according to an exemplary embodiment. Figure 2 The device includes an acquisition unit 201, a generation unit 202, a calculation unit 203, a sorting unit 204, a determination unit 205, a matching unit 206 and a labeling unit 207.
[0136] The acquisition unit 201 is used to acquire the target word segmentation from the text to be annotated;
[0137] A generating unit 202 is used to generate an initial label of a target word segmentation according to a label library using a label generation model; the label library is a label library associated with the field to which the text to be annotated belongs;
[0138] A calculation unit 203 is used to calculate the similarity value between the initial tag and each candidate tag in the synonym library by using multiple similarity calculation methods to obtain multiple similarity values;
[0139] A sorting unit 204 is used to normalize the multiple similarity values and sort the normalized similarity values to obtain a first order;
[0140] A determination unit 205, configured to determine a second order of the plurality of matching modes according to the first order;
[0141] A matching unit 206, configured to sequentially match the initial tag with the candidate tags in the synonym library according to the matching method corresponding to the second order until at least one target candidate tag is obtained;
[0142] The labeling unit 207 is used to label the target word segmentation using the initial label and at least one target candidate label.
[0143] In some embodiments of the present disclosure, the sorting unit 204 may be specifically used to:
[0144] When multiple similarity calculation methods include the first method, the similarity value corresponding to the first method is normalized using the following formula:
[0145]
[0146] Wherein, tf_idf_h(Test[n] is the similarity value obtained by calculating the similarity of the nth candidate tag in the synonym library using the first method, and a is the normalized similarity value corresponding to the first method; the first method is to calculate the similarity value using the term frequency-inverse document frequency TF-IDF algorithm;
[0147] When multiple similarity calculation methods include the second method, the similarity value corresponding to the first method is normalized using the following formula:
[0148]
[0149] Among them, levenshtein_hash(Test[n]) is the similarity value obtained by calculating the similarity of the nth candidate tag in the synonym library using the second method, b is the normalized similarity value corresponding to the second method, and length(n) is the length of the nth candidate tag; the second method is to calculate the similarity value using the edit distance algorithm.
[0150] In some embodiments of the present disclosure, the determining unit 205 may be specifically configured to:
[0151] Obtain mapping relationships between multiple similarity calculation methods and multiple matching methods;
[0152] According to the mapping relationship and the first order, the second order of multiple matching methods is determined; wherein the multiple similarity calculation methods include TF-IDF algorithm, edit distance algorithm, cosine similarity algorithm and Jaccard similarity algorithm; the matching methods include synonym matching, exact matching, fuzzy matching and semantic matching; the mapping relationship is that TF-IDF algorithm corresponds to synonym matching, edit distance algorithm corresponds to exact matching, cosine similarity algorithm corresponds to fuzzy matching, and Jaccard similarity algorithm corresponds to semantic matching.
[0153] In some embodiments of the present disclosure, the matching unit 206 may be specifically used to:
[0154] Determine a current matching mode from among the plurality of matching modes according to a second order;
[0155] Matching the initial tag with the candidate tags in the synonym library according to the current matching method to obtain a matching result; the matching result includes whether the match is successful and the matched candidate tags;
[0156] If the matching result is that no match is successful and the current matching method is not the last matching method in the second order, the next matching method is determined as the current matching method according to the second order, and the process returns to the step of matching the initial tag with the candidate tags in the synonym library according to the current matching method to obtain a matching result;
[0157] When the matching result is successful, the matched candidate tag is determined as the target candidate tag;
[0158] When the matching result is that no matching is successful and the current matching mode is the last matching mode in the second order, it is determined that the matching fails.
[0159] In some embodiments of the present disclosure, the matching unit 206 may be specifically used to:
[0160] When the current matching method is fuzzy matching, for each candidate tag in the synonym library, the comprehensive similarity value between the initial tag and the candidate tag is calculated by the following formula:
[0161]
[0162] Wherein, Target is the comprehensive similarity value, a is the similarity value calculated by the first method, b is the similarity value calculated by the second method, c is the similarity value calculated by the third method, d is the similarity value calculated by the fourth method, λ1 is the weight value corresponding to the first method, λ2 is the weight value corresponding to the second method, λ3 is the weight value corresponding to the third method, and λ4 is the weight value corresponding to the fourth method;
[0163] When the comprehensive similarity value satisfies the first preset condition, the candidate tag is determined as the target candidate tag.
[0164] In some embodiments of the present disclosure, the matching unit 206 may be specifically used to:
[0165] The similarity mean x is calculated by the following formula:
[0166]
[0167] Where n is the number of candidate tags in the synonym library;
[0168] In the case of Target<=x, multiple first intervals are used to determine the similarity level of the candidate tags;
[0169] In the case of Target>x, multiple second intervals are used to determine the similarity level of the candidate tags;
[0170] When the similarity level meets the second preset condition, the candidate tag is determined as the target candidate tag; wherein the interval range corresponding to the first interval whose similarity level meets the second preset condition is larger than the interval range corresponding to the second interval whose similarity level meets the second preset condition.
[0171] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0172] According to the text label annotation device proposed in the embodiment of the present disclosure, by obtaining the target word segmentation from the text to be annotated, using the label generation model, generating the initial label of the target word segmentation according to the label library, using multiple similarity calculation methods to calculate the similarity value between the initial label and each candidate label in the synonym library, obtaining multiple similarity values, normalizing the multiple similarity values, sorting the normalized multiple similarity values to obtain a first order, according to the first order, determining the second order of multiple matching methods, sequentially matching the initial label with the candidate labels in the synonym library according to the matching method corresponding to the second order, until at least one target candidate label is obtained, and annotating the target word segmentation using the initial label and at least one target candidate label. The label of the text is expanded by the secondary generation of the identifier, thereby improving the efficiency of labeling the text while improving the comprehensiveness of the text label, thereby improving the accuracy of the retrieval or query text, and making full use of knowledge resources.
[0173] Figure 3300 is a block diagram of a device for a text labeling method according to an exemplary embodiment. For example, the device 300 may be an electronic device, such as a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0174] Reference Figure 3 , the device 300 may include one or more of the following components: a processing component 302 , a memory 304 , a power component 306 , a multimedia component 308 , an audio component 310 , an input / output (I / O) interface 312 , a sensor component 314 , and a communication component 316 .
[0175] The processing component 302 generally controls the overall operation of the device 300, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 302 may include one or more processors 320 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 302 may include one or more modules to facilitate the interaction between the processing component 302 and other components. For example, the processing component 302 may include a multimedia module to facilitate the interaction between the multimedia component 308 and the processing component 302.
[0176] The memory 304 is configured to store various types of data to support operations on the device 300. Examples of such data include instructions for any application or method operating on the device 300, contact data, phone book data, messages, pictures, videos, etc. The memory 304 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0177] The power component 306 provides power to the various components of the device 300. The power component 306 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 300.
[0178] The multimedia component 308 includes a screen that provides an output interface between the device 300 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 308 includes a front camera and / or a rear camera. When the device 300 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0179] The audio component 310 is configured to output and / or input audio signals. For example, the audio component 310 includes a microphone (MIC), and when the device 300 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 304 or sent via the communication component 316. In some embodiments, the audio component 310 also includes a speaker for outputting audio signals.
[0180] I / O interface 312 provides an interface between processing component 302 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0181] The sensor assembly 314 includes one or more sensors for providing various aspects of status assessment for the device 300. For example, the sensor assembly 314 can detect the open / closed state of the device 300, the relative positioning of components, such as the display and keypad of the device 300, the sensor assembly 314 can also detect the position change of the device 300 or a component of the device 300, the presence or absence of user contact with the device 300, the orientation or acceleration / deceleration of the device 300 and the temperature change of the device 300. The sensor assembly 314 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 314 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 314 can also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.
[0182] The communication component 316 is configured to facilitate wired or wireless communication between the device 300 and other devices. The device 300 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 316 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 316 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0183] In an exemplary embodiment, the apparatus 300 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.
[0184] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 304 including instructions, and the instructions can be executed by the processor 320 of the device 300 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0185] In an exemplary embodiment, a computer program product is also provided, comprising a computer program, which implements the above method when executed by the processor 320 of the device 300 .
[0186] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.
[0187] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A text label marking method, characterized in that: include: Obtain target word segmentation from the text to be annotated; Using a label generation model, generating an initial label for the target word according to a label library; The tag library is a tag library associated with the field to which the text to be annotated belongs; Using multiple similarity calculation methods to calculate the similarity value between the initial tag and each candidate tag in the synonym library to obtain multiple similarity values; Normalizing the multiple similarity values, and sorting the normalized multiple similarity values to obtain a first order; According to the first order, determining a second order of the plurality of matching methods; Matching the initial tag with the candidate tags in the synonym library in sequence according to the matching method corresponding to the second sequence until at least one target candidate tag is obtained; The target word segment is labeled using the initial label and the at least one target candidate label.
2. The text label marking method according to claim 1, characterized in that: The normalizing the multiple similarity values comprises: When the multiple similarity calculation methods include the first method, the similarity value corresponding to the first method is normalized using the following formula: Wherein, tf_idf_h(Test[n] is the similarity value obtained by calculating the similarity of the nth candidate tag in the synonym library using the first method, and a is the normalized similarity value corresponding to the first method; the first method is to calculate the similarity value using the term frequency-inverse document frequency TF-IDF algorithm; When the multiple similarity calculation methods include the second method, the similarity value corresponding to the first method is normalized using the following formula: Among them, levenshtein_hash(Test[n]) is the similarity value obtained by calculating the similarity of the nth candidate tag in the synonym library using the second method, b is the normalized similarity value corresponding to the second method, and length(n) is the length of the nth candidate tag; the second method is to calculate the similarity value using the edit distance algorithm.
3. The text label marking method according to claim 1, characterized in that: Determining a second order of the plurality of matching methods according to the first order includes: Acquire a mapping relationship between the multiple similarity calculation methods and the multiple matching methods; According to the mapping relationship and the first order, a second order of the multiple matching methods is determined; wherein the multiple similarity calculation methods include TF-IDF algorithm, edit distance algorithm, cosine similarity algorithm and Jaccard similarity algorithm; the matching methods include synonym matching, exact matching, fuzzy matching and semantic matching; the mapping relationship is that TF-IDF algorithm corresponds to synonym matching, edit distance algorithm corresponds to exact matching, cosine similarity algorithm corresponds to fuzzy matching, and Jaccard similarity algorithm corresponds to semantic matching.
4. The text label marking method according to claim 1, characterized in that: The matching of the initial tag with the candidate tags in the synonym library in sequence according to the matching method corresponding to the second sequence until at least one target candidate tag is obtained includes: Determine a current matching mode from the plurality of matching modes according to the second order; Matching the initial tag with the candidate tags in the synonym library according to the current matching method to obtain a matching result; the matching result includes whether the match is successful and the matched candidate tags; If the matching result is that no match is successful, and the current matching method is not the last matching method in the second order, the next matching method is determined as the current matching method according to the second order, and the step of matching the initial tag with the candidate tags in the synonym library according to the current matching method to obtain a matching result is returned to the execution; When the matching result is a successful match, determining the matched candidate tag as the target candidate tag; When the matching result is that no matching is successful and the current matching mode is the last matching mode in the second sequence, it is determined that the matching fails.
5. The text label marking method according to claim 4, characterized in that: The multiple matching methods include fuzzy matching, and the initial tag is matched with the candidate tags in the synonym library according to the current matching method to obtain a matching result, including: When the current matching method is fuzzy matching, for each candidate tag in the synonym library, the comprehensive similarity value between the initial tag and the candidate tag is calculated by the following formula: Wherein, Target is the comprehensive similarity value, a is the similarity value calculated by the first method, b is the similarity value calculated by the second method, c is the similarity value calculated by the third method, d is the similarity value calculated by the fourth method, λ1 is the weight value corresponding to the first method, λ2 is the weight value corresponding to the second method, λ3 is the weight value corresponding to the third method, and λ4 is the weight value corresponding to the fourth method; When the comprehensive similarity value satisfies the first preset condition, the candidate tag is determined as the target candidate tag.
6. The text label marking method according to claim 5, characterized in that: In the case where the comprehensive similarity value satisfies the first preset condition, determining the candidate tag as the target candidate tag includes: The similarity mean x is calculated by the following formula: Wherein, n is the number of candidate tags in the synonym library; In the case of Target<=x, a plurality of first intervals are used to determine the similarity level of the candidate tags; In the case of Target>x, multiple second intervals are used to determine the similarity level of the candidate tags; When the similarity level meets the second preset condition, the candidate tag is determined as the target candidate tag; wherein the interval range corresponding to the first interval whose similarity level meets the second preset condition is larger than the interval range corresponding to the second interval whose similarity level meets the second preset condition.
7. A text label marking device, characterized in that: include: An acquisition unit, used to acquire target word segments from the text to be annotated; A generation unit, used to generate an initial label of the target word segmentation according to a label library by using a label generation model; The tag library is a tag library associated with the field to which the text to be annotated belongs; A calculation unit, used to calculate the similarity value between the initial tag and each candidate tag in the synonym library by using multiple similarity calculation methods to obtain multiple similarity values; A sorting unit, configured to normalize the plurality of similarity values, and sort the plurality of similarity values after the normalization process to obtain a first order; A determining unit, configured to determine a second order of the plurality of matching modes according to the first order; a matching unit, configured to match the initial tag with the candidate tags in the synonym library in sequence according to the matching method corresponding to the second sequence until at least one target candidate tag is obtained; A labeling unit is used to label the target word segmentation using the initial label and the at least one target candidate label.
8. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that The computer program implements the method according to any one of claims 1 to 6 when executed by a processor.
Citation Information
Patent Citations
Label automatic generating method and system, computer readable storage medium and equipment
CN108959431A
Word generation method and system of corpus, computer equipment and storage medium
CN110909539A
Label mapping method and system and computer readable storage medium
CN112818117A
Text data labeling method and device, electronic equipment and storage medium
CN114357990A
Cboth document material extraction method and device, equipment, medium and product
CN114971730A