Text region recognition method and device, computer readable medium and electronic device
By performing named entity recognition and word segmentation on the text, combined with a pre-set knowledge base and machine learning model, the problem of identifying fine-grained place name and regional information in text was solved, and accurate identification and classification of text regions were achieved.
Patent Information
- Application Number
- CN202111295460.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-03
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2041-11-03
AI Technical Summary
In existing technologies, it is difficult to accurately identify the regional information of fine-grained place names in texts, resulting in the inability to accurately identify the regional information of articles.
By performing named entity recognition on the text to be processed, the named entities are obtained and the regional words are obtained by querying a preset knowledge base. After word segmentation, the regional embedding codes of the segmented words are obtained and input into a pre-trained machine learning model to obtain regional classification labels.
It achieves accurate identification of text regions, improves the accuracy of text region identification, and supports subsequent text classification and push processing.
Smart Images

Figure CN116070630B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of computers, and particularly relates to a text region identification method and device, a computer readable medium, and an electronic device. BACKGROUND
[0002] In intelligent recommendation such as personalized information flow recommendation, many articles have certain regional attributes. The regional attributes usually make these articles only suitable for users in a certain regional range to read, or more suitable for users in a certain regional range to read. Therefore, how to accurately identify the regional attributes of the text is an urgent problem to be solved.
[0003] Since many articles in the information flow article are articles for tourism recommendation, commercial district recommendation, school information, administrative announcement, and water and electricity outage notice, these articles usually contain many small-range place names of fine granularity, such as scenic spots, commercial districts, streets, towns, and schools. In related technologies, the regional information of the fine-grained place names in the text with fine-grained place names is difficult to identify, which leads to the inability to accurately identify the regional information of the article.
[0004] It should be noted that the information disclosed in the above background section is only used to strengthen the understanding of the background of the present application, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY
[0005] The purpose of the present application is to provide a text region identification method and device, a computer readable medium, and an electronic device. At least to some extent, the technical problem of how to accurately identify the regional information of the article in related technologies is overcome.
[0006] Other characteristics and advantages of the present application will become apparent from the following detailed description, or will be learned by practice of the present application.
[0007] According to one aspect of an embodiment of the present application, a text region identification method is provided. The text region identification method comprises:
[0008] performing named entity recognition on a to-be-processed text to obtain one or more named entities in the to-be-processed text;
[0009] querying a preset knowledge base according to the named entity to obtain a regional word to which the named entity belongs, the preset knowledge base comprising a subordination relationship between the named entity and the regional word;
[0010] performing word segmentation processing on the to-be-processed text to obtain a plurality of words included in the to-be-processed text, the words comprising one or more characters;
[0011] obtain regional embedding codes corresponding to each of the word pieces according to regional words to which the named entities corresponding to the word pieces belong;
[0012] input the regional embedding codes corresponding to each of the word pieces in the text to be processed into a pre-trained machine learning model to obtain regional classification labels corresponding to the text to be processed, the regional classification labels including a regional text label and a non-regional text label.
[0013] According to an aspect of an embodiment of the present application, a text regional identification device is provided. The text regional identification device includes:
[0014] a named entity recognition module configured to perform named entity recognition on a text to be processed to obtain one or more named entities in the text to be processed;
[0015] a regional word query module configured to query a preset knowledge base according to the named entities to obtain regional words to which the named entities belong, the preset knowledge base including a dependency relationship between the named entities and the regional words;
[0016] a word piece module configured to perform word piece processing on the text to be processed to obtain a plurality of word pieces included in the text to be processed, the word pieces including one or more characters;
[0017] a regional embedding code module configured to obtain regional embedding codes corresponding to each of the word pieces according to regional words to which the named entities corresponding to the word pieces belong;
[0018] a regional classification module configured to input the regional embedding codes corresponding to each of the word pieces in the text to be processed into a pre-trained machine learning model to obtain regional classification labels corresponding to the text to be processed, the regional classification labels including a regional text label and a non-regional text label.
[0019] In some embodiments of the present application, based on the above technical solutions, the regional embedding code module includes:
[0020] a regional embedding code first obtaining unit configured to, when the word piece has a corresponding named entity and the named entity corresponding to the word piece has a regional word to which it belongs, query a preset first word table according to the regional word to which the named entity corresponding to the word piece belongs to obtain the regional embedding code corresponding to the word piece;
[0021] a regional embedding code second obtaining unit configured to, when the word piece does not have a corresponding named entity or the named entity corresponding to the word piece does not have a regional word to which it belongs, take a preset encoding as the regional embedding code corresponding to the word piece.
[0022] In some embodiments of the present application, based on the above technical solutions, the regional embedding code first obtaining unit comprises:
[0023] The regional embedding code first obtaining sub-unit is configured to, when the word corresponds to one named entity, query the first word table according to the regional word to which the named entity corresponding to the word belongs, and obtain the regional embedding code corresponding to the word.
[0024] The regional embedding code second obtaining sub-unit is configured to, when the word corresponds to multiple named entities, select one named entity from the multiple named entities as the named entity corresponding to the word, and query the first word table according to the regional word to which the named entity corresponding to the word belongs, and obtain the regional embedding code corresponding to the word.
[0025] In some embodiments of the present application, based on the above technical solutions, the regional embedding code second obtaining sub-unit comprises:
[0026] The correlation calculation sub-unit is configured to calculate the correlation of the named entity at the context position of the word in the text to be processed with the multiple named entities corresponding to the word, and take the named entity with the highest correlation with the context position of the word as the named entity corresponding to the word; or
[0027] The appearance frequency obtaining sub-unit is configured to obtain the appearance frequency of the multiple named entities corresponding to the word in the historical processing text respectively, and take the named entity with the highest appearance frequency in the historical processing text as the named entity corresponding to the word.
[0028] In some embodiments of the present application, based on the above technical solutions, the text regional recognition device further comprises:
[0029] The preset regional entity library obtaining unit is configured to obtain a preset regional entity library, the preset regional entity library comprising multiple named entities with regional attributes;
[0030] The named entity eliminating unit is configured to query the preset regional entity library according to the named entity, and eliminate the named entity not included in the preset regional entity library.
[0031] In some embodiments of the present application, based on the above technical solutions, the named entity recognition module comprises:
[0032] The preset regional entity library obtaining unit is configured to obtain a preset regional entity library, the preset regional entity library comprising multiple named entities with regional attributes;
[0033] The full-word matching unit is configured to perform full-word matching on the to-be-processed text according to the naming entities in the preset regional entity library, and obtain one or more naming entities in the to-be-processed text.
[0034] In some embodiments of the present application, based on the above technical solutions, the naming entities included in the preset regional entity library are all included in the preset knowledge base.
[0035] In some embodiments of the present application, based on the above technical solutions, the text regional recognition device comprises:
[0036] The feature embedding code acquisition unit is configured to query a preset second word table according to the word segmentation, and acquire a feature embedding code corresponding to the word segmentation;
[0037] The position embedding code acquisition unit is configured to query a preset third word table according to the position of the word segmentation in the corresponding sentence, and acquire a position embedding code corresponding to the word segmentation;
[0038] The sentence type embedding code acquisition unit is configured to query a preset fourth word table according to the position of the sentence in which the word segmentation is located in the to-be-processed text, and acquire a sentence type embedding code corresponding to the word segmentation;
[0039] The code input unit is configured to input the feature embedding code, the position embedding code and the sentence type embedding code corresponding to each word segmentation in the to-be-processed text into a pre-trained machine learning model.
[0040] In some embodiments of the present application, based on the above technical solutions, the regional classification module comprises:
[0041] The code addition unit is configured to add the regional embedding code corresponding to each word segmentation in the to-be-processed text to the feature embedding code, the position embedding code and the sentence type embedding code, to obtain a comprehensive embedding code;
[0042] The comprehensive embedding code input unit is configured to input the comprehensive embedding code corresponding to each word segmentation in the to-be-processed text into a pre-trained machine learning model, to obtain a regional classification label corresponding to the to-be-processed text.
[0043] In some embodiments of the present application, based on the above technical solutions, the text regional recognition device comprises:
[0044] The training text naming entity recognition unit is configured to perform naming entity recognition on a training text, and acquire one or more naming entities in the training text;
[0045] The geographical word query unit is configured to query the preset knowledge base according to the named entity, and obtain a geographical word to which the named entity belongs.
[0046] The word segmentation processing unit is configured to perform word segmentation processing on the training text, to obtain a plurality of words included in the training text, the words including one or more characters.
[0047] The geographical embedding encoding unit is configured to obtain geographical embedding encodings corresponding to the words according to geographical words to which named entities corresponding to the words belong.
[0048] The geographical classification unit is configured to take the geographical embedding encodings corresponding to the words in the training text as input of the machine learning model, take geographical classification labels marked in the training text as target output of the machine learning model, and train the machine learning model.
[0049] In some embodiments of the present application, based on the above technical solutions, the preset knowledge base includes a dependency relationship between the named entity and the geographical word in the form of a dependency relationship mapping pair; and the geographical word query module includes:
[0050] The dependency relationship mapping pair query unit is configured to query the dependency relationship mapping pair in the preset knowledge base according to the named entity, and obtain the geographical word to which the named entity belongs.
[0051] In some embodiments of the present application, based on the above technical solutions, the preset knowledge base includes one or more tree-type storage structures with the named entity as a node; and the geographical word query module includes:
[0052] The tree-type storage structure query unit is configured to query the preset knowledge base according to the named entity, and obtain a node corresponding to the named entity in the tree-type storage structure.
[0053] The geographical word obtaining unit is configured to take a named entity corresponding to a preset hierarchical node to which the node corresponding to the named entity belongs, as the geographical word to which the named entity belongs.
[0054] According to an aspect of an embodiment of the present application, there is provided a computer readable medium having stored thereon a computer program, which, when executed by a processor, implements the text geographical recognition method in the above technical solutions.
[0055] According to an aspect of an embodiment of the present application, there is provided an electronic device, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the text geographical recognition method in the above technical solutions by executing the executable instructions.
[0056] According to an aspect of the embodiments of the present application, a computer program product or computer program is provided, which comprises computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to perform the text region identification method in the above technical solutions.
[0057] In the technical solutions provided in the embodiments of the present application, the named entity recognition is performed on the to-be-processed text to obtain one or more named entities in the to-be-processed text; the named entity is used to query a preset knowledge base to obtain a region word to which the named entity belongs; the to-be-processed text is subjected to word segmentation processing to obtain a plurality of words included in the to-be-processed text; the region embedding code corresponding to each word is obtained according to the region word to which the named entity corresponding to the word belongs; and the region embedding code corresponding to each word in the to-be-processed text is input into the pre-trained machine learning model to obtain the region classification label corresponding to the to-be-processed text. Thus, the region type of the to-be-processed text is accurately identified, so that the to-be-processed text can be classified, pushed, and processed according to the region type of the to-be-processed text. It can be understood that the region embedding code corresponding to each word is obtained according to the region word to which the named entity corresponding to the word belongs, and the region embedding code corresponding to each word in the to-be-processed text is input into the pre-trained machine learning model, so that the code of the to-be-processed text has stronger region properties, and thus the machine learning model can identify the region of the to-be-processed text according to the code with enhanced region properties, thereby improving the accuracy of the region identification of the to-be-processed text.
[0058] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present application. BRIEF DESCRIPTION OF DRAWINGS
[0059] The drawings incorporated into the specification and forming a part thereof, illustrate embodiments consistent with the present application and, together with the specification, serve to explain the principles of the present application. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.
[0060] Figure 1 An exemplary device architecture block diagram to which the technical solutions of the present application are applied is schematically shown.
[0061] Figure 2 A step flow of the text region identification method provided by the embodiments of the present application is schematically shown.
[0062] Figure 3The step flow of performing named entity recognition on the to-be-processed text to obtain one or more named entities in the to-be-processed text in the embodiment of the application is schematically shown.
[0063] Figure 4 The schematic diagram of the tree type storage structure of the embodiment of the application is schematically shown.
[0064] Figure 5 The step flow before querying the preset knowledge base according to the named entity in the embodiment of the application is schematically shown.
[0065] Figure 6 The step flow of querying the preset knowledge base according to the named entity in the embodiment of the application is schematically shown.
[0066] Figure 7 The step flow of obtaining the regional embedding code corresponding to each word according to the regional word to which the named entity corresponding to the word belongs in the embodiment of the application is schematically shown.
[0067] Figure 8 The step flow of querying the preset first word table according to the regional word to which the named entity corresponding to the word belongs when the word has the corresponding named entity and the named entity corresponding to the word has the regional word to which it belongs in the embodiment of the application is schematically shown.
[0068] Figure 9 The step flow of selecting one named entity as the named entity corresponding to the word from multiple named entities in the embodiment of the application is schematically shown.
[0069] Figure 10 The step flow before inputting the regional embedding code corresponding to each word in the to-be-processed text into the pre-trained machine learning model to obtain the regional classification label corresponding to the to-be-processed text in the embodiment of the application is schematically shown.
[0070] Figure 11 The step flow of inputting the regional embedding code corresponding to each word in the to-be-processed text into the pre-trained machine learning model to obtain the regional classification label corresponding to the to-be-processed text in the embodiment of the application is schematically shown.
[0071] Figure 12 The process diagram of adding the regional embedding code corresponding to each word in the to-be-processed text to the feature embedding code, the position embedding code and the sentence type embedding code to obtain the comprehensive embedding code, and then inputting the comprehensive embedding code corresponding to each word in the to-be-processed text into the pre-trained machine learning model to obtain the regional classification label corresponding to the to-be-processed text in the embodiment of the application is schematically shown.
[0072] Figure 13 The steps before the step of inputting the regional embedding codes corresponding to each wordpiece in the to-be-processed text into the pre-trained machine learning model to obtain the regional classification label corresponding to the to-be-processed text are schematically shown.
[0073] Figure 14 A structural block diagram of the text regional identification apparatus provided by the embodiment of the present application is schematically shown.
[0074] Figure 15 A structural block diagram of an electronic device for implementing the embodiment of the present application is schematically shown. DETAILED DESCRIPTION
[0075] Example implementations will now be described more fully with reference to the accompanying drawings. Example implementations may, however, be implemented in many different forms and should not be construed as limited to the implementations set forth herein; rather, these implementations are provided so that this disclosure will be thorough and complete, and will fully convey the inventive aspects of example implementations to those skilled in the art.
[0076] Moreover, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the application. One skilled in the relevant art will recognize, however, that the
[0077] The block diagrams shown in the accompanying drawings are merely functional entities, and do not necessarily have to correspond to physically independent entities. That is, these functional entities can be implemented in the form of software, or implemented in one or more hardware modules or integrated circuits, or implemented in different network and / or processor devices and / or microcontroller devices.
[0078] The flowcharts shown in the accompanying drawings are merely exemplary illustrations, and do not necessarily include all contents and operations / steps, nor do they have to be executed in the order described. For example, some operations / steps can be further decomposed, and some operations / steps can be combined or partially combined, so the actual execution order can be changed according to actual conditions.
[0079] Before the technical solutions of the text regional identification method, the text regional identification apparatus, and the like provided by the embodiments of the present application are described in detail, the artificial intelligence technology involved in some embodiments of the present application is briefly introduced.
[0080] Artificial Intelligence (AI) is the theory, method, technology and application devices that use digital computers or digital computer controlled machines to simulate, extend and expand human intelligence, perceive environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology of computer science, which attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making.
[0081] Artificial intelligence technology is a comprehensive discipline, involving a wide range of fields, both hardware and software technologies. Artificial intelligence basic technologies generally include technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction devices, mechatronics, etc. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning, etc.
[0082] Natural Language Processing (NLP) is an important direction in the field of computer science and artificial intelligence. It studies various theories and methods that can realize effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, i.e. the language used in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question and answer, knowledge graph, etc.
[0083] Machine Learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, etc. It is a branch of computer science that studies how computers simulate or implement human learning behavior to acquire new knowledge or skills, and reorganize existing knowledge structure to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental approach to making computers intelligent, and its applications are widespread in various fields of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and rule-based learning.
[0084] With the research and progress of artificial intelligence technology, artificial intelligence technology is researched and applied in many fields, such as common smart home, smart wearable device, virtual assistant, smart speaker, smart marketing, unmanned driving, automatic driving, unmanned aerial vehicle, robot, smart medical treatment, smart customer service, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important value.
[0085] The text region identification method and device provided in the present application will be described in detail below in combination with specific embodiments.
[0086] Figure 1 An exemplary device architecture block diagram to which the technical solutions of the present application are applied is schematically shown.
[0087] As shown in Figure 1 , the device architecture 100 can include a terminal device 110, a network 120 and a server 130. The terminal device 110 can include various electronic devices such as a smartphone, a tablet computer, a notebook computer, a desktop computer, etc. The server 130 can be a standalone physical server, or a server cluster or distributed device composed of multiple physical servers, or a cloud server providing cloud computing services. The network 120 can be various connection type communication media capable of providing a communication link between the terminal device 110 and the server 130, such as a wired communication link or a wireless communication link.
[0088] According to the implementation needs, the device architecture in the embodiments of the present application can have any number of terminal devices, networks and servers. For example, the server 130 can be a server group composed of multiple server devices. In addition, the technical solutions provided in the embodiments of the present application can be applied to the terminal device 110, or can be applied to the server 130, or can be jointly implemented by the terminal device 110 and the server 130, which is not specially limited by the present application. The terminal device includes but is not limited to a mobile phone, a computer, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, etc.
[0089] For example, the server 130 can perform the text region identification method provided in the present application, perform named entity recognition on the to-be-processed text, obtain one or more named entities in the to-be-processed text, query a preset knowledge base according to the named entities, obtain regional words to which the named entities belong, perform word segmentation processing on the to-be-processed text to obtain a plurality of words included in the to-be-processed text, obtain regional embedding codes corresponding to each word according to the regional words to which the named entities corresponding to the words belong, input the regional embedding codes corresponding to each word in the to-be-processed text into a pre-trained machine learning model to obtain a regional classification label corresponding to the to-be-processed text. Thus, accurate identification of the region type of the to-be-processed text is realized, thereby facilitating subsequent classification, pushing and other processing of the to-be-processed text according to the region type of the to-be-processed text.
[0090] It can be understood that, according to the regional words to which the named entities corresponding to the words belong, the regional embedding codes corresponding to each word are obtained, and then the regional embedding codes corresponding to each word in the to-be-processed text are input into the pre-trained machine learning model, so that the codes of the to-be-processed text can have stronger regional properties, thereby enabling the machine learning model to identify the region of the to-be-processed text according to the codes with enhanced regional properties, thereby improving the accuracy of the region identification of the to-be-processed text. In specific embodiments, the present application can be applied in the fields of intelligent transportation, Internet of Vehicles, terminal information recommendation and the like.
[0091] Figure 2 The steps of the text region identification method provided in the embodiments of the present application are schematically shown. The execution subject of the text region identification method can be a terminal device or a server. As shown in Figure 2 The text region identification method can mainly include the following steps S210-S250:
[0092] S210. Perform named entity recognition on the to-be-processed text to obtain one or more named entities in the to-be-processed text.
[0093] The to-be-processed text can be an article, an information text, a paragraph, a sentence or the like, and the present application does not limit the to-be-processed text.
[0094] In some embodiments, performing named entity recognition on the to-be-processed text to obtain one or more named entities in the to-be-processed text can be to recognize all named entities in the to-be-processed text. For example, NER named entity recognition in the BIO format recognizes “Huoying”, “Guomao”, “Zhang San” and “Li Si” in the sentence “Zhang San and Li Si came to Huoying tonight, and will go to Guomao tomorrow” as named entities.
[0095] In some embodiments, the step of performing named entity recognition on the text to be processed to obtain one or more named entities in the text to be processed can be to only recognize named entities with regional properties in the text to be processed. For example, only the named entities with regional properties "Huoying" and "Guomao" in the sentence "Zhang San and Li Si arrived at Huoying tonight, and will go to Guomao tomorrow" are recognized as named entities, and the named entities without regional properties "Zhang San" and "Li Si" are not recognized.
[0096] In some embodiments, the step of performing named entity recognition on the text to be processed to obtain one or more named entities in the text to be processed can be to only recognize fine-grained named entities with regional properties in the text to be processed. For example, only the fine-grained named entities with regional properties "Huoying" and "Guomao" in the sentence "Zhang San and Li Si arrived at Huoying from Shanghai tonight, and will go to Guomao tomorrow" are recognized as named entities, and the coarse-grained named entity without regional properties "Shanghai" is not recognized. It can be understood that "Shanghai" itself has strong regional attributes, and "Shanghai" can not be regionally enhanced. Fine-grained named entities with regional properties in the text to be processed can include small-range place names such as scenic spots, commercial districts, streets, towns, schools, and institutions, etc. In some embodiments, a preset granularity can be marked, and only regional named entities smaller than the preset granularity in the text to be processed are obtained for subsequent regional embedding coding to achieve regional information enhancement for fine-grained named entities with regional properties. The granularity of the regional named entity can be determined according to the geographical range of the regional named entity or manual annotation.
[0097] Figure 3 The step flow of performing named entity recognition on the text to be processed to obtain one or more named entities in the text to be processed in the embodiments of the present application is schematically shown. As shown in Figure 3 On the basis of the above embodiments, in some embodiments, the step of performing named entity recognition on the text to be processed to obtain one or more named entities in the text to be processed in step S210 can further include the following steps S310-S320:
[0098] S310. Obtain a preset regional entity library, the preset regional entity library including a plurality of named entities with regional attributes;
[0099] S320. Perform full-word matching on the text to be processed according to the named entities in the preset regional entity library to obtain one or more named entities in the text to be processed.
[0100] Specifically, the full-word matching is to search and match the text to be processed by taking each named entity in the preset regional entity library as a complete and indivisible search unit, and return the search result. Thus, the accuracy of the named entity searched and matched in the text to be processed can be ensured.
[0101] Thus, according to the preset regional entity library, the named entity in the to-be-processed text is matched with the whole word, the range of recognizing the named entity from the to-be-processed text can be limited according to the plurality of named entities with regional attributes included in the preset regional entity library, so that the named entity recognized from the to-be-processed text can be avoided to be a named entity without a regional attribute, the named entity recognized from the to-be-processed text can have a regional attribute, and the coding effect of the subsequent regional attribute strengthening according to the named entity recognized from the to-be-processed text can be improved. Moreover, the named entity recognized can avoid not having a regional attribute, the query amount of the preset knowledge base according to the named entity can be reduced, the query efficiency can be improved, and thus the regional recognition efficiency of the to-be-processed text can be improved.
[0102] For example, by using this embodiment, the preset regional entity library includes "Huoying" and "Guomao", but does not include "Zhang San" and "Li Si", so that only the named entities "Huoying" and "Guomao" with regional attributes in the sentence "Zhang San and Li Si arrived in Huoying tonight, and will go to Guomao tomorrow." can be recognized as named entities, and the named entities "Zhang San" and "Li Si" without regional attributes can not be recognized.
[0103] In specific embodiments, the preset regional entity library can be constructed offline in advance. Specifically, a structured knowledge base including fine-grained named entities with regional attributes such as scenic spots, business districts, schools, streets, and towns can be constructed through processes such as crawling, manual annotation, sorting, and denoising from the network and existing databases.
[0104] S220. Query the preset knowledge base according to the named entity to obtain a regional word to which the named entity belongs.
[0105] In specific embodiments, the preset knowledge base includes the dependency relationship between the named entity and the regional word, and the preset knowledge base can be the same as the preset knowledge base described in the foregoing embodiments.
[0106] Specifically, in some embodiments, the preset knowledge base includes one or more tree-type storage structures with named entities as nodes. Figure 4 A schematic diagram of the tree-type storage structure of the embodiment of the present application is schematically shown. As shown in Figure 4 The tree-type storage structure can include a plurality of nodes, wherein each node corresponds to a named entity, and the nodes have corresponding dependency relationships. Thus, the second named entity corresponding to the node to which the node of the first named entity depends can be taken as the regional word corresponding to the first named node, so as to query the preset knowledge base according to the named entity to obtain the regional word to which the named entity belongs.
[0107] In some embodiments, the preset knowledge base can include the hierarchical relationship between the named entity and the geographical word in the form of hierarchical relationship mapping pairs. Table 1 schematically shows an example of the hierarchical relationship mapping pairs included in the preset knowledge base according to an embodiment of the present application. As shown in Table 1, the preset knowledge base can include the hierarchical relationship between the named entity and the geographical word in the form of hierarchical relationship mapping pairs. For example, the preset knowledge base can include the hierarchical relationship mapping pairs "Summer Palace - Beijing, Haidian District", "Huoying - Beijing, Changping District", "Guomao - Beijing, Chaoyang District", etc. In Table 1, the geographical word can include multiple levels, and one level can be selected from the multiple levels as the geographical word to which the named entity belongs, such as selecting "Beijing" from "Beijing, Haidian District" as the geographical word to which "Summer Palace" belongs.
[0108] In some embodiments, the geographical word can include only one level, for example, the preset knowledge base can include the hierarchical relationship mapping pairs "Summer Palace - Beijing", "Huoying - Beijing", "Guomao - Beijing", etc. In this case, the one level geographical word is taken as the geographical word to which the named entity belongs. For example, "Beijing" is taken as the geographical word to which the named entity "Summer Palace" belongs.
[0109]
[0110] Table 1
[0111] In Table 1, each named entity tag has a corresponding category, which can facilitate the systematic construction of the preset knowledge base.
[0112] In some embodiments, the hierarchical relationship mapping pairs of the preset knowledge base can be sorted according to the preset category order of the named entity tag, and when searching the hierarchical relationship mapping pairs of the preset knowledge base, the search can be performed according to the preset order of the category according to the type of the article, so as to accelerate the query efficiency of the preset knowledge base. For example, if the article is a business introduction article, the hierarchical relationship mapping pairs of the business circle type can be searched first; for example, if the article is a travel introduction article, the hierarchical relationship mapping pairs of the scenic spot type can be searched first, so as to accelerate the query efficiency of the preset knowledge base.
[0113] It should be noted that in some embodiments, the named entity can not be marked with a corresponding category.
[0114] Figure 5 The step flow before querying the preset knowledge base according to the named entity in the embodiment of the present application is schematically shown. As shown in Figure 5 On the basis of the above embodiment, in some embodiments, before querying the preset knowledge base according to the named entity in step S220, the following steps S510-S520 can be further included:
[0115] S510. Obtain a preset regional entity library, the preset regional entity library including a plurality of named entities with regional attributes;
[0116] S520. Query the preset regional entity library according to the named entity, and eliminate the named entity not included in the preset regional entity library.
[0117] For example, the preset regional entity library can include named entities such as “Huoying”, “Summer Palace”, “Guomao”, “Nangang District”, and “Sanhe City”. Thus, after performing named entity recognition on the to-be-processed text and obtaining one or more named entities in the to-be-processed text, the preset regional entity library can be queried according to the named entity, and the named entity not included in the preset regional entity library can be eliminated, and then the preset knowledge base can be queried according to the named entity. In this way, the query amount of querying the preset knowledge base according to the named entity can be reduced, and the query efficiency can be improved, thereby improving the regional recognition efficiency of the to-be-processed text.
[0118] For example, after identifying all named entities in the to-be-processed text, and identifying “Huoying”, “Guomao”, “Zhang San”, and “Li Si” in the to-be-processed text “Zhang San and Li Si arrived in Huoying tonight, and will go to Guomao tomorrow” as named entities, the named entities “Zhang San” and “Li Si” not included in the preset regional entity library can be eliminated, so as to reduce the query amount of querying the preset knowledge base according to the named entity, improve the query efficiency, and thereby improve the regional recognition efficiency of the to-be-processed text.
[0119] In some embodiments, the preset regional entity library can include fine-grained named entities, that is, named entities used to describe small-scale and fine-grained place names. Thus, by constructing a structured preset regional entity library offline, accurate identification of fine-grained named entities can be achieved, and subsequent enhancement of regional information for the fine-grained named entities through regional embedding coding can make the coding of the to-be-processed text have stronger regional properties, thereby improving the accuracy of regional recognition of the to-be-processed text.
[0120] In some embodiments, on the basis of the above embodiments, the named entities included in the preset regional entity library are all included in the preset knowledge base. Specifically, when the preset knowledge base includes one or more tree-type storage structures with named entities as nodes, the named entities included in the preset regional entity library are all included in the named entities of the nodes of the one or more tree-type storage structures. When the preset knowledge base includes the subordinate relationship between named entities and regional words in the form of subordinate relationship mapping pairs, the named entities included in the preset regional entity library are all included in the named entities of the subordinate relationship mapping pairs.
[0121] Figure 6The step flow of querying the preset knowledge base according to the named entity and obtaining the regional word to which the named entity belongs in the embodiments of the present application is schematically shown. As shown in Figure 6 On the basis of the above embodiments, in some embodiments, the preset knowledge base comprises one or more tree type storage structures with the named entity as a node; and the step of querying the preset knowledge base according to the named entity and obtaining the regional word to which the named entity belongs in step S220 can further comprise the following steps S610-S620:
[0122] S610. Querying the preset knowledge base according to the named entity to obtain the node corresponding to the named entity in the tree type storage structure;
[0123] S620. Taking the named entity corresponding to the preset hierarchical node to which the node corresponding to the named entity belongs as the regional word to which the named entity belongs.
[0124] For example, the preset hierarchy can comprise A1, A2, etc. hierarchy corresponding to the node label of each layer in the tree type storage structure. Taking the tree type storage structure comprised in the preset knowledge base shown in Figure 4 As an example of the tree type storage structure comprised in the preset knowledge base shown in, querying the preset knowledge base according to the named entity “Huoying” obtains the node 401 corresponding to the named entity “Huoying” in the tree type storage structure. Then, taking the named entity “Beijing City” corresponding to the preset hierarchical node 402 at the preset hierarchy A1 to which the node 401 corresponding to the named entity “Huoying” belongs as the regional word “Beijing City” to which the named entity “Huoying” belongs.
[0125] For another example, querying the preset knowledge base according to the named entity “Huoying” obtains the node 401 corresponding to the named entity “Huoying” in the tree type storage structure. Then, taking the named entity “Changping District” corresponding to the preset hierarchical node 403 at the preset hierarchy A2 to which the node 401 corresponding to the named entity “Huoying” belongs as the regional word “Changping District” to which the named entity “Huoying” belongs.
[0126] In other embodiments, the preset knowledge base comprises the hierarchical relationship between the named entity and the regional word in the form of hierarchical relationship mapping pairs. The step of querying the preset knowledge base according to the named entity and obtaining the regional word to which the named entity belongs in step S220 can further comprise the following steps:
[0127] Querying the hierarchical relationship mapping pairs in the preset knowledge base according to the named entity to obtain the regional word to which the named entity belongs.
[0128] For example, taking the preset knowledge base shown in Table 1 as an example, according to the subordinate relationship mapping pair in the preset knowledge base queried by the named entity, the geographical word to which the named entity “Huoying” belongs is obtained. In Table 1, the geographical word “Beijing City, Changping District” of the subordinate relationship mapping pair in which “Huoying” is located includes two levels. Then, the first level can be selected from the two-level geographical word as the geographical word to which the named entity belongs. For example, “Beijing City” is selected as the geographical word to which the named entity “Huoying” belongs. Or, “Changping District” is selected as the geographical word to which the named entity “Huoying” belongs. In the text geographical recognition method, the level of the selected geographical word can be preset. For example, the selected geographical word can be set to a provincial / municipal / autonomous regional administrative unit, a municipal administrative unit, a district / county administrative unit, etc.
[0129] S230. Performing word segmentation processing on the to-be-processed text to obtain a plurality of words included in the to-be-processed text, the words including one or more characters.
[0130] When each word includes only one character, subsequent encoding of the words is character-level encoding. When each word includes multiple characters, subsequent encoding of the words is Subword or Whole Word level encoding. Thus, the degree of word segmentation processing can be controlled to control the subsequent encoding level.
[0131] For example, the to-be-processed text “Zhangsan and Lisi came to Huoying tonight, and will go to Guomao tomorrow.” is subjected to word segmentation processing, and each word includes one character. The word segmentation result is: Zhang / San / and / Li / four / today / night / to / Huoying / , / tomorrow / will / go / to / Guomao / .
[0132] S240. Obtaining geographical embedding codes corresponding to each word according to the geographical word to which the named entity corresponding to the word belongs.
[0133] For example, according to the geographical word “Beijing City” to which the named entity “Huoying” corresponding to the word “Hu” belongs, the geographical embedding code E 北京 corresponding to the word “Hu” is obtained. Thus, the geographical embedding code (PositionEmbedding) corresponding to each word is obtained.
[0134] Thus, according to the geographical word to which the named entity corresponding to each word belongs, the geographical embedding code corresponding to each word is obtained, so that the fine-grained place name in the to-be-processed text can be subjected to the geographical embedding code corresponding to the word segmentation, the geographical information of the fine-grained place name is enhanced, and the geographical embedding code corresponding to the word segmentation obtained by the subsequent geographical information enhancement is input into the pre-trained machine learning model. For the text including more fine-grained place names, accurate geographical recognition can also be achieved.
[0135] Figure 7 The step flow of obtaining the regional embedding code corresponding to each word segmentation according to the regional word subordinate to the named entity corresponding to the word segmentation in the embodiments of the present application is schematically shown. As shown in Figure 7 On the basis of the above embodiments, in some embodiments, the step of obtaining the regional embedding code corresponding to each word segmentation according to the regional word subordinate to the named entity corresponding to the word segmentation in step S240 can further include the following steps S710-S720:
[0136] S710. When the word segmentation has a corresponding named entity, and the named entity corresponding to the word segmentation has a subordinate regional word, the regional embedding code corresponding to the word segmentation is obtained by querying the preset first word table according to the regional word subordinate to the named entity corresponding to the word segmentation;
[0137] S720. When the word segmentation does not have a corresponding named entity, or the named entity corresponding to the word segmentation does not have a subordinate regional word, the preset encoding is taken as the regional embedding code corresponding to the word segmentation.
[0138] For example, the word segmentation “Huo” has a corresponding named entity “Huoying”, and the named entity “Huoying” corresponding to the word segmentation “Huo” has a subordinate regional word “Beijing City”, so the regional embedding code E 北京 corresponding to the word segmentation “Huo” is obtained by querying the preset first word table according to the regional word “Beijing City” subordinate to the named entity “Huoying” corresponding to the word segmentation “Huo”. Similarly, the regional embedding code E 北京 corresponding to the word segmentation “Ying” is obtained. Since the word segmentation “Huo” and the word segmentation “Ying” correspond to the same named entity “Huoying”, they correspond to the same regional word “Beijing City”, and therefore the word segmentation “Huo” and the word segmentation “Ying” correspond to the same regional embedding code E 北京 .
[0139] For example, the word segmentation “He” does not have a corresponding named entity, and the preset encoding E N is taken as the regional embedding code corresponding to the word segmentation “He”. For example, the word segmentation “Zhang” has a corresponding named entity “Zhangsan”, and when the named entity “Zhangsan” corresponding to the word segmentation “Zhang” does not have a subordinate regional word, the preset encoding E N is taken as the regional embedding code corresponding to the word segmentation. Wherein, the preset encoding E N can be used to represent the encoding of embedding coding without regional identifier.
[0140] Figure 8 The step flow of obtaining the regional embedding code corresponding to each word segmentation according to the regional word subordinate to the named entity corresponding to the word segmentation in the embodiments of the present application is schematically shown. As shown in Figure 8As shown, on the basis of the above embodiments, in some embodiments, when the word has a corresponding named entity and the word corresponds to a named entity that has a subordinate regional word in step S710, the step of querying the first word table according to the regional word subordinate to the named entity corresponding to the word to obtain the regional embedding code corresponding to the word can further include steps S810-S820:
[0141] S810. When the word corresponds to a named entity, the first word table is queried according to the regional word subordinate to the named entity corresponding to the word to obtain the regional embedding code corresponding to the word;
[0142] S820. When the word corresponds to multiple named entities, a named entity is selected from the multiple named entities as the named entity corresponding to the word, and the first word table is queried according to the regional word subordinate to the named entity corresponding to the word to obtain the regional embedding code corresponding to the word.
[0143] Thus, the regional embedding code of the word with the relevant regional attribute is realized, so that the encoding of the text to be processed can have stronger regional properties, thereby enabling the machine learning model to strengthen the regional information recognition and judgment ability for fine-grained place names (commercial circles, scenic spots, streets, schools, etc.), thereby improving the accuracy of regional recognition of the text to be processed.
[0144] In addition, when the word corresponds to multiple named entities, a named entity is selected from the multiple named entities as the named entity corresponding to the word, which realizes the disambiguation of the named entity corresponding to the word, can make the regional embedding code of the word with the relevant regional attribute more accurate, and is conducive to improving the accuracy of regional recognition of the text.
[0145] Figure 9 The step flow of selecting a named entity from multiple named entities as the named entity corresponding to the word in the embodiments of the application is schematically shown. As shown in Figure 9 As shown, on the basis of the above embodiments, in some embodiments, the step of selecting a named entity from multiple named entities as the named entity corresponding to the word in step S820 can further include step S910 or step S920:
[0146] S910. The relevance of the named entity at the context position of the word in the text to be processed to the multiple named entities corresponding to the word is calculated, and the named entity with the highest relevance to the named entity at the context position of the word is selected as the named entity corresponding to the word; or
[0147] S920. The occurrence frequency of the multiple named entities corresponding to the word in the historical processing text is obtained respectively, and the named entity with the highest occurrence frequency in the historical processing text is selected as the named entity corresponding to the word.
[0148] For example, the segmented word "国" corresponds to multiple named entities "国贸(1)" and "国贸(2)". Calculate the relevance between the named entity "霍营" at the context position of the segmented word "国" in the text to be processed and the multiple named entities "国贸(1)" and "国贸(2)" corresponding to the segmented word respectively, and use the named entity "国贸(1)" with the highest relevance to the named entity at the context position of the segmented word as the named entity corresponding to the segmented word "国". In some embodiments, the relevance between the named entity at the context position of the segmented word in the text to be processed and the multiple named entities corresponding to the segmented word can be inversely proportional to the geographical distance between the named entities. For example, the geographical distance between "霍营" and "国贸(1)" located in Beijing is less than the geographical distance between "霍营" and "国贸(2)" located in Shenzhen. Therefore, the relevance between "霍营" and "国贸(1)" is greater than the relevance between "霍营" and "国贸(2)". Use the named entity "国贸(1)" with the highest relevance to the named entity "霍营" at the context position of the segmented word "国" as the named entity corresponding to the segmented word "国". Thus, when a segmented word corresponds to multiple named entities, disambiguation of the named entity corresponding to the segmented word is achieved by calculating the relevance, which is beneficial to improving the accuracy of geographical recognition of the text.
[0149] Or for example, respectively obtain the occurrence frequencies of the multiple named entities "国贸(1)" and "国贸(2)" corresponding to the segmented word "国" in the historical processed text, and use the named entity with the highest occurrence frequency in the historical processed text as the named entity corresponding to the segmented word "国". Thus, it is possible to make the named entities with common geographical attributes more likely to be recognized as the named entities corresponding to the segmented word, and the efficiency and accuracy of named entity recognition can be improved.
[0150] S250. Input the geographical embedding codes corresponding to each segmented word in the text to be processed into a pre-trained machine learning model to obtain a geographical classification label corresponding to the text to be processed. The geographical classification label includes a geographical text label and a non-geographical text label.
[0151] The geographical classification label is used to represent the relevance between the text to be processed and the region. Among them, the geographical text label indicates that the text to be processed has a strong relevance to the region and is a geographical text. The non-geographical text label indicates that the text to be processed has a weak relevance to the region and is not a geographical text.
[0152] In some embodiments, the regional embedding codes corresponding to each word in the text to be processed are input into the pre-trained machine learning model. When the regional classification label corresponding to the text to be processed is a regional text label, the machine learning model can further output a regional fine classification label corresponding to the text to be processed. The regional fine classification label is used to represent the relationship between the text to be processed and a specific regional location. The regional fine classification label can include <Beijing>, <Hebei Province>, <Chaoyang District>, <Guangdong Province>, <Shenzhen City>, etc. For example, the regional classification label corresponding to the text to be processed "Zhang San and Li Si came to Huoying tonight, and will go to Guomao tomorrow" is <regional article>, and the regional fine classification label can be <Beijing>. Therefore, the regional embedding codes corresponding to each word in the text to be processed are input into the pre-trained machine learning model, and the output obtained is <regional article, Beijing>.
[0153] Thus, the corresponding regional classification label and regional fine classification label can be obtained according to the text to be processed, so that the regional classification label and regional fine classification label corresponding to the text to be processed can be used as article features or specific strategies in subsequent operations such as model recall, strategy recall, and local slot on the highlight recommendation side. For example, an article with the label <regional article, Beijing> can be exposed in the information stream of a Beijing registered user.
[0154] In a specific embodiment, the text to be processed can be vehicle information, such as vehicle news broadcast, vehicle article podcast, etc. According to the embodiment of the present application, named entity recognition is performed on each piece of vehicle information to obtain one or more named entities in the vehicle information. Then, the named entity is used to query a preset knowledge base to obtain a regional word to which the named entity belongs. The text to be processed is subjected to word segmentation processing to obtain a plurality of words included in the text to be processed. The regional embedding codes corresponding to each word are obtained according to the regional word to which the named entity corresponding to the word belongs. The regional embedding codes corresponding to each word in the text to be processed are input into the pre-trained machine learning model to obtain the regional classification label and the regional fine classification label corresponding to each piece of vehicle information. Thus, when the information intelligent recommendation function of the vehicle device is turned on, according to the above scheme, the geographical location information of the vehicle device can be obtained, the regional fine classification label corresponding to the geographical location information can be obtained, and the vehicle information corresponding to the regional fine classification label can be obtained, so that the vehicle owner can obtain vehicle information recommendation with high relevance to the local area, and the precise recommendation of vehicle information is realized through the embodiment of the present application, thereby improving the user experience.
[0155] Specifically, the geographical location information of the vehicle device can be the geographical location information of the location of the vehicle device, and the geographical location information of the vehicle device can also be set as the geographical location information of other regions other than the location of the vehicle device.
[0156] The pre-trained machine learning model can be a pre-trained BERT model, RoBERTa model, BERT-wwm model, etc.
[0157] Figure 10 Schematically shows the step flow before inputting the regional embedding codes corresponding to each word segment in the text to be processed into the pre-trained machine learning model to obtain the regional classification label corresponding to the text to be processed in the embodiment of the present application. As Figure 10 shown, based on the above embodiment, in some embodiments, before step S250 of inputting the regional embedding codes corresponding to each word segment in the text to be processed into the pre-trained machine learning model to obtain the regional classification label corresponding to the text to be processed, the following steps S1010 to step S1040 can be further included:
[0158] S1010. According to the word segment, query the preset second word list to obtain the feature embedding code corresponding to the word segment;
[0159] S1020. According to the position of the word segment in the corresponding sentence, query the preset third word list to obtain the position embedding code corresponding to the word segment;
[0160] S1030. According to the position of the sentence where the word segment is located in the text to be processed, query the preset fourth word list to obtain the sentence type embedding code corresponding to the word segment;
[0161] S1040. Input the feature embedding code, position embedding code, and sentence type embedding code corresponding to each word segment in the text to be processed into the pre-trained machine learning model.
[0162] The feature embedding code (token embedding) corresponding to the word segment is the code obtained by performing embedding coding on the feature (token) of the word segment. The position embedding code (position embedding) corresponding to the word segment is the code obtained by performing embedding coding on the position (position) of the word segment in the corresponding sentence. The sentence type embedding code (segment embedding) corresponding to the word segment is the code obtained by performing embedding coding on the position of the sentence where the word segment is located in the text to be processed.
[0163] For example, according to the word segment "Huo", query the preset second word list to obtain the feature embedding code E 霍 ; according to the position of the word segment "Huo" as the 10th word segment in the corresponding sentence, query the preset third word list to obtain the position embedding code of the word segment "Huo" as E 10。(It should be noted that when the sentence-initial identifier is added to the to-be-processed text "Zhang San and Li Si came to Huoying tonight, and will go to Guomao tomorrow", the position of the word "Huoying" in the corresponding sentence is the 11th word, and the position embedding code corresponding to the word "Huoying" is E 11 .)
[0164] Then, according to the position of the sentence in which the word "Huoying" is located in the to-be-processed text, the first sentence, the fourth preset word table is queried to obtain the sentence type embedding code E1 corresponding to the word. Then, the feature embedding code E 霍 , the position embedding code E 10 and the sentence type embedding code E1 corresponding to each word in the to-be-processed text are input into the pre-trained machine learning model.
[0165] In some embodiments, the to-be-processed text is an article, and the position of the sentence in which the word is located in the to-be-processed text can include a title position and a body position. When the position of the sentence in which the word is located in the to-be-processed text is the title position, the fourth preset word table can be queried to obtain the sentence type embedding code E 标题 ; when the position of the sentence in which the word is located in the to-be-processed text is the body position, the fourth preset word table can be queried to obtain the sentence type embedding code E 正文 . Thus, when the to-be-processed text is an article, the classification and coding of sentences in different regions of the article are realized, so that the geographical words to which the named entities corresponding to the words in the sentences in different regions of the article belong have different degrees of influence on the geographical classification label of the article, thereby improving the geographical recognition accuracy of the to-be-processed text.
[0166] Figure 11 The step flow of inputting the geographical embedding code corresponding to each word in the to-be-processed text into the pre-trained machine learning model to obtain the geographical classification label corresponding to the to-be-processed text in the embodiments of the present application is schematically shown. As Figure 11 shown in the above embodiments, in some embodiments, the step S250 of inputting the geographical embedding code corresponding to each word in the to-be-processed text into the pre-trained machine learning model to obtain the geographical classification label corresponding to the to-be-processed text can further include the following steps S1110-S1120:
[0167] S1110. Add the geographical embedding code corresponding to each word in the to-be-processed text to the feature embedding code, the position embedding code, and the sentence type embedding code to obtain a comprehensive embedding code;
[0168] S1120. Input the comprehensive embedding code corresponding to each word in the to-be-processed text into the pre-trained machine learning model to obtain the geographical classification label corresponding to the to-be-processed text.
[0169] Specifically, Figure 12 The process of adding the regional embedding encoding corresponding to each wordpiece in the to-be-processed text to the feature embedding encoding, the position embedding encoding, and the sentence type embedding encoding to obtain a comprehensive embedding encoding, and then inputting the comprehensive embedding encoding corresponding to each wordpiece in the to-be-processed text into the pre-trained machine learning model to obtain the regional classification label corresponding to the to-be-processed text is schematically shown. As shown in Figure 12 After adding the beginning-of-sentence flag [CLS] and the end-of-sentence flag [SEP] to the to-be-processed text "Zhang San and Li Si came to Huoying tonight, and will go to Guomao tomorrow.", the to-be-processed text is subjected to wordpiece processing, and each wordpiece includes a single character. The regional embedding encoding E N , the feature embedding encoding E CLS , the position embedding encoding E A , and the sentence type embedding encoding E CLS are added to obtain the comprehensive embedding encoding M N ; the regional embedding encoding E 了 , the feature embedding encoding E 10 , the position embedding encoding E A , and the sentence type embedding encoding E 了 are added to obtain the comprehensive embedding encoding M 北京 ; the regional embedding encoding E 霍 , the feature embedding encoding E 11 , the position embedding encoding E A , and the sentence type embedding encoding E 霍 are added to obtain the comprehensive embedding encoding M 北京 ; the regional embedding encoding E 营 , the feature embedding encoding E 12 , the position embedding encoding E A , and the sentence type embedding encoding E 营 are added to obtain the comprehensive embedding encoding M N ; the regional embedding encoding E SEP , the feature embedding encoding E 22 , the position embedding encoding E A , and the sentence type embedding encoding E SEP are added to obtain the comprehensive embedding encoding M CLS . Then, the comprehensive embedding encodings M 张 , M 三 , M 和 , M 李 , …, M 。 , and M SEPThe pre-trained machine learning model is inputted, and a regional classification label corresponding to the text to be processed is obtained. Moreover, when the regional classification label corresponding to the text to be processed is a regional text label, a regional sub-classification label corresponding to the text to be processed can be obtained.
[0170] Figure 13 The steps before the regional embedding codes corresponding to each word in the text to be processed are inputted into the pre-trained machine learning model to obtain the regional classification label corresponding to the text to be processed in the embodiments of the present application are schematically shown. As shown in Figure 13 Based on the above embodiments, in some embodiments, before the step S250 of inputting the regional embedding codes corresponding to each word in the text to be processed into the pre-trained machine learning model to obtain the regional classification label corresponding to the text to be processed, the following steps S1310-S1350 can be further included:
[0171] S1310. Perform named entity recognition on the training text to obtain one or more named entities in the training text;
[0172] S1320. Query a preset knowledge base according to the named entity to obtain a regional word to which the named entity belongs, and the preset knowledge base includes the dependency relationship between the named entity and the regional word;
[0173] S1330. Perform word segmentation processing on the training text to obtain a plurality of words included in the training text, and each word includes one or more characters;
[0174] S1340. Obtain the regional embedding code corresponding to each word according to the regional word to which the named entity corresponding to the word belongs;
[0175] S1350. Take the regional embedding codes corresponding to each word in the training text as the input of the machine learning model, take the regional classification label of the training text as the target output of the machine learning model, and train the machine learning model.
[0176] Thus, the training of the machine learning model is realized by using the training text. It can be understood that the processing process of the training text in steps S1310-S1340 is similar to the processing process of the text to be processed in steps 210-240. Therefore, the machine learning model trained according to the training text via steps S1310-S1350 can realize more accurate recognition and classification of the text to be processed through steps 210-250, and the accuracy of the model classification can be improved.
[0177] In summary, according to the regional word to which the named entity corresponding to each word segment belongs, the regional embedding code corresponding to each word segment is obtained, and the regional embedding code corresponding to each word segment in the to-be-processed text is input into the pre-trained machine learning model, so that the code of the to-be-processed text can have stronger regional properties, thereby the machine learning model strengthens the identification and judgment ability of regional information of fine-grained place names (commercial circles, scenic spots, streets, schools, etc.), can more accurately identify the regional information of the information flow article, and can significantly improve the revenue of the online recommendation model and the recommendation strategy.
[0178] It should be noted that although the steps of the method in the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired result. In addition or alternatively, some steps can be omitted, a plurality of steps can be combined into one step, and / or one step can be divided into a plurality of steps, etc.
[0179] The device embodiment of the present application is introduced below, which can be used to execute the text regional identification method in the above-mentioned embodiments of the present application. Figure 14 The structure block diagram of the text regional identification device provided by the embodiment of the present application is schematically shown. As shown in Figure 14 The text regional identification device 1400 can include:
[0180] The named entity recognition module 1410 is configured to perform named entity recognition on the to-be-processed text, and obtain one or more named entities in the to-be-processed text;
[0181] The regional word query module 1420 is configured to query a preset knowledge base according to the named entity, and obtain a regional word to which the named entity belongs, the preset knowledge base including the dependency relationship between the named entity and the regional word;
[0182] The word segmentation module 1430 is configured to perform word segmentation processing on the to-be-processed text, and obtain a plurality of word segments included in the to-be-processed text, the word segment including one or more characters;
[0183] The regional embedding code module 1440 is configured to obtain the regional embedding code corresponding to each word segment according to the regional word to which the named entity corresponding to the word segment belongs;
[0184] The regional classification module 1450 is configured to input the regional embedding code corresponding to each word segment in the to-be-processed text into a pre-trained machine learning model, and obtain a regional classification label corresponding to the to-be-processed text, the regional classification label including a regional text label and a non-regional text label.
[0185] In some embodiments of the present application, based on the above implementation, the geographical embedding encoding module comprises:
[0186] The geographical embedding encoding first obtaining unit is configured to, when the word has a corresponding named entity and the word corresponding named entity has a subordinate geographical word, query the preset first word table according to the word corresponding named entity subordinate geographical word to obtain the word corresponding geographical embedding encoding.
[0187] The geographical embedding encoding second obtaining unit is configured to, when the word does not have a corresponding named entity or the word corresponding named entity does not have a subordinate geographical word, take the preset encoding as the word corresponding geographical embedding encoding.
[0188] In some embodiments of the present application, based on the above implementation, the geographical embedding encoding first obtaining unit comprises:
[0189] The geographical embedding encoding first obtaining sub-unit is configured to, when the word corresponds to one named entity, query the first word table according to the word corresponding named entity subordinate geographical word to obtain the word corresponding geographical embedding encoding.
[0190] The geographical embedding encoding second obtaining sub-unit is configured to, when the word corresponds to multiple named entities, select one named entity from the multiple named entities as the word corresponding named entity, and query the first word table according to the word corresponding named entity subordinate geographical word to obtain the word corresponding geographical embedding encoding.
[0191] In some embodiments of the present application, based on the above implementation, the geographical embedding encoding second obtaining sub-unit comprises:
[0192] The correlation calculation sub-unit is configured to calculate the correlation of the word in the context position of the text to be processed with the multiple named entities corresponding to the word, and take the named entity with the highest correlation with the context position of the word as the named entity corresponding to the word; or
[0193] The frequency spectrum obtaining sub-unit is configured to obtain the appearance frequency of the multiple named entities corresponding to the word in the historical processing text respectively, and take the named entity with the highest appearance frequency in the historical processing text as the named entity corresponding to the word.
[0194] In some embodiments of the present application, based on the above implementation, the text geographical recognition device further comprises:
[0195] The preset geographical entity library obtaining unit is configured to obtain a preset geographical entity library, and the preset geographical entity library comprises multiple named entities with geographical attributes.
[0196] The named entity elimination unit is configured to query a preset regional entity library according to the named entity query, and eliminate the named entity not included in the preset regional entity library.
[0197] In some embodiments of the present application, based on the above implementation, the named entity recognition module comprises:
[0198] The preset regional entity library acquisition unit is configured to acquire a preset regional entity library, the preset regional entity library comprising a plurality of named entities with regional attributes.
[0199] The full word matching unit is configured to perform full word matching on the to-be-processed text according to the named entities in the preset regional entity library, and acquire one or more named entities in the to-be-processed text.
[0200] In some embodiments of the present application, based on the above implementation, the named entities included in the preset regional entity library are all included in the preset knowledge base.
[0201] In some embodiments of the present application, based on the above implementation, the text regional recognition device comprises:
[0202] The feature embedding code acquisition unit is configured to query a preset second word table according to the word segmentation, and acquire the feature embedding code corresponding to the word segmentation.
[0203] The position embedding code acquisition unit is configured to query a preset third word table according to the position of the word segmentation in the corresponding sentence, and acquire the position embedding code corresponding to the word segmentation.
[0204] The sentence type embedding code acquisition unit is configured to query a preset fourth word table according to the position of the sentence in which the word segmentation is located in the to-be-processed text, and acquire the sentence type embedding code corresponding to the word segmentation.
[0205] The code input unit is configured to input the feature embedding code, the position embedding code and the sentence type embedding code corresponding to each word segmentation in the to-be-processed text into the pre-trained machine learning model.
[0206] In some embodiments of the present application, based on the above implementation, the regional classification module comprises:
[0207] The code addition unit is configured to add the regional embedding code corresponding to each word segmentation in the to-be-processed text to the feature embedding code, the position embedding code and the sentence type embedding code, to obtain a comprehensive embedding code.
[0208] The comprehensive embedding code input unit is configured to input the comprehensive embedding code corresponding to each word segmentation in the to-be-processed text into the pre-trained machine learning model, to obtain the regional classification label corresponding to the to-be-processed text.
[0209] In some embodiments of the present application, based on the above implementation, the text region recognition apparatus comprises:
[0210] The training text named entity recognition unit is configured to perform named entity recognition on the training text to obtain one or more named entities in the training text;
[0211] The region word query unit is configured to query a preset knowledge base according to the named entity to obtain a region word to which the named entity belongs;
[0212] The word segmentation processing unit is configured to perform word segmentation processing on the training text to obtain a plurality of words included in the training text, the words comprising one or more characters;
[0213] The region embedding encoding unit is configured to obtain a region embedding encoding corresponding to each word according to a region word to which a named entity corresponding to the word belongs;
[0214] The region classification unit is configured to take the region embedding encoding corresponding to each word in the training text as an input of a machine learning model, take a region classification label marked for the training text as a target output of the machine learning model, and train the machine learning model.
[0215] In some embodiments of the present application, based on the above implementation, the preset knowledge base comprises a dependency relationship mapping pair of the named entity and the region word stored in the form of a dependency relationship mapping pair; and the region word query module comprises:
[0216] The dependency relationship mapping pair query unit is configured to query the dependency relationship mapping pair in the preset knowledge base according to the named entity to obtain a region word to which the named entity belongs.
[0217] In some embodiments of the present application, based on the above implementation, the preset knowledge base comprises one or more tree type storage structures with the named entity as a node; and the region word query module comprises:
[0218] The tree type storage structure query unit is configured to query the preset knowledge base according to the named entity to obtain a node corresponding to the named entity in the tree type storage structure;
[0219] The region word obtaining unit is configured to take a named entity corresponding to a preset level node to which a node corresponding to the named entity belongs as a region word to which the named entity belongs.
[0220] The specific details of the text region recognition apparatus provided in the embodiments of the present application have been described in detail in the corresponding method embodiments, and will not be described here.
[0221] Figure 15 A structural block diagram of an electronic device for implementing the embodiments of the present application is schematically shown.
[0222] It should be noted that Figure 15 The electronic device 1500 shown is merely one example. It should not be considered a limitation on the scope or functionality of embodiments of the present application but rather a description of one implementation. As shown, the electronic device 1500 includes a central processing unit 1501 (CPU), which can perform various suitable actions and processes according to programs stored in a read-only memory 1502 (ROM) or loaded into a random access memory 1503 (RAM) from a storage section 1508. Various programs and data required for the operation of the device are also stored in the random access memory 1503. The central processing unit 1501, the read-only memory 1502, and the random access memory 1503 are connected to each other through a bus 1504. An input / output interface 1505 (I / O interface) is also connected to the bus 1504.
[0223] As shown, the electronic device 1500 includes a central processing unit 1501 (CPU), which can perform various suitable actions and processes according to programs stored in a read-only memory 1502 (ROM) or loaded into a random access memory 1503 (RAM) from a storage section 1508. Various programs and data required for the operation of the device are also stored in the random access memory 1503. The central processing unit 1501, the read-only memory 1502, and the random access memory 1503 are connected to each other through a bus 1504. An input / output interface 1505 (I / O interface) is also connected to the bus 1504. Figure 15 The following components are connected to the input / output interface 1505: an input section 1506 including a keyboard, a mouse, etc.; an output section 1507 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1508 including a hard disk, etc.; and a communication section 1509 including a network interface card such as a local area network card, a modem, etc. The communication section 1509 performs communication processing via a network such as the Internet. A drive 1510 is also connected to the input / output interface 1505 as necessary. A removable media 1511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 1510 as necessary, so that a computer program read therefrom is installed into the storage section 1508 as necessary.
[0224] In particular, according to embodiments of the present application, the processes described in the various method flowcharts can be implemented as a computer software program. For example, embodiments of the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication section 1509, and / or installed from the removable media 1511. When the computer program is executed by the central processing unit 1501, various functions defined in the apparatus of the present application are performed.
[0225] In particular, according to embodiments of the present application, the processes described in the various method flowcharts can be implemented as a computer software program. For example, embodiments of the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication section 1509, and / or installed from the removable media 1511. When the computer program is executed by the central processing unit 1501, various functions defined in the apparatus of the present application are performed.
[0226] It should be noted that the computer-readable medium in the embodiments of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor device, device or apparatus, or any combination thereof. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution device, device or apparatus. In the present application, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution device, device or apparatus. The program code contained in the computer-readable medium can be transmitted by any suitable medium, including but not limited to wireless, wired, or the like, or any suitable combination thereof.
[0227] The flowcharts and block diagrams in the drawings illustrate the possible implementation architectures, functions and operations of the apparatus, method and computer program product according to various embodiments of the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, a program segment, or a part of code, which contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different order than that shown in the drawings. For example, two blocks that are shown in succession can actually be executed substantially in parallel, and sometimes they can be executed in reverse order, depending on the involved functions. It should also be noted that each block in the block diagrams or flowcharts, and the combination of blocks in the block diagrams or flowcharts, can be implemented by a dedicated hardware-based device that performs the specified functions or operations, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0228] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, such a division is not mandatory. Indeed, according to an embodiment of the application, the features and functionalities of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functionalities of one module or unit described above can be further divided into embodied by a plurality of modules or units.
[0229] Through the above description of the embodiments, those skilled in the art can easily understand that the example embodiments described herein can be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solutions according to the embodiments of the present application can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (which can be a CD-ROM, a U disk, a mobile hard disk, etc.) or a network, and includes a number of instructions to make a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) execute the method according to the embodiments of the present application.
[0230] Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. It is intended that the present application cover any and all variations of the application that come within the scope of the general inventive concepts described herein and including all such variations as fall within the scope of the following claims.
[0231] The relevant data collection and processing scheme in the present application needs to strictly follow the requirements of relevant national laws and regulations, obtain the informed consent or separate consent of the personal information subject (or have the legal basis provided by relevant national laws and regulations), and carry out subsequent data use and processing behavior within the scope of authorization of laws and regulations and personal information subject.
[0232] It should be understood that the present application is not limited to the precise construction that has been described above and illustrated in the accompanying drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the application should only be limited by the appended claims.
Claims
1. A method for text geo-identification, characterized in that, The method comprises the following steps: performing named entity recognition on a to-be-processed text to obtain one or more named entities in the to-be-processed text, the named entities being fine-grained named entities with regional properties; querying a preset knowledge base according to the named entities to obtain regional words to which the named entities belong, the preset knowledge base comprising a relationship between the named entities and the regional words; performing word segmentation on the to-be-processed text to obtain a plurality of segmented words included in the to-be-processed text, the segmented words comprising one or more characters; obtaining regional embedding codes corresponding to each of the segmented words according to regional words to which named entities corresponding to the segmented words belong; querying a preset second word table according to the segmented words to obtain feature embedding codes corresponding to the segmented words; querying a preset third word table according to positions of the segmented words in corresponding sentences to obtain position embedding codes corresponding to the segmented words; querying a preset fourth word table according to positions of sentences in which the segmented words are located in the to-be-processed text to obtain sentence type embedding codes corresponding to the segmented words; adding the regional embedding codes corresponding to each of the segmented words in the to-be-processed text to the feature embedding codes, the position embedding codes and the sentence type embedding codes to obtain comprehensive embedding codes; inputting the comprehensive embedding codes corresponding to each of the segmented words in the to-be-processed text into a pre-trained machine learning model to obtain regional classification labels corresponding to the to-be-processed text, the regional classification labels comprising regional text labels and non-regional text labels.
2. The method of claim 1, wherein, The method comprises the following steps: when the segmented word has a corresponding named entity and the corresponding named entity of the segmented word has a regional word to which it belongs, querying a preset first word table according to the regional word to which the corresponding named entity of the segmented word belongs to obtain regional embedding codes corresponding to the segmented word; when the segmented word does not have a corresponding named entity or the corresponding named entity of the segmented word does not have a regional word to which it belongs, using a preset code as the regional embedding codes corresponding to the segmented word.
3. The method of claim 2, wherein, The method comprises the following steps: when the segmented word has a corresponding named entity and the corresponding named entity of the segmented word has a regional word to which it belongs, querying a preset first word table according to the regional word to which the corresponding named entity of the segmented word belongs to obtain regional embedding codes corresponding to the segmented word; when the segmented word corresponds to one named entity, querying the first word table according to the regional word to which the corresponding named entity of the segmented word belongs to obtain the regional embedding codes corresponding to the segmented word; 4. The method of claim 3, wherein, when the segmented word corresponds to a plurality of named entities, selecting one named entity from the plurality of named entities as the corresponding named entity of the segmented word and querying the first word table according to the regional word to which the corresponding named entity of the segmented word belongs to obtain the regional embedding codes corresponding to the segmented word. The method comprises the following steps: corresponding to the context position of the wordpiece in the to-be-processed text as the named entity corresponding to the wordpiece; or respectively acquiring occurrence frequencies of the multiple named entities corresponding to the wordpiece in historical processed texts, and taking the named entity with the highest occurrence frequency in the historical processed texts as the named entity corresponding to the wordpiece.
5. The method of claim 1, wherein, Before the querying the preset knowledge base according to the named entity, the method further comprises: acquiring a preset regional entity base, the preset regional entity base comprising multiple named entities with regional attributes; querying the preset regional entity base according to the named entity, and eliminating the named entity not included in the preset regional entity base.
6. The method of claim 1, wherein, The named entity recognition on the to-be-processed text to acquire one or more named entities in the to-be-processed text comprises: acquiring a preset regional entity base, the preset regional entity base comprising multiple named entities with regional attributes; performing full-word matching on the to-be-processed text according to the named entities in the preset regional entity base to acquire one or more named entities in the to-be-processed text.
7. The method of claim 1, wherein, Before the inputting the regional embedding codes corresponding to each wordpiece in the to-be-processed text into the pre-trained machine learning model to obtain the regional classification label corresponding to the to-be-processed text, the method further comprises: performing named entity recognition on the training text to acquire one or more named entities in the training text; querying the preset knowledge base according to the named entity to acquire the regional word to which the named entity belongs; performing wordpiece processing on the training text to obtain multiple wordpieces included in the training text, the wordpieces comprising one or more characters; acquiring regional embedding codes corresponding to each wordpiece according to the regional word to which the named entity corresponding to the wordpiece belongs; training the machine learning model by taking the regional embedding codes corresponding to each wordpiece in the training text as the input of the machine learning model and taking the regional classification label of the training text as the target output of the machine learning model.
8. The method of claim 1, wherein, The preset knowledge base comprises the subordination relationship between the named entities and the regional words in the form of subordination relationship mapping pairs; The querying the preset knowledge base according to the named entity to acquire the regional word to which the named entity belongs comprises: querying the subordination relationship mapping pairs in the preset knowledge base according to the named entity to acquire the regional word to which the named entity belongs.
9. The method of claim 1, wherein, The preset knowledge base comprises one or more tree-type storage structures with named entities as nodes; the querying the preset knowledge base according to the named entity to acquire the regional word to which the named entity belongs comprises: querying the preset knowledge base according to the named entity to obtain the node corresponding to the named entity in the tree-type storage structure; taking the named entity corresponding to the preset hierarchical node to which the node corresponding to the named entity belongs as the regional word to which the named entity belongs.
10. A text geo-identification apparatus, characterized by, The method comprises: The named entity recognition module is configured to perform named entity recognition on the to-be-processed text, and obtain one or more named entities in the to-be-processed text, the named entity being a fine-grained named entity with regional properties; The regional word query module is configured to query a preset knowledge base according to the named entity, and obtain a regional word to which the named entity belongs, the preset knowledge base including a dependency relationship between the named entity and the regional word; The word segmentation module is configured to perform word segmentation processing on the to-be-processed text, and obtain a plurality of segmented words included in the to-be-processed text, the segmented word including one or more characters; The regional embedding encoding module is configured to obtain regional embedding encodings corresponding to each segmented word according to a regional word to which a named entity corresponding to the segmented word belongs; The feature embedding encoding obtaining unit is configured to query a preset second word table according to the segmented word, and obtain a feature embedding encoding corresponding to the segmented word; The position embedding encoding obtaining unit is configured to query a preset third word table according to a position of the segmented word in a corresponding sentence, and obtain a position embedding encoding corresponding to the segmented word; The sentence type embedding encoding obtaining unit is configured to query a preset fourth word table according to a position of a sentence in which the segmented word is located in the to-be-processed text, and obtain a sentence type embedding encoding corresponding to the segmented word; The regional classification module is configured to input the regional embedding encodings corresponding to each segmented word in the to-be-processed text into a pre-trained machine learning model, and obtain a regional classification label corresponding to the to-be-processed text, the regional classification label including a regional text label and a non-regional text label. The regional classification module includes: an encoding addition unit configured to add the regional embedding encodings corresponding to each segmented word in the to-be-processed text with feature embedding encodings, position embedding encodings, and sentence type embedding encodings to obtain comprehensive embedding encodings; and a comprehensive embedding encoding input unit configured to input the comprehensive embedding encodings corresponding to each segmented word in the to-be-processed text into a pre-trained machine learning model, and obtain a regional classification label corresponding to the to-be-processed text.
11. A computer readable medium having stored thereon a computer program, characterized in that, The computer program is executed by a processor to implement the text region identification method of any one of claims 1-9.
12. An electronic device, comprising: It includes: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the text region identification method of any one of claims 1-9 by executing the executable instructions.
13. A computer program product, characterised in that, The computer program product includes computer instructions stored in a computer readable storage medium, a processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the text region identification method of any one of claims 1-9.
Citation Information
Patent Citations
Geographical name recognition method and device, electronic equipment and readable storage medium
CN111144121A
Text classification method and device, storage medium and equipment
CN111444709A
Method and device for recognizing regional attributes of text, server and storage medium
CN111611801A