A method for locating social media users based on heterogeneous graphs
By using a heterogeneous graph-based approach to infer user location using social network data, the problem of incomplete and inaccurate information in existing technologies is solved, achieving higher location prediction accuracy and precision.
Patent Information
- Application Number
- CN202411529175.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-10-30
AI Technical Summary
Existing methods for inferring the home location of social network users suffer from insufficient accuracy due to incomplete or inaccurate information and a lack of effective utilization of known location information.
A heterogeneous graph-based approach is adopted. Frequent user patterns are obtained through data preprocessing, a heterogeneous network is built, user feature extraction and friend filtering are performed, and user location prediction is achieved by combining natural language processing and geographic entity structured query. DBSCAN clustering is used.
It improves the accuracy and precision of user location prediction, simplifies the quality of heterogeneous networks, enhances the versatility and processing speed of the method, solves the ambiguity problem in geographic location reasoning, and improves the performance of location reasoning by more than 10%.
Smart Images

Figure CN119474499B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of social network user attribute reasoning technology, specifically involving a method for locating social media users based on heterogeneous graphs. Background Technology
[0002] With the rapid development of the internet, the use of social media has become increasingly widespread. The rapid development of online social networks such as Twitter, LinkedIn, Facebook, and Weibo has greatly increased the convenience of online interaction and information sharing. In online social networks, accounts serve as the primary tool for their owners to participate in online activities. We can typically obtain a wealth of useful information by analyzing the user data of these accounts, such as location, community, and interests. User location is one of the important attributes of social users; it refers to a user's long-term residential address or main activity area. Inferring a user's location involves extracting, analyzing, and fusing location information from online social network data to estimate the user's location. Such research can solve many related problems: For online social network operators, a user's home location is considered valuable prior knowledge for many business operations, helping them to conduct precise advertising and regional consumption habit analysis, thus improving the efficiency of business activities. For ordinary users, home location is relatively private information, and many users are unwilling to disclose it to the outside world. Therefore, inferring a user's home location can be used to allow users to check whether their home location has been leaked, thereby guiding users to post correctly and raising awareness of protecting personal privacy.
[0003] Existing methods for inferring user home location can be categorized into three types based on the type of online social network information used: content-based methods, relationship-based methods, and context-based methods. Most existing research methods only use single or partial aspects of a user to infer their home location. In many cases, these methods fail to achieve the desired results, which can be broadly summarized in two aspects: First, the extraction of location information is incomplete and inaccurate. A single geographic feature word may refer to multiple different locations, and the size of the area referred to by different geographic features words can vary significantly. Furthermore, users may provide inaccurate location information. Second, existing methods cannot effectively utilize known location information. For example, content-based methods typically use supervised learning to construct feature-based user home location inference models. Many supervised learning methods are affected by the quality of training samples and the algorithm's generalization ability, making accurate estimation difficult.
[0004] In summary, social networks contain a wealth of user location-related information, but this information is hidden within personal descriptions, friend relationships, and user activity data. Furthermore, due to the open nature of social networks, each type of information provides an inaccurate and incomplete description of user location. Existing user location methods lack sophisticated methods for organizing and reasoning about user locations, resulting in accuracy rates that fail to meet expectations when inferring user locations. Summary of the Invention
[0005] To address the aforementioned technical problems, this invention provides a method for locating social media users based on heterogeneous graphs. This method solves the challenges of high data complexity and uncertainty in online social networks and addresses the problems faced by existing methods for inferring user home locations. It comprehensively utilizes information from online social networks and improves inference performance.
[0006] The technical solution adopted in this invention is: a method for locating social media users based on heterogeneous graphs, the specific steps of which are as follows:
[0007] S1. Data preprocessing, which involves collecting data and obtaining frequent user patterns;
[0008] S2. Based on step S1, build a heterogeneous network, extract user features, and then filter user friends.
[0009] S3. Based on step S2, perform user location prediction and optimization, that is, first perform geographic entity structuring processing and then perform geographic location prediction to achieve user positioning.
[0010] Furthermore, step S1 is specifically as follows:
[0011] First, select a social media app and obtain a sufficient number of accounts by applying for the app's API. Then, randomly capture data from A accounts as a sample set. Next, randomly select some users from the sample set as initial "seed users".
[0012] The account data includes: all of the user's personal dynamic text, the user's homepage introduction, and the user's friend list.
[0013] Then, by utilizing the personal homepage information of the seed users and their most recently posted X dynamic records, we can delve deeper into the users' social interaction traces on the platform, including: mutual following relationships, @mention behavior in dynamic content, and information forwarding chains.
[0014] The social interaction traces of the users on the platform not only cover direct friendships, but also include users indirectly connected through shared interests and topic discussions. These users are designated as extended users, and the latest X personal updates and complete user homepage information of the extended users are collected to construct a social network dataset.
[0015] The obtained social network dataset is preprocessed by using association rule mining to obtain frequent patterns of users mentioning geographical location information. Key behavioral nodes that may carry geographical location information are identified from a wide range of user behavior data, including: locations mentioned in the user's personal description, social media content with geotags when posted, geographical location information publicly displayed on the user's homepage, and geographical location-related content posted in the user's WeChat Moments.
[0016] Some user behavior data, including subscription and forwarding statuses in the crawled data, does not contain geographic information. Therefore, an association rule mining algorithm is introduced to obtain frequent patterns of user mentions of geographic entities. By defining support and confidence, the intrinsic relationship between various user behaviors and geographic locations is analyzed, and the strength of their association is quantified. The definitions of support and confidence are as follows:
[0017]
[0018] Where Count(A∪B) represents the number of itemsets that contain both itemsets A and B, N represents the total number of itemsets, Support(A→B) represents the frequency at which itemsets A and B appear together, Confidence(A→B) represents the confidence of itemset A in relation to itemset B, and Support(A) represents the support of itemset A.
[0019] Furthermore, step S2 is specifically as follows:
[0020] S21. Establish a heterogeneous network;
[0021] First, a heterogeneous network is constructed, namely, a master relation network (MRN) is constructed, which is represented in the form of an undirected graph G(V,E).
[0022] Where V represents the vertex set and E represents the edge set.
[0023] Then, the "key behavior nodes" mentioned in step S1 are added to the heterogeneous network as node types, that is, heterogeneous nodes containing geographic information, and the heterogeneous network includes: users and their behavior nodes, and social relationship nodes between users.
[0024] The vertices in the vertex set V include: the user themselves in the social network, and various heterogeneous nodes containing geographic information, namely, user self-description information, user personal dynamic text, information related to user friends, and original text information of forwarded dynamics; the edge set E defines the connection relationship between heterogeneous nodes, including: based on direct user interaction and based on indirect geographic information association.
[0025] The user's self-description information includes: homepage introduction and GPS location; the user's personal dynamic text includes: original dynamics and forwarded dynamics; the user's friends' information includes: friends' personal information, friends' original dynamics, and friends' forwarded dynamics; the original text information of forwarded dynamics includes: the original author's information.
[0026] S22. After extracting user features, filter users' friends.
[0027] Based on step S21, all one-way follow relationships in the social network dataset are excluded, and only the information of friends who follow each other is retained. Then, the feature vectors of users are extracted from the remaining friend relationships, and users are hierarchically clustered. By selecting an appropriate number of clusters, the two-way friend relationships are filtered.
[0028] The user's feature vector includes: a vector-connected text feature vector and a geographic entity feature vector; the extraction of the user's feature vector is as follows:
[0029] (1) Text feature vector;
[0030] First, filter the user's n personal dynamic texts. The fields used for filtering include: lang, retweeted_status_result.
[0031] The filtered and retained tweets are embedded using transformer encoding: first, each tweet is broken down into several tokens using a tokenizer, and then the word embedding E of each token is calculated separately. token Location Embedding E position Segmented embedding of E segment The embedding of each token is represented by E=E position +E token +E segment express.
[0032] Then, a bidirectional attention mechanism is used for the obtained token embedding sequence [E1, E2, E3, ..., E n For position i, E i Calculate its attention score with other vectors to obtain the output sequence [H1, H2, H3, ..., H n Finally, average embedding is used to obtain the vector representation of each dynamic text. This is used to represent the focus of a user's individual dynamic text, and finally, a self-attention mechanism is used to obtain the overall embedding E of the user's text. text =∑W i vec i .
[0033] Among them, W i Vec represents the self-attention weights of the text feature vector.i The vector representation of text, i.e., E sentence .
[0034] (2) Geographic entity feature vectors;
[0035] Natural Language Processing is used to obtain user-generated dynamic text, personal homepage, user self-description, and geographic entities contained in GPS location. The obtained m geographic entity sequences are then embedded using the same method as the dynamic text embedding—a bidirectional attention mechanism—to obtain the geographic entity embeddings. For each obtained user geographic entity (Entity1, Entity2, ..., Entity...),... m ), which are combined into a sequence L = (Entity1, Entity2, ..., Entity) according to the order in which the entities are obtained. m For this sequence, obtain the transformer embedding for each geographic entity, and then use an attention mechanism on these embeddings to use them as a vector representation of the user's geographic location, denoted as vec. location .
[0036] Finally, concatenate the two vectors into E. user =(E text vec location It also considers the degree of relevance of users in terms of personal interests and geographical location.
[0037] Get user's embedded E user Hierarchical clustering was then used to filter users' friend relationships based on intimacy. Friends in the same cluster as the user to be inferred were considered as close friends. A bottom-up clustering approach was used, where each data point was treated as an initial cluster, and clusters were merged based on their nearest neighbor, combining the two closest clusters into a new cluster, until the number of clusters reached the stopping condition, as detailed below:
[0038] The obtained user feature vector E user As data points, the cluster distance is calculated using the Ward method, minimizing the increase in intra-cluster variance ΔS after merging. Cij =S(C ij )-S(C i )-S(C j ).
[0039] Among them, C i C j To represent different clusters, C ij C represents i C j After the clusters are merged, S(C) represents the sum of squares within cluster C, which is the sum of the squared distances from all points within the cluster to the centroid of the cluster, ΔS Cij This indicates the change in variance after cluster merging.
[0040] Furthermore, step S3 is specifically as follows:
[0041] Based on step S2, after filtering user friend relationships and extracting geographical entities from the set of close users using natural language processing, the Nominatim local service is installed and configured for structured queries.
[0042] Nominatim is used by users to accurately retrieve geographic entities based on multiple fields; these fields include: city, state, and country, representing geographic location information at the city, state / province, and country levels, respectively.
[0043] Structured queries solve two key problems, as follows:
[0044] 1. Place name duplication problem: By using Nominatim's structured query, place names are specified down to the specific administrative division based on the fields country and state, thereby eliminating ambiguity and ensuring the accuracy of query results.
[0045] 2. Multi-level location reasoning and verification: Structured queries provide precise classification of place names, allowing for step-by-step reasoning of user location attributes according to the hierarchical structure of country, state / province, and city.
[0046] While classifying geographic entities using the Nominatim service, the place name entities are converted into their corresponding geographic latitude and longitude coordinates [p1, p2, ..., p n The user's location is predicted using DBSCAN clustering on these coordinates, as follows:
[0047] First, initialize all geographic coordinates obtained after latitude and longitude conversion, mark all points as unvisited, then find the core point, and calculate the neighborhood N of each point p. ε (p) = {q∈D|distance(q,p)≤ε}. If the number of points in the neighborhood is greater than the set threshold A, then p is considered a core point.
[0048] Where, N ε (p) represents the neighborhood centered at point p, point q represents another point, and distance(q,p) represents the distance between points p and q. This expression means that all points whose distance from point p is less than ε are considered to be within its neighborhood.
[0049] For each core point p and its corresponding cluster, add all points within its neighborhood to this cluster. If the added points p i This is also the core point, so p iAll points within the neighborhood are added to the cluster until no new points can be added. Points not marked as core or boundary points after this process is completed for all core points are considered noise points. After DBSCAN clustering is completed, the cluster with the highest density is selected as the reliable cluster, and the location of its center point is used as the predicted result as the user's possible home location, thus completing the user's location.
[0050] In addition, considering the occurrence of abbreviations, a token position check is introduced to eliminate the ambiguity of abbreviations, as follows:
[0051] 1. Abbreviations appearing alone;
[0052] If no other information about geographical location appears in the text, the specific meaning of this abbreviation cannot be determined, and in this case, the abbreviation is not processed.
[0053] 2. Abbreviations appear in combination with other place names;
[0054] By designing a method to determine the location of tokens, if two entities appear consecutively and their appearance is a combination of a simple geographical entity and an abbreviated geographical entity, they are combined into a complex place name, thereby determining the specific meaning of the abbreviated geographical entity.
[0055] The beneficial effects of this invention are as follows: The method of this invention obtains the behaviors or relationships of users that are most likely to generate geographical location information through association rule mining, and uses heterogeneous graphs to add the user's relationships as nodes into a user-centered heterogeneous network. It comprehensively utilizes the content, relationships, and contextual information in the social network, constructs the user's feature vector through the user's text information and extracted location information, obtains the user group with the highest similarity to the user to be predicted by filtering users, and improves the accuracy of location prediction by using structured processing of geographical entities.
[0056] This invention improves the accuracy and precision of social media user prediction. It identifies frequent patterns of user mentions of geographic entities through association rule mining, enhancing the quality of heterogeneous networks and eliminating nodes useless for geographic location inference, thus increasing the method's versatility across different types of social networks. By modeling user text features combined with geographic information features to obtain feature vectors, hierarchical clustering is used to filter user affinity, improving the quality of geographic entities of friends added to heterogeneous graph nodes, thereby increasing the accuracy of geographic location inference. A self-built place name latitude and longitude conversion service, configured with a Nominatim local server, achieves high concurrency, fast response, and large-scale processing capabilities for the latitude and longitude conversion service, improving the processing speed and stability of this method. Structured processing of geographic entities addresses the issue of varying inference granularity, employing a reasoning approach that gradually optimizes user location from a broad to a narrow scope, and utilizing the inclusion relationships of geographic entities to analyze the rationality of the reasoning results. Parsing the position of geographic entities in the text resolves the problem of ambiguous abbreviations, compensating for the common lack of complex place name recognition capabilities in natural language processing models, and reducing the impact of ambiguity on the reasoning results. Attached Figure Description
[0057] Figure 1 This is a flowchart of a method for locating social media users based on heterogeneous graphs according to the present invention.
[0058] Figure 2 This is a schematic diagram of the heterogeneous graph components in an embodiment of the present invention.
[0059] Figure 3 This is a flowchart of the user feature vector extraction process in an embodiment of the present invention. Detailed Implementation
[0060] The method of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0061] like Figure 1 The flowchart of a method for locating social media users based on heterogeneous graphs according to the present invention is shown below. The specific steps are as follows:
[0062] S1. Data preprocessing, which involves collecting data and obtaining frequent user patterns;
[0063] S2. Based on step S1, build a heterogeneous network, extract user features, and then filter user friends.
[0064] S3. Based on step S2, perform user location prediction and optimization, that is, first perform geographic entity structuring processing and then perform geographic location prediction to achieve user positioning.
[0065] In this embodiment, step S1 is specifically as follows:
[0066] First, select a social software and obtain a sufficient number of accounts by applying for the software's API. Randomly capture A=100,000 account data from these accounts as a sample set. Then, randomly select some users from the sample set as initial "seed users." The selection of these users aims to ensure the diversity and representativeness of the data.
[0067] The account data includes: all of the user's personal dynamic text, the user's homepage introduction, and the user's friend list.
[0068] Then, by utilizing the personal homepage information of the seed users and their most recently posted X=500 dynamic records, we can delve deeper into the users' social interaction traces on the platform, including: mutual following relationships, @mention behavior in dynamic content, and information forwarding chains.
[0069] The social interaction traces of the users on the platform not only cover direct friendships, but also include users indirectly connected through shared interests and topic discussions. These users are designated as extended users, and the latest X=500 personal updates and complete user homepage information of the extended users are collected to construct a rich and comprehensive social network dataset.
[0070] When dealing with complex social network datasets, given the massive amounts of user behavior and relationship data they contain, this embodiment proposes an efficient data refinement method. This method aims to improve the accuracy of user location inference by constructing simplified heterogeneous graphs. The core of this method lies in utilizing association rule mining techniques, shifting from manually selecting data to be added to the heterogeneous graph to acquiring frequent user patterns. It intelligently filters out relationships and behavioral nodes that substantially contribute to user location inference, thereby effectively reducing data redundancy and improving analysis efficiency. This approach has strong generalization ability across various social networks with different data structures, while simplifying the heterogeneous graph structure and avoiding the addition of excessive redundant information.
[0071] Specifically, this embodiment preprocesses the obtained social network dataset by using association rule mining to obtain frequent patterns of users mentioning geographical location information. It then identifies potential "key behavioral nodes" carrying geographical location information from a wide range of user behavior data, including: locations mentioned in the user's personal description, social media content (tweets / personal updates text) with geographic tags when posted, geographical location information publicly displayed on the user's homepage, and geographical location-related content posted in the user's Moments.
[0072] Some user behavior data lacks geographic information, including subscription and forwarding statuses in the crawled data. Therefore, an association rule mining algorithm is introduced to extract frequent patterns of user mentions of geographic entities. By defining support and confidence, the intrinsic relationship between various user behaviors and geographic locations is analyzed, and the strength of the association is quantified. This process not only helps eliminate behavioral data with low contribution to location inference but also reveals behavioral combinations that highly indicate a user's home location or place of residence. The definitions of support and confidence are as follows:
[0073]
[0074] Where Count(A∪B) represents the number of itemsets that contain both itemsets A and B, N represents the total number of itemsets, Support(A→B) represents the frequency at which itemsets A and B appear together, Confidence(A→B) represents the confidence of itemset A in relation to itemset B, and Support(A) represents the support of itemset A.
[0075] In this embodiment, step S2 is specifically as follows:
[0076] S21. Establish a heterogeneous network;
[0077] In response to the common problems of inaccurate, incomplete, and ambiguous information in online social network accounts, this embodiment cleverly introduces an innovative heterogeneous network model, which aims to comprehensively utilize multiple dimensions of user location information to significantly improve the accuracy of inferring the user's precise home location.
[0078] First, a heterogeneous network is constructed, namely, a master relation network (MRN) is constructed, which is represented in the form of an undirected graph G(V,E).
[0079] Where V represents the vertex set and E represents the edge set.
[0080] Then, the "key behavioral nodes" mentioned in step S1 are added to the heterogeneous network as node types, namely, heterogeneous nodes containing geographic information. The heterogeneous network includes: user and their behavioral nodes, and social relationship nodes between users. In this way, a complex network containing multiple information types is constructed, which can comprehensively reflect users' activities in social networks and their potential geographic information.
[0081] like Figure 2As shown, the vertices in the vertex set V include: the user themselves in the social network, and various heterogeneous nodes containing geographical information, namely, user self-description information, user personal dynamic text, information related to user friends, and original information of forwarded dynamics (forwarded article information); this design enables the network to comprehensively capture the multi-dimensional characteristics of users in the social space, including their direct behavior, indirect associations, and implicit expressions of geographical location.
[0082] The edge set E defines the connections between heterogeneous nodes, including: direct user interactions (such as mutual following, forwarding, etc.) and indirect geographic information associations (such as two users' tweets mentioning the same location). By meticulously constructing these edges, MRN successfully weaves the intricate social relationships and geographic location information between users into a tight network, providing rich contextual information for subsequent location inference.
[0083] The user's self-description information includes: homepage introduction and GPS location; the user's personal dynamic text includes: original dynamics and forwarded dynamics; the user's friends' information includes: friends' personal information, friends' original dynamics, and friends' forwarded dynamics; the original text information of forwarded dynamics includes: the original author's information.
[0084] S22. After extracting user features, filter users' friends.
[0085] The friendships users build in cyberspace often deviate from their real-life social relationships. This discrepancy directly affects the accuracy of inferring users' true location information through social relationships. Taking Weibo as an example, the following behavior between users is relatively free. This asymmetrical social relationship, which may be based on various motivations (such as interests, celebrity effect, etc.), cannot fully reflect the true geographical proximity or social closeness between users.
[0086] To address this challenge and reduce the interference of noise information on the inference of users' home location information, this embodiment proposes a targeted user friend relationship filtering mechanism, which aims to simplify the main relationship network (MRN) and eliminate social links that contribute little to location inference or may introduce misleading information.
[0087] First, based on step S21, all one-way follow relationships in the social network dataset are excluded, and only mutual follower information is retained. These relationships are more likely to be friendships in real life than one-way follow relationships. Then, user feature vectors are extracted from the remaining friend relationships, and hierarchical clustering is performed on the users. By selecting an appropriate number of clusters, the two-way friend relationships are filtered to control the granularity of intimacy filtering and improve the accuracy of user location inference.
[0088] like Figure 3 As shown, the user's feature vector includes: a vector-connected text feature vector and a geographic entity feature vector; the extraction of the user's feature vector is as follows:
[0089] (1) Text feature vector;
[0090] First, filter the user's n personal dynamic texts. The fields used for filtering include: lang, retweeted_status_result.
[0091] The filtered and retained tweets are embedded using transformer encoding: first, each tweet is broken down into several tokens using a tokenizer, and then the word embedding E of each token is calculated separately. token Location Embedding E position Segmented embedding of E segment The embedding of each token is represented by E=E position +E token +E segment express.
[0092] Then, a bidirectional attention mechanism is used for the obtained token embedding sequence [E1, E2, E3, ..., E n For position i, E i Calculate its attention score with other vectors to obtain the output sequence [H1, H2, H3, ..., H n Finally, average embedding is used to obtain the vector representation of each dynamic text. This is used to represent the focus of a user's individual dynamic text, and finally, a self-attention mechanism is used to obtain the overall embedding (text feature vector) of the user's text, E. text =∑W i Vec i .
[0093] Among them, W i The vec represents the self-attention weights of the text feature vector. i The vector representation of text (text vector), i.e., E sentence It is used to indicate user interests, topics that individuals are interested in, etc.
[0094] (2) Geographic entity feature vectors;
[0095] Natural Language Processing is used to obtain user-generated dynamic text, personal homepage, user self-description, and geographic entities contained in GPS location. The obtained m geographic entity sequences are then embedded using the same method as the dynamic text embedding—a bidirectional attention mechanism—to obtain the geographic entity embeddings. For each obtained user geographic entity (Entity1, Entity2, ..., Entity...),... m), which are combined into a sequence L = (Entity1, Entity2, ..., Entity) according to the order in which the entities are obtained. m For this sequence, obtain the transformer embedding for each geographic entity, and then use an attention mechanism on these embeddings to use them as a vector representation of the user's geographic location (geographic entity feature vector), denoted as vec. location .
[0096] Finally, concatenate the two vectors into E. user =(E text vec location It also considers the degree of relevance of users in terms of personal interests and geographical location.
[0097] Get user's embedded E user Hierarchical clustering is then used to filter users' friend relationships based on intimacy. Friends within the same cluster as the user being inferred are considered as close friends. A bottom-up clustering approach is used, where each data point is treated as an initial cluster, and clusters are merged based on their closest proximity. The two closest clusters are merged into a new cluster until the number of clusters reaches a stopping condition (set according to actual conditions), as detailed below:
[0098] The obtained user feature vector E user As data points, the cluster distance is calculated using the Ward method, minimizing the increase in intra-cluster variance ΔS after merging. Cij =S(C ij )-S(C i )-S(C j This merging method is very suitable for cluster analysis, as it maintains consistency within clusters during merging, which means maximizing the similarity of users within clusters.
[0099] Among them, C i C j To represent different clusters, C ij C represents i C j After the clusters are merged, S(C) represents the sum of squares within cluster C, which is the sum of the squared distances from all points within the cluster to the centroid of the cluster, ΔS Cij This indicates the change in variance after cluster merging.
[0100] In this embodiment, step S3 is specifically as follows:
[0101] Based on step S2, after filtering user friend relationships and extracting geographic entities from the close user set using natural language processing, the next crucial step is to efficiently process this geographic data to support accurate user location inference. This involves installing and configuring the Nominatim local service for structured queries. Nominatim can meet the high-frequency geographic location query needs, ensuring responsiveness and stability during data processing. As an open-source geocoding and reverse geocoding service, Nominatim provides rich structured query capabilities, allowing users to accurately retrieve geographic entities based on multiple fields.
[0102] Nominatim is used by users to accurately retrieve geographic entities based on multiple fields; these fields include: city, state, and country, representing geographic location information at the city, state / province, and country levels, respectively.
[0103] Structured queries solve two key problems, as follows:
[0104] 1. Duplicate Place Names: Duplicate place names are a common challenge in online social networks, especially when specific context is lacking. For example, "New York" could refer to the city of New York in the United States, a small town in the United Kingdom, or a place in another country. Nominatim's structured queries, based on the fields "country" and "state," pinpoint place names to specific administrative divisions, thus eliminating ambiguity and ensuring the accuracy of query results.
[0105] 2. Multi-level Location Reasoning and Verification: Structured queries provide precise classification of place names, allowing for progressive inference of a user's location attributes based on a hierarchical structure of country, state / province, and city. This hierarchical reasoning method has significant advantages: First, it can progressively narrow down the possible location range of a user from macro to micro; second, the results of reasoning at each level can serve as prior knowledge for reasoning at the next level, helping to verify and correct the inferred results. For example, if the approximate location of a user is determined first through a country-level query, then subsequent state / province and city queries can more effectively filter results, ensuring the coherence and accuracy of the reasoning process.
[0106] While classifying geographic entities using the Nominatim service, the place name entities are converted into their corresponding geographic latitude and longitude coordinates [p1, p2, ..., p n The user's location is predicted using DBSCAN clustering on these coordinates. This clustering method does not require specifying the number of clusters; instead, it finds clusters of arbitrary shapes based on density, as detailed below:
[0107] First, initialize all geographic coordinates obtained after latitude and longitude conversion, mark all points as unvisited, then find the core point, and calculate the neighborhood N of each point p. ε (p) = {q∈D|distance(q,p)≤ε}. If the number of points in the neighborhood is greater than the set threshold A, then p is considered a core point.
[0108] Where, N ε (p) represents the neighborhood centered at point p, point q represents another point, and distance(q,p) represents the distance between points p and q. This expression means that all points whose distance from point p is less than ε are considered to be within its neighborhood.
[0109] For each core point p and its corresponding cluster, add all points within its neighborhood to this cluster. If the added points p i This is also the core point, so p i All points within the neighborhood are added to the cluster until no new points can be added. Points not marked as core or boundary points after this process is completed for all core points are considered noise points. After DBSCAN clustering is completed, the cluster with the highest density is selected as the reliable cluster, and the location of its center point is used as the predicted result as the user's possible home location, thus completing the user's location.
[0110] Structured queries suffer from the inability to fully recognize complex combinations of place names, resulting in excessive abbreviations and ambiguity in geographic entities. For example, the abbreviation "CA" could refer to California in the United States or Canada in the United States. This problem is particularly pronounced with structured queries, which, by reasoning downwards from a broad scope to a narrower one, gradually increases the accuracy. Such ambiguity, referring to different locations within different scopes, leads to inference errors over a wider range, further impacting the accuracy of structured queries. Therefore, it is necessary to determine the specific location referred to by a particular abbreviation or to combine the abbreviation with other geographic locations to resolve the ambiguity. To this end, this embodiment considers both the occurrence of abbreviations and introduces token location judgment to eliminate abbreviation ambiguity, as follows:
[0111] 1. Abbreviations appearing alone;
[0112] If no other information about geographical location appears in the text, the specific meaning of this abbreviation cannot be determined, and in this case, the abbreviation is not processed.
[0113] 2. Abbreviations appear in combination with other place names;
[0114] In such cases, the meaning of the abbreviation can usually be determined based on the meanings of other place names, thus eliminating the influence of ambiguity on reasoning. By designing a token location-based judgment method, if two entities appear consecutively and their appearance is a combination of a simple geographical entity and an abbreviation geographical entity, they are combined into a complex place name, thereby determining the specific meaning of the abbreviation geographical entity. This design method compensates for the common lack of general natural language processing models in recognizing complex geographical entities.
[0115] In summary, the method of this invention simplifies the types of nodes within a heterogeneous graph by acquiring frequent user patterns, filters out high-intimacy objects by hierarchical clustering of users based on their text and geographic location to achieve noise reduction, and infers the user's home location by combining structured processing of geographic entities with the DBSCAN clustering method. Compared with existing inference methods, the inference effect is improved by more than 10%.
[0116] Those skilled in the art will recognize that the embodiments described herein are intended to help the reader understand the principles of the invention, and should be understood that the scope of protection of the invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific modifications and combinations based on the technical teachings disclosed in this invention without departing from the spirit of the invention, and these modifications and combinations are still within the scope of protection of this invention.
Claims
1. A method for locating social media users based on heterogeneous graphs, the specific steps of which are as follows: S1. Data preprocessing, which involves collecting data and obtaining frequent user patterns; Collect the latest X personal updates from extended users and complete user profile information to construct a social network dataset; preprocess the obtained social network dataset by using association rule mining to obtain frequent patterns of users mentioning geographical location information, and identify potential "key behavioral nodes" carrying geographical location information from the user's extensive behavioral data, including: Locations mentioned in a user's profile, social media content with geotags, publicly displayed location information on a user's profile page, and location-related content posted in a user's social media feed; Some user behavior data does not contain geographic information, including subscription and forwarding status in the crawled data. Therefore, an association rule mining algorithm is introduced to obtain the frequent patterns of users mentioning geographic entities. By defining support and confidence, the intrinsic relationship between various user behaviors and geographic locations is analyzed, and the strength of their association is quantified. S2. Based on step S1, build a heterogeneous network, extract user features, and then filter user friends. S21. Establish a heterogeneous network; First, a heterogeneous network is constructed, namely, a master relation network (MRN) is constructed, which is represented in the form of an undirected graph G(V,E); Where V represents the vertex set and E represents the edge set; Then, the "key behavior nodes" mentioned in step S1 are added to the heterogeneous network as node types, namely, heterogeneous nodes containing geographic information, and the heterogeneous network includes: users and their behavior nodes, and social relationship nodes between users. S22. After extracting user features, filter users' friends. Based on step S21, all one-way follow relationships in the social network dataset are excluded, and only the information of friends who follow each other is retained. Then, the feature vectors of users are extracted from the remaining friend relationships, and users are hierarchically clustered. By selecting an appropriate number of clusters, the two-way friend relationships are filtered. The user's feature vector includes: a vector-connected text feature vector and a geographic entity feature vector; S3. Based on step S2, perform user location prediction and optimization, that is, first perform geographic entity structuring processing and then perform geographic location prediction to achieve user positioning.
2. The method for locating social media users based on heterogeneous graphs according to claim 1, characterized in that, The specific steps of S1 are as follows: First, select a social media app and obtain a sufficient number of accounts by applying for the app's API. Then, randomly capture data from A accounts as a sample set. Next, randomly select some users from the sample set as initial "seed users". The account data includes: all of the user's personal dynamic text, the user's homepage introduction, and the user's friend list; Then, by utilizing the personal homepage information of the seed users and their most recently posted X dynamic records, we can delve deeper into the users' social interaction traces on the platform, including: mutual follow relationships, @mention behavior in dynamic content, and information forwarding chains; The social interaction traces of the users on the platform not only cover direct friendships, but also include users indirectly connected through shared interests and topic discussions. These users are designated as extended users, and the latest X personal updates and complete user homepage information of the extended users are collected to construct a social network dataset. The obtained social network dataset is preprocessed, that is, the frequent patterns of users mentioning geographical location information are obtained by association rule mining. "Key behavioral nodes" that may carry geographical location information are identified from the extensive behavioral data of users, including: locations mentioned in the user's personal description, social media content with geographical tags when posted, geographical location information publicly displayed on the user's homepage, and geographical location-related content posted in the user's WeChat Moments. Some user behavior data does not contain geographic information, including subscription and forwarding status in the crawled data. Therefore, an association rule mining algorithm is introduced to obtain frequent patterns of user mentions of geographic entities. By defining support and confidence, the intrinsic relationship between various user behaviors and geographic locations is analyzed, and the strength of their association is quantified. The definitions of support and confidence are as follows: Where Count(A∪B) represents the number of itemsets that contain both itemsets A and B, N represents the total number of itemsets, Support(A→B) represents the frequency at which itemsets A and B appear together, Confidence(A→B) represents the confidence of itemset A in relation to itemset B, and Support(A) represents the support of itemset A.
3. The method for locating social media users based on heterogeneous graphs according to claim 1, characterized in that, Step S2 is as follows: S21. Establish a heterogeneous network; First, a heterogeneous network is constructed, namely, a master relation network (MRN) is constructed, which is represented in the form of an undirected graph G(V,E); Where V represents the vertex set and E represents the edge set; Then, the "key behavior nodes" mentioned in step S1 are added to the heterogeneous network as node types, namely, heterogeneous nodes containing geographic information, and the heterogeneous network includes: users and their behavior nodes, and social relationship nodes between users. The vertices in the vertex set V include: the user themselves in the social network, and various heterogeneous nodes containing geographic information, namely, user self-description information, user personal dynamic text, information related to the user's friends, and original information of forwarded dynamics; the edge set E defines the connection relationship between heterogeneous nodes, including: based on direct user interaction and based on indirect geographic information association. The user's self-description information includes: homepage introduction and GPS location; the user's personal dynamic text includes: original dynamics and forwarded dynamics; the user's friends' information includes: friends' personal information, friends' original dynamics, and friends' forwarded dynamics; the original text information of forwarded dynamics includes: the original author's information; S22. After extracting user features, filter users' friends. Based on step S21, all one-way follow relationships in the social network dataset are excluded, and only the information of friends who follow each other is retained. Then, the feature vectors of users are extracted from the remaining friend relationships, and users are hierarchically clustered. By selecting an appropriate number of clusters, the two-way friend relationships are filtered. The user's feature vector includes: a vector-connected text feature vector and a geographic entity feature vector; the extraction of the user's feature vector is as follows: (1) Text feature vector; First, filter the user's n personal dynamic texts. The fields used for filtering include: lang, retweeted_status_result; The filtered and retained tweets are embedded using transformer encoding: first, each tweet is broken down into several tokens using a tokenizer, and then the word embedding E of each token is calculated separately. token Location Embedding E position Segmented embedding E segment The embedding of each token is represented by E=E position +E token +E segment express; Then, a bidirectional attention mechanism is used for the obtained token embedding sequence [E1, E2, E3, ..., E n For position i, E i Calculate its attention score with other vectors to obtain the output sequence [H1, H2, H3, ..., H n Finally, average embedding is used to obtain the vector representation of each dynamic text. This is used to represent the focus of a user's individual dynamic text, and finally, a self-attention mechanism is used to obtain the overall embedding E of the user's text. text =∑W i vec i ; Among them, W i Vec represents the self-attention weights of the text feature vector. i The vector representation of text, i.e., E sentence ; (2) Geographic entity feature vectors; Natural Language Processing is used to obtain user-generated dynamic text, personal homepage, user self-description, and geographic entities contained in GPS location. The obtained m geographic entity sequences are then embedded using the same method as the dynamic text embedding—a bidirectional attention mechanism—to obtain the geographic entity embeddings. For each obtained user geographic entity (Entity1, Entity2, ..., Entity...),... m ), which are combined into a sequence L = (Entity1, Entity2, ..., Entity) according to the order in which the entities are obtained. m For this sequence, obtain the transformer embedding for each geographic entity, and then use an attention mechanism on these embeddings to use them as a vector representation of the user's geographic location, denoted as vec. location ; Finally, concatenate the two vectors into E. user =(E text vec location It also considers the degree of relevance of users in terms of personal interests and geographical location; Get user's embedded E user Hierarchical clustering was then used to filter users' friend relationships based on intimacy. Friends in the same cluster as the user to be inferred were considered as close friends. A bottom-up clustering approach was used, where each data point was treated as an initial cluster, and clusters were merged based on their nearest neighbor, combining the two closest clusters into a new cluster, until the number of clusters reached the stopping condition, as detailed below: The obtained user feature vector E user As data points, the cluster distance is calculated using the Ward method to minimize the increase in intra-cluster variance after merging. Among them, C i C j To represent different clusters, C ij Indicate C i C j After merging clusters, S(C) represents the sum of squares within cluster C, which is the sum of the squared distances from all points within the cluster to the centroid of the cluster. This indicates the change in variance after cluster merging.
4. The method for locating social media users based on heterogeneous graphs according to claim 1, characterized in that, Step S3 is as follows: Based on step S2, after filtering user friend relationships and extracting geographical entities from the set of close users using natural language processing, Nominatim local service is installed and configured for structured querying. Nominatim is used by users to accurately retrieve geographic entities based on multiple fields; these fields include: city, state, and country, representing geographic location information at the city, state / province, and country levels, respectively. Structured queries solve two key problems, as follows: (1) Place name duplication problem: By using Nominatim's structured query, place names are specified to specific administrative divisions based on the fields country and state, thereby eliminating ambiguity and ensuring the accuracy of query results; (2) Multi-level location reasoning and verification: Structured queries provide accurate classification of place names and allow users to infer their location attributes step by step according to the hierarchical structure of country, state / province and city; While classifying geographic entities using the Nominatim service, the place name entities are converted into their corresponding geographic latitude and longitude coordinates [p1, p2, ..., p n The user's location is predicted using DBSCAN clustering on these coordinates, as follows: First, initialize all geographic coordinates obtained after latitude and longitude conversion, mark all points as unvisited, then find the core point, and calculate the neighborhood N of each point p. ε (p)={q∈D|distance(q,p)≤ε}, if the number of points in the neighborhood is greater than the set threshold A, then p is considered a core point; Where, N ε (p) represents the neighborhood centered at point p, point q represents another point, distance(q,p) represents the distance between points p and q. This expression means that all points whose distance from point p is less than ε are considered to be within its neighborhood. For each core point p and its corresponding cluster, add all points within its neighborhood to this cluster. If the added points p i This is also the core point, so p i All points within the neighborhood are added to the cluster until no new points can be added to the cluster; points that are not marked as core points or boundary points after all core points have completed this operation are considered noise points; after DBSCAN clustering is completed, the cluster with the highest density is selected as the reliable cluster, and the location of its center point is used as the prediction result as the user's possible home location to complete the user's location. In addition, considering the occurrence of abbreviations, a token position check is introduced to eliminate the ambiguity of abbreviations, as follows: (1) Abbreviations appearing alone; If no other information about geographical location appears in the text, the specific meaning of this abbreviation cannot be determined, and in this case, the abbreviation is not processed. (2) Abbreviations appear in combination with other place names; By designing a method to determine the location of tokens, if two entities appear consecutively and their appearance is a combination of a simple geographical entity and an abbreviated geographical entity, they are combined into a complex place name, thereby determining the specific meaning of the abbreviated geographical entity.
Citation Information
Patent Citations
Social network user interest association rule mining method based on community division
CN103838804A
Knowledge reasoning method based on multi-modal knowledge graph
CN112288091A