The article recommends a method, device, computer readable storage medium and electronic equipment

CN117033786BActive Publication Date: 2026-08-18INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311008081.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-10
Publication Date
2026-08-18
Estimated Expiration
2043-08-10

AI Technical Summary

Technical Problem

[0005]本发明实施例提供了一种文章推荐方法、装置、计算机可读存储介质及电子设备,以至少解决相关技术中向用户推荐文章时,存在推荐准确度低的技术问题

Benefits of technology

[0017] In this embodiment of the invention, articles are recommended to users based on the relationship between the hash values ​​of search keywords and the hash values ​​of articles to be recommended. This involves obtaining at least one search keyword sent by the target user for searching for articles, determining the term frequency (IF) and inverse document frequency (IRF) of each search keyword, calculating a first hash value for each search keyword using a target hash algorithm, obtaining the second hash value of each article to be recommended, and determining the recommendation level value for each article based on all the first and second hash values. Based on the magnitude of the recommendation level values ​​of each article to be recommended, a target article is determined from the multiple articles to be recommended and recommended to the target user. Specifically, the target hash algorithm calculates the initial hash value of the search keyword based on its IF to obtain the first hash value, and the second hash value of the article to be recommended is determined based on the hash values ​​of the keywords within the article.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117033786B_ABST
    Figure CN117033786B_ABST
Patent Text Reader

Abstract

The application discloses an article recommendation method and device, a computer readable storage medium and an electronic device. It relates to the field of artificial intelligence, and the method comprises the following steps: obtaining at least one search keyword for searching articles sent by a target object, and determining the term frequency-inverse document frequency of each search keyword; obtaining at least one search keyword for searching articles sent by a target object, and determining the term frequency-inverse document frequency of each search keyword; obtaining the second hash value of each article to be recommended in a plurality of articles to be recommended, and for each article to be recommended, determining the recommendation degree value of the article to be recommended according to all the first hash values and the second hash values; and determining a target article from the plurality of articles to be recommended according to the size of the recommendation degree value of each article to be recommended, and recommending the target article to the target object. The application solves the technical problem of low recommendation accuracy when recommending articles to users in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence, and more specifically, to an article recommendation method, apparatus, computer-readable storage medium, and electronic device. Background Technology

[0002] With the explosive growth of information on the internet, people face the problem of information overload when searching for information of interest (such as articles, products, etc.). Recommendation methods, as a solution, have been widely used in e-commerce, social networking sites, personalized search, and academia.

[0003] Currently, collaborative filtering is commonly used in related technologies to recommend information of interest to users. Collaborative filtering methods include user-based collaborative filtering and item-based collaborative filtering. The basic idea of ​​user-based collaborative filtering is to calculate user similarity and select a small subset of users with similar interests to the target user from a large pool of users as neighbors. Users who have previously agreed on something are likely to agree again in the future. The basic idea of ​​item-based collaborative filtering is to first explore the relationships between items, rather than the relationships between users. This method finds a group of similar items to the items the target user likes and then recommends these similar items to the user. The above collaborative filtering methods rely solely on the relationships between users and items or between items. However, the construction of these relationships depends on a large amount of data, and these relationships are not stable over time. Therefore, related technologies suffer from low recommendation accuracy when recommending articles to users.

[0004] There is currently no effective solution to the above problems. Summary of the Invention

[0005] This invention provides an article recommendation method, apparatus, computer-readable storage medium, and electronic device to at least address the technical problem of low recommendation accuracy when recommending articles to users in related technologies.

[0006] According to one aspect of the present invention, an article recommendation method is provided, comprising: acquiring at least one search keyword sent by a target object for searching for articles, and determining the term frequency inverse document frequency (TRF) of each search keyword; for each search keyword, calculating a first hash value of the search keyword using a target hash algorithm, wherein the target hash algorithm calculates the first hash value by processing an initial hash value of the search keyword based on the TRF of the search keyword; acquiring a second hash value of each of a plurality of articles to be recommended, and for each article to be recommended, determining a recommendation degree value of the article to be recommended based on all the first hash values ​​and second hash values, wherein the second hash value of the article to be recommended is determined based on the hash values ​​of the keywords in the article to be recommended; determining a target article from the plurality of articles to be recommended based on the magnitude of the recommendation degree value of each article to be recommended, and recommending the target article to the target object.

[0007] Furthermore, the article recommendation method also includes: obtaining search information sent by the target object, wherein the search information is a search term or an article used for searching; if the search information is a search term, determining the search term as a search keyword; if the search information is an article used for searching, extracting at least one search keyword from the article used for searching.

[0008] Furthermore, the article recommendation method also includes: the text is composed of all keywords; for each search keyword, the term frequency inverse document frequency of the search keyword is determined based on the text.

[0009] Furthermore, the article recommendation method also includes: using information digest methods to perform hash calculations on search keywords to obtain an initial hash value, where the initial hash value is binary; for each bit in the initial hash value, determining the calculation method corresponding to the current bit value based on the magnitude of the current bit value, where the calculation method is one of the following: adding the current bit value to the inverse document frequency (IVF) of the search keyword, or subtracting the current bit value from the IVF of the search keyword; processing the current bit value according to the calculation method to obtain the initial value corresponding to the current bit; determining the assignment value for assigning to the current bit based on the relationship between the initial value of the current bit and 0, and processing the current bit according to the assignment value to obtain the target value corresponding to the current bit; combining the target values ​​corresponding to each bit to obtain the first hash value.

