Chinese search optimization method and device
By building a preset reference dictionary and a custom analyzer, we optimized the Chinese search process in Elasticsearch, solving the problems of inaccurate Chinese text segmentation and low relevance of search results, and improving search efficiency and accuracy.
Patent Information
- Application Number
- CN202510699459.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-09-16
AI Technical Summary
Elasticsearch results in inaccurate word segmentation of Chinese text when performing Chinese searches, resulting in low relevance of search results.
By building a preset reference dictionary, the text to be recognized is segmented based on the accuracy of the segmentation, a correspondence between each reference field and the reference index is established, and query results are generated based on the query conditions. A custom analyzer is used to optimize the Chinese search process.
It improves the efficiency and relevance of Chinese text searches and solves the problem of inaccurate Chinese text word segmentation affecting search results.
Smart Images

Figure CN120653732A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of search engines, and in particular to a Chinese search optimization method and device. Background Art
[0002] Elasticsearch is a distributed, highly scalable, and highly real-time search and data analytics engine. It easily enables search, analysis, and exploration of large amounts of data. Leveraging Elasticsearch's horizontal scalability makes data more valuable in production environments. Elasticsearch's implementation primarily involves the following steps: First, users submit data to the Elasticsearch database. The tokenizer controller then tokenizes the corresponding sentence, storing its weights and the tokenized results in the database. When users search for data, the results are ranked and scored based on their weights, and the returned results are presented to the user. Custom analyzers are a powerful feature in Elasticsearch, allowing users to preprocess, tokenize, and filter text data according to specific requirements. Custom analyzers consist of three parts: character filters, tokenizers, and token filters. These components work in a specific order to generate the final search index or query results. However, when searching Chinese text in Elasticsearch, this can lead to inaccurate token segmentation and low relevance in search results. Summary of the Invention
[0003] The present invention is proposed to solve the above technical problems. The embodiments of the present invention provide a Chinese search optimization method and device, which can solve the problems of inaccurate Chinese text segmentation and low relevance of search results when performing Chinese search in Elasticsearch.
[0004] According to one aspect of the present invention, a Chinese search optimization method is provided, comprising:
[0005] Get the text to be recognized input by the user;
[0006] Based on a preset reference dictionary, an index corresponding to the text to be recognized is determined; wherein the method for constructing the preset reference dictionary includes:
[0007] Get reference text;
[0008] Determine the level of precision of word segmentation;
[0009] Based on the accuracy of the word segmentation, the reference text is segmented to obtain a plurality of reference fields;
[0010] Constructing a correspondence between each reference field and a reference index to obtain the preset reference dictionary;
[0011] Constructing query conditions based on the index and logical words;
[0012] Based on the query conditions, a query result corresponding to the text to be recognized is generated.
[0013] In one embodiment, segmenting the reference text based on the accuracy of the segmentation to obtain multiple reference fields includes:
[0014] If the accuracy of the word segmentation is the first accuracy, the reference text is segmented based on the reading order of the reference text and the meanings of the words in the reference text to obtain a plurality of reference fields.
[0015] In one embodiment, the Chinese search optimization method further includes:
[0016] If the word segmentation accuracy is a second accuracy, determining the longest length of the reference text; wherein the second accuracy is less than the first accuracy;
[0017] Determining the meaning of the reference text based on the longest length;
[0018] If the meaning of the reference text satisfies the first preset meaning, the field corresponding to the reference text is determined to be a reference field.
[0019] In one embodiment, the Chinese search optimization method further includes:
[0020] If the meaning of the reference text does not satisfy the preset meaning, reducing the maximum length to obtain an adjusted length;
[0021] Based on the adjusted length, determining a cutoff text corresponding to the start and end positions to the cutoff position in the reference text;
[0022] If the meaning of the cutoff text satisfies the second preset meaning, the field corresponding to the cutoff text is determined as a reference field.
[0023] In one embodiment, the Chinese search optimization method further includes:
[0024] Get the remaining text;
[0025] If the remaining text satisfies the third preset word meaning, it is determined that the multiple reference fields include a field corresponding to the remaining text and a field corresponding to the cutoff text.
[0026] In one embodiment, constructing a correspondence between each reference field and a reference index includes:
[0027] Determining a field language corresponding to the reference field;
[0028] If the field language is the default field language, changing the language format of the reference field;
[0029] Build a correspondence between the changed reference fields and the reference index.
[0030] In one embodiment, generating a query result corresponding to the text to be recognized based on the query condition includes:
[0031] Based on the query condition, documents that meet the query condition are screened; wherein the query result includes the document.
[0032] In one embodiment, after determining the index corresponding to the text to be recognized based on a preset reference dictionary, the Chinese search optimization method further includes:
[0033] If there is a target field in the text to be recognized that cannot be matched with the preset reference dictionary, obtaining the target word meaning corresponding to the target field;
[0034] Obtaining a reference word meaning corresponding to a reference field in the preset reference dictionary;
[0035] Calculating the similarity between the reference word meaning and the target word meaning;
[0036] The index corresponding to the reference word meaning having a similarity greater than a preset similarity is determined as the target index of the target word.
[0037] In one embodiment, constructing a correspondence between each reference field and a reference index to obtain the preset reference dictionary includes:
[0038] Obtaining synonyms corresponding to the reference field;
[0039] Determine the reference applicable scenarios corresponding to the synonyms;
[0040] A correspondence between the reference field, the synonyms corresponding to the reference field, and the reference application scenarios corresponding to the synonyms is constructed to obtain the preset reference dictionary.
[0041] According to another aspect of the present invention, a Chinese search optimization device is provided, comprising:
[0042] The acquisition module is used to obtain the text to be recognized input by the user;
[0043] a determination module, configured to determine an index corresponding to the text to be recognized based on a preset reference dictionary; wherein the method for constructing the preset reference dictionary comprises: obtaining a reference text; determining a degree of word segmentation accuracy; performing word segmentation on the reference text based on the degree of word segmentation accuracy to obtain a plurality of reference fields; and constructing a correspondence between each reference field and a reference index to obtain the preset reference dictionary;
[0044] The query module is used to construct query conditions based on the index and logical words; based on the query conditions, generate query results corresponding to the text to be recognized.
[0045] The Chinese search optimization method and device provided by the present invention include: obtaining the text to be recognized input by the user, and determining the index corresponding to the text to be recognized based on a preset reference dictionary, wherein the method for constructing the preset reference dictionary includes: obtaining the reference text, determining the accuracy of the word segmentation, and based on the accuracy of the word segmentation, segmenting the reference text to obtain multiple reference fields, constructing a correspondence between each reference field and a reference index to obtain a preset reference dictionary, constructing query conditions based on the index and logical words, and generating query results corresponding to the text to be recognized based on the query conditions. The present invention is based on the ElasticSearch Chinese search optimization method of a custom analyzer. Since it uses a custom analyzer to segment Chinese text and optimizes the overall process of storage and query, it solves the problems of inaccurate Chinese text segmentation affecting search results and slow query speed, thereby improving the efficiency of Chinese text search and the relevance of results. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The above and other objects, features, and advantages of the present invention will become more apparent through a more detailed description of the embodiments of the present invention in conjunction with the accompanying drawings. The accompanying drawings are provided to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and are not intended to limit the present invention. In the drawings, the same reference numerals generally represent the same components or steps.
[0047] Figure 1 It is a flowchart of a Chinese search optimization method provided by an exemplary embodiment of the present invention.
[0048] Figure 2 It is a flowchart of a method for establishing a correspondence between each reference field and a reference index provided by an exemplary embodiment of the present invention.
[0049] Figure 3 It is a structural diagram of a Chinese search optimization device provided by an exemplary embodiment of the present invention.
[0050] Figure 4It is a structural diagram of a Chinese search optimization device provided by another exemplary embodiment of the present invention.
[0051] Figure 5 is a structural diagram of an electronic device provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0052] Below, the exemplary embodiments according to the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments of the present invention, and it should be understood that the present invention is not limited to the exemplary embodiments described herein.
[0053] Figure 1 It is a flowchart of a Chinese search optimization method provided by an exemplary embodiment of the present invention.
[0054] like Figure 1 As shown, Chinese search optimization methods include:
[0055] Step 110: Obtain the text to be recognized input by the user.
[0056] In an embodiment of the present invention, a user may input the text to be recognized through a query box or a search box, and reply with an answer corresponding to the text to be recognized through character recognition, intent analysis, etc. of the text to be recognized.
[0057] Step 120: Determine the index corresponding to the text to be recognized based on a preset reference dictionary.
[0058] In an embodiment of the present invention, an index is a logical namespace containing a series of documents. Each document is a series of fields, each consisting of key-value pairs containing data. This structure enables Elasticsearch to efficiently store and search large amounts of structured and unstructured data. The present invention can determine the word segmentation accuracy of the text to be recognized based on user evaluations of historical answers. This accuracy allows for more accurate processing of the text to be recognized, improving search accuracy and performance.
[0059] Specifically, the present invention dynamically selects the accuracy of word segmentation of the text to be recognized by constructing a preset reference dictionary and the user's evaluation of historical answers. First, determine the historical answers in the same field as the text to be recognized. For example, if the field of the text to be recognized is home appliances, then the historical answers should also be related to home appliances. Then, determine the historical questions corresponding to the historical answers, locate multiple target historical questions in the same target time period as the historical questions, and select the first historical question whose time point is earlier than the preset time point from the multiple target historical questions. For example, a user may have asked questions in the same field multiple times on different days of a month, so the present invention needs to locate the user's questions in a continuous time period to prevent questions in other fields from being mixed in with questions within a longer time period. For example, question B is the question input by the user at the next moment after question A.
[0060] Determine whether the field of the first historical question is the same as the field corresponding to the text to be recognized. If they are the same, obtain the number of questions in the target time period. If the number of questions is greater than the preset number, determine that the word segmentation accuracy of the text to be recognized is the first accuracy. If the number of questions is less than the preset number, determine that the word segmentation accuracy of the text to be recognized is the second accuracy. If the field of the first historical question is different from the field corresponding to the text to be recognized, obtain the second historical question at a time point adjacent to the first historical question; wherein, the second historical question is the same as the field of the first historical question and obtain the number of questions from the second historical question to the third historical question. wherein, the third historical question is the question at the final time point in the target time period, and the field of the third historical question is the same as that of the first historical question.
[0061] Among them, the method for constructing a preset reference dictionary includes: obtaining a reference text; determining the accuracy of word segmentation; based on the accuracy of word segmentation, segmenting the reference text to obtain multiple reference fields; constructing a correspondence between each reference field and a reference index to obtain a preset reference dictionary.
[0062] Optionally, consider the cluster's hardware resources and data volume to appropriately configure the number of shards and replicas for your index. Excessive shards increase management complexity, while excessive replicas consume more storage space. Generally speaking, the number of shards should match the number of nodes in your cluster, and the number of replicas should be determined based on the importance of your data and your fault tolerance requirements.
[0063] Sharding involves dividing an index into multiple parts, each called a shard. When properly setting the number of shards, consider the following: The number of shards should match the number of nodes in the cluster. If there are multiple nodes, set the number of shards to a multiple of the number of nodes to ensure load balancing. For example, if there are three nodes, set six shards so that each node can store two shards. The number of shards should also match the amount of data. For indices with large data volumes, increasing the number of shards appropriately can prevent individual shards from becoming too large, thereby improving query performance.
[0064] Replicas are backups of shards, primarily used to improve data availability and fault tolerance. When setting the number of replicas, consider setting a higher number for critical indexes to ensure data availability in the event of a node failure. For example, you can set at least one replica so that if the primary shard fails, you can quickly switch to a replica shard. Increasing the number of replicas can improve query performance because queries can be executed in parallel across multiple replicas. For scenarios with frequent read operations, consider increasing the number of replicas to improve concurrent processing capabilities.
[0065] Optionally, periodically use the Optimize API to optimize the index, consolidate fragments, and free up unused disk space to improve index storage efficiency and search performance. The Optimize API is an application programming interface (API) used to optimize data processing, query performance, or resource utilization.
[0066] Step 130: Construct query conditions based on the index and logical words.
[0067] In an embodiment of the present invention, an appropriate query type is selected according to business needs and data characteristics, such as match query, term query, bool query, etc. For Chinese search, match query can be selected because it can process text fields processed by the analyzer. Match Query is a query type used to perform full-text search. It will analyze the text entered by the user (such as word segmentation, removal of stop words, etc.), and then search for results that match the analyzed terms in the document. Term Query is used to accurately match the specific value of a field and will not analyze the input. This means that it will only find documents that are exactly the same as the given value. Bool Query is a compound query type that allows multiple queries to be combined together and uses Boolean logic (such as AND, OR, NOT) to control the behavior of the query.
[0068] Specifically, the present invention can combine multiple query conditions through Boolean queries to construct complex query logic. By properly setting clauses such as must, should, and must_not, query results can be precisely controlled and unnecessary document scanning can be reduced. Logical terms include must, should, and must_not.
[0069] Optional paging methods include Scroll or Search After. These two methods can more efficiently handle paging queries for large amounts of data, reducing memory and CPU consumption. Scroll is a method for retrieving large-scale query results, particularly suitable for paging and traversing large amounts of data. Search After is a method for deep paging, particularly suitable for sorting result sets.
[0070] Step 140: Generate query results corresponding to the text to be recognized based on the query conditions.
[0071] In the embodiment of the present invention, the documents that meet the query conditions from the multiple documents are the query results. Step 140 may include the following steps:
[0072] Step 141: Based on the query condition, filter the documents that meet the query condition; wherein the query result includes the document.
[0073] For example, suppose there is a database about products, and the index contains the following fields: product name, category, price, rating, and inventory status, as shown in Table 1.
[0074] Table 1 Product database
[0075] Product Name category price score Product A Electronics 100 4.5 Product B Household items 50 4.0 Product C Electronics 150 4.8 Product D Electronics 80 3.5 Product E Household items 30 4.2
[0076] Construct a must (must match condition), for example, it must be an electronic product and the score must be greater than 4. The query results are shown in Table 2.
[0077] Table 2 Query results
[0078] Product Name category price score Inventory Status Product A Electronics 100 4.5 In stock Product C Electronics 150 4.8 In stock
[0079] In one embodiment, step 120 may be specifically implemented as follows: if the accuracy of the word segmentation is the first accuracy, then the reference text is segmented based on the reading order of the reference text and the meaning of the words in the reference text to obtain multiple reference fields.
[0080] In an embodiment of the present invention, the present invention can create a word segmenter and perform word segmentation processing on the word segmenter using a word segmentation method. The present invention can use ik_max_word (the fine-grained word segmentation mode of the IK word segmenter) to segment Chinese text. Specifically, if the word segmentation accuracy is the first accuracy, the meanings of the characters in the reference text are sequentially identified according to the reading order of the reference text to obtain multiple words with meanings; wherein the multiple reference fields include multiple words with meanings.
[0081] In which, it is determined whether the character to be recognized in the reference text has a word meaning. If it does, based on the reading order, it is determined whether there are adjacent characters in the reference text in the direction opposite to the reading order of the character to be recognized. If there are adjacent characters, the number of other adjacent characters in the direction opposite to the reading order is determined. If the number of other characters is 0, it is determined whether the word formed by the character to be recognized and the adjacent characters has a word meaning. If the word formed by the character to be recognized and the adjacent characters has a word meaning, the character to be recognized and the word formed by the character to be recognized and the adjacent characters are obtained; wherein, the reference field includes the character to be recognized and the word formed by the character to be recognized and the adjacent characters. If the number of other characters is greater than 0, it is determined whether the other characters, the adjacent characters, and the word formed by the character to be recognized have a word meaning. If the other characters and the word formed by the character to be recognized and the adjacent characters have a word meaning, the character to be recognized and the other characters, and the word formed by the character to be recognized and the adjacent characters are obtained; wherein, the reference field includes the recognized character and the other characters, and the word formed by the character to be recognized and the adjacent characters.
[0082] In the present invention, if there are multiple other characters, then the other words, adjacent characters, and the word to be recognized are added in sequence. For example, ABCD, D is the character to be recognized, C is the adjacent character, first recognize the meaning of the word composed of BCD, and then recognize the meaning of the word composed of ABCD.
[0083] It can be understood that the present invention traverses from the first character to determine whether the first character has a meaning. If so, the first character is a reference field. Then, it is determined whether the second character has a meaning. If so, the second character is a reference field. It is determined whether the word formed by the first and second characters has a meaning. If so, the word formed by the first and second characters is a reference field. This process is repeated until all characters in the reference text are recognized.
[0084] In one embodiment, step 120 can be specifically implemented as follows: if the accuracy of the word segmentation is the second accuracy, determining the longest length of the reference text; wherein the second accuracy is less than the first accuracy; based on the longest length, determining the meaning of the reference text; if the meaning of the reference text satisfies the first preset meaning, determining the field corresponding to the reference text as the reference field.
[0085] In an embodiment of the present invention, the present invention can use ik_smart (the intelligent segmentation mode of the IK segmenter) to segment text with the second level of segmentation accuracy. Specifically, the longest length of the reference text is first determined, which is the number of characters in the reference text. If the reference text with the longest length has a word meaning, then the reference text is considered a reference field.
[0086] In one embodiment, step 120 can be specifically implemented as follows: based on the adjusted length, determining the cutoff text corresponding to the start and end positions to the end position in the reference text; if the meaning of the cutoff text meets the second preset meaning, determining the field corresponding to the cutoff text as the reference field.
[0087] In the embodiment of the present invention, "word meaning" refers to the significance or implication of a word. It relates to the content and concept expressed by a word in a specific context. If the longest reference text does not have word meaning, then characters are reduced in the reverse direction of the reading order, and it is determined whether the text after the characters are reduced has word meaning. If so, the reduced characters and the text after the characters are reduced are used as reference fields.
[0088] In one embodiment, step 120 may be specifically implemented as follows: obtaining the remaining text; if the remaining text satisfies the third preset word meaning, determining that the multiple reference fields include a field corresponding to the remaining text and a field corresponding to the cutoff text.
[0089] In an embodiment of the present invention, if it does not have a word meaning, then the words are reduced again, and the currently reduced words and the words reduced last time are combined into a word and it is determined whether it has a word meaning. If it has a word meaning and the text after the words are reduced has a word meaning, then the currently reduced words and the words reduced last time are combined into a word and the text after the words are reduced is the reference field.
[0090] Figure 2 FIG. 1 is a flow chart of a method for constructing a corresponding relationship between each reference field and a reference index provided by an exemplary embodiment of the present invention. Figure 2 As shown, step 120 may include:
[0091] Step 121: Determine the field language corresponding to the reference field.
[0092] In an embodiment of the present invention, it is identified whether English letters or letters of other languages are present in the reference field. In addition, the present invention can construct a word segmentation filter, such as lowercase conversion (although Chinese is not case-sensitive, it may be used to handle situations where English is mixed), stop word filtering (creating a stop word list and configuring it in the word segmentation filter to remove common meaningless words in the text), synonym replacement (creating a synonym dictionary as needed and configuring it in the word segmentation filter to achieve replacement or merging of synonyms), etc., all of which run on the word segmentation filter.
[0093] Step 122: If the field language is the default field language, change the language format of the reference field.
[0094] In an embodiment of the present invention, the preset field language includes English, Japanese, Korean, etc. If the field language is the preset field language, the uppercase letters in the reference field are changed to lowercase letters.
[0095] Step 123: Construct a correspondence between the changed reference field and the reference index.
[0096] In one embodiment, after step 120, the Chinese search optimization method may be specifically implemented as follows: if there is a target field in the text to be recognized that cannot be matched with the preset reference dictionary, obtaining a target word meaning corresponding to the target field; obtaining a reference word meaning corresponding to a reference field in the preset reference dictionary;
[0097] Calculate the similarity between the reference word meaning and the target word meaning; determine the index corresponding to the reference word meaning whose similarity is greater than the preset similarity as the target index of the target word.
[0098] In an embodiment of the present invention, if, during word segmentation of a text to be recognized, a target field exists in the text to be recognized that cannot be matched with a preset reference dictionary, a target word meaning corresponding to the target field and a reference word meaning corresponding to a reference field in the preset reference dictionary are obtained, and the similarity between the target word meaning and the reference word meaning is calculated. The present invention can use cosine similarity to calculate the phase velocity between the target word meaning and the reference word meaning. The index corresponding to the reference word meaning having a similarity greater than the preset similarity is then determined as the target index of the target word.
[0099] In one embodiment, step 120 can be specifically implemented as follows: obtaining synonyms corresponding to the reference field; determining the reference application scenarios corresponding to the synonyms; constructing a correspondence between the reference field, the synonyms corresponding to the reference field, and the reference application scenarios corresponding to the synonyms to obtain a preset reference dictionary.
[0100] In an embodiment of the present invention, in order to construct a preset reference dictionary, it is first necessary to extract synonyms from a given reference field, which can be achieved by using a synonym dictionary or natural language processing tools. Next, each synonym is analyzed to determine its applicable scenario, that is, in what context or context these synonyms are most appropriate. Finally, a one-to-one correspondence is established between the reference field, its corresponding synonym, and its applicable scenario to form a structured dictionary. This process not only helps to enrich language expression, but also provides effective guidance for the use of words in specific situations, thereby improving the accuracy and expression effect of the text.
[0101] In one embodiment, before step 120 , the Chinese search optimization method may be specifically implemented as follows: creating a stop word list to remove meaningless words in the text to be recognized.
[0102] The present invention can input the Chinese search optimization method into an SSD hard drive (SSD (Solid State Drive) is a storage device based on flash memory technology), a high-speed CPU and sufficient memory to provide faster reading and writing speeds and data processing capabilities. In addition, in order for Elasticsearch to efficiently run the Chinese search optimization method, it is ensured that the network connection between the nodes in the Elasticsearch cluster is high-speed and stable to reduce data transmission delays and packet loss rates. The specific operations adopted in this solution include implementing a network redundancy strategy, optimizing TCP / IP parameters (such as TCP buffer size, timeout period, etc.), and using efficient communication protocols (such as Infiniband or RDMA).
[0103] This paper leverages Elasticsearch's query caching functionality to cache frequently executed query results, reducing the time it takes to repeatedly execute the same query. This paper employs two approaches: node query caching and shard request caching. The node query cache primarily caches query results, particularly filter query results. This cache is per-node and shared across all shards, while the shard request cache caches search request results, particularly aggregation results, on a per-shard basis, making it suitable for scenarios where the same search request is frequently used.
[0104] In one embodiment, before step 120, the Chinese search optimization method may be specifically implemented by constructing a character filter, which is used to remove HTML tags from the text to be recognized. The character filter may be an html_strip character filter. The html_strip character filter is a tool for processing text data containing HTML tags. Its main function is to remove HTML tags from text.
[0105] Figure 3 It is a structural diagram of a Chinese search optimization device provided by an exemplary embodiment of the present invention.
[0106] like Figure 3 As shown, the Chinese search optimization device includes:
[0107] An acquisition module 201 is used to acquire the text to be recognized input by the user; a determination module 202 is used to determine the index corresponding to the text to be recognized based on a preset reference dictionary; wherein, a method for constructing the preset reference dictionary includes: acquiring a reference text; determining the accuracy of word segmentation; based on the accuracy of word segmentation, segmenting the reference text to obtain multiple reference fields; constructing a correspondence between each reference field and a reference index to obtain a preset reference dictionary; a query module 203 is used to construct query conditions based on the index and logical words; and generating query results corresponding to the text to be recognized based on the query conditions.
[0108] Figure 4 FIG. 1 is a structural diagram of a Chinese search optimization device provided by another exemplary embodiment of the present invention. Figure 4 As shown, the word segmenter 202 can be specifically implemented as follows: if the word segmentation accuracy is the first accuracy, the reference text is segmented based on the reading order of the reference text and the meanings of the words in the reference text to obtain multiple reference fields.
[0109] In one embodiment, the determination module 202 may include: a word segmenter 2021, which is used to determine the longest length of the reference text if the accuracy of the word segmentation is the second accuracy; wherein the second accuracy is less than the first accuracy; based on the longest length, determine the meaning of the reference text; if the meaning of the reference text meets the first preset meaning, determine that the field corresponding to the reference text is a reference field.
[0110] In one embodiment, the word segmenter 2021 can be specifically implemented as follows: if the meaning of the reference text does not meet the preset meaning, the maximum length is reduced to obtain an adjusted length; based on the adjusted length, the cutoff text corresponding to the start and end positions to the cutoff position in the reference text is determined; if the meaning of the cutoff text meets the second preset meaning, the field corresponding to the cutoff text is determined to be the reference field.
[0111] In one embodiment, the determination module 202 may include: a word segmentation filter 2022 for obtaining the remaining text; if the remaining text satisfies the third preset word meaning, determining that the multiple reference fields include a field corresponding to the remaining text and a field corresponding to the cutoff text.
[0112] In one embodiment, the word segmentation filter 2022 can be specifically configured to: determine the field language corresponding to the reference field; if the field language is a preset field language, change the language format of the reference field; and establish a correspondence between the changed reference field and the reference index.
[0113] In one embodiment, the query module 203 may be specifically configured to: based on the query condition, filter documents that meet the query condition; wherein the query result includes the document.
[0114] In one embodiment, after determining module 202, the Chinese search optimization device can be specifically configured as follows: if there is a target field in the text to be recognized that cannot be matched with a preset reference dictionary, then obtaining the target word meaning corresponding to the target field; obtaining the reference word meaning corresponding to the reference field in the preset reference dictionary; calculating the similarity between the reference word meaning and the target word meaning; and determining the index corresponding to the reference word meaning whose similarity is greater than the preset similarity as the target index of the target word.
[0115] In one embodiment, the determination module 202 can be specifically configured to: obtain synonyms corresponding to the reference field; determine the reference application scenarios corresponding to the synonyms; construct a correspondence between the reference field, the synonyms corresponding to the reference field, and the reference application scenarios corresponding to the synonyms to obtain a preset reference dictionary.
[0116] Figure 5 The figure shows a block diagram of an electronic device according to an embodiment of the present application.
[0117] like Figure 5 As shown, the electronic device 10 includes one or more processors 11 and a memory 12 .
[0118] The processor 11 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 10 to perform desired functions.
[0119] The memory 12 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may, for example, include read-only memory (ROM), a hard disk, a flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 11 may run the program instructions to implement the Chinese search optimization method of each embodiment of the present application described above and / or other desired functions. Various contents such as input signals, signal components, noise components, etc. may also be stored in the computer-readable storage medium.
[0120] In one example, the electronic device 10 may further include an input device 13 and an output device 14 , and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0121] When the electronic device 10 is a stand-alone device, the input device 13 may be a communication network connector, configured to receive collected input signals from the first device and the second device.
[0122] In addition, the input device 13 may also include, for example, a keyboard, a mouse, and the like.
[0123] The output device 14 can output various information to the outside, including determined distance information, direction information, etc. The output device 14 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.
[0124] Of course, to simplify, Figure 5 Only some of the components related to the present application in the electronic device 10 are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, the electronic device 10 may further include any other appropriate components according to specific application scenarios.
[0125] The computer program product may be written in any combination of one or more programming languages to implement the program code for performing the operations of the embodiments of the present application, including object-oriented programming languages such as Java, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0126] The computer-readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can, for example, include but is not limited to a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0127] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A Chinese search optimization method, characterized in that: include: Get the text to be recognized input by the user; Based on a preset reference dictionary, an index corresponding to the text to be recognized is determined; wherein the method for constructing the preset reference dictionary includes: Get reference text; Determine the level of precision of word segmentation; Based on the accuracy of the word segmentation, the reference text is segmented to obtain a plurality of reference fields; Constructing a correspondence between each reference field and a reference index to obtain the preset reference dictionary; Constructing query conditions based on the index and logical words; Based on the query conditions, a query result corresponding to the text to be recognized is generated.
2. The Chinese search optimization method according to claim 1, characterized in that: The word segmentation of the reference text based on the accuracy of the word segmentation to obtain multiple reference fields includes: If the accuracy of the word segmentation is the first accuracy, the reference text is segmented based on the reading order of the reference text and the meanings of the words in the reference text to obtain a plurality of reference fields.
3. The Chinese search optimization method according to claim 2, characterized in that: Also includes: If the word segmentation accuracy is a second accuracy, determining the longest length of the reference text; wherein the second accuracy is less than the first accuracy; Determining the meaning of the reference text based on the longest length; If the meaning of the reference text satisfies the first preset meaning, the field corresponding to the reference text is determined to be a reference field.
4. The Chinese search optimization method according to claim 3, characterized in that: Also includes: If the meaning of the reference text does not satisfy the preset meaning, reducing the maximum length to obtain an adjusted length; Based on the adjusted length, determining a cutoff text corresponding to the start and end positions to the cutoff position in the reference text; If the meaning of the cutoff text satisfies the second preset meaning, the field corresponding to the cutoff text is determined as a reference field.
5. The Chinese search optimization method according to claim 4, characterized in that: Also includes: Get the remaining text; If the remaining text satisfies the third preset word meaning, it is determined that the multiple reference fields include a field corresponding to the remaining text and a field corresponding to the cutoff text.
6. The Chinese search optimization method according to claim 1, characterized in that: The constructing of a correspondence between each reference field and a reference index includes: Determining a field language corresponding to the reference field; If the field language is the default field language, changing the language format of the reference field; Build a correspondence between the changed reference fields and the reference index.
7. The Chinese search optimization method according to claim 1, characterized in that: Generating a query result corresponding to the text to be recognized based on the query condition includes: Based on the query condition, documents that meet the query condition are screened; wherein the query result includes the document.
8. The Chinese search optimization method according to claim 1, characterized in that: After determining the index corresponding to the text to be recognized based on the preset reference dictionary, the method further includes: If there is a target field in the text to be recognized that cannot be matched with the preset reference dictionary, obtaining the target word meaning corresponding to the target field; Obtaining a reference word meaning corresponding to a reference field in the preset reference dictionary; Calculating the similarity between the reference word meaning and the target word meaning; The index corresponding to the reference word meaning having a similarity greater than a preset similarity is determined as the target index of the target word.
9. The Chinese search optimization method according to claim 1, characterized in that: The step of constructing a correspondence between each reference field and a reference index to obtain the preset reference dictionary includes: Obtaining synonyms corresponding to the reference field; Determine the reference applicable scenarios corresponding to the synonyms; A correspondence between the reference field, the synonyms corresponding to the reference field, and the reference application scenarios corresponding to the synonyms is constructed to obtain the preset reference dictionary.
10. A Chinese search optimization device, characterized in that: include: The acquisition module is used to obtain the text to be recognized input by the user; a determination module, configured to determine an index corresponding to the text to be recognized based on a preset reference dictionary; wherein the method for constructing the preset reference dictionary comprises: obtaining a reference text; determining a degree of word segmentation accuracy; performing word segmentation on the reference text based on the degree of word segmentation accuracy to obtain a plurality of reference fields; and constructing a correspondence between each reference field and a reference index to obtain the preset reference dictionary; The query module is used to construct query conditions based on the index and logical words; based on the query conditions, generate query results corresponding to the text to be recognized.