WO2020107835A1 - 一种样本数据处理方法及装置 - Google Patents
一种样本数据处理方法及装置 Download PDFInfo
- Publication number
- WO2020107835A1 WO2020107835A1 PCT/CN2019/088803 CN2019088803W WO2020107835A1 WO 2020107835 A1 WO2020107835 A1 WO 2020107835A1 CN 2019088803 W CN2019088803 W CN 2019088803W WO 2020107835 A1 WO2020107835 A1 WO 2020107835A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- keyword
- word
- bag
- vector
- element set
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/279—Recognition of textual entities
- G06F40/289—Phrasal analysis, e.g. finite state techniques or chunking
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Definitions
- the present application relates to the field of computer technology, and in particular, to a sample data processing method and device.
- Text classification can help people quickly and effectively obtain key information from massive data, and the accuracy of text classification depends on the performance of machine learning models, and the performance of machine learning models depends on sample data.
- Embodiments of the present application provide a sample data processing method and device, which can increase the amount of information of short text sample data, improve the performance of a machine learning model constructed using the short text sample data, and thereby improve the accuracy of short text classification.
- an embodiment of the present application provides a sample data processing method.
- the method includes:
- the first element set is determined according to the word segmentation result and the keyword word bag, and the first element set includes N elements, and the value of each element in the first element set is the value of each keyword in the keyword bag The number of occurrences in the word segmentation results;
- the target word includes the word that exists in the word segmentation result and does not exist in the keyword word bag word;
- the first element in the first element set is updated according to the similarity value of the target word and the first keyword
- the first element corresponding to the keyword gets the second element set
- each element in the second element set is used to construct a machine learning model for short text classification.
- an embodiment of the present application provides a sample data processing device, which includes:
- the first obtaining module is used to obtain a word segmentation result obtained by segmenting short text samples, and obtain a keyword word bag containing N keywords, and the word segmentation result includes at least one word;
- a determining module configured to determine a first element set according to the word segmentation result and the keyword word bag, the first element set includes N elements, and the value of each element in the first element set is the keyword word bag The number of times each keyword appears in the segmentation result;
- the second obtaining module is used to obtain the target word in the word segmentation result, and obtain the similarity value between the target word and each keyword in the keyword word bag.
- the target word includes the key word existing in the word segmentation result and the key word. Words that do not exist in the word bag;
- the update module is configured to update the first element according to the similarity value of the target word and the first keyword when the similarity value of the target word and the first keyword in the keyword word bag is greater than the similarity threshold
- the first element corresponding to the first keyword in the set obtains the second element set
- each element in the second element set is used to construct a machine learning model for short text classification.
- an embodiment of the present application provides a terminal, including a processor and a memory, the processor and the memory are connected to each other, wherein the memory is used to store a computer program that supports the terminal to execute the above method, and the computer program includes program instructions
- the processor is configured to call the program instruction to execute the sample data processing method of the first aspect.
- an embodiment of the present application provides a computer-readable storage medium storing a computer program, the computer program including program instructions, which when executed by a processor causes the processor to execute The sample data processing method of the above-mentioned first aspect.
- the amount of information in the element set of the short text sample can be increased, the performance of the machine learning model built using the element set of the short text sample can be improved, and the short text The accuracy of this category.
- FIG. 1 is a schematic flowchart of a sample data processing method provided by an embodiment of the present application
- FIG. 2 is a schematic flowchart of a keyword word bag generation method provided by an embodiment of the present application.
- FIG. 3 is a schematic diagram of entries returned by the keyword "basketball" provided by an embodiment of the present application.
- FIG. 4 is another schematic flowchart of a sample data processing method provided by an embodiment of the present application.
- FIG. 5 is a schematic block diagram of a sample data processing device provided by an embodiment of the present application.
- FIG. 6 is a schematic block diagram of a terminal provided by an embodiment of the present application.
- FIG. 1 is a schematic flowchart of a sample data processing method provided by an embodiment of the present application. As shown in FIG. 1, the sample data processing method may include steps:
- the terminal obtains a word segmentation result obtained after short text samples are segmented, and obtains a key word bag containing N keywords.
- the terminal may obtain a short text sample input by a user, and may use a word segmentation method based on string matching or a machine learning algorithm based on statistics to segment the short text sample to obtain a word segmentation result after word segmentation .
- the word segmentation result may include at least one word.
- the terminal may obtain any keyword word bag containing N keywords from the keyword word bag database. N can be an integer greater than 1.
- the keyword word bag database may include preset keyword word bags of multiple categories. Each keyword word bag in the keyword word bag database includes N keywords.
- the keyword word bag can be used to represent a set of words in the text that ignore word order, grammar, and syntax. For example, the short text sample is "how is the weather today?", and the result of the word segmentation after the word segmentation is "today/weather/how".
- the information length of short text samples is relatively short, usually within 200 words, so the effective information contained is also very small, usually with sparseness, real-time, irregularity and other characteristics.
- Word segmentation methods based on string matching can include forward maximum matching method, reverse maximum matching method, bidirectional matching word segmentation method, etc.
- statistical-based machine learning algorithms can include hidden Markov model (HMM), conditional random field (conditional random fields, CRF), etc.
- FIG. 2 is a schematic flowchart of a keyword word bag generation method provided by an embodiment of the present application. As shown in FIG. 2, the method for generating a keyword word bag according to an embodiment of the present application may include the following steps:
- S1011 Obtain a training sample set for generating keyword word bags.
- the terminal may input predetermined keywords of different categories on Baidu Know to search, and may crawl the titles returned by the keywords of the different categories, such as searching for weather keywords "weather”, “Little rain”, etc.; sports keywords “basketball”, “baseball”, “running”, etc.
- the terminal can manually classify and label the titles crawled on Baidu Know to obtain training samples corresponding to each category.
- the terminal may add training samples corresponding to each category to the set of training samples to form a training sample set.
- One category may correspond to one training sample, and the training sample may include multiple titles (samples) of the same category.
- FIG. 3 it is a schematic diagram of the entry returned by the keyword "basketball".
- basketball is one of the keywords in the sports category. Enter the keyword “basketball” on Baidu Know to search, and the terminal crawls the first 50 titles returned by the keyword “basketball”. As shown in Figure 3, the titles “How big is the diameter of a basketball", “The size of a basketball?", “What is the standard size of a basketball court?” and so on.
- S1012 Determine N keywords from the training sample set according to the word frequency-inverse document frequency algorithm, and generate keyword word bags according to the N keywords.
- the terminal may use a word segmentation tool (such as jieba word segmentation, stanfordCoreNlp word segmentation, etc.) to perform word segmentation on each sample (ie, title) in each training sample of the above training sample set.
- a word segmentation tool such as jieba word segmentation, stanfordCoreNlp word segmentation, etc.
- the terminal can use the term frequency-inverse document frequency (TF-IDF) algorithm to calculate the TF-IDF value of each word obtained by segmenting each sample in the training sample, and
- the calculated TF-IDF values of the category can be sorted from large to small to obtain the TF-IDF sequence, and the N words corresponding to the first N TF-IDF values can be extracted from the TF-IDF sequence.
- the N words are manually added or deleted to obtain a keyword bag containing N keywords.
- N is an integer greater than 1.
- the terminal may preset a keyword word bag database, and the keyword word bag database may be used to store keyword word bags of at least one category. Each keyword word bag in the keyword word bag database includes N keywords.
- the TF-IDF value is equal to the product of the IDF w and TF w, TF w, and IDF w satisfy:
- the entry w can be used to represent any word obtained by segmenting each sample in the training sample.
- the corpus can be used to represent the set of all training samples, that is, the training sample set.
- the number can be equal to the number of categories of the training sample. It should be noted that the total number of documents in the corpus in the embodiment of the present application is greater than 2, that is, there are at least three categories of training samples in the training sample set.
- the terminal uses the jieba word segmentation tool or stanfordCoreNlp word segmentation tool to segment all samples (titles) in the "weather” category, and then calculates the TF-IDF of each word after segmentation according to the TF-IDF formula. Value, sort the calculated TF-IDF values of the "weather” category from large to small, and filter out the top 100 words in the "weather” category with the TF-IDF value as the keyword word bags of the "weather” category.
- the corpus in TF-IDF is composed of training samples in three categories: "weather", “credit card” and "air ticket".
- the entry w is any word obtained by segmenting the training samples in the "weather” category.
- the document is Training samples.
- the total number of documents in the IDF w corpus is 3, which are the training samples of the three categories of "weather", “credit card”, and "air ticket”, and the number of documents containing the entry w is 1, which is the training sample of the "weather” category. .
- a keyword bag contains 1000 keywords, and the short text is short (usually within 200 words), so for short text, the traditional key The vector dimension generated by the word bag is too large.
- the terminal in the embodiment of the present application uses the TF-IDF algorithm to construct a small keyword word bag (including 100 keywords), which greatly avoids the problem of excessively large dimensions when generating vectors using the keyword word bag.
- the terminal determines the first element set according to the word segmentation result and the keyword word bag.
- the terminal may count the number of times each keyword in the keyword word bag appears in the segmentation result of the short text sample.
- the terminal may use the number of occurrences of each keyword in the keyword word bag in the word segmentation result as an element in the first element set.
- the first element set may include N elements.
- the foregoing first element set may be a first vector, and the first vector may include N elements.
- the first vector satisfies:
- V 1 represents the first vector
- n represents the number of times the nth word in the keyword word bag appears in the segmentation result of the short text sample.
- the value of n ranges from 1 to N natural number.
- the first vector V 1 includes 5 elements. Keywords word hypothesis bags second key word "weather” and the fifth keyword “Today” in the segmentation result of a short sample text appears once in each terminal determines a first vector V 1 and the second element The fifth element is 1.
- the terminal obtains the target word in the word segmentation result, and obtains the similarity value between the target word and each keyword in the keyword word bag.
- the terminal may search whether the target word exists in the word segmentation result of the above short text sample. If there is at least one target word in the word segmentation result, the terminal may acquire any target word in the word segmentation result. The terminal may calculate the similarity value between the target word and each keyword in the keyword word bag, such as the cosine value and the Euclidean distance. If the target word does not exist in the word segmentation result, the terminal may determine the first element set as the second element set. The target word may be used to indicate a word that exists in the word segmentation result and does not exist in the keyword word bag.
- the terminal detects whether the same keywords as the words C1, C2, C3, C4, and C5 exist in the keyword word bags. If the same keywords as the words C2 and C5 do not exist in the keyword word bag, the terminal determines the words C2 and C5 as the target words, respectively. The terminal obtains any one of the target words C2 and C5, such as C2, and the terminal calculates the similarity value between the target word C2 and each keyword in the keyword word bag.
- S104 If the similarity value of the target word and the first keyword in the keyword word bag is greater than the similarity threshold, the terminal updates the first keyword in the first element set according to the similarity value of the target word and the first keyword The first element to get the second element set.
- the terminal may detect whether the similarity value between the target word and each keyword Greater than the preset similarity threshold. When it is detected that the similarity value between the target word and the first keyword in the keyword bag is greater than the similarity threshold, it means that the target word and the first keyword are synonymous, then the terminal can use the target word and the The similarity value of the first keyword updates the first element corresponding to the first keyword in the first element set to obtain a second element set.
- the terminal can obtain the above The similarity value between the next target word in the word segmentation result and each keyword in the keyword bag. If the similarity value between each target word in the above word segmentation result and each keyword in the keyword word bag is less than or equal to the similarity threshold, it means that there is no synonym for any target word in the keyword word bag, then The terminal may determine the above-mentioned first element set as the second element set. Each element in the second element set can be used to build a machine learning model for short text classification.
- the word segmentation results of the keyword word bag and the short text sample are used to determine the first element set, some information in the short text sample is lost, ie The case where the word present in the segmentation result of the short text sample is not in the keyword word bag, that is, the target word appears in the short text sample. And because each element in the first element set is the number of times each keyword in the keyword word bag appears in the word segmentation result, the target word in the word segmentation result is not reflected in the first element set.
- the similarity value of each keyword in the target word and the keyword word bag is searched for the synonym of the target word in the keyword word bag, and the corresponding element in the first element set of the synonym of the target word is updated The second element collection.
- the terminal obtains a word segmentation result after word segmentation by acquiring a short text sample, and obtains a keyword word bag containing N keywords, and determines a first element set according to the word segmentation result and the keyword word bag, Obtain the target word in the word segmentation result, and obtain the similarity value of the target word and each keyword in the keyword word bag, when the similarity value of the target word and the first keyword in the keyword word bag is greater than Similarity threshold, the first element corresponding to the first keyword in the first element set is updated according to the similarity value of the target word and the first keyword to obtain a second element set, the Each element is used to build a machine learning model for short text classification, which can increase the amount of information in the element set of the short text sample, improve the performance of the machine learning model built using the element set of the short text sample, and thus improve the short text classification Accuracy.
- sample data processing method may include steps:
- the terminal obtains a word segmentation result obtained after short text samples are segmented, and acquires a keyword word bag containing N keywords.
- the terminal determines the first element set according to the word segmentation result and the keyword word bag.
- step S401-step S402 in the embodiment of the present application, reference may be made to the implementation manner of step S101-step S102 in the embodiment shown in FIG. 1, and details are not described herein again.
- the terminal obtains the target word in the word segmentation result.
- the terminal obtains the word vector of the target word from the word vector database, and obtains the word vector of each keyword in the keyword word bag from the word vector database.
- the terminal calculates a similarity value between the word vector of the target word and the word vector of each keyword.
- the terminal updates the first element corresponding to the first keyword in the first element set to the sum of the product and the first element to obtain the second element set.
- the terminal may search whether the target word exists in the word segmentation result of the above short text sample. If there is at least one target word in the word segmentation result, the terminal may acquire any target word in the word segmentation result.
- the terminal may obtain the word vector of the target word from the word vector database, and may obtain the word vector of each keyword in the keyword word bag from the word vector database.
- the terminal may calculate the similarity value (such as cosine value, Euclidean distance, etc.) between the word vector of the target word and the word vector of each keyword.
- the terminal may detect whether the similarity value between the word vector of the target word and the word vector of each keyword is greater than a preset similarity threshold.
- the terminal When it is detected that the similarity value between the word vector of the target word and the word vector of the first keyword in the keyword bag is greater than the similarity threshold, it means that the target word and the first keyword are synonyms, then the terminal The product of the similarity value and the number of times the target word appears in the segmentation result of the short text sample can be calculated.
- the terminal may update the first element corresponding to the first keyword in the first element set to the sum of the product and the first element to obtain the second element set.
- the target word may be used to indicate a word that exists in the word segmentation result and does not exist in the keyword word bag.
- the terminal may determine the first element set as the second element set. Or, when it is detected that the similarity value between the word vector of the target word and the word vector of each keyword in the keyword bag is less than or equal to the similarity threshold, it means that the target word is not in the keyword bag , The terminal can obtain the similarity value between the word vector of the next target word in the word segmentation result and the word vector of each keyword in the keyword bag.
- the terminal may determine the first element set as the second element set.
- the method of generating the word vector database may be: (1) The terminal crawls a large-scale unlabeled corpus from Wikipedia (approximately around 10 Gs), and segment the unlabeled corpus, These corpora after word segmentation are input into a continuous keyword bag of words (CBOW) model for training. (2) After the CBOW model training is completed, the terminal can obtain the word vectors of all words in these corpora output by the CBOW model, and can store the word vectors of all words in these corpora into the word vector database.
- CBOW continuous keyword bag of words
- the foregoing second element set may be a second vector, and the second vector may include N elements. This second vector satisfies:
- V 2 represents the second vector
- w j represents the target word in the segmentation result of the short text sample
- w k represents the k-th keyword in the keyword word bag is the first keyword
- cos(w k ,w j ) Represents the cosine value between the word vector of the target word w j and the word vector of the first keyword w k in the keyword word bag
- cos(w k , w j ) is greater than a preset similarity threshold such as 0.7
- ie w j and w k are synonyms.
- the terminal converts the first element in the first vector V 1 Update to Represents the number of times the target word appears in the segmentation result of the short text sample, Indicates the number of times the first keyword in the keyword word bag appears in the segmentation result of the short text sample.
- target words in the word segmentation result of the short text sample which are the target word w j1 and the target word w j2 respectively .
- keywords in the keyword bag which are w 1 , w 2 , w 3 ,..., w 10 .
- the preset similarity threshold is 0.7.
- the terminal respectively calculates the cosine value between the word vector of the target word w j1 and the word vectors of 10 keywords w 1 , w 2 , w 3 ,..., w 10 in the keyword word bag.
- the terminal calculates the cosine value cos(w 4 , w j1 ) The number of occurrences of the target word w j1 in the word segmentation result Product of The terminal converts the fourth element in the first vector V 1 Update to the fourth element And product Sum, ie The terminal separately calculates the cosine value between the word vector of the target word w j2 and the word vectors of 10 keywords w 1 , w 2 , w 3 ,..., w 10 in the keyword word bag.
- the terminal updates the third element of the first vector V 1 Sixth element And the seventh element
- the terminal obtains M second keywords corresponding to M 0 elements in the second element set.
- the terminal may detect whether there is an 0 element in the second element set. If there are 0 elements in the second element set, the terminal may acquire the M zero elements in the second element set, and may determine the keyword corresponding to each 0 element in the second element set as the second keyword, Thus, M second keywords are obtained. If there is no 0 element in the second element set, the terminal may determine the second element set as the third element set.
- M can be an integer greater than or equal to 1.
- the 0 element in the second element set can be used to indicate that a keyword in the keyword word bag appears 0 times in the word segmentation result and the synonyms of the keyword also appear in the word segmentation result in 0 times , That is, the second keyword does not appear in the segmentation result and the synonyms of the second keyword do not appear in the segmentation result.
- the terminal may take any keyword from the above keyword word bag, and may detect whether the keyword in the keyword word bag is completely taken. If the keyword in the keyword word bag is not finished, check whether the number of occurrences of the keyword in the word segmentation result is 0. When the number of occurrences of the keyword in the word segmentation result is 0, calculate the The similarity value between the keyword and each word in the word segmentation result, when the similarity value between the keyword and each word in the word segmentation result is less than or equal to the preset similarity threshold, it means that the word segmentation result If there is no synonym for the keyword, the keyword can be determined as the second keyword. If the second keyword does not exist in the keyword word bag, the second element set may be determined as the third element set.
- the terminal acquires at least one third keyword in the keyword word bag.
- the terminal may acquire at least one third keyword from the keyword word bag, and the number of times that the third keyword appears in the word segmentation result is greater than or equal to 1.
- the terminal may calculate the similarity value (such as cosine value, Euclidean distance, etc.) between each of the second keywords in the M second keywords and each third keyword in the keyword bag, and according to the similarity
- the degree value replaces the 0 element in the second element to obtain the third element set.
- Each element in the third element set is used to construct a machine learning model for short text classification. Because the main principle of the machine learning model is to multiply each element in the element set by a weight, and finally output the probability that the element set belongs to different categories.
- the 0 element is multiplied by the weight of any value, and you still get 0.
- the probability of the output of the machine learning model may be 0, resulting in the construction of the element set with 0 elements for short text.
- the accuracy of machine learning models in this category is not high. Therefore, in this embodiment of the present application, by replacing the 0 element in the second element set, that is, there is no 0 element in the third element set, the accuracy of the machine learning model can be improved while ensuring the information amount of the element set, thereby improving short text Classification accuracy.
- the terminal may acquire the word vector of each second keyword of the M second keywords from the word vector database, and may obtain the word vector from the word
- the vector database obtains word vectors of each third keyword of at least one third keyword in the keyword word bag.
- the terminal may acquire the similarity between the word vector of the second keyword i and the word vector of each third keyword in the at least one third keyword Degree value (such as cosine value, Euclidean distance, etc.). If the similarity value between the word vector of the second keyword i and the third keyword m of the at least one third keyword is the largest, the terminal may obtain the occurrence of the third keyword m in the above word segmentation result frequency.
- the terminal may calculate the product of the similarity value between the word vector of the second keyword i and the third keyword m and the number of times, and may divide the 0 element corresponding to the second keyword i in the second element set Replace with the product.
- the terminal may obtain the third element set after replacing all M zero elements corresponding to the M second keywords in the second element set.
- Each element in the third element set is used to construct a machine learning model for short text classification.
- the foregoing third element set may be a third vector, and the third vector may include N elements. This third vector satisfies:
- V 3 represents the third vector
- w m represents the mth keyword in the keyword word bag is the third keyword
- the w i indicates that the i-th keyword in the keyword word bag is the second keyword
- [cos(w m , w i )] max indicates the m-th keyword in the keyword word bag and the keyword word bag
- the i-th keyword in has the highest similarity value.
- the terminal calculates the cosine value between the word vector of the second keyword w 5 and the word vectors of the third keywords w 3 , w 6 and w 12 respectively.
- the terminal updates the first element set by calculating the similarity value between the word vector of the target word in the word segmentation result of the short text sample and the word vector of each keyword in the keyword word bag, Get the second set of elements. Then replace the 0 element in the second element set according to the similarity value between the word vector of the second keyword in the keyword word bag and the word vector of the third keyword in the keyword word bag to obtain the third element set.
- Each element in the third element set is used to construct a machine learning model for short text classification. It can improve the accuracy of machine learning models while ensuring the amount of element set information, thereby improving the accuracy of short text classification.
- FIG. 5 it is a schematic block diagram of a sample data processing apparatus provided by an embodiment of the present application.
- the sample data processing device in the embodiment of the present application includes:
- the first obtaining module 10 is used to obtain a word segmentation result obtained by segmenting short text samples, and obtain a keyword word bag containing N keywords, and the word segmentation result includes at least one word;
- the determining module 20 is configured to determine a first element set according to the word segmentation result and the keyword word bag, the first element set includes N elements, and the value of each element in the first element set is the keyword word bag The number of times each keyword in the word segmentation result appears;
- the second obtaining module 30 is used to obtain the target word in the word segmentation result, and obtain the similarity value between the target word and each keyword in the keyword word bag.
- the target word is included in the word segmentation result and is included in the Keywords that do not exist in the keyword bag;
- the update module 40 is configured to update the first word according to the similarity value of the target word and the first keyword when the similarity value of the target word and the first keyword in the keyword word bag is greater than the similarity threshold
- the first element corresponding to the first keyword in the element set obtains the second element set
- each element in the second element set is used to construct a machine learning model for short text classification.
- the first acquisition module 10 includes a first acquisition unit 101 and a second acquisition unit 102.
- the first acquisition unit 101 is used to acquire a word segmentation result obtained by segmenting short text samples, and the word segmentation result includes at least one word;
- the second acquisition unit 102 is used to acquire a keyword word bag containing N keywords.
- the second obtaining unit 102 is specifically configured to: obtain a training sample set for generating keyword word bags; determine N keywords from the training sample set according to the word frequency-inverse document frequency algorithm, and according to the N keywords Generate the keyword word bag.
- the first element set is a first vector
- the first vector includes N elements
- the first vector satisfies:
- V 1 represents the first vector
- the value of n ranges from 1 to N natural numbers.
- the second acquisition module 30 includes a third acquisition unit 301 and a fourth acquisition unit 302.
- the third obtaining unit 301 is used to obtain the target word in the word segmentation result, and the target word includes words that are present in the word segmentation result but not in the keyword word bag;
- the fourth obtaining unit 302 is used to obtain the The similarity value between the target word and each keyword in the keyword bag.
- the fourth obtaining unit 302 is specifically used to: obtain the word vector of the target word from the word vector database, and obtain the word vector of each keyword in the keyword word bag from the word vector database; calculate the target word The similarity value between the word vector of and the word vector of each keyword.
- the update module 40 is specifically configured to: if the similarity value between the word vector of the target word and the word vector of the first keyword in the keyword word bag is greater than the similarity threshold, calculate the similarity value and the target word The product of the number of occurrences in the word segmentation result; update the first element corresponding to the first keyword in the first element set to the sum of the product and the first element to obtain the second element set.
- the device further includes a third acquisition module 50, a fourth acquisition module 60, and a replacement module 70.
- the third obtaining module 50 is used to obtain M second keywords corresponding to the M zero elements in the second element set; the fourth obtaining module 60 is used to obtain at least one third in the keyword word bag Keywords, the number of times that the third keyword appears in the word segmentation result is greater than or equal to 1; the replacement module 70 is used for according to each of the M second keywords and each of the second keywords in the keyword word bag The similarity value between the third keywords replaces the 0 element in the second element set to obtain the third element set.
- each element in the third element set is used to construct a machine learning model for short text classification.
- the replacement module 70 is specifically used for:
- the third element set is a third vector, and the third vector includes N elements, and the third vector satisfies:
- V 3 represents the third vector
- w m represents the m-th keyword in the keyword word bag is the third keyword
- the w i indicates that the i-th keyword in the keyword word bag is the second keyword
- [cos(w m , w i )] max indicates the m-th keyword in the keyword word bag and the keyword word bag
- the i-th keyword has the largest similarity value.
- the above-mentioned sample data processing device may execute the implementation provided by each step in the implementation provided in FIG. 1, FIG. 2, or FIG. 4 through the above-mentioned modules to realize the functions realized in the above-mentioned embodiments. Reference may be made to the corresponding description provided in each step in the method embodiments shown in FIG. 1, FIG. 2 or FIG. 4, which will not be repeated here.
- the sample data processing device obtains a word segmentation result after word segmentation by acquiring a short text sample, and obtains a keyword word bag containing N keywords, and determines the first word segmentation result according to the word segmentation result and the keyword word bag Element collection, obtain the target word in the word segmentation result, and obtain the similarity value between the target word and each keyword in the keyword word bag, when the target word is similar to the first keyword in the keyword word bag If the degree value is greater than the similarity threshold, the first element corresponding to the first keyword in the first element set is updated according to the similarity value of the target word and the first keyword to obtain a second element set, the second element Each element in the set is used to build a machine learning model for short text classification, which can increase the amount of information in the element set of short text samples, improve the performance of machine learning models built with the element set of short text samples, and further improve The accuracy of short text classification.
- the terminal in the embodiment of the present application may include: one or more processors 601 and a memory 602.
- the processor 601 and the memory 602 are connected through a bus 603.
- the memory 602 is used to store a computer program, and the computer program includes program instructions, and the processor 601 is used to execute the program instructions stored in the memory 602.
- the processor 601 is configured to call the program instructions to execute:
- the first element set is determined according to the word segmentation result and the keyword word bag, and the first element set includes N elements, and the value of each element in the first element set is the value of each keyword in the keyword bag The number of occurrences in the word segmentation results;
- the target word includes the word that exists in the word segmentation result and does not exist in the keyword word bag word;
- the first element in the first element set is updated according to the similarity value of the target word and the first keyword
- the first element corresponding to the keyword gets the second element set
- each element in the second element set is used to construct a machine learning model for short text classification.
- the so-called processor 601 may be a central processing unit (Central Processing Unit, CPU), and the processor may also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP) , Application Specific Integrated Circuit (Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
- the general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
- the memory 602 may include a read-only memory and a random access memory, and provide instructions and data to the processor 601. A portion of the memory 602 may also include non-volatile random access memory. For example, the memory 602 may also store device type information.
- the processor 601 described in the embodiment of the present application may execute the implementation of the sample data processing method provided in the embodiment of the present application, or the keyword word bag generation method provided in the embodiment of the present application,
- the implementation manner of the sample data processing device described in the embodiments of the present application may also be performed, and details are not described herein again.
- Embodiments of the present application also provide a computer-readable storage medium that stores a computer program, and the computer program includes program instructions, which are executed by a processor to implement the samples shown in FIG. 1 and FIG. 4.
- the computer program includes program instructions, which are executed by a processor to implement the samples shown in FIG. 1 and FIG. 4.
- the data processing method or the keyword word bag generation method shown in FIG. 2 for specific details, please refer to the description of the embodiment shown in FIG. 1, FIG. 2 or FIG. 4, which will not be repeated here.
- the foregoing computer-readable storage medium may be the sample data processing device or the internal storage unit of the terminal described in any of the foregoing embodiments, such as the hard disk or the memory of the terminal.
- the computer-readable storage medium may also be an external storage device of the terminal, such as a plug-in hard disk equipped on the terminal, a smart memory card (smart media card, SMC), a secure digital (SD) card, and a flash memory card (flash card) etc.
- the computer-readable storage medium may also include both an internal storage unit of the terminal and an external storage device.
- the computer-readable storage medium is used to store the computer program and other programs and data required by the electronic device.
- the computer-readable storage medium can also be used to temporarily store data that has been or will be output.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本申请实施例公开了一种样本数据处理方法及装置,该方法适用于短文本分类的机器学习模型训练,该方法包括:获取短文本样本进行分词后的分词结果,并获取包含N个关键词的关键词词袋,根据该分词结果与该关键词词袋确定出第一元素集合,获取该分词结果中的目标词,并获取该目标词与该关键词词袋中各个关键词的相似度值,当该目标词与该关键词词袋中的第一关键词的相似度值大于相似度阈值,则根据该目标词与该第一关键词的相似度值更新该第一元素集合中的第一元素,得到第二元素集合,该第二元素集合中的各个元素用于构建用于短文本分类的机器学习模型。采用本申请实施例,可以提高利用元素集合构建的机器学习模型的性能。
Description
本申请要求于2018年11月26日提交中国专利局、申请号为2018114211608、申请名称为“一种样本数据处理方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及计算机技术领域,尤其涉及一种样本数据处理方法及装置。
随着微博、社交网站和热线电话等应用的发展,越来越多的信息开始以短文本的形式呈现,并且呈爆炸式增长。文本分类可以帮助人们快速有效的从海量数据中获取关键信息,而文本分类的准确性依赖于机器学习模型的性能,机器学习模型的性能又依赖于样本数据。
现有的文本样本数据处理方法大多采用基于关键词词袋(Bag of Words)模型的方法,该方法用在长文本中通常能取得较好的效果,但是用在短文本中常常效果不佳、质量低。主要原因是,相较于长文本,短文本具有特征稀疏、主题不明确的特点。首先,由于短文本长度的限制,其特征词很少,而用关键词词袋模型生成的样本数据维度大,这增加了文本处理的难度。其次,在长文本中,跟主题相关的词通常会大量出现,可以由此来判断整篇文章的主要内容;而在短文本中则不能根据词频来判断主要内容。比如短文本“咨询羽毛球主题的餐厅中”,“羽毛球”和“餐厅”的词频相同,但显然该文本的主题是“餐厅”,在文本分类时应被分到“餐饮”这一类别而不是“运动”类别。由此可见,现有的样本数据处理方法不能很好的表示短文本。
综上,因为短文本具有上述的特征稀疏和主题不明确的特点,所以,利用现有的样本数据处理方法得到的样本数据构建用于文本分类的机器学习模型的性能差,文本分类准确性低。
发明内容
本申请实施例提供一种样本数据处理方法及装置,可以增加短文本样本数据的信息量,提高利用该短文本样本数据构建的机器学习模型的性能,进而提高短文本分类的精确度。
第一方面,本申请实施例提供了一种样本数据处理方法,该方法包括:
获取短文本样本进行分词后得到的分词结果,并获取包含N个关键词的关键词词袋,该分词结果中包括至少一个词;
根据该分词结果与该关键词词袋确定出第一元素集合,该第一元素集合中包括N个元素,该第一元素集合中各个元素的值为该关键词词袋中各个关键词在该分词结果中出现的次数;
获取该分词结果中的目标词,并获取该目标词与该关键词词袋中各个关键词的相似度值,该目标词包括在该分词结果中存在且在该关键词词袋中不存在的词;
若该目标词与该关键词词袋中的第一关键词的相似度值大于相似度阈值,则根据该目标词与该第一关键词的相似度值更新该第一元素集合中该第一关键词对应的第一元素,得 到第二元素集合;
其中,该第二元素集合中的各个元素用于构建用于短文本分类的机器学习模型。
第二方面,本申请实施例提供了一种样本数据处理装置,该装置包括:
第一获取模块,用于获取短文本样本进行分词后得到的分词结果,并获取包含N个关键词的关键词词袋,该分词结果中包括至少一个词;
确定模块,用于根据该分词结果与该关键词词袋确定出第一元素集合,该第一元素集合中包括N个元素,该第一元素集合中各个元素的值为该关键词词袋中各个关键词在该分词结果中出现的次数;
第二获取模块,用于获取该分词结果中的目标词,并获取该目标词与该关键词词袋中各个关键词的相似度值,该目标词包括在该分词结果中存在且在该关键词词袋中不存在的词;
更新模块,用于当该目标词与该关键词词袋中的第一关键词的相似度值大于相似度阈值时,根据该目标词与该第一关键词的相似度值更新该第一元素集合中该第一关键词对应的第一元素,得到第二元素集合;
其中,该第二元素集合中的各个元素用于构建用于短文本分类的机器学习模型。
第三方面,本申请实施例提供了一种终端,包括处理器和存储器,该处理器和存储器相互连接,其中,该存储器用于存储支持终端执行上述方法的计算机程序,该计算机程序包括程序指令,该处理器被配置用于调用该程序指令,执行上述第一方面的样本数据处理方法。
第四方面,本申请实施例提供了一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,该计算机程序包括程序指令,该程序指令当被处理器执行时使该处理器执行上述第一方面的样本数据处理方法。
本申请实施例通过更新短文本关键词的元素集合中的元素,可以增加短文本样本的元素集合中的信息量,提高利用该短文本样本的元素集合构建的机器学习模型的性能,进而提高短文本分类的精确度。
图1是本申请实施例提供的样本数据处理方法的一示意流程图;
图2是本申请实施例提供的关键词词袋生成方法的一示意流程图;
图3是本申请实施例提供的关键词“篮球”返回的词条的示意图;
图4是本申请实施例提供的样本数据处理方法的另一示意流程图;
图5是本申请实施例提供的样本数据处理装置的一示意性框图;
图6是本申请实施例提供的终端的一示意性框图。
下面将结合图1至图6,对本申请实施例提供的样本数据处理方法及装置进行说明。
参见图1,是本申请实施例提供的样本数据处理方法的一示意流程图。如图1所示,该样本数据处理方法可包括步骤:
S101,终端获取短文本样本进行分词后得到的分词结果,并获取包含N个关键词的关 键词词袋。
在一些可行的实施方式中,终端可以获取用户输入的短文本样本,并可以采用基于字符串匹配的分词方法或基于统计的机器学习算法等对该短文本样本进行分词,得到分词后的分词结果。该分词结果中可以包括至少一个词。终端可以从关键词词袋数据库中获取任意一个包含N个关键词的关键词词袋。N可以为大于1的整数。该关键词词袋数据库中可以包括预设的多个类别的关键词词袋。该关键词词袋数据库中的各个关键词词袋均包括N个关键词。该关键词词袋可以用于表示文本中忽略词序、语法和句法的词的集合。例如,短文本样本为“今天天气怎么样?”,经过分词后的分词结果为“今天/天气/怎么样”这三个词。
其中,短文本样本的信息长度都比较短,通常在200字以内,因此所包含的有效信息也非常少,通常具有稀疏性、实时性、不规则性等特点。基于字符串匹配的分词方法可以包括正向最大匹配法、逆向最大匹配法、双向匹配分词法等,基于统计的机器学习算法可以包括隐马尔可夫模型(hidden markov model,HMM)、条件随机场(conditional random fields,CRF)等。
在一些可行的实施方式中,终端获取关键词词袋的方式可以参见图2。图2为本申请实施例提供的关键词词袋生成方法的一示意流程图。如图2所示,本申请实施例的关键词词袋生成方法可包括步骤:
S1011,获取用于生成关键词词袋的训练样本集。
在一些可行的实施方式中,终端可以在百度知道上输入预先确定的不同类别的关键词进行搜索,并可以爬取该不同类别的关键词返回的标题,如搜索天气类关键词“天气”、“小雨”等;运动类关键词“篮球”、“棒球”、“跑步”等。终端可以将在百度知道上爬取到的标题进行人工分类和标注,得到各个类别对应的训练样本。终端可以将各个类别对应的训练样本加入训练样本的集合中,形成训练样本集。其中,一个类别可以对应一个训练样本,该训练样本中可以包括同一类别的多个标题(样本)。
例如,如图3所示,是关键词“篮球”返回的词条的示意图。其中,篮球为运动类的关键词之一,在百度知道上输入关键词“篮球”进行搜索,终端爬取关键词“篮球”返回的前50条标题。如图3所示的标题“一个篮球的直径有多大”、“篮球的规格?”、“篮球场的标准尺寸是多少?”等等。
S1012,根据词频-逆文档频率算法从训练样本集中确定出N个关键词,根据N个关键词生成关键词词袋。
在一些可行的实施方式中,终端可以利用分词工具(如jieba分词、stanfordCoreNlp分词等)对上述训练样本集的每个训练样本中的各个样本(即标题)进行分词。针对每个类别的训练样本,终端可以利用词频-逆文档频率(term frequency-inverse document frequency,TF-IDF)算法计算该训练样本中各个样本进行分词后得到的各个词的TF-IDF值,并可以将计算出的该类别的TF-IDF值按从大到小排序,得到TF-IDF序列,并可以从该TF-IDF序列中提取出前N个TF-IDF值对应的N个词,再可以对该N个词进行人工增删得到包含N个关键词的关键词词袋。N为大于1的整数。终端可以预设一个关键词词袋数据库,该关键词词袋数据库可以用于存储至少一个类别的关键词词袋。该关键词词袋数据库中的各 个关键词词袋均包括N个关键词。
其中,TF-IDF的值等于TF
w与IDF
w的乘积,TF
w和IDF
w分别满足:
词条w可以用于表示训练样本中各样本进行分词后得到的任一词,语料库可以用于表示所有训练样本的集合,即训练样本集,文档数可以用于表示训练样本的个数,文档数可以与训练样本的类别数相等。需要说明的是,本申请实施例中语料库的文档总数大于2,即训练样本集中至少有3个类别的训练样本。
例如,假设爬取到“天气、信用卡、机票”三个类别的训练样本。N=100。由于每个类别的关键词词袋生成方式一致,故以生成“天气”类别的关键词词袋为例。首先终端利用jieba分词工具或stanfordCoreNlp分词工具将“天气”类别中的所有样本(标题)进行分词,再根据TF-IDF的公式计算“天气”类别的样本进行分词后得到的各个词的TF-IDF值,将计算出的“天气”类别的TF-IDF值按从大到小排序,并筛选出“天气”类别中TF-IDF值在前100的词语作为“天气”类别的关键词词袋。其中,TF-IDF中的语料库由“天气”、“信用卡”和“机票”三个类别的训练样本组成,词条w为“天气”类别的训练样本进行分词后得到的任一词,文档为训练样本。此时IDF
w中语料库的文档总数为3,分别为“天气”、“信用卡”和“机票”三个类别的训练样本,包含词条w的文档数为1,即“天气”类别的训练样本。
由于传统关键词词袋中的关键词较多,比如一个关键词词袋中包括1000个关键词,而短文本长度较短(通常在200字以内),因此对于短文本来说,用传统的关键词词袋生成的向量维度过大。本申请实施例中的终端利用TF-IDF算法构建了较小的关键词词袋(包括100个关键词),极大的避免了在利用关键词词袋生成向量时维度过大的问题。
S102,终端根据分词结果与关键词词袋确定出第一元素集合。
在一些可行的实施方式中,终端可以统计上述关键词词袋中各个关键词在上述短文本样本的分词结果中出现的次数。终端可以将该关键词词袋中各个关键词在该分词结果中出现的次数作为第一元素集合中的元素。其中,该第一元素集合中可以包括N个元素。
在一些可行的实施方式中,上述第一元素集合可以为第一向量,该第一向量中可以包括N个元素。该第一向量满足:
例如,假设关键词词袋中有5个关键词,分别是“篮球/天气/足球/跑步/今天”,那么第一向量V
1中包括5个元素。假设关键词词袋中的第二个关键词“天气”和第五个关键词“今天”在短文本样本的分词结果中各出现一次,终端确定第一向量V
1中的第二个元素和第五个元素为1。而关键词词袋中的其他关键词(即第一个关键词“篮球”、第三个关键词“足球”以及第四个关键词“跑步”)在短文本样本的分词结果中出现的次数为0,终端确定第 一向量V
1中的第一个、第三个、第四个元素全为0,此时第一向量V
1=[0,1,0,0,1]。
S103,终端获取分词结果中的目标词,并获取目标词与关键词词袋中各个关键词的相似度值。
在一些可行的实施方式中,终端可以查找上述短文本样本的分词结果中是否存在目标词。若该分词结果中存在至少一个目标词,则终端可以获取该分词结果中的任一目标词。终端可以计算该目标词与上述关键词词袋中的各个关键词之间的相似度值,如余弦值、欧氏距离等。若该分词结果中不存在目标词,则终端可以将上述第一元素集合确定为第二元素集合。其中,该目标词可以用于表示在该分词结果中存在且在上述关键词词袋中不存在的词。
例如,假设短文本样本的分词结果中包括5个词,分别为C1、C2、C3、C4以及C5。终端分别检测关键词词袋中是否存在与词C1、C2、C3、C4、C5相同的关键词。若关键词词袋中不存在与词C2和C5相同的关键词,则终端分别将词C2和C5确定为目标词。终端获取目标词C2和C5中任一目标词如C2,终端计算目标词C2与关键词词袋中各个关键词之间的相似度值。
S104,若目标词与关键词词袋中的第一关键词的相似度值大于相似度阈值,则终端根据目标词与第一关键词的相似度值更新第一元素集合中第一关键词对应的第一元素,得到第二元素集合。
在一些可行的实施方式中,终端在获取到上述目标词与上述关键词词袋中各个关键词之间的相似度值之后,可以检测该目标词与该各个关键词之间的相似度值是否大于预设的相似度阈值。当检测到该目标词与该关键词袋中第一关键词之间的相似度值大于该相似度阈值时,说明该目标词与该第一关键词为同义词,则终端可以该目标词与该第一关键词的相似度值更新上述第一元素集合中该第一关键词对应的第一元素,得到第二元素集合。当检测到该目标词与该关键词袋中各个关键词之间的相似度值均小于或等于该相似度阈值时,说明该关键词词袋中没有该目标词的同义词,则终端可以获取上述分词结果中下一个目标词与该关键词词袋中各个关键词之间的相似度值。若上述分词结果中的各个目标词与该关键词词袋中各个关键词之间的相似度值均小于或等于该相似度阈值,说明该关键词词袋中没有任一目标词的同义词,则终端可以将上述第一元素集合确定为第二元素集合。该第二元素集合中的各个元素可以用于构建用于短文本分类的机器学习模型。
由于本申请实施例中关键词词袋的关键词数量较少,从而导致在利用关键词词袋和短文本样本的分词结果确定第一元素集合时,短文本样本中的部分信息损失,即出现短文本样本的分词结果中存在的词不在关键词词袋中的情况,也即短文本样本中出现目标词的情况。又因为第一元素集合中的各元素为关键词词袋中各关键词在分词结果中出现的次数,那么分词结果中的目标词未在第一元素集合中体现。所以本申请实施例通过目标词与关键词词袋中各个关键词的相似度值,在关键词词袋中寻找目标词的同义词,更新目标词的同义词在第一元素集合中对应的元素,得到第二元素集合。从而增加了第一元素集合中的信息量,解决了因为关键词词袋的缩小而损失信息的问题,进而在利用第二元素集合构建用于短文本分类的传统机器学习模型时,可以得到性能较好的机器学习模型,使得短文本分类更准确。
在本申请实施例中,终端通过获取短文本样本进行分词后的分词结果,并获取包含N个关键词的关键词词袋,根据该分词结果与该关键词词袋确定出第一元素集合,获取该分词结果中的目标词,并获取该目标词与该关键词词袋中各个关键词的相似度值,当该目标词与该关键词词袋中的第一关键词的相似度值大于相似度阈值,则根据该目标词与该第一关键词的相似度值更新该第一元素集合中该第一关键词对应的第一元素,得到第二元素集合,该第二元素集合中的各个元素用于构建用于短文本分类的机器学习模型,可以增加短文本样本的元素集合中的信息量,提高利用该短文本样本的元素集合构建的机器学习模型的性能,进而提高短文本分类的精确度。
参见图4,是本申请实施例提供的样本数据处理方法的另一示意流程图。如图4所示,该样本数据处理方法可包括步骤:
S401,终端获取短文本样本进行分词后得到的分词结果,并获取包含N个关键词的关键词词袋。
S402,终端根据分词结果与关键词词袋确定出第一元素集合。
在一些可行的实施方式中,本申请实施例中步骤S401-步骤S402的实现方式可以参考图1所示实施例中的步骤S101-步骤S102的实现方式,在此不再赘述。
S403,终端获取分词结果中的目标词。
S404,终端从词向量数据库中获取目标词的词向量,并从词向量数据库中获取关键词词袋中各个关键词的词向量。
S405,终端计算目标词的词向量与各个关键词的词向量之间的相似度值。
S406,若目标词的词向量与关键词词袋中第一关键词的词向量之间的相似度值大于相似度阈值,则终端计算相似度值与目标词在分词结果中出现的次数的乘积。
S407,终端将第一元素集合中第一关键词对应的第一元素更新为乘积与第一元素之和,得到第二元素集合。
在一些可行的实施方式中,终端可以查找上述短文本样本的分词结果中是否存在目标词。若该分词结果中存在至少一个目标词,则终端可以获取该分词结果中的任一目标词。终端可以从词向量数据库中获取该目标词的词向量,并可以从该词向量数据库中获取该关键词词袋中各个关键词的词向量。终端可以计算该目标词的词向量与该各个关键词的词向量之间的相似度值(如余弦值、欧氏距离等)。终端可以检测该目标词的词向量与该各个关键词的词向量之间的相似度值是否大于预设的相似度阈值。当检测到该目标词的词向量与该关键词袋中第一关键词的词向量之间的相似度值大于该相似度阈值时,说明该目标词与该第一关键词为同义词,则终端可以计算该相似度值与该目标词在上述短文本样本的分词结果中出现的次数的乘积。终端可以将上述第一元素集合中该第一关键词对应的第一元素更新为该乘积与该第一元素之和,得到第二元素集合。其中,该目标词可以用于表示在该分词结果中存在且在上述关键词词袋中不存在的词。
在一些可行的实施方式中,若该分词结果中不存在目标词,则终端可以将上述第一元素集合确定为第二元素集合。或者,当检测到该目标词的词向量与该关键词袋中各个关键词的词向量之间的相似度值均小于或等于该相似度阈值时,说明该关键词词袋中没有该目 标词的同义词,则终端可以获取上述分词结果中下一个目标词的词向量与该关键词词袋中各个关键词的词向量之间的相似度值。若上述分词结果中各个目标词的词向量与该关键词词袋中各个关键词的词向量之间的相似度值均小于或等于该相似度阈值,说明该关键词词袋中没有任一目标词的同义词,则终端可以将上述第一元素集合确定为第二元素集合。
在一些可行的实施方式中,词向量数据库的生成方法可以为:(1)终端从维基百科中爬取大规模无标注语料(大概在10个G左右),并对这些无标注语料进行分词,将分词后的这些语料输入连续关键词词袋模型(continuous bag of words,CBOW)中进行训练。(2)在CBOW模型训练结束后,终端可以获取CBOW模型输出的这些语料中所有词的词向量,并可以将这些语料中所有词的词向量存储到词向量数据库中。
在一些可行的实施方式中,上述第二元素集合可以为第二向量,该第二向量中可以包括N个元素。该第二向量满足:
其中,V
2表示第二向量,w
j表示短文本样本的分词结果中的目标词,w
k表示关键词词袋中的第k个关键词为第一关键词,cos(w
k,w
j)表示目标词w
j的词向量与关键词词袋中第一关键词w
k的词向量之间的余弦值,cos(w
k,w
j)大于预设的相似度阈值如0.7,即w
j与w
k是同义词。终端将第一向量V
1中的第一元素
更新为
表示目标词在短文本样本的分词结果中出现的次数,
表示关键词词袋中的第一关键词在短文本样本的分词结果中出现的次数。
例如,假设短文本样本的分词结果中有2个目标词,分别为目标词w
j1和目标词w
j2。假设关键词词袋中有10个关键词,分别为w
1,w
2,w
3,...,w
10。预设的相似度阈值为0.7。终端分别计算目标词w
j1的词向量与关键词词袋中10个关键词w
1,w
2,w
3,...,w
10的词向量之间的余弦值。假设目标词w
j1的词向量与第四个关键词w
4的词向量之间的余弦值cos(w
4,w
j1)=0.8大于预设的相似度阈值0.7,终端计算余弦值cos(w
4,w
j1)与目标词w
j1在分词结果中出现的次数
的乘积
终端将第一向量V
1中的第四个元素
更新为第四个元素
与乘积
之和,即
终端分别计算目标词w
j2的词向量与关键词词袋中10个关键词w
1,w
2,w
3,...,w
10的词向量之间的余弦值。假设目标词w
j2的词向量与第三个关键词w
3、第六个关键词w
6、第七个关键词w
7的词向量之间的余弦值均大于相似度阈值0.7,即cos(w
3,w
j2)、cos(w
6,w
j2)和cos(w
7,w
j2)的值均大于0.7。终端分别更新第一向量V
1中的第三个元素
第六个元素
和第七个元素
S408,终端获取第二元素集合中M个0元素对应的M个第二关键词。
在一些可行的实施方式中,终端可以检测上述第二元素集合中是否存在0元素。若该第二元素集合中存在0元素,则终端可以获取上述第二元素集合中的M个0元素,并可以将该第二元素集合中各个0元素对应的关键词确定为第二关键词,从而得到M个第二关键词。若该第二元素集合中不存在任何0元素,则终端可以将上述第二元素集合确定为第三元素集合。其中,M可以为大于或等于1的整数。第二元素集合中的0元素可以用于表示上述关键词词袋中的某个关键词在上述分词结果中出现的次数为0且该关键词的同义词也在上述分词结果中出现的次数为0,即第二关键词未在该分词结果中出现过且该第二关键词的同义词也未在该分词结果中出现过。
在一些可行的实施方式中,终端可以从上述关键词词袋中任取一个关键词,并可以检测该关键词词袋中的关键词是否取完。若该检测该关键词词袋中的关键词未取完,检测该关键词在上述分词结果中出现的次数是否为0,当该关键词在上述分词结果中出现的次数为0时,计算该关键词与该分词结果中各个词之间的相似度值,当该关键词与该分词结果中各个词之间的相似度值均小于或等于预设的相似度阈值时,说明该分词结果中没有该关键词的同义词,则可以将该关键词确定为第二关键词。若该关键词词袋中不存在第二关键词,则可以将上述第二元素集合确定为第三元素集合。
S409,终端获取关键词词袋中的至少一个第三关键词。
S410,根据M个第二关键词中各个第二关键词与关键词词袋中各个第三关键词之间的相似度值替换第二元素集合中的0元素,得到第三元素集合。
在一些可行的实施方式中,终端可以从上述关键词词袋中获取至少一个第三关键词,该第三关键词在上述分词结果中出现的次数大于或等于1。终端可以计算上述M个第二关键词中各个第二关键词与上述关键词词袋中各个第三关键词之间的相似度值(如余弦值、欧氏距离等),并可以根据该相似度值替换上述第二元素中的0元素,得到第三元素集合。该第三元素集合中的各个元素用于构建用于短文本分类的机器学习模型。因为机器学习模型的主要原理是在元素集合中的每个元素上乘以一个权重,最后输出该元素集合属于不同类别的概率。若元素集合中存在0元素,那么0元素与任意值的权重相乘,仍会得到0,这时机器学习模型输出的概率就可能为0,从而导致存在0元素的元素集合构建的用于短文本分类的机器学习模型精确度不高。所以,本申请实施例通过替换掉第二元素集合中的0元素,即第三元素集合中不存在0元素,可以在保证元素集合信息量的同时提高机器学习模型的准确度,从而提高短文本分类的精确度。
在一些可行的实施方式中,终端在获取到至少一个第三关键词之后,可以从上述词向量数据库中获取上述M个第二关键词的各个第二关键词的词向量,并可以从该词向量数据库中获取上述关键词词袋中至少一个第三关键词的各个第三关键词的词向量。针对该M个第二关键词中任一第二关键词i,终端可以获取该第二关键词i的词向量与该至少一个第三关键词中各个第三关键词的词向量之间的相似度值(如余弦值、欧氏距离等)。若该第二关键词i的词向量与该至少一个第三关键词中的第三关键词m之间的相似度值最大,则终端可以获取该第三关键词m在上述分词结果中出现的次数。终端可以计算该第二关键词i的词向量与该第三关键词m之间的相似度值与该次数的乘积,并可以将上述第二元素集合中该第二关键词i对应的0元素替换为该乘积。终端将该第二元素集合中该M个第二关键词对应的M个0元素全部替换后可以得到第三元素集合。该第三元素集合中的各个元素用于构建用于短文本分类的机器学习模型。
在一些可行的实施方式中,上述第三元素集合可以为第三向量,该第三向量中可以包括N个元素。该第三向量满足:
其中,V
3表示第三向量,w
m表示关键词词袋中的第m个关键词为第三关键词,
表示关键词词袋中第m个关键词在短文本样本的分词结果中出现的次数,
所述w
i表示关键词词袋中的第i个关键词为第二关键词,[cos(w
m,w
i)]
max表示关键词词袋中的第m 个关键词与关键词词袋中的第i个关键词的相似度值最大。
例如,假设第二元素集合中的第5个元素为0,第二元素集合中第5个元素对应关键词为w
5(即第二关键词)。假设关键词词袋中存在3个第三关键词,分别为w
3、w
6以及w
12。终端分别计算第二关键词w
5的词向量与各个第三关键词w
3、w
6以及w
12的词向量之间的余弦值。假设cos(w
3,w
5)=0.3、cos(w
6,w
5)=0.7、cos(w
12,w
5)=0.5,由于第二关键词w
5与第三关键词w
6之间的余弦值最大,则终端获取第三关键词在分词结果中出现的次数
其中
终端计算余弦值cos(w
6,w
5)与该次数
的乘积
终端将第二元素集合中的第5个元素
替换为该乘积
在本申请实施例中,终端通过计算短文本样本的分词结果中目标词的词向量与关键词词袋中各个关键词的词向量之间的相似度值,来对第一元素集合进行更新,得到第二元素集合。再根据关键词词袋中第二关键词的词向量与关键词词袋中第三关键词的词向量之间的相似度值来替换第二元素集合中的0元素,得到第三元素集合。该第三元素集合中的各个元素用于构建用于短文本分类的机器学习模型。可以在保证元素集合信息量的同时提高机器学习模型的准确度,从而提高短文本分类的精确度。
参见图5,是本申请实施例提供的样本数据处理装置的一示意性框图。如图5所示,本申请实施例中的样本数据处理装置包括:
第一获取模块10,用于获取短文本样本进行分词后得到的分词结果,并获取包含N个关键词的关键词词袋,该分词结果中包括至少一个词;
确定模块20,用于根据该分词结果与该关键词词袋确定出第一元素集合,该第一元素集合中包括N个元素,该第一元素集合中各个元素的值为该关键词词袋中各个关键词在该分词结果中出现的次数;
第二获取模块30,用于获取该分词结果中的目标词,并获取该目标词与该关键词词袋中各个关键词的相似度值,该目标词包括在该分词结果中存在且在该关键词词袋中不存在的词;
更新模块40,用于当该目标词与该关键词词袋中的第一关键词的相似度值大于相似度阈值时,根据该目标词与该第一关键词的相似度值更新该第一元素集合中该第一关键词对应的第一元素,得到第二元素集合;
其中,该第二元素集合中的各个元素用于构建用于短文本分类的机器学习模型。
在一些可行的实施方式中,该第一获取模块10中包括第一获取单元101和第二获取单元102。该第一获取单元101用于获取短文本样本进行分词后得到的分词结果,该分词结果中包括至少一个词;该第二获取单元102用于获取包含N个关键词的关键词词袋。
其中,该第二获取单元102具体用于:获取用于生成关键词词袋的训练样本集;根据词频-逆文档频率算法从该训练样本集中确定出N个关键词,根据该N个关键词生成该关键词词袋。
在一些可行的实施方式中,该第一元素集合为第一向量,该第一向量中包括N个元素,该第一向量满足:
在一些可行的实施方式中,该第二获取模块30包括第三获取单元301和第四获取单元302。该第三获取单元301用于获取该分词结果中的目标词,该目标词包括在该分词结果中存在且在该关键词词袋中不存在的词;该第四获取单元302用于获取该目标词与该关键词词袋中各个关键词的相似度值。
其中,该第四获取单元302具体用于:从词向量数据库中获取该目标词的词向量,并从该词向量数据库中获取该关键词词袋中各个关键词的词向量;计算该目标词的词向量与该各个关键词的词向量之间的相似度值。该更新模块40具体用于:若该目标词的词向量与该关键词词袋中第一关键词的词向量之间的相似度值大于相似度阈值,则计算该相似度值与该目标词在该分词结果中出现的次数的乘积;将该第一元素集合中该第一关键词对应的第一元素更新为该乘积与该第一元素之和,得到第二元素集合。
在一些可行的实施方式中,该装置还包括第三获取模块50、第四获取模块60以及替换模块70。
该第三获取模块50,用于获取该第二元素集合中M个0元素对应的M个第二关键词;该第四获取模块60,用于获取该关键词词袋中的至少一个第三关键词,该第三关键词在该分词结果中出现的次数大于或等于1;该替换模块70,用于根据该M个第二关键词中各个第二关键词与该关键词词袋中各个第三关键词之间的相似度值替换该第二元素集合中的0元素,得到第三元素集合。其中,该第三元素集合中的各个元素用于构建用于短文本分类的机器学习模型。
在一些可行的实施方式中,该替换模块70具体用于:
从词向量数据库中获取该M个第二关键词中各个第二关键词的词向量,并从该词向量数据库中获取该关键词词袋中至少一个第三关键词的各个第三关键词的词向量;获取该M个第二关键词中任一第二关键词i的词向量与该至少一个第三关键词中各个第三关键词的词向量之间的相似度值;若该第二关键词i的词向量与该至少一个第三关键词中的第三关键词m的词向量之间的相似度值最大,则将该第二元素集合中该第二关键词i对应的0元素替换为该第二关键词i与该第三关键词m之间的相似度值与该第三关键词m在该分词结果中出现的次数的乘积,得到第三元素集合。
在一些可行的实施方式中,该第三元素集合为第三向量,该第三向量中包括N个元素,该第三向量满足:
其中,该V
3表示该第三向量,该w
m表示关键词词袋中的第m个关键词为第三关键词,
表示关键词词袋中第m个关键词在该分词结果中的出现次数,
该w
i表示关键词词袋中的第i个关键词为第二关键词,[cos(w
m,w
i)]
max表示关键词词袋中的第m个关键词与关键词词袋中的第i个关键词的相似度值最大。
具体实现中,上述样本数据处理装置可通过上述各个模块执行上述图1、图2或图4所提供的实现方式中各个步骤所提供的实现方式,实现上述各实施例中所实现的功能,具体可参见上述图1、图2或图4所示的方法实施例中各个步骤提供的相应描述,在此不再 赘述。
在本申请实施例中,样本数据处理装置通过获取短文本样本进行分词后的分词结果,并获取包含N个关键词的关键词词袋,根据该分词结果与该关键词词袋确定出第一元素集合,获取该分词结果中的目标词,并获取该目标词与该关键词词袋中各个关键词的相似度值,当该目标词与该关键词词袋中的第一关键词的相似度值大于相似度阈值,则根据该目标词与该第一关键词的相似度值更新该第一元素集合中该第一关键词对应的第一元素,得到第二元素集合,该第二元素集合中的各个元素用于构建用于短文本分类的机器学习模型,可以增加短文本样本的元素集合中的信息量,提高利用该短文本样本的元素集合构建的机器学习模型的性能,进而提高短文本分类的精确度。
参见图6,是本申请实施例提供的终端的一示意性框图。如图6所示,本申请实施例中的终端可以包括:一个或多个处理器601和存储器602。上述处理器601和存储器602通过总线603连接。存储器602用于存储计算机程序,所述计算机程序包括程序指令,处理器601用于执行存储器602存储的程序指令。其中,处理器601被配置用于调用所述程序指令执行:
获取短文本样本进行分词后得到的分词结果,并获取包含N个关键词的关键词词袋,该分词结果中包括至少一个词;
根据该分词结果与该关键词词袋确定出第一元素集合,该第一元素集合中包括N个元素,该第一元素集合中各个元素的值为该关键词词袋中各个关键词在该分词结果中出现的次数;
获取该分词结果中的目标词,并获取该目标词与该关键词词袋中各个关键词的相似度值,该目标词包括在该分词结果中存在且在该关键词词袋中不存在的词;
若该目标词与该关键词词袋中的第一关键词的相似度值大于相似度阈值,则根据该目标词与该第一关键词的相似度值更新该第一元素集合中该第一关键词对应的第一元素,得到第二元素集合;
其中,该第二元素集合中的各个元素用于构建用于短文本分类的机器学习模型。
应当理解,在本申请实施例中,所称处理器601可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
该存储器602可以包括只读存储器和随机存取存储器,并向处理器601提供指令和数据。存储器602的一部分还可以包括非易失性随机存取存储器。例如,存储器602还可以存储设备类型的信息。
具体实现中,本申请实施例中所描述的处理器601可执行本申请实施例提供的样本数据处理方法的实现方式,也可执行本申请实施例提供的关键词词袋生成方法的实现方式,还可执行本申请实施例所描述的样本数据处理装置的实现方式,在此不再赘述。
本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,该计算机程序包括程序指令,该程序指令被处理器执行时实现图1、图4所示的样本数据处理方法或图2所示的关键词词袋生成方法,具体细节请参照图1、图2或图4所示实施例的描述,在此不再赘述。
上述计算机可读存储介质可以是前述任一实施例所述的样本数据处理装置或终端的内部存储单元,例如终端的硬盘或内存。该计算机可读存储介质也可以是该终端的外部存储设备,例如该终端上配备的插接式硬盘,智能存储卡(smart media card,SMC),安全数字(secure digital,SD)卡,闪存卡(flash card)等。进一步地,该计算机可读存储介质还可以既包括该终端的内部存储单元也包括外部存储设备。该计算机可读存储介质用于存储该计算机程序以及该电子设备所需的其他程序和数据。该计算机可读存储介质还可以用于暂时地存储已经输出或者将要输出的数据。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。
Claims (20)
- 一种样本数据处理方法,其特征在于,包括:获取短文本样本进行分词后得到的分词结果,并获取包含N个关键词的关键词词袋,所述分词结果中包括至少一个词;根据所述分词结果与所述关键词词袋确定出第一元素集合,所述第一元素集合中包括N个元素,所述第一元素集合中各个元素的值为所述关键词词袋中各个关键词在所述分词结果中出现的次数;获取所述分词结果中的目标词,并获取所述目标词与所述关键词词袋中各个关键词的相似度值,所述目标词包括在所述分词结果中存在且在所述关键词词袋中不存在的词;若所述目标词与所述关键词词袋中的第一关键词的相似度值大于相似度阈值,则根据所述目标词与所述第一关键词的相似度值更新所述第一元素集合中所述第一关键词对应的第一元素,得到第二元素集合;其中,所述第二元素集合中的各个元素用于构建用于短文本分类的机器学习模型。
- 根据权利要求1所述的方法,其特征在于,所述获取包含N个关键词的关键词词袋,包括:获取用于生成关键词词袋的训练样本集;根据词频-逆文档频率算法从所述训练样本集中确定出N个关键词,根据所述N个关键词生成所述关键词词袋。
- 根据权利要求1-3任意一项所述的方法,其特征在于,所述获取所述目标词与所述关键词词袋中各个关键词的相似度值,包括:从词向量数据库中获取所述目标词的词向量,并从所述词向量数据库中获取所述关键词词袋中各个关键词的词向量;计算所述目标词的词向量与所述各个关键词的词向量之间的相似度值;所述若所述目标词与所述关键词词袋中的第一关键词的相似度值大于相似度阈值,则根据所述目标词与所述第一关键词的相似度值更新所述第一元素集合中所述第一关键词对应的第一元素,得到第二元素集合,包括:若所述目标词的词向量与所述关键词词袋中第一关键词的词向量之间的相似度值大于相似度阈值,则计算所述相似度值与所述目标词在所述分词结果中出现的次数的乘积;将所述第一元素集合中所述第一关键词对应的第一元素更新为所述乘积与所述第一元素之和,得到第二元素集合。
- 根据权利要求1-4任意一项所述的方法,其特征在于,所述在得到所述第二元素集合之后,所述方法还包括:获取所述第二元素集合中M个0元素对应的M个第二关键词;获取所述关键词词袋中的至少一个第三关键词,所述第三关键词在所述分词结果中出现的次数大于或等于1;根据所述M个第二关键词中各个第二关键词与所述关键词词袋中各个第三关键词之间的相似度值替换所述第二元素集合中的0元素,得到第三元素集合;其中,所述第三元素集合中的各个元素用于构建用于短文本分类的机器学习模型。
- 根据权利要求5所述的方法,其特征在于,所述根据所述M个第二关键词中各个第二关键词与所述关键词词袋中各个第三关键词之间的相似度值替换所述第二元素集合中的0元素,得到第三元素集合,包括:从词向量数据库中获取所述M个第二关键词中各个第二关键词的词向量,并从所述词向量数据库中获取所述关键词词袋中至少一个第三关键词的各个第三关键词的词向量;获取所述M个第二关键词中任一第二关键词i的词向量与所述至少一个第三关键词中各个第三关键词的词向量之间的相似度值;若所述第二关键词i的词向量与所述至少一个第三关键词中的第三关键词m的词向量之间的相似度值最大,则将所述第二元素集合中所述第二关键词i对应的0元素替换为所述第二关键词i与所述第三关键词m之间的相似度值与所述第三关键词m在所述分词结果中出现的次数的乘积,得到第三元素集合。
- 一种样本数据处理装置,其特征在于,包括:第一获取模块,用于获取短文本样本进行分词后得到的分词结果,并获取包含N个关键词的关键词词袋,所述分词结果中包括至少一个词;确定模块,用于根据所述分词结果与所述关键词词袋确定出第一元素集合,所述第一元素集合中包括N个元素,所述第一元素集合中各个元素的值为所述关键词词袋中各个关键词在所述分词结果中出现的次数;第二获取模块,用于获取所述分词结果中的目标词,并获取所述目标词与所述关键词词袋中各个关键词的相似度值,所述目标词包括在所述分词结果中存在且在所述关键词词袋中不存在的词;更新模块,用于当所述目标词与所述关键词词袋中的第一关键词的相似度值大于相似度阈值时,根据所述目标词与所述第一关键词的相似度值更新所述第一元素集合中所述第一关键词对应的第一元素,得到第二元素集合;其中,所述第二元素集合中的各个元素用于构建用于短文本分类的机器学习模型。
- 根据权利要求8所述的装置,其特征在于,所述第一获取模块包括:第一获取单元,用于获取短文本样本进行分词后得到的分词结果,所述分词结果中包括至少一个词;第二获取单元,用于获取用于生成关键词词袋的训练样本集,并根据词频-逆文档频率算法从所述训练样本集中确定出N个关键词,根据所述N个关键词生成所述关键词词袋。
- 根据权利要求8-10任意一项所述的装置,其特征在于,所述第二获取模块包括:第三获取单元,用于获取所述分词结果中的目标词,所述目标词包括在所述分词结果中存在且在所述关键词词袋中不存在的词;第四获取单元,用于从词向量数据库中获取所述目标词的词向量,并从所述词向量数据库中获取所述关键词词袋中各个关键词的词向量,计算所述目标词的词向量与所述各个关键词的词向量之间的相似度值;所述更新模块具体用于:若所述目标词的词向量与所述关键词词袋中第一关键词的词向量之间的相似度值大于相似度阈值,则计算所述相似度值与所述目标词在所述分词结果中出现的次数的乘积;将所述第一元素集合中所述第一关键词对应的第一元素更新为所述乘积与所述第一元素之和,得到第二元素集合。
- 根据权利要求8-11任意一项所述的装置,其特征在于,所述装置还包括:第三获取模块,用于获取所述第二元素集合中M个0元素对应的M个第二关键词;第四获取模块,用于获取所述关键词词袋中的至少一个第三关键词,所述第三关键词在所述分词结果中出现的次数大于或等于1;替换模块,用于根据所述M个第二关键词中各个第二关键词与所述关键词词袋中各个第三关键词之间的相似度值替换所述第二元素集合中的0元素,得到第三元素集合;其中,所述第三元素集合中的各个元素用于构建用于短文本分类的机器学习模型。
- 根据权利要求12所述的装置,其特征在于,所述替换模块具体用于:从词向量数据库中获取所述M个第二关键词中各个第二关键词的词向量,并从所述词向量数据库中获取所述关键词词袋中至少一个第三关键词的各个第三关键词的词向量;获取所述M个第二关键词中任一第二关键词i的词向量与所述至少一个第三关键词中各个第三关键词的词向量之间的相似度值;若所述第二关键词i的词向量与所述至少一个第三关键词中的第三关键词m的词向量之间的相似度值最大,则将所述第二元素集合中所述第二关键词i对应的0元素替换为所述第二关键词i与所述第三关键词m之间的相似度值与所述第三关键词m在所述分词结果中出现的次数的乘积,得到第三元素集合。
- 一种终端,其特征在于,包括处理器和存储器,所述处理器和存储器相互连接,其中,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令执行:获取短文本样本进行分词后得到的分词结果,并获取包含N个关键词的关键词词袋,所述分词结果中包括至少一个词;根据所述分词结果与所述关键词词袋确定出第一元素集合,所述第一元素集合中包括N个元素,所述第一元素集合中各个元素的值为所述关键词词袋中各个关键词在所述分词结果中出现的次数;获取所述分词结果中的目标词,并获取所述目标词与所述关键词词袋中各个关键词的相似度值,所述目标词包括在所述分词结果中存在且在所述关键词词袋中不存在的词;若所述目标词与所述关键词词袋中的第一关键词的相似度值大于相似度阈值,则根据所述目标词与所述第一关键词的相似度值更新所述第一元素集合中所述第一关键词对应的第一元素,得到第二元素集合;其中,所述第二元素集合中的各个元素用于构建用于短文本分类的机器学习模型。
- 根据权利要求15所述的终端,其特征在于,所述处理器具体用于:获取用于生成关键词词袋的训练样本集;根据词频-逆文档频率算法从所述训练样本集中确定出N个关键词,根据所述N个关键词生成所述关键词词袋。
- 根据权利要求15-17任意一项所述的终端,其特征在于,所述处理器具体用于:从词向量数据库中获取所述目标词的词向量,并从所述词向量数据库中获取所述关键词词袋中各个关键词的词向量;计算所述目标词的词向量与所述各个关键词的词向量之间的相似度值;若所述目标词的词向量与所述关键词词袋中第一关键词的词向量之间的相似度值大于相似度阈值,则计算所述相似度值与所述目标词在所述分词结果中出现的次数的乘积;将所述第一元素集合中所述第一关键词对应的第一元素更新为所述乘积与所述第一元素之和,得到第二元素集合。
- 根据权利要求15-18任意一项所述的终端,其特征在于,所述处理器还用于:获取所述第二元素集合中M个0元素对应的M个第二关键词;获取所述关键词词袋中的至少一个第三关键词,所述第三关键词在所述分词结果中出现的次数大于或等于1;根据所述M个第二关键词中各个第二关键词与所述关键词词袋中各个第三关键词之间的相似度值替换所述第二元素集合中的0元素,得到第三元素集合;其中,所述第三元素集合中的各个元素用于构建用于短文本分类的机器学习模型。
- 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求1-7任一项所述的方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811421160.8A CN109508378B (zh) | 2018-11-26 | 2018-11-26 | 一种样本数据处理方法及装置 |
| CN201811421160.8 | 2018-11-26 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020107835A1 true WO2020107835A1 (zh) | 2020-06-04 |
Family
ID=65750624
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/088803 Ceased WO2020107835A1 (zh) | 2018-11-26 | 2019-05-28 | 一种样本数据处理方法及装置 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN109508378B (zh) |
| WO (1) | WO2020107835A1 (zh) |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113312481A (zh) * | 2021-05-27 | 2021-08-27 | 中国平安人寿保险股份有限公司 | 基于区块链的文本分类方法、装置、设备以及存储介质 |
| CN114090878A (zh) * | 2021-11-04 | 2022-02-25 | 北京淘友天下科技发展有限公司 | 职位推荐方法、装置、电子设备、可读介质及程序产品 |
| CN114510565A (zh) * | 2020-11-16 | 2022-05-17 | 威联通科技股份有限公司 | 短文自动化萃取分类及关键字方法及采用该方法的装置 |
| CN114548261A (zh) * | 2022-02-18 | 2022-05-27 | 北京百度网讯科技有限公司 | 数据处理方法、装置、电子设备以及存储介质 |
| CN115168360A (zh) * | 2022-07-19 | 2022-10-11 | 深圳微众信用科技股份有限公司 | 征信数据的处理方法及相关装置 |
| CN117009519A (zh) * | 2023-07-19 | 2023-11-07 | 上交所技术有限责任公司 | 一种基于词袋模型的企业挂靠产业方法 |
Families Citing this family (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109508378B (zh) * | 2018-11-26 | 2023-07-14 | 平安科技(深圳)有限公司 | 一种样本数据处理方法及装置 |
| JP7475844B2 (ja) * | 2019-11-27 | 2024-04-30 | 株式会社東芝 | 情報処理装置、情報処理方法及びプログラム |
| CN111353050A (zh) * | 2019-12-27 | 2020-06-30 | 北京合力亿捷科技股份有限公司 | 一种电信客服垂直领域的词库构建方法及工具 |
| CN111625468B (zh) * | 2020-06-05 | 2024-04-16 | 中国银行股份有限公司 | 一种测试案例去重方法及装置 |
| CN113935387B (zh) * | 2020-06-29 | 2026-01-27 | 中国电信股份有限公司 | 文本相似度的确定方法、装置和计算机可读存储介质 |
| CN113011533B (zh) * | 2021-04-30 | 2023-10-24 | 平安科技(深圳)有限公司 | 文本分类方法、装置、计算机设备和存储介质 |
| CN113779959B (zh) * | 2021-08-31 | 2023-06-06 | 西南电子技术研究所(中国电子科技集团公司第十研究所) | 小样本文本数据混合增强方法 |
| CN117370809B (zh) * | 2023-11-02 | 2024-04-12 | 快朵儿(广州)云科技有限公司 | 一种基于深度学习的人工智能模型构建方法、系统及存储介质 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102622378A (zh) * | 2011-01-30 | 2012-08-01 | 北京千橡网景科技发展有限公司 | 从文本流检测事件的方法和设备 |
| CN105045875A (zh) * | 2015-07-17 | 2015-11-11 | 北京林业大学 | 个性化信息检索方法及装置 |
| CN105488023A (zh) * | 2015-03-20 | 2016-04-13 | 广州爱九游信息技术有限公司 | 一种文本相似度评估方法及装置 |
| US20160253597A1 (en) * | 2015-02-27 | 2016-09-01 | Xerox Corporation | Content-aware domain adaptation for cross-domain classification |
| CN107103012A (zh) * | 2016-01-28 | 2017-08-29 | 阿里巴巴集团控股有限公司 | 识别违禁网页的方法、装置及服务器 |
| CN109508378A (zh) * | 2018-11-26 | 2019-03-22 | 平安科技(深圳)有限公司 | 一种样本数据处理方法及装置 |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20100235343A1 (en) * | 2009-03-13 | 2010-09-16 | Microsoft Corporation | Predicting Interestingness of Questions in Community Question Answering |
| US9501569B2 (en) * | 2013-04-23 | 2016-11-22 | Microsoft Technology Licensing, Llc | Automatic taxonomy construction from keywords |
| CN104199959A (zh) * | 2014-09-18 | 2014-12-10 | 浪潮软件集团有限公司 | 一种针对互联网涉税数据的文本分类方法 |
| CN104462244B (zh) * | 2014-11-19 | 2017-10-03 | 武汉大学 | 一种基于元模型的智慧城市异构数据共享方法 |
-
2018
- 2018-11-26 CN CN201811421160.8A patent/CN109508378B/zh active Active
-
2019
- 2019-05-28 WO PCT/CN2019/088803 patent/WO2020107835A1/zh not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102622378A (zh) * | 2011-01-30 | 2012-08-01 | 北京千橡网景科技发展有限公司 | 从文本流检测事件的方法和设备 |
| US20160253597A1 (en) * | 2015-02-27 | 2016-09-01 | Xerox Corporation | Content-aware domain adaptation for cross-domain classification |
| CN105488023A (zh) * | 2015-03-20 | 2016-04-13 | 广州爱九游信息技术有限公司 | 一种文本相似度评估方法及装置 |
| CN105045875A (zh) * | 2015-07-17 | 2015-11-11 | 北京林业大学 | 个性化信息检索方法及装置 |
| CN107103012A (zh) * | 2016-01-28 | 2017-08-29 | 阿里巴巴集团控股有限公司 | 识别违禁网页的方法、装置及服务器 |
| CN109508378A (zh) * | 2018-11-26 | 2019-03-22 | 平安科技(深圳)有限公司 | 一种样本数据处理方法及装置 |
Cited By (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114510565A (zh) * | 2020-11-16 | 2022-05-17 | 威联通科技股份有限公司 | 短文自动化萃取分类及关键字方法及采用该方法的装置 |
| CN113312481A (zh) * | 2021-05-27 | 2021-08-27 | 中国平安人寿保险股份有限公司 | 基于区块链的文本分类方法、装置、设备以及存储介质 |
| CN114090878A (zh) * | 2021-11-04 | 2022-02-25 | 北京淘友天下科技发展有限公司 | 职位推荐方法、装置、电子设备、可读介质及程序产品 |
| CN114548261A (zh) * | 2022-02-18 | 2022-05-27 | 北京百度网讯科技有限公司 | 数据处理方法、装置、电子设备以及存储介质 |
| US12174917B2 (en) | 2022-02-18 | 2024-12-24 | Beijing Baidu Netcom Science Technology Co., Ltd. | Data processing method |
| CN115168360A (zh) * | 2022-07-19 | 2022-10-11 | 深圳微众信用科技股份有限公司 | 征信数据的处理方法及相关装置 |
| CN117009519A (zh) * | 2023-07-19 | 2023-11-07 | 上交所技术有限责任公司 | 一种基于词袋模型的企业挂靠产业方法 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109508378A (zh) | 2019-03-22 |
| CN109508378B (zh) | 2023-07-14 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020107835A1 (zh) | 一种样本数据处理方法及装置 | |
| CN111104794B (zh) | 一种基于主题词的文本相似度匹配方法 | |
| CN113268995B (zh) | 中文学术关键词抽取方法、装置和存储介质 | |
| CN107133213B (zh) | 一种基于算法的文本摘要自动提取方法与系统 | |
| WO2021139262A1 (zh) | 文献主题词聚合方法、装置、计算机设备及可读存储介质 | |
| CN107644010B (zh) | 一种文本相似度计算方法及装置 | |
| WO2021189951A1 (zh) | 文本搜索方法、装置、计算机设备和存储介质 | |
| CN102831246B (zh) | 藏文网页分类方法和装置 | |
| WO2020140373A1 (zh) | 一种意图识别方法、识别设备及计算机可读存储介质 | |
| CN107784110B (zh) | 一种索引建立方法及装置 | |
| CN110334202A (zh) | 基于新闻应用软件的用户兴趣标签构建方法及相关设备 | |
| US20210224264A1 (en) | Systems and methods for mapping a term to a vector representation in a semantic space | |
| CN105631009A (zh) | 基于词向量相似度的检索方法和系统 | |
| CN108763348B (zh) | 一种扩展短文本词特征向量的分类改进方法 | |
| CN113722478B (zh) | 多维度特征融合相似事件计算方法、系统及电子设备 | |
| CN110688836A (zh) | 基于监督学习的领域词典自动化构建方法 | |
| CN102495892A (zh) | 一种网页信息抽取方法 | |
| CN104699817B (zh) | 一种基于改进谱聚类的搜索引擎排序方法与系统 | |
| CN106570196B (zh) | 视频节目的搜索方法和装置 | |
| CN106933800A (zh) | 一种金融领域的事件句抽取方法 | |
| CN108959314A (zh) | 一种语义检索方法和装置 | |
| CN110795573A (zh) | 一种网页内容的地理位置预测方法及装置 | |
| CN105550169A (zh) | 一种基于字符长度识别兴趣点名称的方法和装置 | |
| CN111859079B (zh) | 信息搜索方法、装置、计算机设备及存储介质 | |
| CN106844482A (zh) | 一种基于搜索引擎的检索信息匹配方法及装置 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19890649 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 19890649 Country of ref document: EP Kind code of ref document: A1 |