[0010] Furthermore, the article recommendation method also includes: for each article to be recommended, determining N keywords in the article and determining the importance value of each keyword, where N is a positive integer greater than 1; calculating the hash value of the keywords using a target hash algorithm; sorting the hash values ​​of the N keywords according to their importance values, and combining the sorted hash values ​​to obtain the second hash value of the article to be recommended.

[0011] Furthermore, the article recommendation method also includes: segmenting the articles to be recommended to obtain multiple words; for each word, calculating the inverse document frequency (IVF) of the word based on the multiple articles to be recommended; sorting the multiple words according to the IVF values ​​of each word in descending order to obtain sorted words; determining the top N words among the sorted words as N keywords, and determining the IVF of the keywords as the importance value of the keywords.

[0012] Furthermore, the article recommendation method also includes: when there is only one search keyword, determining whether the string lengths of the first hash value and the second hash value are equal; when the string lengths are not equal, padding the last digit of the shorter hash value in the first and second hash values ​​to obtain the third hash value; calculating the Hamming distance between the first target hash value and the third hash value to obtain the first Hamming distance value, wherein the first target hash value is the unpadded hash value in the first and second hash values; and determining the recommendation level of the article to be recommended based on the first Hamming distance value.

[0013] Furthermore, the article recommendation method also includes: when there are multiple search keywords, sorting the first hash values ​​of the multiple search keywords according to the order in which they were obtained, and combining the sorted first hash values ​​to obtain a fourth hash value; determining whether the string lengths of the fourth hash value and the second hash value are equal; if the string lengths are not equal, padding the last digit of the shorter hash value in the fourth hash value and the second hash value to obtain a fifth hash value; calculating the Hamming distance between the second target hash value and the fifth hash value to obtain the second Hamming distance value, where the second target hash value is the unpadded hash value in the fourth hash value and the second hash value; and determining the recommendation level of the article to be recommended based on the second Hamming distance value.

[0014] According to another aspect of the present invention, an article recommendation apparatus is also provided, comprising: a first acquisition module, configured to acquire at least one search keyword sent by a target object for searching articles, and determine the term frequency inverse document frequency (TRF) of each search keyword; a first calculation module, configured to calculate a first hash value of each search keyword using a target hash algorithm, wherein the target hash algorithm calculates the first hash value by processing the initial hash value of the search keyword based on the TRF of the search keyword; a second acquisition module, configured to acquire a second hash value of each of a plurality of articles to be recommended, and for each article to be recommended, determine a recommendation degree value of the article to be recommended based on all the first hash values ​​and second hash values, wherein the second hash value of the article to be recommended is determined based on the hash values ​​of the keywords in the article to be recommended; and a first determination module, configured to determine a target article from the plurality of articles to be recommended based on the magnitude of the recommendation degree value of each article to be recommended, and recommend the target article to the target object.

[0015] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is configured to execute the above-described article recommendation method at runtime.

[0016] According to another aspect of the present invention, an electronic device is also provided, the electronic device including one or more processors; a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are configured to run the programs, wherein the programs are configured to execute the above-described article recommendation method during runtime.

[0017] In this embodiment of the invention, articles are recommended to users based on the relationship between the hash values ​​of search keywords and the hash values ​​of articles to be recommended. This involves obtaining at least one search keyword sent by the target user for searching for articles, determining the term frequency (IF) and inverse document frequency (IRF) of each search keyword, calculating a first hash value for each search keyword using a target hash algorithm, obtaining the second hash value of each article to be recommended, and determining the recommendation level value for each article based on all the first and second hash values. Based on the magnitude of the recommendation level values ​​of each article to be recommended, a target article is determined from the multiple articles to be recommended and recommended to the target user. Specifically, the target hash algorithm calculates the initial hash value of the search keyword based on its IF to obtain the first hash value, and the second hash value of the article to be recommended is determined based on the hash values ​​of the keywords within the article.

[0018] In the above process, by obtaining at least one search keyword sent by the target user for searching articles, the target user's current interests are effectively determined. This avoids the problem in related technologies where collaborative filtering relies solely on the relationship between users and projects or between projects, thus failing to effectively determine the target user's current preferences when the relationship changes. Furthermore, by calculating the first hash value of each search keyword and determining the second hash value of the article to be recommended based on the hash values ​​of the keywords in the article, the content of both the search keywords and the content of the article to be recommended is effectively extracted. Even further, by determining the recommendation level of the article to be recommended based on all the first and second hash values, the recommendation level is determined based on the relationship between the search content and the content to be recommended, thus achieving accurate determination of the recommendation level and improving the accuracy of article recommendations to users.

[0019] Therefore, the solution provided in this application achieves the goal of recommending articles to users based on the relationship between the hash value of search keywords and the hash value of the articles to be recommended, thereby improving the technical effect of recommendation accuracy and solving the technical problem of low recommendation accuracy in related technologies. Attached Figure Description

[0020] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:

[0021] Figure 1 This is a flowchart of an optional article recommendation method according to an embodiment of the present invention;

[0022] Figure 2 This is a schematic diagram of an optional article recommendation method according to an embodiment of the present invention;

[0023] Figure 3 This is a schematic diagram of an optional article recommendation device according to an embodiment of the present invention;

[0024] Figure 4 This is a schematic diagram of an optional electronic device according to an embodiment of the present invention. Detailed Implementation

[0025] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0026] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0027] 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 display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.

[0028] Example 1

[0029] According to an embodiment of the present invention, an embodiment of an article recommendation method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0030] Figure 1 This is a flowchart of an optional article recommendation method according to an embodiment of the present invention, such as... Figure 1 As shown, the method includes the following steps:

