Natural language spatial relationship positioning method and device, equipment, medium and product
The ALBERT-BiLSTM-CRF model recognizes the place name and spatial relationship in the natural language spatial relationship question, and uses the natural language spatial relationship expression model for positioning, which solves the problem that the existing technology is difficult to understand the natural language spatial relationship, and realizes the correctness of the problem. Accurate positioning of natural language spatial relationship questions.
Patent Information
- Application Number
- CN202411509130.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-01-14
AI Technical Summary
The existing positioning navigation methods are difficult to understand the spatial relationships in natural language, resulting in the inability to provide effective search and query services and cannot meet the extensive demands of geographic information systems for positioning services.
The ALBERT-BiLSTM-CRF model is used to identify the place names and spatial relationships in natural language spatial relationship questions, and input the recognition results into the trained natural language spatial relationship expression model, using reference land objects, spatial relationships and natural language space. Relational combination mode for positioning.
It realizes in-depth analysis and accurate matching of spatial relationship questions described by multiple natural languages, significantly improves positioning accuracy, and can effectively understand spatial relationships in natural language and performs precise positioning.
Smart Images

Figure CN119312790A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of geographic information technology, and in particular to a method, device, equipment, medium and product for locating natural language spatial relations. Background Art
[0002] With the rapid development of Internet technology, it has become a common phenomenon to use spatial relationships in natural language to express location information. Natural language spatial relationships are often used as an important attribute when describing the location of place names. At present, place name positioning mainly relies on the address text entered by the user, and the address nouns are extracted for retrieval. However, when the user cannot clearly give a specific name or address and instead uses spatial relationships to describe it, the existing positioning and navigation methods often find it difficult to provide effective search query services. Therefore, how to make computers understand spatial relationships in natural language and perform precise positioning based on this has become a key issue that needs to be solved urgently.
[0003] At present, the research on natural language spatial relations mainly focuses on two directions: one is spatial relationship query based on natural language, which is committed to extracting geographic entities and spatial relationships from natural language and converting them into formal language recognizable by computers; the other is spatial quantitative expression based on text, which focuses on quantitative calculation of spatial relationships in natural language sentences and determines the geographical location described by spatial relationship semantics through structured modeling methods. However, although the research in these two directions has made some progress, the recognition and understanding of spatial relationships in natural language and the positioning research based on this are still relatively scarce. This results in the inability of existing methods to meet the widespread demand for positioning services in geographic information systems. Summary of the invention
[0004] The purpose of this application is to provide a natural language spatial relationship positioning method, device, equipment, medium and product, which can deeply analyze and accurately match spatial relationship questions described in various natural languages, thereby achieving significant results in improving positioning accuracy.
[0005] To achieve the above objectives, this application provides the following solutions: In a first aspect, the present application provides a method for locating a natural language spatial relationship, the method comprising: Obtain natural language spatial relation questions.
[0006] The ALBERT-BiLSTM-CRF model is used to identify place names and spatial relationships in the natural language spatial relationship questions.
[0007] The identified place names and spatial relationships are input into a trained natural language spatial relationship expression model, and the position of the question in the natural language spatial relationship question is located according to the spatial algorithm corresponding to the place names and spatial relationships; the natural language spatial relationship expression model is composed of reference features, spatial relationships and natural language spatial relationship combination patterns.
[0008] In a second aspect, the present application provides a natural language spatial relationship positioning device, the positioning device comprising: The question acquisition module is used to acquire natural language spatial relationship questions.
[0009] The recognition module is used to recognize the place names and spatial relationships in the natural language spatial relationship questions by using the ALBERT-BiLSTM-CRF model.
[0010] A positioning module is used to input the identified place names and spatial relationships into a trained natural language spatial relationship expression model, and locate the position of the question in the natural language spatial relationship question according to the spatial algorithm corresponding to the place names and spatial relationships; the natural language spatial relationship expression model is composed of reference features, spatial relationships and natural language spatial relationship combination patterns.
[0011] In a third aspect, the present application provides a computer device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement a method for locating a natural language spatial relationship as described above.
[0012] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-mentioned methods for locating natural language spatial relationships.
[0013] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements any one of the above-mentioned methods for locating natural language spatial relationships.
[0014] According to the specific embodiments provided in this application, this application discloses the following technical effects: The present application provides a method, device, equipment, medium and product for locating natural language spatial relations, the method comprising: first, capturing natural language spatial relation questions; then, using the ALBERT-BiLSTM-CRF model to accurately identify the place names and the implied spatial relations in the sentence; then, importing the recognition results into a pre-trained natural language spatial relation representation model, and accurately calibrating the geographical location inquired in the query sentence according to the spatial logic algorithm corresponding to the place names and spatial relations; this natural language spatial relation representation model is constructed by referring to geographic entities, spatial relations and natural language spatial relation combination paradigms. The present application aims to achieve in-depth understanding and accurate positioning of a wide range of natural language spatial relation questions. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0016] Figure 1 This is a diagram of the application environment of a natural language spatial relationship positioning method in one embodiment of the present application.
[0017] Figure 2 A flowchart of a method for locating a natural language spatial relationship is provided in accordance with an embodiment of the present application.
[0018] Figure 3 A natural language spatial relationship recognition and positioning flow chart provided for one embodiment of the present application.
[0019] Figure 4 A schematic diagram of functional modules of a natural language spatial relationship positioning device provided in one embodiment of the present application.
[0020] Figure 5 A schematic diagram of the structure of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0021] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0022] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0023] The method for locating the natural language spatial relationship provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be set up separately, integrated on the server 104, or placed on the cloud or other servers. The terminal 102 can send the natural language spatial relationship question to be processed to the server 104. After the server 104 receives the natural language spatial relationship question to be processed, for the natural language spatial relationship question to be processed, the server 104 uses the ALBERT-BiLSTM-CRF model to identify the place names and spatial relationships in the natural language spatial relationship question; the identified place names and spatial relationships are input into the trained natural language spatial relationship expression model, and the position of the question in the natural language spatial relationship question is located according to the spatial algorithm corresponding to the place names and spatial relationships. The server 104 can feedback the position of the question in the obtained natural language spatial relationship question to the terminal 102. In addition, in some embodiments, the method for locating natural language spatial relationships can also be implemented independently by the server 104 or the terminal 102. For example, the terminal 102 can directly perform question recognition on the natural language spatial relationship question to be processed, or the server 104 can obtain the natural language spatial relationship question to be processed from the data storage system and perform question recognition on the natural language spatial relationship question to be processed.
[0024] The terminal 102 may be, but is not limited to, various desktop computers, laptop computers, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart vehicle-mounted devices, etc. The portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers, or may be a cloud server.
[0025] In an exemplary embodiment, Figure 2 As shown, a method for locating a natural language spatial relationship is provided. The method is executed by a computer device, and can be executed by a computer device such as a terminal or a server alone, or by a terminal and a server together. In the embodiment of the present application, the method is applied to Figure 1 The server 104 in the example is used as an example to illustrate, including the following steps 201 to 203. Among them: Step 201: Obtain a natural language spatial relation question.
[0026] Step 202: Use the ALBERT-BiLSTM-CRF model to identify the place names and spatial relationships in the natural language spatial relationship question.
[0027] Step 203, input the identified place names and spatial relationships into a trained natural language spatial relationship expression model, and locate the position of the question in the natural language spatial relationship question according to the spatial algorithm corresponding to the place names and spatial relationships; the natural language spatial relationship expression model is composed of reference features, spatial relationships and natural language spatial relationship combination patterns.
[0028] When executing step 201, the specific steps may be as follows: Acquiring natural language spatial relationship questions refers to extracting questions describing spatial relationships from natural language texts. These questions usually involve spatial concepts such as location, direction, and distance, such as "In which direction of the school is the library?" or "How far is the restaurant from the dormitory?".
[0029] Before executing step 202, the method further includes: Establish a natural language spatial relationship expression model, which can be as follows: In the study of natural language spatial relations, it is necessary to understand the spatial relations and spatial semantics in natural language, and analyze several common spatial syntaxes according to the spatial relations that appear. To this end, this embodiment proposes a natural language spatial relationship expression model. The natural language spatial relationship expression model can be expressed in the form of a tuple, which contains three key elements: reference features and spatial relationship combination patterns. As shown in formula (1), NLSRM is a natural language spatial relationship expression model, RL, SR, and C are reference features, spatial relations, and natural language spatial relationship combination patterns, respectively.
[0030] .
[0031] The reference features are as follows: The geographic entities contained in natural language spatial relationship questions are mainly reference features for expressing the locations of spatial relationships in the city. The standard GB / T 13923-2022 divides basic geographic information elements into nine categories: positioning basis, water system, settlements and facilities, transportation, pipelines, boundaries and political regions, landforms, vegetation and soil, and place names. When looking for the location of the target feature in the city, the positioning basis, water system, pipelines, boundaries and political regions, landforms, vegetation and soil are not considered as reference entities. Only the two major geographic entity elements of settlements and facilities and place names are considered. The reference features analyzed in the above text retrieve the corresponding coordinates in the place name database and are brought into the solution of the spatial combination model as spatial operators.
[0032] The spatial relationships are as follows: Egenhofer established the famous intersection model, including the 4-intersection model and the 9-intersection model. According to the model, topological relationships can be divided into eight forms: intersection, adjacency, inclusion, inclusion, separation, coverage, coverage, and equality. In real life, geographic entities of the same level often occupy different geographical locations, such as "A City West Station" and "A City South Station". In the description of spatial relationships, "coverage" is usually not used to describe this kind of same-level face geographic entity relationship. In natural language spatial relationship queries, usually only four topological relationships are involved: adjacency, separation, inclusion, and intersection.
[0033] Directional relationships in descriptions are usually described using directional predicates in an absolute reference frame. However, people may choose different descriptions for the same directional relationship, such as due east, slightly east, and middle east. Due to the diversity of natural language descriptions, the same directional relationship also has many different semantic variants. Therefore, based on the five basic spatial locative words of east, south, west, north, and center, eight commonly used directional relationships can be summarized by combining them in pairs: east, south, west, north, southeast, northeast, southwest, and northwest.
[0034] Distance relationships are expressed quantitatively, which describes spatial distances by using a "numeral + length unit". Common length units include centimeters, decimeters, meters, kilometers, miles, and kilometers. In spatial descriptions, meters, kilometers, and kilometers are commonly used units.
[0035] Table 1 Spatial relationship classification
[0036] In order to make the spatial direction relationship in the description of spatial relationship in natural language conform to spatial cognition, it is necessary to convert the qualitative description into quantitative expression. The eight-direction cone model can be used to quantitatively express the qualitative description of the spatial direction relationship in natural language.
[0037] Specifically, the direction intervals corresponding to the main direction relations are: (1) DIR(A,B)=N(North)∈[0,π / 8] ∪[15 / π,2π]; (2) DIR(A,B)=NE(Northeast)∈[π / 8,3π / 8]; (3)DIR(A,B)=E(East)∈[3π / 8,5π / 8]; (4)DIR(A,B)=SE(Southeast)∈[5π / 8,7π / 8]; (5)DIR(A,B)= S(South)∈[7π / 8,9π / 8]; (6) DIR(A,B)=SW(Southwest)∈[9π / 8,11π / 8]; (7) DIR(A,B)=W(West)∈[11π / 8,13π / 8]; (8) DIR(A,B)=NW(Northwest)∈[13π / 8,15π / 8].
[0038] It can be seen from the membership of the spatial direction that the membership is maximum when the described direction angle is the middle value of each interval. In order to reduce the uncertainty of the spatial direction description in natural language, this embodiment stipulates that the middle value of each direction interval is the specific direction of the spatial quantitative expression.
[0039] That is (1) DIR (A, B) = N (north) = 0; (2) DIR (A, B) = NE (northeast) = 2π / 8; (3) DIR (A, B) = E (east) = 4π / 8; (4) DIR (A, B) = SE (southeast) = 6π / 8; ( 5) DIR (A, B) = S (south) = π; (6) DIR (A, B) = SW (southwest) = 10π / 8; (7) DIR (A, B) = W (west) = 12π / 8; (8) DIR (A, B) = NW (northwest) = 14π / 8.
[0040] Among them, the natural language spatial relationship combination mode is as follows: 1) Natural language expresses spatiotemporal constraints: In the study of spatial relations, topological relations and directional relations are two basic spatial relations, which describe the mutual relations between spatial objects from different perspectives. Topological relations mainly focus on boundary relations such as contact and inclusion between spatial objects, while directional relations focus on the relative position and direction between spatial objects. These two relations are not completely independent, and there are certain connections and mutual constraints between them.
[0041] (1) Constraints of topological relationships on directional relationships: The topological relationship and the directional relationship affect each other. The topological relationship can constrain the directional relationship. In this embodiment, the directional relationship in the combination matrix is deduced from the topological relationship between the spatial objects, and then the possible directional relationship is determined, and the following two theorems are obtained: ① When the topological relationship is separate and adjacent, there is a directional relationship between the spatial objects.
[0042] ②When the topological relationship is contained, the directional relationship refers to all directional relationships of the reference object.
[0043] (2) Constraints of directional relationships on topological relationships: In spatial relationships, directional relationships also constrain topological relationships. The topological relationships between spatial objects can be determined based on directional relationships, and then the topological relationships between spatial objects can be determined based on these relationships. The following two theorems are obtained: ① For the case where the direction combination does not include the middle of the direction, the topological relationship between the space targets A and B is separated or adjacent.
[0044] ② For the case where the direction combination is equal to the middle of the direction slice, the topological relationship between the space objects A and B may be inclusion.
[0045] (3) Distance relationship constraints on topological relationships: In spatial relations, distance relations also constrain topological relations. Based on the analysis of natural language questions, the following theorem is obtained.
[0046] ① For spatial relationships with quantitative distance relationships, the topological relationship between spatial targets A and B is separation and inclusion.
[0047] The above five theorems express the mutual constraints between spatial relationships. When designing spatial relationship combination patterns, unreasonable combination descriptions can be eliminated based on the above theorems, and possible spatial orientation relationship combination descriptions can be inferred.
[0048] 2) Construction of natural language spatial relationship combination model: According to the classification of spatial relationships, this embodiment proposes three single spatial relationship question patterns: 1. Natural language questions that only contain topological relationships; 2. Natural language questions that only contain directional relationships; 3. Natural language questions that only contain distance relationships. Analysis of natural language spatial relationship questions in real life found that when a single spatial relationship describes a location, the ambiguity is large and the location description has great uncertainty. Usually, multiple spatial relationships are used for combined description. According to the mutual constraints of the above-mentioned spatial relationship combination descriptions, and considering the rationality of various combinations, this embodiment summarizes four composite spatial relationship combination patterns.
[0049] Specifically, they are divided according to the topological relationship, namely: Under the condition of topological disjunction: ① reference feature + direction relationship + distance relationship. Considering that the disjunction relationship is not explicitly expressed in natural language description, there is usually a distance relationship between the two, and the topological relationship between the two is assumed to be disjunction.
[0050] Under the condition of topological adjacent relationship: ② reference object + direction relationship; under the condition of topological inclusion: ③ reference object + direction relationship. The intersection is composed of the intersection of two roads, so the intersection of two line segments has practical significance in reality.
[0051] Under the condition of topological relationship intersection: ④ Road 1 + intersection + road 2. This embodiment constructs a model for these four spatial relationship combinations, which are defined as follows: Under the condition of topological separation: 1) Reference features + distance relationship + direction relationship (e.g. the Surveying and Mapping Building in City A is 200 meters east).
[0052] Query(RO,DIS,DIR)→convert(point(X,Y),Length,Azimuth).
[0053] Under the condition of topological proximity: 2) Reference features + direction relationship (such as the Surveying and Mapping Building of City A to the north).
[0054] Query(RO,adjacent,DIR)→convert(point(X,Y),Length(80),Azimuth).
[0055] Under the condition that the topological relationship contains: 3) Reference features + direction relationship (such as the western district of Geosciences University in City A).
[0056] Query(RO,contain,DIR)→convert(point(X,Y),Length(200),Azimuth).
[0057] Under the condition of topological intersection: 4) Road 1 Road 2.
[0058] Query(segment1,intersect,segment2)→convert(intersection(segment(a),segment(b))).
[0059] There are two topological relationships, adjacent and contained. If there is no clear indication of the distance relationship between the reference feature and the target object, the distance of the two topological relationships is quantitatively expressed. According to regulations, when multi-story buildings are arranged in parallel, the distance between them shall not be less than 1.0 times the height of the higher building; when high-rise buildings are arranged in parallel, the distance between their buildings shall not be less than 0.4 times the height of the higher building, and shall not be less than 20 meters. In summary, this embodiment sets the distance between the reference feature and the target object under the adjacent relationship to 80 meters. The containment relationship mostly appears in schools, communities, parks and other features with large areas in the description of natural language spatial relationships. This embodiment quantifies the distance between the center point of the reference feature and the target object as 200 meters.
[0060] In some embodiments, when executing step 202, the specific steps may be as follows: The ALBERT input representation layer includes a word embedding layer and a Transformer encoding layer; the word embedding layer is used to convert each character in the vocabulary into a word vector, and combine the text vector and the position vector to form a comprehensive feature vector; the Transformer encoding layer is used to determine the word vector representation of the place name in the natural language spatial relationship question based on the comprehensive feature vector.
[0061] The BiLstm encoding layer is composed of a forward LSTM and a backward LSTM, and is used to learn the semantic information of spatial relationship vocabulary and reference feature vocabulary.
[0062] The CRF output layer is used to calculate the probability formula based on core(x,y) = Predict the label sequence; For prediction The score of the i-th character of the label; yes Tags transferred to The score of the label.
[0063] To understand the spatial relationship in natural language, this embodiment needs to identify and locate the spatial relationship in natural language. First, the spatial relationship elements are identified using the natural language spatial relationship recognition model, the identified reference features are matched with the place name database, and the corresponding coordinates are queried. Secondly, the spatial relationship is matched with the combination pattern in the natural language spatial relationship expression model constructed in the previous section, and finally the reference feature coordinates and the quantitative spatial relationship are brought into the positioning algorithm corresponding to the pattern to locate the coordinates of the target feature.
[0064] The current positioning of natural language spatial relationships does not take into account the understanding of spatial relationships in natural language. Based on this, this embodiment establishes a spatial relationship recognition model to recognize spatial relationship elements in natural language. The elements to be recognized are: reference objects and spatial relationships. Spatial relationships are divided into distance relationships, directional relationships, and topological relationships according to recognition requirements.
[0065] This embodiment uses the ALBERT-BiLSTM-CRF method to identify spatial relationship vocabulary and geographic entities in natural language spatial relationship questions.
[0066] First, ALBERT is used to obtain the word vector representation of the address.
[0067] Secondly, the feature vector is input into the BiLSTM layer for feature calculation, features in the context are extracted, and the semantic information of spatial relationship vocabulary and geographic vocabulary is learned.
[0068] Finally, CRF is used to construct the constraint relationship between labels, consider the transfer characteristics between labels, obtain the dependency relationship between adjacent labels and output the corresponding labels.
[0069] Specifically, the ALBERT-BiLSTM-CRF model consists of an ALBERT input representation layer, a BiLSTM encoding layer and a CRF output layer.
[0070] The ALBERT layer can be divided into two parts: one part is the word embedding layer, which is The other part is the encoding layer of Transformer, namely Trm in the figure. The word embedding layer first converts each character into a word vector by querying the vocabulary, that is, the text sequence is represented as y={y1,y2,…,y n In addition, there are text vectors and position vectors. The text vectors are used to distinguish different sentences of the input, represented by 0 and 1 respectively. The position vector represents the temporal nature of the input sequence. Then the three feature vectors are added to form Finally, the feature vector is obtained through multi-layer Transformer (Trm) training. , It combines character features, position features and text features.
[0071] LSTM (Long Short-term Memory) network is a special type of recurrent neural network (RNN) that controls the flow of information through forget gate, input gate and output gate, so that it can learn long-term dependencies. The specific formula is as follows: .
[0072] .
[0073] .
[0074] .
[0075] .
[0076] .
[0077] In the formula, ft Forget Gate , it For input gate ,ot Output gate , is the memory cell state at the candidate time step , wxya , W , Wxya , Whc is the weight matrix , Wxc , WxO , Whi , Who is the weight matrix , tanh is the hyperbolic tangent function, is the encoded word vector, is the hidden state at the previous time step, is the memory cell state at the previous time step, b f 、b i 、b c 、b o is the bias vector, c t is the memory cell state at the current time step, h t is the hidden state of the current time step, and is a sigmoid function used to calculate the output of the gate. BiLSTM consists of two LSTMs, forward and backward, which can learn the context information of the current corpus to obtain more comprehensive semantic features. Hidden state h t It consists of two parts: Always positive hidden state and the reverse hidden state .
[0078] .
[0079] Among them, CRF is a statistical-based sequence labeling algorithm that regards sequence labeling as a k-classification problem, taking into account contextual information and the sequence relationship of adjacent labels, obtaining global information and then obtaining the globally optimal labeling sequence.
[0080] By sequence The CRF layer uses past and future labels to predict the most likely label sequence. , its probability formula can be expressed as: core(x,y) = .
[0081] in For prediction The score of the i-th character of the label; yes Tags transferred to The score of the label.
[0082] In some embodiments, before executing step 203, the method further includes: The natural language spatial relationship recognition model training can be specifically as follows: A data set containing natural language spatial relationship questions is collected to obtain a training data set for a natural language spatial relationship expression model.
[0083] Preprocess the data in the dataset; the preprocessing includes word segmentation tags and semantic annotation.
[0084] Based on word segmentation and semantic annotation, the types of labels in natural language spatial relationship questions are identified, and the entities in the dataset are divided into reference features, topological relationships, directional relationships, and distance relationships according to the labels.
[0085] The natural language spatial relationship question in the training data set is used as input, and the word segmentation and semantic annotation of the natural language spatial relationship question is used as labels to train the natural language spatial relationship expression model to obtain a trained natural language spatial relationship expression model.
[0086] Specifically, this embodiment combines the hierarchical address model and the spatial relationship model, uses word segmentation tags and semantic annotations, identifies the type of tags in natural language spatial relationship questions, and divides the entities in the training data into four types according to the tags: reference features, topological relationships, directional relationships, and distance relationships (Table 2). Its semantic annotation system is shown in the table. Spatial relationship vocabulary is the focus of this embodiment. By summarizing the common spatial relationship vocabulary in the address, and performing corresponding replacement operations on the spatial relationship vocabulary existing in the Chinese address on the basis of annotation, the data is enhanced to improve the quantity and quality of the data.
[0087] Table 2 Entity type categories
[0088] In some embodiments, when executing step 203, the specific steps may be as follows: Among them, the natural language spatial relationship expression pattern matching can be specifically as follows: In the model of spatial relationship recognition, spatial relationship vocabulary is finally divided into three categories: directional relationship, topological relationship, and distance relationship according to label classification, and the recognition results are brought into the calculation of the corresponding spatial combination pattern. If the classification labels in the recognition data set are designed according to small categories, too many labels may make it difficult for the model to learn the distinguishing features of each label during the training process, resulting in blurred boundaries between labels, making it difficult for the model to accurately distinguish different entity types. To this end, this embodiment counts directional relationship vocabulary and topological relationship vocabulary, and classifies spatial relationship vocabulary, as shown in the table. Construct a vocabulary for topological relationship vocabulary and directional relationship vocabulary respectively, and match the recognized entities with the words in the vocabulary using text similarity. Use text space vector representation to match the entities to be matched and words in the vocabulary Represented as two m-dimensional vectors, namely , , k∈1,...,m. The cosine of the angle between the two can be calculated using the following formula. The closer the cosine value is to 1, the more similar the two words are.
[0089] .
[0090] After using text similarity to classify the three types of spatial relationships, spatial relationship vocabulary is used to match the spatial relationship combination pattern in the spatial relationship expression model. If the spatial relationship in the question is only a distance relationship, it can be determined as mode one; if there is a distance relationship and a direction relationship in the question, it is mode two. In questions with a direction relationship but no distance relationship, it is necessary to perform pattern matching based on the topological relationship. The adjacent topological vocabulary is determined as mode three, and the containing topological vocabulary is determined as mode four; mode five is to locate road intersections. The intersection relationship in urban features is usually between roads, so after identifying the intersection relationship, it is directly determined as mode five.
[0091] Then, the natural language spatial relationship expression space positioning is performed, which can be specifically as follows: like Figure 3As shown, spatial positioning is to analyze the function of the corresponding combination pattern in the spatial relationship expression model to obtain the coordinates of the target position. The identified reference features are searched in the place name database, the coordinates of the features are queried, and the coordinates are brought into the previously matched spatial combination pattern to perform combined spatial calculations. The following is the spatial positioning algorithm of the combination pattern of this embodiment: 1) Mode 1 positioning: reference feature (RO) + topological relationship (separation) + direction relationship + distance relationship.
[0092] query(RO, DIS, DIR) → positioning(point(x, y), multiply(DIR, DIS)).
[0093] For the target positioning algorithm, it can be formalized using the pseudo code in Table 3, where (latA, longA) is the latitude and longitude coordinates of the reference point. , are distance and azimuth respectively.
[0094] Table 3 Positioning algorithm pseudo code
[0095] In modes 2 and 3, the distance between the reference object and the target object in the adjacent topological relationship given in this embodiment is 30 meters, and the distance including the topological relationship is 100 meters. Calculation is performed according to the formula of mode 1 to locate the two modes.
[0096] 2) Mode 2 positioning: reference features (RO) + topological relationship (adjacent) + directional relationship.
[0097] query(RO,adjacent,DIR)→positioning(point(x,y),multiply(DIR,30)).
[0098] 3) Mode three positioning: reference features (RO) + topological relationship (inclusion) + directional relationship.
[0099] query(RO,contain,DIR)→positioning(point(x,y),multiply(DIR,100)).
[0100] 4) Mode 4 positioning: reference features + topological relationship (intersection).
[0101] Query(segment1,intersect,segment2)→positioning(intersection(segment1(LON),segment2(LAT))).
[0102] Mode 4 is to locate the intersection of two roads. In urban roads, if two roads intersect, the two roads can be approximately regarded as perpendicular to each other. The longitude of the intersection coordinates is the longitude of the vertical street, and the latitude is the latitude of the horizontal road.
[0103] This application also provides an experiment and analysis, which applies the above-mentioned natural language spatial relationship positioning method. Specifically: This embodiment collects 10,000 pieces of address data for model recognition. Since there are duplicate data and data lacking spatial relationships in the original data, this embodiment cleans the original data, deletes duplicate data, eliminates data lacking spatial relationships and redundant spatial relationships, and performs data enhancement operations to replace spatial relationships, obtaining 7,500 pieces of data. The training data is labeled data, that is, the input is a spatial relationship text sequence, and the output is a labeled sequence. The training data in this embodiment is divided into a training data set, a validation data set, and a test data set in a ratio of 6:2:2. Among them, the training set is used to train the model; the validation set is used to evaluate and adjust the model during the training process to prevent the model from overfitting; the test set is used after the model training is completed to evaluate the performance of the model on unseen data.
[0104] Table 4 Training data
[0105] Based on the address data, the address data was changed into the form of questions, and 200 texts were constructed in each of the four combination patterns to test the matching and positioning effects of the natural language spatial relationship expression model.
[0106] This embodiment uses the following indicators commonly used in named entity recognition tasks to evaluate and compare the performance of the model in this embodiment, including: precision, recall, and F1 value. The entity is considered to be correctly identified only when the boundary and category of the entity are correctly identified. The calculation formulas for each evaluation indicator are as follows: .
[0107] .
[0108] .
[0109] Where TP is the number of named entities recognized correctly; FP is the number of named entities recognized incorrectly; FN is the number of named entities not recognized.
[0110] Among them, the recognition results of different types of entities by the ALBERT-BiLSTM-CRF model are shown in Table 5. It can be seen from the table that the method proposed in this embodiment has a high accuracy rate in all types of entities. The F1 value for the recognition of distance relationship entities is the highest, reaching 97.95%. This is because the expression of distance relationship entities is relatively regular and the format is standardized, and it appears as a suffix combination of quantifiers and distance units. Since the directional relationship entity type appears in natural language questions with high recognition, the directional vocabulary is used in the sentence to represent the directional relationship, for example, the words such as east and east, and this type of entity also achieves a high F1 value. There are a lot of nestings in the entity type of geographic entity, causing a geographic entity to be parsed into two geographic entity elements. The nesting between entities is the reason that affects the accuracy of the model. The reason why the topological relationship entity has the lowest F1 value is that in spatial relationship sentences, the description of distance and directional relationships is generally used, and the topological relationship is implicitly included in it, resulting in fewer relevant description methods in the training corpus. Consider supplementing topological relationship data in subsequent research to further improve the accuracy of the model.
[0111] Table 5 Entity recognition results
[0112] The constructed 800 texts were used to match the combination patterns in the natural language spatial relationship expression model, and the results are shown in Table 6. First, the reference feature recognition does not match the address database, which affects the matching of these four types of combination patterns. The distance and direction relationship in pattern one is easy to identify, and a higher matching rate is achieved; the adjacent and inclusion relationships in patterns two and three are implicitly expressed in the text, and there is no clear vocabulary, which affects the matching of the pattern; the intersection topological relationship in pattern four is easy to identify, and the number of matches is the largest.
[0113] The 710 texts that were successfully matched were calculated according to the positioning algorithm in the corresponding spatial relationship combination mode. The positioning results were compared with the spatial orientation of the reference feature description through manual verification. 693 texts were consistent with the orientation described in natural language, indicating that this model can better understand the spatial relationship in natural language. After analysis, the text that did not meet the description was caused by the large scale of the reference feature. For example, "500 meters east of Peking University" was calculated based on the coordinates of the center point of the reference feature Peking University. The positioning position was still within Peking University, resulting in a positioning deviation from the natural language spatial relationship description.
[0114] Table 6 Combination pattern matching rate
[0115] Based on the same inventive concept, the embodiment of the present application also provides a positioning device for implementing the above-mentioned natural language spatial relationship positioning method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more question recognition device embodiments provided below can refer to the limitations of the natural language spatial relationship positioning method above, and will not be repeated here.
[0116] In an exemplary embodiment, Figure 4 As shown, a natural language spatial relationship positioning device is provided, and the positioning device includes: The question acquisition module 401 is used to acquire natural language spatial relationship questions.
[0117] The recognition module 402 is used to recognize the place names and spatial relationships in the natural language spatial relationship question by using the ALBERT-BiLSTM-CRF model.
[0118] The positioning module 403 is used to input the identified place names and spatial relationships into a trained natural language spatial relationship expression model, and locate the position of the question in the natural language spatial relationship question according to the spatial algorithm corresponding to the place names and spatial relationships; the natural language spatial relationship expression model is composed of reference features, spatial relationships and natural language spatial relationship combination patterns.
[0119] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store question recognition data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for locating a natural language spatial relationship is implemented.
[0120] Those skilled in the art will understand that Figure 5The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0121] In an exemplary embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0122] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0123] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0124] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0125] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM may be in various forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
[0126] The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. The non-relational database may include a distributed database based on blockchain, etc., but is not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but is not limited thereto.
[0127] In summary, this application has the following technical effects: Existing spatial database queries cannot locate unknown locations, and there is a lack of universal and standardized structured spatial relationship description methods. This application uses a named entity recognition model to identify geographic entities and spatial relationships in natural language spatial relationship questions, matches the identified spatial relationships to the established spatial relationship combination pattern, and solves the coordinates of the location in the question according to the corresponding spatial calculation operations in the combination pattern, solving the problem that the location in the spatial query cannot be queried in the spatial database. Experiments show that the method of this application can effectively locate the target queried in the natural language spatial relationship question.
[0128] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0129] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.
Claims
1. A method for locating natural language spatial relations, characterized in that: The positioning method comprises: Obtain natural language spatial relation questions; The ALBERT-BiLSTM-CRF model is used to identify the place names and spatial relationships in the natural language spatial relationship questions; The identified place names and spatial relationships are input into a trained natural language spatial relationship expression model, and the position of the question in the natural language spatial relationship question is located according to the spatial algorithm corresponding to the place names and spatial relationships; the natural language spatial relationship expression model is composed of reference features, spatial relationships and natural language spatial relationship combination patterns.
2. A method for locating natural language spatial relations according to claim 1, characterized in that: The reference features in the natural language spatial relationship expression model include: positioning basis, water system, residential areas and facilities, transportation, pipelines, boundaries and political divisions, landforms, vegetation and soil quality, and place names.
3. The method for locating a natural language spatial relationship according to claim 1, characterized in that: The spatial relationship in the natural language spatial relationship expression model includes topological relationship, directional relationship and distance relationship; The topological relationships include intersection, adjacency, inclusion, inclusion, separation, covering, being covered and equality; The directional relationships include: east, south, west, north, central, southeast, northeast, southwest and northwest; The distance relationship is described by combining numerals with length units.
4. The method for locating a natural language spatial relationship according to claim 1, characterized in that: The natural language spatial relationship combination mode in the natural language spatial relationship expression model includes: the constraint of topological relationship on directional relationship, the constraint of directional relationship on topological relationship and the constraint of distance relationship on topological relationship; The constraints of the topological relationship on the directional relationship include: when the topological relationship between the spatial objects is separation and adjacency, the spatial objects have a directional relationship, and when the topological relationship between the spatial objects is inclusion, the directional relationship is all directional relationships of the reference objects; The constraints of the directional relationship on the topological relationship include: when the directional relationship between the space objects does not contain the directional middle, the topological relationship between the space objects is separated or adjacent, and when the directional relationship between the space objects is equal to the directional middle, the topological relationship between the space objects is included; The constraint of the distance relationship on the topological relationship includes: when there is a quantitative distance relationship in the spatial relationship between the spatial objects, the topological relationship between the spatial objects is separation or inclusion.
5. The method for locating a natural language spatial relationship according to claim 1, characterized in that: The training process of the natural language spatial relationship expression model is as follows: Collect a data set containing natural language spatial relationship questions to obtain a training data set for a natural language spatial relationship expression model; Preprocessing the data in the data set; the preprocessing includes word segmentation tags and semantic annotation; Based on word segmentation and semantic annotation, identify the type of labels in natural language spatial relationship questions, and classify the entities in the dataset into reference features, topological relationships, directional relationships, and distance relationships according to the labels; The natural language spatial relationship question in the training data set is used as input, and the word segmentation and semantic annotation of the natural language spatial relationship question is used as labels to train the natural language spatial relationship expression model to obtain a trained natural language spatial relationship expression model.
6. A method for locating natural language spatial relations according to claim 1, characterized in that: The ALBERT-BiLSTM-CRF model consists of an ALBERT input representation layer, a BiLSTM encoding layer, and a CRF output layer; The ALBERT input representation layer includes a word embedding layer and a Transformer encoding layer; the word embedding layer is used to convert each character in the vocabulary into a word vector, and combine the text vector and the position vector to form a comprehensive feature vector; the Transformer encoding layer is used to determine the word vector representation of the place name in the natural language spatial relationship question based on the comprehensive feature vector; The BiLstm encoding layer is composed of a forward LSTM and a backward LSTM, and is used to learn the semantic information of spatial relationship vocabulary and reference feature vocabulary; The CRF output layer is used to calculate the probability formula based on core(x,y) = Predict the label sequence; For prediction The score of the i-th character of the label; yes Tags transferred to The score of the label.
7. A natural language spatial relationship positioning device, characterized in that: The positioning device comprises: A question acquisition module is used to acquire natural language spatial relationship questions; A recognition module, for recognizing place names and spatial relationships in the natural language spatial relationship question using an ALBERT-BiLSTM-CRF model; A positioning module is used to input the identified place names and spatial relationships into a trained natural language spatial relationship expression model, and locate the position of the question in the natural language spatial relationship question according to the spatial algorithm corresponding to the place names and spatial relationships; the natural language spatial relationship expression model is composed of reference features, spatial relationships and natural language spatial relationship combination patterns.
8. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement a method for locating a natural language spatial relationship as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, a method for locating a natural language spatial relationship according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, a method for locating a natural language spatial relationship according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Context-considered spatial relationship natural language statement conversion method and device
CN120951951A
A method and apparatus for natural language sentence conversion that takes into account spatial relationships in context
CN120951951B