Text classification method, device, electronic device and computer-readable storage medium
By calculating the similarity value between the text type and the text to be classified, and using seed words and keyword vectors, the problem of low efficiency and poor accuracy of news classification in the existing technology is solved, and efficient and accurate text classification is achieved.
Patent Information
- Application Number
- CN201910181839.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-03-11
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2039-03-11
AI Technical Summary
Existing news classification methods are inefficient and have poor classification accuracy. Manual annotation is inefficient, supervised model training and tuning cycles are long, and unsupervised models such as LDA have poor clustering accuracy.
By using the word vector corresponding to the seed word of the text type and the keyword of the text to be classified, the similarity value is calculated, and compared according to the similarity threshold, the type of the text to be classified is determined. Seed words can be obtained through manual screening or TF-IDF method, and optimized through word vector expansion and weight calculation.
It improves the efficiency and accuracy of text classification and provides efficient classification results.
Smart Images

Figure CN111753079B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and more specifically, to a text classification method, a text classification device, an electronic device and a computer-readable storage medium. Background Art
[0002] At present, there are mainly two methods for news classification:
[0003] The first method: manual labeling and classification, which is inefficient.
[0004] The second method is to use classification models to classify news. Classification models mainly include supervised models and unsupervised models. Supervised models require a large number of samples and have a long training and tuning cycle. Unsupervised models (for example, LDA (Latent Dirichlet Allocation)) have poor clustering accuracy.
[0005] Currently, a new classification method needs to be provided. Summary of the invention
[0006] An object of the present invention is to provide a new technical solution for text classification.
[0007] According to a first aspect of the present invention, there is provided a text classification method, comprising:
[0008] Using the word vectors corresponding to the seed words of each text type, the vectors of each text type are obtained;
[0009] Using the word vectors corresponding to the keywords of the text to be classified, obtaining the text vector to be classified;
[0010] Calculating similarity values between the text to be classified and each text type according to the text to be classified vector and each text type vector;
[0011] Each similarity value is compared with the corresponding similarity threshold, and the text type corresponding to the similarity value exceeding the similarity threshold is used as the type of the text to be classified.
[0012] Optionally, the seed words of each text type are obtained by at least one of the following methods:
[0013] Obtain seed words of each text type obtained by manual screening; or,
[0014] Entity words of texts of known categories are extracted, and seed words of each text type are obtained using the TF-IDF statistical method.
[0015] Optionally, the seed words of each text type are expanded in the following manner:
[0016] Get the word vectors of the seed words of each text type;
[0017] A word vector whose distance from the word vector of the seed word of each text type is less than a preset distance threshold is obtained, and the words corresponding to the obtained word vector are added to the seed word of each text type.
[0018] Optionally, the obtaining each text type vector by using the word vector corresponding to the seed word of each text type includes:
[0019] Based on each text type, obtain the weight values of the word vectors corresponding to various subwords;
[0020] A text type vector is obtained according to the word vectors corresponding to the various sub-words and the weight values of the word vectors corresponding to the various sub-words.
[0021] Optionally, obtaining the vector of the text to be classified by using the word vector corresponding to the keyword of the text to be classified includes:
[0022] Obtaining keywords from the title of the text to be classified;
[0023] Obtain a first text vector using the word vectors corresponding to the keywords in the title;
[0024] Obtaining keywords in the body of the text to be classified;
[0025] Using the word vectors corresponding to the keywords in the text, a second text vector is obtained;
[0026] The to-be-classified text vector is obtained according to the first text vector and the second text vector.
[0027] Optionally, obtaining the first text vector by using the word vector corresponding to the keyword in the title includes:
[0028] Obtaining weight values of word vectors corresponding to keywords in the title;
[0029] Obtaining a first text vector according to the word vector corresponding to the keyword in the title and the weight value of the word vector corresponding to the keyword in the title; and
[0030] The obtaining of the second text vector by using the word vector corresponding to the keyword in the text includes:
[0031] Obtaining weight values of word vectors corresponding to keywords in the text;
[0032] A second text vector is obtained according to the word vectors corresponding to the keywords in the text and the weight values of the word vectors corresponding to the keywords in the text.
[0033] Optionally, the similarity thresholds of the text types are determined by the following steps:
[0034] Based on each text type, use the word vectors corresponding to the keywords of the training text to obtain the vectors of each training text;
[0035] According to the training text vectors and the text type vector, obtaining a similarity value between the training texts and the text type vector;
[0036] Comparing the similarity values between each training text and the text type vector with the initial similarity value, respectively, to obtain training texts whose similarity values exceed the initial similarity value;
[0037] Detecting whether the category of the training text whose similarity value exceeds the initial similarity value is consistent with the text type, and obtaining a detection result;
[0038] Determining the accuracy of training sample classification according to the detection results;
[0039] The initial similarity value is adjusted according to the accuracy rate.
[0040] According to a second aspect of the present invention, there is provided a text classification device, comprising:
[0041] A text type vector determination module, used to obtain each text type vector using the word vector corresponding to the seed word of each text type;
[0042] A module for determining a text vector to be classified, used to obtain the text vector to be classified by using the word vector corresponding to the keyword of the text to be classified;
[0043] A similarity value calculation module, used for calculating the similarity value between the text to be classified and each text type according to the text vector to be classified and each text type vector;
[0044] The comparison module is used to compare each similarity value with the corresponding similarity threshold value, and take the text type corresponding to the similarity value exceeding the similarity threshold value as the type of the text to be classified.
[0045] According to a third aspect of the present invention, there is provided an electronic device, comprising a processor and a memory, wherein the memory is used to store executable instructions, and the processor is used to operate the electronic device to execute the method according to any one of the first aspects under the control of the instructions.
[0046] According to a fourth aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the method according to any one of the first aspects when executed by a processor.
[0047] The text classification method provided by the embodiment of the present invention has high classification efficiency and high accuracy of classification results.
[0048] Further features and advantages of the present invention will become apparent from the following detailed description of exemplary embodiments of the present invention with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention.
[0050] Figure 1 The present invention is a block diagram of a hardware configuration of an electronic device that can be used to implement the text classification method according to any embodiment of the present invention.
[0051] Figure 2 is a processing flow chart of a text classification method according to an embodiment of the present invention.
[0052] Figure 3 A processing flow chart of a text classification method according to an example of the present invention.
[0053] Figure 4 4 is a functional block diagram of a text classification device according to an embodiment of the present invention.
[0054] Figure 5 is a principle block diagram of an electronic device according to an embodiment of the present invention.
[0055] Figure 6 FIG. 4 is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0056] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless otherwise specifically stated.
[0057] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
[0058] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.
[0059] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0060] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0061] <Hardware Configuration>
[0062] Figure 1 The present invention is a block diagram of a hardware configuration of an electronic device that can be used to implement the text classification method according to any embodiment of the present invention.
[0063] In one embodiment, Figure 1 As shown, the electronic device may be a server 1000 .
[0064] The server 1000 provides a business point for processing, database, and communication facilities. The server 1000 can be a monolithic server or a distributed server across multiple computers or computer data centers. The server can be of various types, such as but not limited to, a network server, a news server, a mail server, a message server, an advertising server, a file server, an application server, an interactive server, a database server, or a proxy server. In some embodiments, each server may include hardware, software, or an embedded logic component or a combination of two or more such components for executing the appropriate functions supported or implemented by the server. For example, the server may be a blade server, a cloud server, etc., or may be a server group consisting of multiple servers, which may include one or more of the above-mentioned types of servers, etc.
[0065] In one example, server 1000 may be configured as follows: Figure 1 As shown, the server includes a processor 1100, a memory 1200, an interface device 1300, a communication device 1400, a display device 1500, and an input device 1600. The server may also include a speaker, a microphone, and the like.
[0066] The processor 1100 may be, for example, a central processing unit (CPU), a microprocessor (MCU), etc. The memory 1200 may include, for example, a ROM (read-only memory), a RAM (random access memory), a non-volatile memory such as a hard disk, etc. The interface device 1300 may include, for example, a USB interface, a serial interface, an infrared interface, etc. The communication device 1400 may be capable of wired or wireless communication, for example. The display device 1500 may be, for example, a liquid crystal display, an LED display, a touch display, etc. The input device 1600 may include, for example, a touch screen, a keyboard, etc.
[0067] Despite Figure 1 In the figure, multiple devices are shown for the server 1000, but the present invention may only involve some of the devices, for example, the server 1000 only involves the memory 1200 and the processor 1100.
[0068] In the embodiment of the present invention, the memory 1200 of the server 1000 is used to store instructions, and the instructions are used to control the processor 1100 to execute the text classification method provided by the embodiment of the present invention.
[0069] In the above description, a technician can design instructions according to the scheme disclosed in the present invention. How instructions control the processor to operate is well known in the art, so it will not be described in detail here.
[0070] <Method Example>
[0071] Figure 2 is a processing flow chart of a text classification method according to an embodiment of the present invention. Figure 1 The server 1000 is implemented in.
[0072] according to Figure 2 As shown, the text classification method may include the following steps S2100-S2400.
[0073] Step S2100, using the word vector corresponding to the seed word of each text type, obtain the vector of each text type.
[0074] In this embodiment, the word vector is generated using the word2vec (word to vector) model. For example, articles published in the last year are obtained, and the title and body of the article are preprocessed by word segmentation to obtain multiple words, and then the word2vec model is used to generate the word vector corresponding to each word.
[0075] Seed words are words used to represent text types. Based on each text type, the seed words of the text type can be obtained by at least one of the following methods.
[0076] The first method is to obtain the seed words of each text type obtained through manual screening. In this method, editors and operators provide the seed words of each text type.
[0077] The second method is to extract entity words of texts of known categories and use the TF-IDF (Term Frequency–Inverse Document Frequency) statistical method to obtain seed words for each text type.
[0078] Entity words include nouns, verbs, adjectives, pronouns, etc.
[0079] The importance value of each entity word for a known category of text is evaluated using the TF-IDF statistical method. The importance value can be determined by the number of times the entity word appears in the known category of text, that is, the more times the entity word appears in the known category of text, the higher the importance value. Entity words whose importance values exceed the preset importance threshold are selected as seed words of the text type corresponding to the known category of text.
[0080] In one embodiment, based on each text type, the seed words of the text type can be expanded in the following manner to improve the seed words of each text type. First, the word vector of the seed word of each text type is obtained. Then, the word vector whose distance from the word vector of the seed word of each text type is less than a preset distance threshold is obtained, and the words corresponding to the obtained word vector are added to the seed words of each text type.
[0081] For example, a word vector of a seed word of a certain text type is obtained. From the word vectors generated by the word2vec (word to vector) model, a word vector whose distance to the word vector of the seed word of the text type is less than a preset distance threshold is obtained.
[0082] In this embodiment, step S2100 may further include steps S2110 - S2120 .
[0083] Step S2110, based on each text type, obtain the weight values of the word vectors corresponding to various sub-words.
[0084] The weight values of the word vectors corresponding to various sub-words can be set according to the importance values of various sub-words to the text type.
[0085] The weight values of the word vectors corresponding to various subwords can be set according to the number of seed words. For example, if the number of seed words of a certain text type is n, then the weight values of the word vectors corresponding to various subwords are 1 / n.
[0086] Step S2120, obtaining a text type vector according to the word vectors corresponding to various sub-words and the weight values of the word vectors corresponding to various sub-words.
[0087] The text type vector is calculated based on the following formula (1):
[0088]
[0089] Among them, vec category is the text type vector, n is the number of seed words, w k is the weight value of the word vector corresponding to the kth seed word, vec k1 is the word vector corresponding to the kth seed word.
[0090] Step S2200, using the word vectors corresponding to the keywords of the text to be classified, to obtain the vector of the text to be classified.
[0091] Step S2200 may further include the following steps S2210-S2250.
[0092] Step S2210, obtaining keywords in the title of the text to be classified.
[0093] Get entity words in the title of the text to be classified as keywords in the title.
[0094] Step S2220, using the word vectors corresponding to the keywords in the title to obtain the first text vector.
[0095] First, the weight value of the word vector corresponding to the keyword in the title is obtained. Then, the first text vector is obtained according to the word vector corresponding to the keyword in the title and the weight value of the word vector corresponding to the keyword in the title.
[0096] The weight value of the word vector corresponding to the keyword in the title can be determined based on the word frequency of each keyword (the number of times it appears in the title). For example, the weight value of the word vector corresponding to the keyword in the title is calculated based on the following calculation formula (2):
[0097]
[0098] Among them, w ck is the weight value of the word vector corresponding to the kth keyword in the title, n is the number of keywords in the title, and f k is the frequency of the kth keyword in the title.
[0099] The first text vector is calculated based on the following formula (3):
[0100]
[0101] Among them, vec title is the first text vector, n is the number of keywords in the title, and w ck is the weight value of the word vector corresponding to the kth keyword in the title, vec k2 is the word vector corresponding to the kth keyword in the title.
[0102] Step S2230, obtaining keywords in the body of the text to be classified.
[0103] In this embodiment, the NLP (Neuro-Linguistic Programming) model is used to process the text to be classified to obtain the keywords in the body of the text to be classified and the weight value of each keyword.
[0104] Step S2240, using the word vectors corresponding to the keywords in the text, obtain a second text vector.
[0105] First, the weight values of the word vectors corresponding to the keywords in the text are obtained. The weight values of the word vectors corresponding to the keywords in the text can be the weight values of each keyword obtained using the NLP model.
[0106] Then, a second text vector is obtained according to the word vectors corresponding to the keywords in the text and the weight values of the word vectors corresponding to the keywords in the text.
[0107] The second text vector is calculated based on the following formula (4):
[0108]
[0109] Among them, vec text is the second text vector, n is the number of keywords in the text, and w tk is the weight value of the word vector corresponding to the kth keyword in the text, vec k3 is the word vector corresponding to the kth keyword in the text.
[0110] Step S2250: Obtain a text vector to be classified according to the first text vector and the second text vector.
[0111] First, the weight values of the first text vector and the second text vector are obtained, and then, the text vector to be classified is obtained according to the first text vector, the second text vector and the weight values of the two.
[0112] The weight values of the first text vector and the second text vector can be set according to the importance values of the two to the text vector to be classified.
[0113] The text vector to be classified is calculated based on the following formula (5):
[0114] vec doc =αvec title +(1-α)vec text —Calculation formula (5),
[0115] Among them, vec doc is the text vector to be classified, vec title is the first text vector, α is the weight value of the first text vector, vec text is the second text vector.
[0116] Step S2300, obtaining similarity values between the text to be classified and each text type according to the text vector to be classified and each text type vector.
[0117] Based on each text type, the similarity value between the text to be classified and the text type is calculated based on the following calculation formula (6):
[0118]
[0119] Among them, cosθ is the similarity value between the text to be classified and the text type.
[0120] Step S2400 , each similarity value is compared with the corresponding similarity threshold, and the text type corresponding to the similarity value exceeding the similarity threshold is used as the type of the text to be classified.
[0121] Each text type corresponds to a similarity threshold. The similarity threshold corresponding to each text type can be determined by following the steps S2410-S2460.
[0122] Step S2410, based on each text type, using the word vectors corresponding to the keywords of the training text, to obtain each training text vector.
[0123] The method for determining each training text vector may refer to the method for determining the text vector to be classified involved in steps S2210 - S2250 .
[0124] Step S2420, obtaining a similarity value between each training text and the corresponding text type vector according to each training text vector and the corresponding text type vector.
[0125] The similarity value between each training text and the corresponding text type vector can refer to the above calculation formula (6).
[0126] Step S2430 , respectively comparing the similarity values between each training text and the corresponding text type vector with the initial similarity value, and obtaining training texts whose similarity values exceed the initial similarity value.
[0127] The initial similarity value can be set according to the actual test situation.
[0128] Step S2440 , detecting whether the category of the training text whose similarity value exceeds the initial similarity value is consistent with the text type, and obtaining a detection result.
[0129] Step S2450, determining the accuracy of the training sample classification according to the detection result.
[0130] The detection results are used to screen out training texts whose categories and text types are consistent, and the number of training texts whose categories and text types are consistent is counted. The accuracy of training text classification is determined based on the number of training texts whose categories and text types are consistent and the number of training texts whose similarity values exceed the initial similarity value.
[0131] Step S2460, adjusting the initial similarity value according to the accuracy.
[0132] When the accuracy rate exceeds the preset accuracy rate, it can be determined that the current similarity value can meet the accuracy requirement of text classification.
[0133] When the accuracy rate does not exceed the preset accuracy rate, it can be determined that the current similarity value does not meet the accuracy requirements of text classification, and the initial similarity value is increased. Then, according to the above steps S2410-S2450, the corresponding accuracy rate after adjusting the initial similarity value is determined until the adjusted similarity value meets the accuracy requirements of text classification.
[0134] In one embodiment, when the accuracy rate does not exceed the preset accuracy rate, the seed words of the text type may also be modified, such as adding seed words or deleting seed words.
[0135] The text classification method provided by the embodiment of the present invention has high classification efficiency and high accuracy of classification results.
[0136] <Example>
[0137] Figure 3 A processing flow chart of a text classification method according to an example of the present invention.
[0138] according to Figure 3 As shown, the text classification method may include the following steps S301-S309.
[0139] Step S301, generate word vectors using the word2vec model.
[0140] Step S302, query the word vectors corresponding to various sub-words.
[0141] Based on each text type, query the word vectors corresponding to various subwords from the word vector.
[0142] Step S303, obtaining a text type vector according to the word vectors corresponding to various sub-words.
[0143] Step S304, performing text preprocessing on the text to be classified to obtain keywords in the title and keywords in the text.
[0144] Step S305, obtaining the word vectors corresponding to the keywords in the title and the word vectors corresponding to the keywords in the text.
[0145] Step S306, obtaining the text vector to be classified. Using the word vector corresponding to the keyword in the title, obtain the first text vector, using the word vector corresponding to the keyword in the text, obtain the second text vector, and obtain the text vector to be classified based on the first text vector and the second text vector.
[0146] Step S307: calculate and obtain the similarity value between the text to be classified and each text type.
[0147] Step S308: Compare each similarity value with the corresponding similarity threshold to obtain a comparison result.
[0148] Step S309: output the type of the text to be classified according to the comparison result.
[0149] <Device Example>
[0150] Figure 4 4 is a functional block diagram of a text classification device according to an embodiment of the present invention.
[0151] according to Figure 4 As shown, the text classification device 4000 of this embodiment may include a text type vector determination module 4100 , a to-be-classified text vector determination module 4200 , a similarity value calculation module 4300 , and a comparison module 4400 .
[0152] The text type vector determination module 4100 is used to obtain each text type vector using the word vector corresponding to the seed word of each text type.
[0153] The module 4200 for determining the text vector to be classified is used to obtain the text vector to be classified by using the word vectors corresponding to the keywords of the text to be classified.
[0154] The similarity value calculation module 4300 is used to calculate the similarity value between the text to be classified and each text type according to the text vector to be classified and each text type vector.
[0155] The comparison module 4400 is used to compare each similarity value with the corresponding similarity threshold, and take the text type corresponding to the similarity value exceeding the similarity threshold as the type of the text to be classified.
[0156] In one embodiment, the seed words of each text type are obtained by at least one of the following methods: obtaining the seed words of each text type obtained by manual screening; or extracting entity words of texts of known categories and using the TF-IDF statistical method to obtain the seed words of each text type.
[0157] In this embodiment, the seed words of each text type are expanded in the following manner: obtaining the word vector of the seed word of each text type; obtaining the word vector whose distance from the word vector of the seed word of each text type is less than a preset distance threshold, and adding the words corresponding to the obtained word vector to the seed word of each text type.
[0158] In one embodiment, the text type vector determination module 4100 is also used to obtain the weight values of the word vectors corresponding to various sub-words based on each text type; and obtain the text type vector according to the word vectors corresponding to various sub-words and the weight values of the word vectors corresponding to various sub-words.
[0159] In one embodiment, the module 4200 for determining the text vector to be classified is also used to obtain keywords in the title of the text to be classified; obtain a first text vector using the word vectors corresponding to the keywords in the title; obtain keywords in the body of the text to be classified; obtain a second text vector using the word vectors corresponding to the keywords in the body; and obtain a text vector to be classified based on the first text vector and the second text vector.
[0160] In one embodiment, the module 4200 for determining the text vector to be classified is also used to obtain the weight value of the word vector corresponding to the keyword in the title, and obtain the first text vector based on the word vector corresponding to the keyword in the title and the weight value of the word vector corresponding to the keyword in the title; and to obtain the weight value of the word vector corresponding to the keyword in the text, and obtain the second text vector based on the word vector corresponding to the keyword in the text and the weight value of the word vector corresponding to the keyword in the text.
[0161] In one embodiment, the similarity threshold of each text type is determined by the following steps: based on each text type, each training text vector is obtained using the word vector corresponding to the keyword of the training text; based on each training text vector and the text type vector, a similarity value between each training text and the text type vector is obtained; the similarity value between each training text and the text type vector is compared with the initial similarity value respectively to obtain a training text whose similarity value exceeds the initial similarity value; whether the category of the training text whose similarity value exceeds the initial similarity value is consistent with the text type, and a detection result is obtained; the accuracy of the training sample classification is determined according to the detection result; and the initial similarity value is adjusted according to the accuracy.
[0162] <Electronic Equipment Embodiment>
[0163] In this embodiment, an electronic device is also provided. The electronic device may be Figure 1 The server shown.
[0164] according to Figure 5 As shown, the electronic device 5000 may include a text classification device 4000 according to any embodiment of the present invention, for implementing a text classification method according to any embodiment of the present invention.
[0165] In another embodiment, the electronic device 5000 may further include a processor 5100 and a memory 5200, wherein the memory 5200 is used to store executable instructions; the processor 5100 is used to control the electronic device 5000 to execute the text classification method according to any embodiment of the present invention under the control of the instructions.
[0166] <Computer Readable Storage Medium>
[0167] In this embodiment, a computer-readable storage medium is further provided, on which a computer program is stored. When the computer program is executed by a processor, the text classification method according to any embodiment of the present invention is implemented.
[0168] The present invention may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present invention.
[0169] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0170] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0171] The computer program instructions for performing the operation of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present invention.
[0172] Various aspects of the present invention are described herein with reference to the flow charts and / or block diagrams of the methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each box of the flow chart and / or block diagram and the combination of each box in the flow chart and / or block diagram can be implemented by computer-readable program instructions.
[0173] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0174] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0175] The flowchart and block diagram in the accompanying drawings show the possible architecture, functions and operations of the system, method and computer program product according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of an instruction, and a part of a module, a program segment or an instruction contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that it is equivalent to implement it by hardware, implement it by software, and implement it by combining software and hardware.
[0176] Embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements to the technology in the marketplace, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein. The scope of the present invention is defined by the appended claims.
Claims
1. A text classification method, comprising: Using the word vectors corresponding to the seed words of each text type, the vectors of each text type are obtained; Using the word vectors corresponding to the keywords of the text to be classified, obtaining the text vector to be classified; Calculating similarity values between the text to be classified and each text type according to the text to be classified vector and each text type vector; Each similarity value is compared with the corresponding similarity threshold, and the text type corresponding to the similarity value exceeding the similarity threshold is used as the type of the text to be classified; wherein, The similarity thresholds of the text types are determined by the following steps: The similarity values of each training text and the text type vector are respectively compared with the initial similarity value to obtain training texts whose similarity values exceed the initial similarity value; Detecting whether the category of the training text whose similarity value exceeds the initial similarity value is consistent with the text type, and obtaining a detection result; Determining the accuracy of training sample classification according to the detection results; The initial similarity value is adjusted according to the accuracy rate.
2. The method according to claim 1, wherein: The seed words of each text type are obtained by at least one of the following methods: Obtain seed words of each text type obtained by manual screening; or, Entity words of texts of known categories are extracted, and seed words of each text type are obtained using the TF-IDF statistical method.
3. The method according to claim 2, wherein: The seed words of each text type are expanded in the following ways: Get the word vectors of the seed words of each text type; A word vector whose distance from the word vector of the seed word of each text type is less than a preset distance threshold is obtained, and the words corresponding to the obtained word vector are added to the seed word of each text type.
4. The method according to claim 1, wherein: The obtaining of each text type vector by using the word vector corresponding to the seed word of each text type comprises: Based on each text type, obtain the weight values of the word vectors corresponding to various subwords; A text type vector is obtained according to the word vectors corresponding to the various sub-words and the weight values of the word vectors corresponding to the various sub-words.
5. The method according to claim 1, wherein: The obtaining of the vector of the text to be classified by using the word vector corresponding to the keyword of the text to be classified comprises: Obtaining keywords from the title of the text to be classified; Obtain a first text vector using the word vectors corresponding to the keywords in the title; Obtaining keywords in the body of the text to be classified; Using the word vectors corresponding to the keywords in the text, a second text vector is obtained; The to-be-classified text vector is obtained according to the first text vector and the second text vector.
6. The method according to claim 5, wherein: The obtaining of the first text vector by using the word vector corresponding to the keyword in the title includes: Obtaining weight values of word vectors corresponding to keywords in the title; Obtaining a first text vector according to the word vector corresponding to the keyword in the title and the weight value of the word vector corresponding to the keyword in the title; and The obtaining of the second text vector by using the word vector corresponding to the keyword in the text includes: Obtaining weight values of word vectors corresponding to keywords in the text; A second text vector is obtained according to the word vectors corresponding to the keywords in the text and the weight values of the word vectors corresponding to the keywords in the text.
7. The method according to claim 1, wherein: The similarity values between each training text and the text type vector are determined by the following steps: Based on each text type, use the word vectors corresponding to the keywords of the training text to obtain the vectors of each training text; According to the training text vectors and the text type vector, a similarity value between the training texts and the text type vector is obtained.
8. A text classification device, comprising: A text type vector determination module, used to obtain each text type vector using the word vector corresponding to the seed word of each text type; A module for determining a text vector to be classified, used to obtain the text vector to be classified by using the word vector corresponding to the keyword of the text to be classified; A similarity value calculation module, used for calculating the similarity value between the text to be classified and each text type according to the text vector to be classified and each text type vector; A comparison module is used to compare each similarity value with the corresponding similarity threshold, and take the text type corresponding to the similarity value exceeding the similarity threshold as the type of the text to be classified; wherein, The similarity thresholds of the text types are determined by the following steps: The similarity values of each training text and the text type vector are respectively compared with the initial similarity value to obtain training texts whose similarity values exceed the initial similarity value; Detecting whether the category of the training text whose similarity value exceeds the initial similarity value is consistent with the text type, and obtaining a detection result; Determining the accuracy of training sample classification according to the detection results; The initial similarity value is adjusted according to the accuracy rate.
9. An electronic device, comprising a processor and a memory, wherein the memory is used to store executable instructions, and the processor is used to control the electronic device to execute the method according to any one of claims 1 to 7 under the control of the instructions.
10. A computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the method according to any one of claims 1 to 7 when executed by a processor.