[0031] Step S101: Obtain at least one search keyword sent by the target object for searching articles, and determine the term frequency inverse document frequency of each search keyword.

[0032] Optionally, electronic devices, application systems, servers, and other devices can be used as the execution subject of this application. In this embodiment, the target recommendation system is used as the execution subject to obtain at least one of the above-mentioned search keywords.

[0033] The target object can be a user, and at least one search keyword can be directly entered by the user or extracted by the target recommendation system from the information entered by the target object. For example, if the target object enters the sentence "I want to search for articles related to plants", the target recommendation system can extract "plants" as the search keyword.

[0034] Furthermore, once the search keywords are obtained, the target recommendation system can determine the term frequency (TF-IDF) for each keyword. TF-IDF is a statistical method used to measure the importance of a word in text. TF-IDF consists of two parts: Term Frequency (TF) and Inverse Document Frequency (IDF). Term Frequency is the number of times a word appears in a text divided by the total number of words in that text; it represents the word's relative frequency within the text. Inverse Document Frequency is the logarithm of the total number of texts containing the word. The main function of Inverse Document Frequency is to adjust the weights of words that appear frequently in multiple texts, focusing on words that appear less frequently but may be more informative. The value of TF-IDF is the product of Term Frequency and Inverse Document Frequency. A higher TF-IDF value indicates that a word is more important in a specific text but appears less frequently in the overall text set.

[0035] Step S102: For each search keyword, calculate the first hash value of the search keyword using the target hash algorithm. The target hash algorithm calculates the first hash value by processing the initial hash value of the search keyword based on the term frequency inverse document frequency of the search keyword.

[0036] Optionally, the target hash algorithm mentioned above is the SimHash algorithm. SimHash is an algorithm used for deduplicating large amounts of text. Unlike traditional hash algorithms, SimHash is a locality-sensitive hashing algorithm. For each search keyword, the target recommendation system can hash the search keyword using one of the following hash algorithms: information digest, SHA1, SHA224, SHA256, SHA384, or SHA512, to obtain an initial hash value.

[0037] Furthermore, the target hash algorithm can calculate the initial hash value of the search keyword based on the term frequency inverse document frequency (IF) of the search keyword, thereby obtaining the first hash value, which is the SimHash value. By calculating the SimHash value, the computational complexity is reduced, effectively improving search efficiency.

[0038] Step S103: Obtain the second hash value of each of the multiple articles to be recommended, and for each article to be recommended, determine the recommendation level value of the article to be recommended based on all the first hash values ​​and second hash values, wherein the second hash value of the article to be recommended is determined based on the hash value of the keywords in the article to be recommended.

[0039] Optionally, the multiple articles to be recommended can be stored within the target recommendation system or in a database where the target recommendation system can exchange information. For each article to be recommended, the target recommendation system can obtain the keywords of the article, and then calculate the hash value of the keywords using the target hash algorithm described above. The second hash value of the recommended article is then determined by the hash values ​​of all the keywords of the article. For example, the second hash value can be obtained by arranging and combining the hash values ​​of all the keywords of the recommended article.

[0040] Once the second hash value of each article to be recommended is determined, for each article to be recommended, the target recommendation system can either directly calculate the similarity between the first hash value and the second hash value if the first hash value is one, and determine the similarity value as the recommendation degree value, or calculate the Hamming distance between the first hash value and the second hash value, and then determine the recommendation degree value based on the Hamming distance value.

[0041] Optionally, if there are multiple first hash values, the target recommendation system can first process the multiple first hash values ​​to obtain a unique hash value, and then calculate the similarity value or Hamming distance value between the unique hash value and the second hash value to determine the recommendation degree value.

[0042] Step S104: Based on the recommendation degree value of each article to be recommended, determine the target article from the multiple articles to be recommended, and recommend the target article to the target audience.

[0043] Optionally, the target recommendation system can sort all articles to be recommended in descending order of their recommendation strength value, obtaining a sorted list of articles to be recommended. Then, the top M articles to be recommended are identified as target articles and recommended to the target audience. Here, M is a positive integer greater than or equal to 1.

[0044] Based on the scheme defined in steps S101 to S104 above, it can be understood that in this embodiment of the invention, articles are recommended to users based on the relationship between the hash value of the search keyword and the hash value of the article to be recommended. This involves obtaining at least one search keyword sent by the target object for searching for articles, determining the term frequency inverse document frequency (TNF) of each search keyword, calculating the first hash value of each search keyword using a target hash algorithm, obtaining the second hash value of each article to be recommended, and determining the recommendation level value of each article based on all the first and second hash values. Thus, based on the magnitude of the recommendation level value of each article to be recommended, a target article is determined from the multiple articles to be recommended and recommended to the target object. Specifically, the target hash algorithm calculates the initial hash value of the search keyword based on the TNF of the search keyword to obtain the first hash value, and the second hash value of the article to be recommended is determined based on the hash values ​​of the keywords in the article to be recommended.

[0045] It is noteworthy that, in the above process, by obtaining at least one search keyword sent by the target user for searching articles, the target user's current interests are effectively determined. This avoids the phenomenon in related technologies where collaborative filtering relies solely on the relationship between users and items or between items, thus failing to effectively determine the target user's current preferences when the relationship changes. Furthermore, by calculating the first hash value of each search keyword and determining the second hash value of the article to be recommended based on the hash values ​​of the keywords in the article, the content of both the search keywords and the content of the article to be recommended is effectively extracted. Even further, by determining the recommendation level value of the article to be recommended based on all the first and second hash values, the recommendation level of the article to be recommended is determined based on the relationship between the search content and the content to be recommended, thereby achieving accurate determination of the recommendation level value and improving the accuracy of article recommendations to users.

[0046] Therefore, the solution provided in this application achieves the goal of recommending articles to users based on the relationship between the hash value of search keywords and the hash value of the articles to be recommended, thereby improving the technical effect of recommendation accuracy and solving the technical problem of low recommendation accuracy in related technologies.

[0047] In one optional embodiment, during the process of obtaining at least one search keyword sent by the target object for searching articles, the target recommendation system can obtain the search information sent by the target object, and then, if the search information is a search term, determine the search term as the search keyword; if the search information is an article used for searching, extract at least one search keyword from the article used for searching. Here, the search information is either a search term or an article used for searching.

[0048] Optionally, if the search information input by the target object is a search term, then a search term is directly identified as a search keyword. If the search information input by the target object is an article used for searching, the target recommendation system can perform word segmentation on the article used for searching to obtain multiple search terms, and then calculate the term frequency inverse document frequency (TNF) of the obtained search terms. The TNF of a search term is the number of times the search term appears in the article used for searching divided by the total number of words in the article used for searching. When calculating the TNF of a search term, the total number of texts can be assumed to be the number of articles used for searching input by the target object, which is 1. Optionally, the total number of articles to be recommended and the number of articles used for searching can be used as the total number of texts. Then, the total number of texts can be divided by the number of articles containing the aforementioned search term to obtain a value. The logarithm of this value is then taken to obtain the TNF of the search term. Articles containing the aforementioned search term refer to both the articles to be recommended and the articles used for searching that contain the aforementioned search term.

[0049] Furthermore, the target recommendation system can identify the top P search terms with the highest inverse document frequency (IVF) in the article used for searching as search keywords, thereby enabling the extraction of at least one search keyword, and the IVF of the search term can be identified as the IVF of the search keyword.

[0050] It should be noted that through the above process, the target recommendation system can effectively extract search keywords when users enter search terms or articles for searching, thus providing users with more input options and making the search process more flexible.

[0051] In an optional embodiment, when the search information is a search term, in the process of determining the term frequency inverse document frequency (TNF) of each search term, the target recommendation system can form a text composed of all keywords, and for each search term, determine the TNF of the search term based on the text.

[0052] Optionally, since calculating the term frequency (TNF) and inverse document frequency (IVF) of search keywords requires text information, in this embodiment, when the user inputs search keywords, the target recommendation system can default to a text composed of all keywords. Then, for each search keyword, the search keyword is determined by dividing the number of times it appears in the text by the total number of words in the text. When calculating the IVF of search keywords, the total number of texts can be assumed to be the number of texts composed of all keywords, which is 1. Optionally, the total number of articles to be recommended and the number of texts composed of all keywords can be summed to determine the total number of texts. Then, the total number of texts can be divided by the number of texts containing the search keywords to obtain a value. Taking the logarithm of this value yields the IVF of the search keyword. Articles containing the search keyword refer to articles to be recommended that contain the search keyword and the texts composed of all keywords. This achieves the determination of the term frequency and IVF of search keywords.

[0053] It should be noted that the above process enables the accurate determination of the inverse document frequency (IVF) of the search keywords.

[0054] In one optional embodiment, during the calculation of the first hash value of the search keyword using the target hash algorithm, the target recommendation system can utilize information digest method to perform hash calculation on the search keyword to obtain an initial hash value. Then, for each bit in the initial hash value, the calculation method corresponding to the current bit value is determined based on the current bit's value. Next, the current bit value is calculated according to the calculation method to obtain the initial value corresponding to the current bit. Then, based on the relationship between the initial value of the current bit and 0, the assignment value used to assign a value to the current bit is determined, and the current bit is assigned a value according to the assignment value to obtain the target value corresponding to the current bit. Thus, the target values ​​corresponding to each bit are combined to obtain the first hash value. The initial hash value is binary, and the calculation method is one of the following: adding the current bit value to the inverse document frequency (IVF) of the search keyword, or subtracting the current bit value from the IVF of the search keyword.

[0055] Optionally, after determining the search keywords, the target recommendation system can assign a unique encoding identifier to each keyword. Different words will have different encoding identifiers, and each word's encoding identifier is unique. The correspondence between words and encoding identifiers can be preset by the target recommendation system; for example, the encoding identifier for "I" is 1, and the encoding identifier for "you" is 2. Then, the target recommendation system can use information digest methods to hash the encoding identifiers matching the search keywords to obtain an initial hash value. Optionally, the target recommendation system can also directly use information digest methods to hash the text content of the search keywords to obtain an initial hash value.

[0056] Furthermore, for each bit in the obtained initial hash value, the target recommendation system can add the value of the current bit to the inverse document frequency of the search keyword if the value of the current bit is 1, and subtract the value of the current bit from the inverse document frequency of the search keyword if the value of the current bit is 0, thereby obtaining the initial value corresponding to the current bit.

[0057] Furthermore, after determining the initial value of each bit in the initial hash value, for each bit, if the initial value of the current bit is greater than 0, the value used to assign the current bit is determined to be 1; conversely, if the initial value of the current bit is less than or equal to 0, the value used to assign the current bit is determined to be 0. Then, the target recommendation system can assign a value to the current bit based on the determined value to obtain the target value corresponding to the current bit.

[0058] Optionally, the target recommendation system can then combine the target values ​​corresponding to each digit to obtain the first hash value. For example, if the target value of the first digit is 1, the target value of the second digit is 0, the target value of the third digit is 0, and the target value of the fourth digit is 1, then the corresponding first hash value is 1001.

[0059] It should be noted that the above process enables the accurate determination of the first hash value.

[0060] In one optional embodiment, the second hash value of each article to be recommended can be determined as follows: For each article to be recommended, N keywords in the article are identified, and the importance value of each keyword is determined; the hash value of the keywords is calculated using a target hash algorithm; the hash values ​​of the N keywords are sorted according to their importance values, and the sorted hash values ​​are combined to obtain the second hash value of the article to be recommended. Here, N is a positive integer greater than 1.

[0061] Optionally, the keywords in the article to be recommended can be preset, or determined by the target recommendation system based on the inverse document frequency (IVF) of the words in the article. Furthermore, the importance value of the keywords can be preset, or determined by the target recommendation system based on the IVF of the keywords.

[0062] Furthermore, the target recommendation system can calculate the hash value of keywords using the target hash algorithm described above. The process of determining the hash value of keywords is the same as the process of determining the first hash value, so it will not be repeated here. Going further, the target recommendation system can sort the hash values ​​of N keywords in descending order of importance, and then combine the sorted hash values ​​to obtain the second hash value of the article to be recommended. For example, if the highest importance hash value is 1000, the second highest is 1001, and the lowest is 0000, then the combined second hash value is 100010010000.

[0063] It should be noted that, through the above process, on the one hand, the computational cost of the second hash value of the article to be recommended is reduced, and on the other hand, it is ensured that the second hash value can accurately reflect the information characteristics of the article to be recommended, thereby facilitating the improvement of recommendation accuracy.

[0064] In one optional embodiment, in the process of determining N keywords in the article to be recommended and determining the importance value of each keyword, the target recommendation system can perform word segmentation on the article to be recommended to obtain multiple words. Then, for each word, the inverse document frequency (IVF) of the word is calculated based on the multiple articles to be recommended. Next, the multiple words are sorted in descending order of the IVF values ​​of each word to obtain sorted words. The top N words in the sorted words are then determined as N keywords, and the IVF of the keywords is determined as the importance value of the keywords.

[0065] Optionally, for each article to be recommended, if the article is in Chinese, the target recommendation system can use the jieba word segmentation tool to segment the article, obtaining multiple word segments. Then, each word segment is assigned an encoding identifier, and the frequency of its occurrence in the article is determined. Afterward, a bag-of-words (BODY) corresponding to the article is generated based on the encoding identifiers of all word segments and their frequencies in the article. The BODY records the encoding identifiers of each word segment, their frequencies in the article, and the correspondence between them.

[0066] Optionally, for each article to be recommended, if the article is in English, the target recommendation system can perform word segmentation. Word segmentation includes the following three steps: 1. Obtaining word groups based on spaces, symbols, or paragraphs; 2. Excluding stop words like "a," "an," "the," and "is," which have no actual meaning in the sentence; 3. Stemming and lemmatization. English words have -ing and -ed inflections, and complex singular and plural forms. For example, "eating" and "eat," "tree" and "trees," and "think" and "thought" are actually the same word. Therefore, they should be treated as the same word when calculating relevance. Stemming is used to combine different forms of a word, i.e., lemmatization, to improve the efficiency of text processing. Lexical reconstruction is used to restore any form of a word to its general form, such as restoring the past tense and plural to their general forms. Furthermore, the target recommendation system assigns an encoding identifier to each segmented word and determines the number of times the segmented word appears in the article to be recommended. Then, based on the encoding identifiers of all segments and the number of times the segmented word appears in the article to be recommended, a bag of words corresponding to the article to be recommended is generated. The bag of words records the encoding identifiers of each segmented word, the number of times the segmented word appears in the article to be recommended, and the correspondence between the two.

[0067] Furthermore, after obtaining the bag-of-words, for each word segment in the bag, the target recommendation system can divide the number of times that word appears in the corresponding article to be recommended by the total number of all words in that article to be recommended, thus obtaining the word frequency. The target recommendation system can divide the total number of articles to be recommended by the number of articles containing that word to be recommended, obtaining a value, and then take the logarithm of this value to obtain the corresponding inverse document frequency (IVF). Further, the target recommendation system can multiply the aforementioned word frequency and IVF to obtain the word frequency-inverse document frequency (IF-IDF) of that word segment. In determining the IF-IDF of a word segment, the target recommendation system can utilize the IF-TDF calculation function `TfidfModel()` in the `gensim.models` library to calculate the IF-IDF of the word segment based on the aforementioned bag-of-words, thereby improving the calculation efficiency of the word frequency-inverse document frequency.

[0068] Optionally, since the higher the inverse document frequency (IVF) value of a word segment, the higher its information value, after obtaining the IVF of each word in a certain article to be recommended, the target recommendation system can determine N keywords from multiple word segments based on the IVF of the word segments, and determine the importance value of each keyword.

[0069] It should be noted that the above process enables the accurate identification of keywords in the recommended articles and the accurate determination of the importance value of the keywords, thereby further improving the accuracy of article recommendations.

[0070] In an optional embodiment, during the process of determining the recommendation level of the article to be recommended based on all first hash values ​​and second hash values, the target recommendation system can, if the search keyword is only one, determine whether the string lengths of the first hash value and the second hash value are equal. If the string lengths are not equal, the system pads the last digit of the shorter hash value between the first and second hash values ​​to obtain a third hash value. Then, it calculates the Hamming distance between the first target hash value and the third hash value to obtain the first Hamming distance value, and determines the recommendation level of the article to be recommended based on the first Hamming distance value. The first target hash value is the unpadded hash value between the first and second hash values.

[0071] Hamming distance is a metric used to measure the difference between two strings of equal length. It represents the number of distinct characters at the same position in both strings. In other words, the Hamming distance is the number of bits that need to be flipped to make the two strings equal. For example, if one string is "1001" and the other is "1111", the Hamming distance between them is 2. Conversely, if one string is "1000" and the other is "1100", the Hamming distance is 1.

[0072] Optionally, when there is only one search keyword, for each article to be recommended, the target recommendation system can determine whether the string lengths of the first hash value of the search keyword and the second hash value of the article to be recommended are equal. If they are equal, the Hamming distance between the first hash value and the second hash value can be directly calculated. Then, the recommendation degree value of the article to be recommended can be determined based on the obtained Hamming distance value. Since the smaller the Hamming distance, the smaller the difference between the two compared strings, the obtained Hamming distance value is negatively correlated with the recommendation degree value of the article to be recommended.

[0073] Optionally, if the string lengths of the first hash value and the second hash value are not equal, then the shorter hash value is padded with zeros to obtain the third hash value. For example, if the first hash value is "1000" and the second hash value is "101111", then the last bit of the first hash value is padded with zeros to make the third hash value equal in length to the second hash value, i.e., the third hash value is "100000". The second hash value can then be determined as the first target hash value. The Hamming distance between the first target hash value and the third hash value is then calculated to obtain the first Hamming distance value. The recommendation level of the article to be recommended is determined based on the first Hamming distance value. The first Hamming distance value is negatively correlated with the recommendation level of the article to be recommended.

[0074] It should be noted that, based on the above process, the degree of correlation between search information and information to be recommended is quantified using Hamming distance, thereby making the recommendation degree value of the article to be recommended determined based on the first Hamming distance value more accurate, and thus facilitating the improvement of the accuracy of article recommendation.

[0075] In an optional embodiment, during the process of determining the recommendation level of the article to be recommended based on all first hash values ​​and second hash values, the target recommendation system can, when there are multiple search keywords, sort the first hash values ​​of the multiple search keywords in the order in which they were obtained, and combine the sorted first hash values ​​to obtain a fourth hash value. Then, it determines whether the string lengths of the fourth hash value and the second hash value are equal. If the string lengths are unequal, it performs a padding operation on the end of the shorter hash value in the fourth and second hash values ​​to obtain a fifth hash value. Then, it calculates the Hamming distance between the second target hash value and the fifth hash value to obtain a second Hamming distance value. Finally, it determines the recommendation level of the article to be recommended based on the second Hamming distance value. The second target hash value is the unpadded hash value between the fourth and second hash values.

[0076] For example, if the search keywords include "plant", "animal", and "human", the first hash value for "plant" is "1011", the first hash value for "animal" is "1001", and the hash value for "human" is "0000", and the target object enters the search keywords in the order of "plant", "human", and "animal", then the sorted first hash value is "1011", "0000", and "1001", and the fourth hash value is "101100001001". The order in which the target object enters the search keywords is the order in which the target recommendation system obtains multiple search keywords.

[0077] Furthermore, the target recommendation system can directly calculate the Hamming distance between the fourth hash value and the second hash value when the string lengths are the same, and determine the recommendation degree value of the article to be recommended based on the obtained Hamming distance value. Here, the obtained Hamming distance value is set to be negatively correlated with the recommendation degree value of the article to be recommended.

[0078] Optionally, if the string lengths of the fourth hash value and the second hash value are not equal, then the last bit of the shorter hash value is padded to obtain the fifth hash value. The method for obtaining the fifth hash value is the same as that for obtaining the third hash value, so it will not be elaborated here. Further, the target recommendation system can determine the second Hamming distance value by referring to the method used to determine the first Hamming distance value, and determine the recommendation strength value of the article to be recommended based on the second Hamming distance value. The second Hamming distance value is negatively correlated with the recommendation strength value of the article to be recommended.

[0079] It should be noted that, based on the above process, the degree of correlation between search information and information to be recommended is quantified using Hamming distance, thereby making the recommendation degree value of the article to be recommended determined by the second Hamming distance value more accurate, and thus facilitating the improvement of the accuracy of article recommendation.

[0080] In one alternative embodiment, Figure 2 This is a schematic diagram of an optional article recommendation method according to an embodiment of the present invention, such as... Figure 2 As shown, an application process of the article recommendation method in this embodiment is explained. Figure 2 As shown, the target recommendation system can acquire multiple articles to be recommended, and then preprocess these articles to obtain multiple word segments corresponding to each article. Next, for each article, the target recommendation system calculates the term frequency inverse document frequency (TNF) of the word segments in that article, then determines the keywords of the article based on the TNF, and determines the second hash value of the article based on the hash value of the keywords. Further, the target recommendation system can receive at least one search keyword sent by the target object, determine the first hash value of each search keyword, then determine a unique search hash value based on all the first hash values, and calculate the Hamming distance between this unique search hash value and the second hash value of each article to be recommended. Finally, the target recommendation system determines the target article from the multiple articles to be recommended based on the Hamming distance values.

[0081] Therefore, the solution provided in this application achieves the goal of recommending articles to users based on the relationship between the hash value of search keywords and the hash value of the articles to be recommended, thereby improving the technical effect of recommendation accuracy and solving the technical problem of low recommendation accuracy in related technologies.

[0082] Example 2

[0083] According to an embodiment of the present invention, an embodiment of an article recommendation device is provided, wherein, Figure 3 This is a schematic diagram of an optional article recommendation device according to an embodiment of the present invention, such as... Figure 3 As shown, the device includes:

[0084] The first acquisition module 301 is used to acquire at least one search keyword sent by the target object for searching articles, and to determine the term frequency inverse document frequency of each search keyword;

[0085] The first calculation module 302 is used to calculate the first hash value of each search keyword using a target hash algorithm. The target hash algorithm calculates the first hash value by processing the initial hash value of the search keyword based on the term frequency inverse document frequency of the search keyword.

[0086] The second acquisition module 303 is used to acquire the second hash value of each of the multiple articles to be recommended, and for each article to be recommended, determine the recommendation degree value of the article to be recommended based on all the first hash values ​​and second hash values, wherein the second hash value of the article to be recommended is determined based on the hash value of the keywords in the article to be recommended;

[0087] The first determining module 304 is used to determine the target article from multiple articles to be recommended based on the recommendation degree value of each article to be recommended, and to recommend the target article to the target object.

[0088] It should be noted that the first acquisition module 301, the first calculation module 302, the second acquisition module 303 and the first determination module 304 mentioned above correspond to steps S101 to S104 in the above embodiments. The four modules and the corresponding steps implement the same examples and application scenarios, but are not limited to the content disclosed in the above embodiment 1.

[0089] Optionally, the first acquisition module 301 further includes: a first acquisition submodule, used to acquire search information sent by the target object, wherein the search information is a search term or an article used for searching; a first determination submodule, used to determine the search term as a search keyword when the search information is a search term; and a second determination submodule, used to extract at least one search keyword from the article used for searching when the search information is an article used for searching.

[0090] Optionally, the first acquisition module 301 further includes: a processing submodule for forming text from all keywords; and a third determination submodule for determining the term frequency inverse document frequency of each search keyword based on the text.

[0091] Optionally, the first calculation module 302 further includes: a first calculation submodule, used to perform hash calculation on the search keywords using the information digest method to obtain an initial hash value, wherein the initial hash value is binary; a fourth determination submodule, used to determine the calculation method corresponding to the value of the current bit for each bit in the initial hash value, based on the magnitude of the current bit value, wherein the calculation method is one of the following: adding the value of the current bit to the inverse document frequency of the search keyword, or subtracting the value of the current bit from the inverse document frequency of the search keyword; a second calculation submodule, used to perform calculation processing on the value of the current bit according to the calculation method to obtain the initial value corresponding to the current bit; a fifth determination submodule, used to determine the assignment value for assigning to the current bit based on the magnitude relationship between the initial value of the current bit and 0, and to perform assignment processing on the current bit according to the assignment value to obtain the target value corresponding to the current bit; and a first combination submodule, used to combine the target values ​​corresponding to each bit to obtain the first hash value.

[0092] Optionally, the article recommendation device further includes: a second determining module, used to determine N keywords in each article to be recommended, and determine the importance value of each keyword, where N is a positive integer greater than 1; a second calculating module, used to calculate the hash value of the keywords using a target hash algorithm; and a combining module, used to sort the hash values ​​of the N keywords according to their importance values, and combine the sorted hash values ​​to obtain the second hash value of the article to be recommended.

[0093] Optionally, the second determining module further includes: a word segmentation submodule, used to segment the articles to be recommended into multiple words; a third calculation submodule, used to calculate the inverse document frequency (IVF) of each word based on the multiple articles to be recommended; a sorting submodule, used to sort the multiple words in descending order of their IVF values ​​to obtain sorted words; and a sixth determining submodule, used to determine the top N words from the sorted words as N keywords, and to determine the IVF of the keywords as the importance value of the keywords.

[0094] Optionally, the second acquisition module 303 further includes: a first judgment submodule, used to determine whether the string lengths of the first hash value and the second hash value are equal when there is only one search keyword; a first padding submodule, used to pad the last bit of the shorter hash value in the first hash value and the second hash value when the string lengths are not equal, to obtain a third hash value; a fourth calculation submodule, used to calculate the Hamming distance between the first target hash value and the third hash value, to obtain a first Hamming distance value, wherein the first target hash value is the unpadded hash value in the first hash value and the second hash value; and a seventh determination submodule, used to determine the recommendation degree value of the article to be recommended based on the first Hamming distance value.

[0095] Optionally, the second acquisition module 303 further includes: a second combination submodule, used to sort the first hash values ​​of multiple search keywords according to the order in which the multiple search keywords are acquired, and combine the sorted first hash values ​​to obtain a fourth hash value; a second judgment submodule, used to determine whether the string lengths of the fourth hash value and the second hash value are equal; a second padding submodule, used to pad the last bit of the shorter hash value in the fourth hash value and the second hash value when the string lengths are not equal, to obtain a fifth hash value; a fifth calculation submodule, used to calculate the Hamming distance between the second target hash value and the fifth hash value to obtain a second Hamming distance value, wherein the second target hash value is the unpadded hash value in the fourth hash value and the second hash value; and an eighth determination submodule, used to determine the recommendation degree value of the article to be recommended based on the second Hamming distance value.

[0096] Example 3

[0097] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, wherein the computer program is configured to execute the above-described article recommendation method at runtime.

[0098] Example 4

[0099] According to another aspect of the present invention, an electronic device is also provided, wherein, Figure 4 This is a schematic diagram of an optional electronic device according to an embodiment of the present invention, such as... Figure 4 As shown, the electronic device includes one or more processors; and a memory for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to run the programs, wherein the programs are configured to execute the methods recommended in the article above during runtime.

[0100] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0101] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0102] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between units or modules may be electrical or other forms.

[0103] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0104] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0105] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0106] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. An article recommendation method characterized by comprising: include: Obtain at least one search keyword sent by the target object for searching articles, and determine the term frequency inverse document frequency of each search keyword; For each search keyword, a first hash value of the search keyword is calculated using a target hash algorithm, wherein the target hash algorithm calculates the first hash value by processing the initial hash value of the search keyword based on the term frequency inverse document frequency of the search keyword; Obtain the second hash value of each of the multiple articles to be recommended, and for each article to be recommended, determine the recommendation degree value of the article to be recommended based on all the first hash values ​​and the second hash values, wherein the second hash value of the article to be recommended is determined based on the hash values ​​of the keywords in the article to be recommended; Based on the recommendation strength value of each article to be recommended, a target article is determined from the plurality of articles to be recommended, and the target article is recommended to the target object; Based on all the first hash values ​​and the second hash values, the recommendation level value of the article to be recommended is determined, including: When there are multiple search keywords, the first hash values ​​of the multiple search keywords are sorted according to the order in which they were obtained, and the sorted first hash values ​​are combined to obtain a fourth hash value. Determine whether the string lengths of the fourth hash value and the second hash value are equal; If the string lengths are not equal, the last bit of the shorter string in the fourth hash value and the second hash value is padded to obtain the fifth hash value; Calculate the Hamming distance between the second target hash value and the fifth hash value to obtain the second Hamming distance value, wherein the second target hash value is the fourth hash value and the unpadded hash value of the second hash value; The recommendation level of the article to be recommended is determined based on the second Hamming distance value.

2. The method of claim 1, wherein, Obtain at least one search keyword sent by the target object for searching articles, including: Obtain the search information sent by the target object, wherein the search information is a search term or an article used for searching; If the search information is the search term, then the search term is determined as the search keyword; If the search information is the article used for searching, then at least one search keyword is extracted from the article used for searching.

3. The method of claim 2, wherein, When the search information is the search term, determining the term frequency inverse document frequency (TNF) of each search keyword includes: The text consists of all the keywords; For each search keyword, the inverse document frequency (IVF) of the search keyword is determined based on the text.

4. The method of claim 1, wherein, The first hash value of the search keyword is calculated using a target hash algorithm, including: The search keywords are hashed using the information digest method to obtain the initial hash value, wherein the initial hash value is binary; For each bit in the initial hash value, the calculation method corresponding to the value of the current bit is determined according to the value of the current bit, wherein the calculation method is one of the following: adding the value of the current bit to the inverse document frequency of the search keyword, or subtracting the value of the current bit from the inverse document frequency of the search keyword. The value of the current position is calculated and processed according to the calculation method to obtain the initial value corresponding to the current position; Based on the relationship between the initial value of the current bit and 0, determine the assignment value to be assigned to the current bit, and perform the assignment process on the current bit according to the assignment value to obtain the target value corresponding to the current bit. Combine each corresponding target value to obtain the first hash value.

5. The method of claim 1, wherein, The second hash value of each article to be recommended is determined in the following way: For each article to be recommended, N keywords in the article to be recommended are determined, and the importance value of each keyword is determined, where N is a positive integer greater than 1; The hash value of the keyword is calculated using the target hash algorithm; The hash values ​​of the N keywords are sorted according to their importance values, and the sorted hash values ​​are combined to obtain the second hash value of the article to be recommended.

6. The method according to claim 5, characterized in that, Identify N keywords from the articles to be recommended, and determine the importance value of each keyword, including: The article to be recommended is segmented into multiple words. For each word segment, the inverse document frequency (IVF) of the word segment is calculated based on the multiple articles to be recommended. The multiple word segments are sorted in descending order of their inverse document frequency (IVF) values ​​to obtain sorted word segments. The first N words from the sorted word segments are determined as the N keywords, and the inverse document frequency of the keyword is determined as the importance value of the keyword.

7. The method according to claim 1, characterized in that, Based on all the first hash values ​​and the second hash values, the recommendation level value of the article to be recommended is determined, including: If there is only one search keyword, determine whether the string lengths of the first hash value and the second hash value are equal; If the string lengths are not equal, the last bit of the shorter string in the first hash value and the second hash value is padded to obtain the third hash value; Calculate the Hamming distance between the first target hash value and the third hash value to obtain the first Hamming distance value, wherein the first target hash value is the unpadded hash value between the first hash value and the second hash value; The recommendation level of the article to be recommended is determined based on the first Hamming distance value.

8. An article recommendation device, characterized in that, For performing the method according to any one of claims 1 to 7, comprising: The first acquisition module is used to acquire at least one search keyword sent by the target object for searching articles, and to determine the term frequency inverse document frequency of each search keyword; The first calculation module is used to calculate the first hash value of each search keyword using a target hash algorithm, wherein the target hash algorithm calculates the first hash value by processing the initial hash value of the search keyword based on the term frequency inverse document frequency of the search keyword. The second acquisition module is used to acquire the second hash value of each of the multiple articles to be recommended, and for each article to be recommended, determine the recommendation degree value of the article to be recommended based on all the first hash values ​​and the second hash values, wherein the second hash value of the article to be recommended is determined based on the hash values ​​of the keywords in the article to be recommended; The first determining module is used to determine the target article from the plurality of articles to be recommended based on the recommendation degree value of each article to be recommended, and to recommend the target article to the target object.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the article recommendation method according to any one of claims 1 to 7 when it is run.

10. An electronic device, characterized in that, The electronic device includes one or more processors; A memory for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to be configured to run the programs, wherein the programs are configured to execute the article recommendation method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Text comparison method based on synonymous related words

    CN107908622A

  • Document processing method and device, processor and electronic equipment

    CN114840735A

  • Data request anti-duplication method and device, electronic equipment and storage medium

    CN114860712A