Movatterモバイル変換


[0]ホーム

URL:


CN114296606A - Text search method and device, electronic equipment and storage medium - Google Patents

Text search method and device, electronic equipment and storage medium
Download PDF

Info

Publication number
CN114296606A
CN114296606ACN202111613097.XACN202111613097ACN114296606ACN 114296606 ACN114296606 ACN 114296606ACN 202111613097 ACN202111613097 ACN 202111613097ACN 114296606 ACN114296606 ACN 114296606A
Authority
CN
China
Prior art keywords
search
information
chinese character
search information
pinyin
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111613097.XA
Other languages
Chinese (zh)
Other versions
CN114296606B (en
Inventor
姜勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu Yuexuebang Network Technology Co ltd
Original Assignee
Wuhan Yuexuebang Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Yuexuebang Network Technology Co LtdfiledCriticalWuhan Yuexuebang Network Technology Co Ltd
Priority to CN202111613097.XApriorityCriticalpatent/CN114296606B/en
Publication of CN114296606ApublicationCriticalpatent/CN114296606A/en
Application grantedgrantedCritical
Publication of CN114296606BpublicationCriticalpatent/CN114296606B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Landscapes

Abstract

The disclosure provides a text search method, a text search device, an electronic device and a storage medium, wherein the method comprises the following steps: acquiring search information input by a user; judging whether the searching mode of the searching information is accurate matching searching or fuzzy matching searching; under the condition that the search mode of the search information is the fuzzy matching search, performing first highlight display on first target texts corresponding to the search information at two ends of the separator; and under the condition that the searching mode of the searching information is the accurate matching searching, performing second highlighting on a second target text corresponding to the searching information, wherein the second highlighting is different from the first highlighting in display mode. According to the embodiment of the disclosure, the highlight display modes of the target text are different according to different search modes of the user, so that the diversity of the highlight display modes is increased, the user can distinguish prompts of key information corresponding to different search modes conveniently, and the user experience is improved.

Description

Translated fromChinese
一种文本搜索方法、装置、电子设备及存储介质A text search method, device, electronic device and storage medium

技术领域technical field

本公开涉及计算机技术领域,具体而言,涉及一种文本搜索方法、装置、电子设备及存储介质。The present disclosure relates to the field of computer technology, and in particular, to a text search method, apparatus, electronic device, and storage medium.

背景技术Background technique

随着电子设备应用技术的不断发展,关键词搜索已经被广泛应用在不同的业务场景中。在一些电子设备应用的搜索界面中,当用户输入搜索关键字时,为方便显示文本中的重要信息,常常会对文本中与搜索关键字相关联的部分文字进行高亮显示。比如,在手机通讯录或者A应用程序的通讯录的搜索界面,当用户输入“zhaozh”时,搜索界面会出现“zhaozh”相关联的姓名“赵真”或者“赵志”并进行高亮显示。With the continuous development of electronic device application technology, keyword search has been widely used in different business scenarios. In a search interface of some electronic device applications, when a user inputs a search keyword, in order to conveniently display important information in the text, part of the text associated with the search keyword is often highlighted in the text. For example, in the search interface of the mobile phone address book or the address book of the A application, when the user enters "zhaozh", the name "Zhao Zhen" or "Zhao Zhi" associated with "zhaozh" will appear in the search interface and be highlighted. .

然而,现有技术的高亮显示形式过于单一,比如当用户输入搜索关键字“zhaozh”或者“zhao zh”的情况下,两种搜索方式显然不同,存在搜索信息中可能存在分隔符(比如空格)的情况,而现有技术针对上述两种搜索方式的高亮显示形式是相同的,比如都是变化相同的字体颜色或者字体加粗,显示形式不够灵活,缺乏针对性,用户体验欠佳。However, the highlight display form of the prior art is too simple. For example, when the user enters the search keyword "zhaozh" or "zhao zh", the two search methods are obviously different, and there may be separators (such as spaces) in the search information. ), and the prior art has the same highlight display form for the above two search methods, for example, the font color changes the same or the font is bold, the display form is not flexible enough, lacks pertinence, and the user experience is not good.

发明内容SUMMARY OF THE INVENTION

本公开实施例至少提供一种文本搜索方法、装置、电子设备及计算机可读存储介质。Embodiments of the present disclosure provide at least a text search method, apparatus, electronic device, and computer-readable storage medium.

第一方面,本公开实施例提供了一种文本搜索方法,包括:In a first aspect, an embodiment of the present disclosure provides a text search method, including:

获取用户输入的搜索信息;Get the search information entered by the user;

判断所述搜索信息的搜索方式是精确匹配搜索还是模糊匹配搜索;其中,所述模糊匹配搜索是指所述搜索信息中存在分隔符,且所述精确匹配搜索是指所述搜索信息中不存在分隔符;Determine whether the search method of the search information is an exact match search or a fuzzy match search; wherein, the fuzzy match search means that there is a separator in the search information, and the exact match search means that the search information does not exist separator;

在所述搜索信息的搜索方式为所述模糊匹配搜索的情况下,将所述分隔符两端的搜索信息对应的第一目标文本进行第一高亮显示;When the search method of the search information is the fuzzy matching search, first highlight the first target text corresponding to the search information at both ends of the separator;

在所述搜索信息的搜索方式为所述精确匹配搜索的情况下,将所述搜索信息对应的第二目标文本进行第二高亮显示;其中,所述第二高亮显示与所述第一高亮显示的显示方式不同。In the case where the search method of the search information is the exact match search, second highlighting is performed on the second target text corresponding to the search information; wherein the second highlighting is the same as the first highlighting Highlights are displayed differently.

本公开实施例中,针对用户不同的搜索方式,目标文本的高亮显示方式不同,增加了高亮显示方式的多样性,便于用户区分不同搜索方式对应的关键信息的提示,提升了用户体验。In the embodiment of the present disclosure, for different search methods of users, the highlight display methods of target text are different, which increases the variety of highlight display methods, facilitates users to distinguish prompts of key information corresponding to different search methods, and improves user experience.

根据第一方面,在一种可能的实施方式中,所述将所述分隔符两端的搜索信息对应的第一目标文本进行第一高亮显示,包括:According to the first aspect, in a possible implementation manner, the first highlighting of the first target text corresponding to the search information at both ends of the separator includes:

获取与所述搜索信息关联的搜索字段;obtaining a search field associated with the search information;

判断所述搜索信息是否为第一种类信息,所述第一种类信息包括拼音;Determine whether the search information is the first type of information, and the first type of information includes pinyin;

在所述搜索信息为第一种类信息的情况下,构建所述搜索信息与所述搜索信息对应的汉字在所述搜索字段中的位置的第一映射;In the case that the search information is the first type of information, constructing a first mapping of the positions of the search information and the Chinese characters corresponding to the search information in the search field;

基于所述第一映射,确定所述搜索信息在所述搜索字段中对应的第一起始位置和第一结束位置;determining, based on the first mapping, a first start position and a first end position corresponding to the search information in the search field;

遍历所述搜索字段,根据所述第一起始位置和所述第一结束位置确定所述第一目标文本,并将所述第一目标文本进行所述第一高亮显示。Traverse the search field, determine the first target text according to the first start position and the first end position, and perform the first highlighting on the first target text.

本公开实施例中,通过将搜索信息与搜索信息对应的汉字在搜索字段中的位置形成映射进行高亮显示,提高了高亮显示的准确率,能够处理多种情形的搜索方式。In the embodiment of the present disclosure, by mapping the search information and the position of the Chinese character corresponding to the search information in the search field for highlighting, the accuracy of highlighting is improved, and various search methods can be handled.

根据第一方面,在一种可能的实施方式中,所述方法还包括:According to the first aspect, in a possible implementation manner, the method further includes:

在所述搜索信息不是所述第一种类信息的情况下,确定所述搜索信息在所述搜索字段中对应的第二起始位置和第二结束位置;In the case that the search information is not the first type of information, determining a second start position and a second end position corresponding to the search information in the search field;

遍历所述搜索字段,根据所述第二起始位置和所述第二结束位置确定第一目标文本,并将所述第一目标文本进行第一高亮显示。The search field is traversed, the first target text is determined according to the second start position and the second end position, and the first target text is first highlighted.

本公开实施例中,在搜索信息不是第一种类信息的情况下,也能将第一目标文本进行高亮显示,使得搜索方式和高亮显示方法更加全面,扩大应用范围。In the embodiment of the present disclosure, in the case where the search information is not the first type of information, the first target text can also be highlighted, so that the search method and the highlight display method are more comprehensive and the application scope is expanded.

根据第一方面,在一种可能的实施方式中,所述构建所述搜索信息与所述搜索信息对应的汉字在所述搜索字段中的位置的第一映射,包括:According to the first aspect, in a possible implementation manner, the constructing a first mapping between the search information and the positions of the Chinese characters corresponding to the search information in the search field includes:

将所述搜索字段转换为拼音,并构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射;Converting the search field into Pinyin, and constructing a second mapping between each Chinese character in the search field and the corresponding Pinyin of each Chinese character;

构建所述搜索字段中每个汉字与所述每个汉字在所述搜索字段中位置之间的第三映射;constructing a third mapping between each Chinese character in the search field and the position of each Chinese character in the search field;

基于所述搜索信息、所述第二映射和所述第三映射,构建所述第一映射。The first map is constructed based on the search information, the second map and the third map.

本公开实施例中,通过构建第二映射和第三映射进而构建第一映射,实现了搜索信息中的搜索关键字与搜索关键字在搜索字段中位置的对应关系,保证了目标文本高亮显示方法的准确性。In the embodiment of the present disclosure, by constructing the second mapping and the third mapping and then constructing the first mapping, the corresponding relationship between the search keywords in the search information and the positions of the search keywords in the search field is realized, and the highlighted display of the target text is ensured accuracy of the method.

根据第一方面,在一种可能的实施方式中,所述构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射,包括:According to the first aspect, in a possible implementation manner, the constructing the second mapping between each Chinese character in the search field and the pinyin corresponding to each Chinese character includes:

针对所述搜索信息的第一个关键字,构建所述搜索字段中每个汉字与所述每个汉字对应的以首字母开始的拼音之间的第四映射;For the first keyword of the search information, construct a fourth mapping between each Chinese character in the search field and the pinyin corresponding to the first letter of each Chinese character;

针对所述搜索信息的第一个关键字之外的其他关键字,构建所述搜索字段中每个汉字与所述每个汉字对应的以任意字母开始的拼音之间的第五映射;For other keywords other than the first keyword of the search information, construct a fifth mapping between each Chinese character in the search field and the pinyin starting with any letter corresponding to each Chinese character;

基于所述搜索信息、所述第四映射及所述第五映射构建所述第二映射。The second map is constructed based on the search information, the fourth map, and the fifth map.

本公开实施例中,由于搜索信息中第一个关键字之外的其他关键字可以构建以任意字母开始的映射,扩大高亮显示范围,提高搜索方式的全面性。In the embodiment of the present disclosure, because other keywords other than the first keyword in the search information can construct a map starting with any letter, the highlighted display range is expanded, and the comprehensiveness of the search method is improved.

根据第一方面,在一种可能的实施方式中,所述构建所述搜索字段中每个汉字与所述每个汉字对应的以任意字母开始的拼音之间的第五映射之后,所述方法还包括:According to the first aspect, in a possible implementation manner, after the fifth mapping between each Chinese character in the search field and the pinyin corresponding to each Chinese character starting with any letter is constructed, the method Also includes:

在所述其他关键字的起始位置小于等于所述第一个关键字的结束位置的情况下,将所述第一个关键字的起始位置和所述其他关键字的结束位置确定为第三起始位置和第三结束位置;In the case that the starting position of the other keywords is less than or equal to the ending position of the first keyword, the starting position of the first keyword and the ending position of the other keywords are determined as the first keyword. Three starting positions and third ending positions;

遍历所述搜索字段,根据所述第三起始位置和所述第三结束位置确定所述第一目标文本,并将所述第一目标文本进行所述第一高亮显示。Traverse the search field, determine the first target text according to the third start position and the third end position, and perform the first highlighting on the first target text.

本公开实施例中,可以避免重复高亮,减少处理步骤。In the embodiment of the present disclosure, repeated highlighting can be avoided and processing steps are reduced.

根据第一方面,在一种可能的实施方式中,所述将所述搜索字段转换为拼音之前,所述方法还包括:According to the first aspect, in a possible implementation manner, before converting the search field into Pinyin, the method further includes:

判断所述搜索字段中的字符是否为表情;Determine whether the characters in the search field are expressions;

在所述搜索字段中的字符不是表情的情况下,将所述搜索字段转换为拼音,并构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射;In the case that the characters in the search field are not expressions, converting the search field into pinyin, and constructing a second mapping between each Chinese character in the search field and the corresponding pinyin of each Chinese character;

在所述搜索字段中的字符是表情的情况下,则不转换。In the case where the characters in the search field are expressions, no conversion is made.

本公开实施例中,可以提高转换效率,提高转换精度。In the embodiment of the present disclosure, the conversion efficiency and the conversion precision can be improved.

根据第一方面,在一种可能的实施方式中,所述将所述搜索字段转换为拼音,并构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射,包括:According to the first aspect, in a possible implementation, converting the search field into pinyin, and constructing a second mapping between each Chinese character in the search field and the pinyin corresponding to each Chinese character ,include:

将转换后的拼音对应的全拼存储到全拼集合,并构建所述搜索字段中每个汉字与所述每个汉字对应的全拼之间的第二映射;和/或,The full spelling corresponding to the converted pinyin is stored in the full spelling set, and the second mapping between each Chinese character and the corresponding full spelling of each Chinese character in the search field is constructed; and/or,

将转换后的拼音对应的汉字首字母存储到首字母集合,并构建所述搜索字段中每个汉字与所述每个汉字对应的首字母之间的第二映射。The first letter of the Chinese character corresponding to the converted pinyin is stored in the initial letter set, and a second mapping between each Chinese character in the search field and the initial letter corresponding to each Chinese character is constructed.

本公开实施例中,不仅可以对用户输入的全拼对应的目标文本进行高亮显示,还可以对用户输入的首字母对应的目标文本进行高亮显示,提高了搜索范围。In the embodiment of the present disclosure, not only the target text corresponding to the full spell input by the user can be highlighted, but also the target text corresponding to the first letter input by the user can be highlighted, thereby improving the search range.

第二方面,本公开实施例还提供一种文本搜索装置,包括:In a second aspect, an embodiment of the present disclosure further provides a text search apparatus, including:

获取模块,用于获取用户输入的搜索信息;The acquisition module is used to acquire the search information input by the user;

判断模块,用于判断所述搜索信息的搜索方式是精确匹配搜索还是模糊匹配搜索;其中,所述模糊匹配搜索是指所述搜索信息中存在分隔符,且所述精确匹配搜索是指所述搜索信息中不存在分隔符;a judging module for judging whether the search method of the search information is an exact match search or a fuzzy match search; wherein, the fuzzy match search refers to the existence of a separator in the search information, and the exact match search refers to the There is no delimiter in the search information;

第一显示模块,用于在所述搜索信息的搜索方式为所述模糊匹配搜索的情况下,将所述分隔符两端的搜索信息对应的第一目标文本进行第一高亮显示;a first display module, configured to first highlight the first target text corresponding to the search information at both ends of the separator when the search method of the search information is the fuzzy matching search;

第二显示模块,用于在所述搜索信息的搜索方式为所述精确匹配搜索的情况下,将所述搜索信息对应的第二目标文本进行第二高亮显示;其中,所述第二高亮显示与所述第一高亮显示的显示方式不同。The second display module is configured to perform a second highlight display on the second target text corresponding to the search information when the search method of the search information is the exact match search; The highlight display is displayed differently from the first highlight display.

根据第二方面,在一种可能的实施方式中,所述第一显示模块具体用于:According to the second aspect, in a possible implementation manner, the first display module is specifically used for:

获取与所述搜索信息关联的搜索字段;obtaining a search field associated with the search information;

判断所述搜索信息是否为第一种类信息,所述第一种类信息包括拼音;Determine whether the search information is the first type of information, and the first type of information includes pinyin;

在所述搜索信息为第一种类信息的情况下,构建所述搜索信息与所述搜索信息对应的汉字在所述搜索字段中的位置的第一映射;In the case that the search information is the first type of information, constructing a first mapping of the positions of the search information and the Chinese characters corresponding to the search information in the search field;

基于所述第一映射,确定所述搜索信息在所述搜索字段中对应的第一起始位置和第一结束位置;determining, based on the first mapping, a first start position and a first end position corresponding to the search information in the search field;

遍历所述搜索字段,根据所述第一起始位置和所述第一结束位置确定所述第一目标文本,并将所述第一目标文本进行所述第一高亮显示。Traverse the search field, determine the first target text according to the first start position and the first end position, and perform the first highlighting on the first target text.

根据第二方面,在一种可能的实施方式中,所述第一显示模块还用于:According to the second aspect, in a possible implementation manner, the first display module is further configured to:

在所述搜索信息不是所述第一种类信息的情况下,确定所述搜索信息在所述搜索字段中对应的第二起始位置和第二结束位置;In the case that the search information is not the first type of information, determining a second start position and a second end position corresponding to the search information in the search field;

遍历所述搜索字段,根据所述第二起始位置和所述第二结束位置确定第一目标文本,并将所述第一目标文本进行第一高亮显示。The search field is traversed, the first target text is determined according to the second start position and the second end position, and the first target text is first highlighted.

根据第二方面,在一种可能的实施方式中,所述第一显示模块具体用于:According to the second aspect, in a possible implementation manner, the first display module is specifically used for:

将所述搜索字段转换为拼音,并构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射;Converting the search field into Pinyin, and constructing a second mapping between each Chinese character in the search field and the corresponding Pinyin of each Chinese character;

构建所述搜索字段中每个汉字与所述每个汉字在所述搜索字段中位置之间的第三映射;constructing a third mapping between each Chinese character in the search field and the position of each Chinese character in the search field;

基于所述搜索信息、所述第二映射和所述第三映射,构建所述第一映射。The first map is constructed based on the search information, the second map and the third map.

根据第二方面,在一种可能的实施方式中,所述第一显示模块具体用于:According to the second aspect, in a possible implementation manner, the first display module is specifically used for:

针对所述搜索信息的第一个关键字,构建所述搜索字段中每个汉字与所述每个汉字对应的以首字母开始的拼音之间的第四映射;For the first keyword of the search information, construct a fourth mapping between each Chinese character in the search field and the pinyin corresponding to the first letter of each Chinese character;

针对所述搜索信息的第一个关键字之外的其他关键字,构建所述搜索字段中每个汉字与所述每个汉字对应的以任意字母开始的拼音之间的第五映射;For other keywords other than the first keyword of the search information, construct a fifth mapping between each Chinese character in the search field and the pinyin starting with any letter corresponding to each Chinese character;

基于所述搜索信息、所述第四映射及所述第五映射构建所述第二映射。The second map is constructed based on the search information, the fourth map, and the fifth map.

根据第二方面,在一种可能的实施方式中,所述第一显示模块还用于:According to the second aspect, in a possible implementation manner, the first display module is further configured to:

在所述其他关键字的起始位置小于等于所述第一个关键字的结束位置的情况下,将所述第一个关键字的起始位置和所述其他关键字的结束位置确定为第三起始位置和第三结束位置;In the case that the starting position of the other keywords is less than or equal to the ending position of the first keyword, the starting position of the first keyword and the ending position of the other keywords are determined as the first keyword. Three starting positions and third ending positions;

遍历所述搜索字段,根据所述第三起始位置和所述第三结束位置确定所述第一目标文本,并将所述第一目标文本进行所述第一高亮显示。Traverse the search field, determine the first target text according to the third start position and the third end position, and perform the first highlighting on the first target text.

根据第二方面,在一种可能的实施方式中,所述第一显示模块还用于:According to the second aspect, in a possible implementation manner, the first display module is further configured to:

判断所述搜索字段中的字符是否为表情;Determine whether the characters in the search field are expressions;

在所述搜索字段中的字符不是表情的情况下,将所述搜索字段转换为拼音,并构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射;In the case that the characters in the search field are not expressions, converting the search field into pinyin, and constructing a second mapping between each Chinese character in the search field and the corresponding pinyin of each Chinese character;

在所述搜索字段中的字符是表情的情况下,则不转换。In the case where the characters in the search field are expressions, no conversion is made.

根据第二方面,在一种可能的实施方式中,所述第一显示模块具体用于:According to the second aspect, in a possible implementation manner, the first display module is specifically used for:

将转换后的拼音对应的全拼存储到全拼集合,并构建所述搜索字段中每个汉字与所述每个汉字对应的全拼之间的第二映射;和/或,The full spelling corresponding to the converted pinyin is stored in the full spelling set, and the second mapping between each Chinese character and the corresponding full spelling of each Chinese character in the search field is constructed; and/or,

将转换后的拼音对应的汉字首字母存储到首字母集合,并构建所述搜索字段中每个汉字与所述每个汉字对应的首字母之间的第二映射。The first letter of the Chinese character corresponding to the converted pinyin is stored in the initial letter set, and a second mapping between each Chinese character in the search field and the initial letter corresponding to each Chinese character is constructed.

第三方面,本公开实施例还提供一种电子设备,包括:处理器、存储器和总线,所述存储器存储有所述处理器可执行的机器可读指令,当电子设备运行时,所述处理器与所述存储器之间通过总线通信,所述机器可读指令被所述处理器执行时执行上述第一方面,或第一方面中任一种可能的实施方式中所述的文本搜索方法。In a third aspect, embodiments of the present disclosure further provide an electronic device, including: a processor, a memory, and a bus, where the memory stores machine-readable instructions executable by the processor, and when the electronic device runs, the processing The processor and the memory communicate through a bus, and the machine-readable instructions execute the first aspect or the text search method described in any possible implementation manner of the first aspect when the machine-readable instructions are executed by the processor.

第四方面,本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述第一方面,或第一方面中任一种可能的实施方式中所述的文本搜索方法。In a fourth aspect, embodiments of the present disclosure further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to execute the first aspect, or any one of the first aspect. A text search method described in a possible implementation.

为使本公开的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。In order to make the above-mentioned objects, features and advantages of the present disclosure more obvious and easy to understand, the preferred embodiments are exemplified below, and are described in detail as follows in conjunction with the accompanying drawings.

附图说明Description of drawings

为了更清楚地说明本公开实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,此处的附图被并入说明书中并构成本说明书中的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。应当理解,以下附图仅示出了本公开的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to explain the technical solutions of the embodiments of the present disclosure more clearly, the following briefly introduces the accompanying drawings required in the embodiments, which are incorporated into the specification and constitute a part of the specification. The drawings illustrate embodiments consistent with the present disclosure, and together with the description serve to explain the technical solutions of the present disclosure. It should be understood that the following drawings only show some embodiments of the present disclosure, and therefore should not be regarded as limiting the scope. Other related figures are obtained from these figures.

图1示出了本公开实施例所提供的一种文本搜索方法的流程图;FIG. 1 shows a flowchart of a text search method provided by an embodiment of the present disclosure;

图2示出了本公开实施例所提供的一种将第一目标文本进行第一高亮显示的示意图;FIG. 2 shows a schematic diagram of first highlighting the first target text provided by an embodiment of the present disclosure;

图3示出了本公开实施例所提供的一种将第一目标文本进行第一高亮显示的具体方法流程图;3 shows a flowchart of a specific method for first highlighting the first target text provided by an embodiment of the present disclosure;

图4示出了本公开实施例所提供的一种构建搜索信息与搜索信息对应的汉字在搜索字段中的位置的第一映射的方法流程图;4 shows a flowchart of a method for constructing a first mapping between search information and the position of a Chinese character corresponding to the search information in a search field provided by an embodiment of the present disclosure;

图5示出了本公开实施例所提供的一种高亮显示方法的逻辑流程图;FIG. 5 shows a logic flow diagram of a highlighting method provided by an embodiment of the present disclosure;

图6示出了本公开实施例所提供的一种文本搜索装置的结构示意图;FIG. 6 shows a schematic structural diagram of a text search apparatus provided by an embodiment of the present disclosure;

图7示出了本公开实施例所提供的一种电子设备的示意图。FIG. 7 shows a schematic diagram of an electronic device provided by an embodiment of the present disclosure.

具体实施方式Detailed ways

为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本公开实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本公开的实施例的详细描述并非旨在限制要求保护的本公开的范围,而是仅仅表示本公开的选定实施例。基于本公开的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only These are some, but not all, embodiments of the present disclosure. The components of the disclosed embodiments generally described and illustrated in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the disclosure provided in the accompanying drawings is not intended to limit the scope of the disclosure as claimed, but is merely representative of selected embodiments of the disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present disclosure.

应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。It should be noted that like numerals and letters refer to like items in the following figures, so once an item is defined in one figure, it does not require further definition and explanation in subsequent figures.

本文中术语“和/或”,仅仅是描述一种关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中术语“至少一种”表示多种中的任意一种或多种中的至少两种的任意组合,例如,包括A、B、C中的至少一种,可以表示包括从A、B和C构成的集合中选择的任意一个或多个元素。The term "and/or" in this paper only describes an association relationship, which means that there can be three kinds of relationships, for example, A and/or B, which can mean: the existence of A alone, the existence of A and B at the same time, the existence of B alone. a situation. In addition, the term "at least one" herein refers to any combination of any one of the plurality or at least two of the plurality, for example, including at least one of A, B, and C, and may mean including from A, B, and C. Any one or more elements selected from the set of B and C.

随着电子设备应用技术的不断发展,关键词搜索已经被广泛应用在不同的业务场景中。在一些电子设备应用的搜索界面中,当用户输入搜索关键字时,为方便显示文本中的重要信息,常常会对文本中与搜索关键字相关联的部分文字进行高亮显示。比如,在手机通讯录或者A应用程序的通讯录的搜索界面,当用户输入“zhaozh”时,搜索界面会出现“zhaozh”相关联的姓名“赵真”或者“赵志”并进行高亮显示。With the continuous development of electronic device application technology, keyword search has been widely used in different business scenarios. In a search interface of some electronic device applications, when a user inputs a search keyword, in order to conveniently display important information in the text, part of the text associated with the search keyword is often highlighted in the text. For example, in the search interface of the mobile phone address book or the address book of the A application, when the user enters "zhaozh", the name "Zhao Zhen" or "Zhao Zhi" associated with "zhaozh" will appear in the search interface and be highlighted. .

经研究发现,现有技术的高亮显示形式过于单一,比如当用户输入搜索关键字“zhaozh”或者“zhao zh”的情况下,两种搜索方式显然不同,存在搜索关键字中可能存在分隔符(比如空格)的情况,而现有技术针对上述两种搜索方式的高亮显示形式是相同的,比如都是变化相同的字体颜色或者字体加粗,显示形式不够灵活,缺乏针对性,用户体验欠佳。After research, it is found that the highlighting form of the existing technology is too simple. For example, when the user enters the search keyword "zhaozh" or "zhao zh", the two search methods are obviously different, and there may be separators in the search keywords. (such as spaces), and the prior art has the same highlight display form for the above two search methods, such as the same font color or bold font, the display form is not flexible enough, lacks pertinence, and user experience Poor.

基于上述研究,本公开提供了一种文本搜索方法,该方法通过获取用户输入的搜索信息,然后判断所述搜索信息的搜索方式是精确匹配搜索还是模糊匹配搜索,其中,所述模糊匹配搜索是指所述搜索信息中存在分隔符,所述精确匹配搜索是指所述搜索信息中不存在分隔符,在所述搜索信息的搜索方式为所述模糊匹配搜索的情况下,将所述分隔符两端的搜索信息对应的第一目标文本进行第一高亮显示,在所述搜索信息的搜索方式为所述精确匹配搜索的情况下,将所述搜索信息对应的第二目标文本进行第二高亮显示,其中,所述第二高亮显示与所述第一高亮显示的显示方式不同,如此,针对用户不同的搜索方式,目标文本的高亮显示方式不同,增加了高亮显示方式的多样性,便于用户区分不同搜索方式对应的关键信息的提示,提升了用户体验。Based on the above research, the present disclosure provides a text search method. The method obtains search information input by a user, and then determines whether the search method of the search information is an exact match search or a fuzzy match search, wherein the fuzzy match search is It means that there is a separator in the search information, and the exact match search means that there is no separator in the search information. If the search method of the search information is the fuzzy matching search, the separator is The first target text corresponding to the search information at both ends is first highlighted, and in the case that the search method of the search information is the exact match search, the second target text corresponding to the search information is subjected to the second highlight. Highlight display, wherein, the second highlight display is different from the first highlight display mode, so, according to different search modes of users, the highlight display mode of the target text is different, and the highlight display mode is increased. Diversity, it is convenient for users to distinguish the prompts of key information corresponding to different search methods, which improves the user experience.

为便于对本实施例进行理解,首先对本公开实施例所公开的一种文本搜索方法进行详细介绍,本公开实施例所提供的文本搜索方法的执行主体一般为具有一定计算能力的电子设备,该电子设备例如包括:终端设备或服务器或其它处理设备,终端设备可以为移动设备、用户终端、手持设备、计算设备、车载设备、可穿戴设备等。在一些可能的实现方式中,该文本搜方法可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。In order to facilitate the understanding of this embodiment, a text search method disclosed by the embodiment of the present disclosure is first introduced in detail. The execution subject of the text search method provided by the embodiment of the present disclosure is generally an electronic device with The device includes, for example, a terminal device or a server or other processing device, and the terminal device may be a mobile device, a user terminal, a handheld device, a computing device, a vehicle-mounted device, a wearable device, and the like. In some possible implementations, the text search method may be implemented by a processor invoking computer-readable instructions stored in a memory.

参见图1所示,为本公开实施例所提供的一种文本搜索方法的流程图,其中,该方法可以应用于上述电子设备中,或应用于本地或云端的服务器中。图1所示的文本搜索方法包括以下S101~S104:Referring to FIG. 1 , which is a flowchart of a text search method provided by an embodiment of the present disclosure, the method may be applied to the above-mentioned electronic device, or applied to a local or cloud server. The text search method shown in FIG. 1 includes the following S101 to S104:

S101,获取用户输入的搜索信息。S101, acquiring search information input by a user.

示例地,用户输入搜索信息的方式,对于电脑终端,可以是键盘输入、触摸输入或者鼠标输入等输入方式,对于智能移动终端,可以是键盘输入、触摸输入或者轨迹球输入等输入方式。For example, the user input search information may be keyboard input, touch input or mouse input for a computer terminal, and may be keyboard input, touch input or trackball input for an intelligent mobile terminal.

其中,所述搜索信息包括用户在终端的搜索界面输入的搜索关键字,所述搜索关键字可以是单个字符或字符串。所述搜索关键字的语言类型可以包括但不限于数字、中文、英文、日文、法文、德文等。比如,用户在A应用程序的通讯录中查找“赵真”这个姓名时,可以在通讯录的搜索界面输入搜索信息“zhaozhen”,也可以输入“zhaozh”,还可以直接输入汉字“赵真”,在此不做限定。Wherein, the search information includes a search keyword input by the user on a search interface of the terminal, and the search keyword may be a single character or a string. The language types of the search keywords may include but are not limited to numbers, Chinese, English, Japanese, French, German and the like. For example, when a user searches for the name "Zhao Zhen" in the address book of the A application, he can enter the search information "zhaozhen" in the search interface of the address book, or enter "zhaozh", or directly enter the Chinese character "Zhao Zhen" , which is not limited here.

S102,判断所述搜索信息的搜索方式是精确匹配搜索还是模糊匹配搜索;其中,所述模糊匹配搜索是指所述搜索信息中存在分隔符,且所述精确匹配搜索是指所述搜索信息中不存在分隔符。S102: Determine whether the search method of the search information is an exact match search or a fuzzy match search; wherein, the fuzzy match search means that a separator exists in the search information, and the exact match search means that the search information contains a delimiter. No delimiter exists.

示例地,所述精确匹配搜索为用户完全清楚需要搜索的目标文本的情况下的搜索方式,也即用户输入的搜索信息为连续的,不存在间断或者分隔符,比如搜索信息可以是“lixiaoming”,还可以是“lixiaom”等。而所述模糊匹配搜索为用户可能忘记需要搜索的目标文本的某个字或者误输入的情况,输入的搜索信息中存在分隔符,比如搜索信息可以是“li ming”,还可以是“li,ming”,用户可能忘记了通讯录中的好友姓名“李小明”中的“小”字,在输入搜索信息时用分隔符“空格”代替了“小”字。因此,在对目标文本进行高亮显示之前,需要判断用户的搜索方式是精确匹配搜索还是模糊匹配搜索。Illustratively, the exact match search is a search method when the user is completely clear about the target text to be searched, that is, the search information input by the user is continuous, without interruption or separator, for example, the search information can be "lixiaoming". , can also be "lixiaom", etc. In the fuzzy matching search, the user may forget a certain word of the target text to be searched or input it by mistake, and there is a separator in the input search information, for example, the search information may be "li ming" or "li, ming", the user may have forgotten the "small" character in the friend's name "Li Xiaoming" in the address book, and replaced the "small" character with the separator "space" when entering the search information. Therefore, before highlighting the target text, it is necessary to determine whether the user's search mode is an exact match search or a fuzzy match search.

S103,在所述搜索信息的搜索方式为所述模糊匹配搜索的情况下,将所述分隔符两端的搜索信息对应的第一目标文本进行第一高亮显示。S103 , when the search method of the search information is the fuzzy matching search, perform a first highlight display on the first target text corresponding to the search information at both ends of the separator.

示例地,比如用户输入的搜索信息为“zhao zh”,所述第一目标文本则可以是用户终端通讯录中好友姓名“赵真”中的“赵”和“真”字。所述高亮显示的方式可以是加粗目标文本的字体,也可以是改变目标文本的字体显示颜色,以能够相对于普通文本区别显示为准,进而给予用户相应的提示。比如对于普通文本为加粗的黑体,则可以通过改变字体颜色实现高亮显示,对于字体本身具有特殊颜色,可以通过改变字体粗细等方式实现高亮显示。在一些实施方式中,还可以通过其他方式实现目标文本的高亮显示,在此不做限定。For example, if the search information input by the user is "zhao zh", the first target text may be the words "Zhao" and "zhen" in the friend's name "Zhao Zhen" in the address book of the user terminal. The highlighting manner may be to bold the font of the target text, or to change the font display color of the target text, whichever can be displayed differently from ordinary text, and then give the user a corresponding prompt. For example, for ordinary text that is bold, it can be highlighted by changing the font color. For the font itself with a special color, it can be highlighted by changing the font thickness. In some implementation manners, the highlighting of the target text may also be implemented in other manners, which are not limited herein.

示例地,参见图2所示,为本公开实施例所提供的一种将第一目标文本进行第一高亮显示的示意图,其中“zhao zh”为搜索信息a,“赵真”、“赵正”以及“赵立志”中的“赵”和“志”为“空格”两端的“zhao”和“zh”对应的第一目标文本b,图中对第一目标文本高亮显示的方式为“字体加粗”,也即“赵真”、“赵正”以及“赵立志”中的“赵”和“志”的字体相较于其他普通字体而言是加粗的,如此,方便用户看到目标文本中的重要信息。For example, referring to FIG. 2, it is a schematic diagram of first highlighting the first target text provided by the embodiment of the present disclosure, wherein "zhao zh" is search information a, "Zhao Zhen", "Zhao Zhen", "Zhao Zhen" and "Zhao Zhen" are "Zhao" and "Zhao" and "zhi" in "Zhao Lizhi" are the first target text b corresponding to "zhao" and "zh" at both ends of the "space". The way of highlighting the first target text in the figure is as follows "Bold font", that is, "Zhao Zhen", "Zhao Zheng" and "Zhao" and "Zhi" in "Zhao Lizhi" are bold compared to other ordinary fonts, so it is convenient for users See important information in the target text.

S104,在所述搜索信息的搜索方式为所述精确匹配搜索的情况下,将所述搜索信息对应的第二目标文本进行第二高亮显示;其中,所述第二高亮显示与所述第一高亮显示的显示方式不同。S104, when the search method of the search information is the exact match search, perform a second highlight display on the second target text corresponding to the search information; wherein the second highlight display is the same as the The first highlight is displayed differently.

该步骤中,所述搜索信息为连续的,中间没有分隔符,比如“zhaozh”,其对应的第二目标文本可以是“赵真”或者“赵正”,而第二高亮显示的方式可以与第一高亮显示的显示方式不同。比如第一高亮显示的显示方式为“字体加粗”,则第二高亮显示的显示方式可以为“改变字体颜色”;又比如第一高亮显示的显示方式为“字体为红色”,则第二高亮显示的显示方式可以为“字体为黄色”。所述显示方式还可以为其他方式,在此不做限定。In this step, the search information is continuous without a separator, such as "zhaozh", the corresponding second target text can be "Zhao Zhen" or "Zhao Zheng", and the second highlighting method can be Displayed differently than the first highlight. For example, the display mode of the first highlighted display is "bold font", then the display mode of the second highlighted display can be "change font color"; for example, the display mode of the first highlighted display is "font is red", Then, the display mode of the second highlighted display may be "font is yellow". The display manner may also be other manners, which are not limited herein.

本公开实施方式中,针对用户不同的搜索方式,目标文本的高亮显示方式不同,增加了高亮显示方式的多样性,便于用户区分不同搜索方式对应的关键信息的提示,提升了用户体验。In the embodiment of the present disclosure, for different search methods of users, the highlight display methods of target text are different, which increases the diversity of highlight display methods, facilitates users to distinguish prompts of key information corresponding to different search methods, and improves user experience.

针对上述S103,参见图3所示,为本公开实施例所提供的一种将第一目标文本进行第一高亮显示的具体方法流程图,包括以下S1031~S1037:For the above S103, referring to FIG. 3, a flowchart of a specific method for first highlighting the first target text provided by the embodiment of the present disclosure includes the following S1031-S1037:

S1031,获取与所述搜索信息关联的搜索字段。S1031: Acquire a search field associated with the search information.

示例地,当用户输入搜索信息时,用户终端可以接收用户通过搜索界面输入的搜索信息,根据搜索信息从本地的数据库中查找并获取带有搜索信息的搜索字段或上下文。其中,具体获取是搜索字段还是上下文,结合具体的业务场景,本公开实施例对此不做限定。For example, when the user inputs search information, the user terminal may receive the search information input by the user through the search interface, and search and acquire a search field or context with the search information from a local database according to the search information. Wherein, whether the specific acquisition is a search field or a context is not limited in this embodiment of the present disclosure in combination with a specific business scenario.

比如,当用户在A应用程序的通讯录搜索界面输入的搜索信息为“zhaozh”时,用户终端可以获取到A应用程序的通讯录中包含“zhaozh”对应的汉字的搜索字段,比如可以是“赵正阳”,还可以是“张振东”,也即“zhaozh”在通讯录中对应的所有的好友姓名。For example, when the search information entered by the user in the address book search interface of application A is "zhaozh", the user terminal can obtain the search field containing the Chinese character corresponding to "zhaozh" in the address book of application A, such as "zhaozh". Zhao Zhengyang", or "Zhang Zhendong", that is, all the friends' names corresponding to "zhaozh" in the address book.

S1032,判断所述搜索信息是否为第一种类信息,所述第一种类信息包括拼音;若是执行步骤S1033;若否执行步骤S1036。S1032: Determine whether the search information is the first type of information, and the first type of information includes pinyin; if so, go to step S1033; if not, go to step S1036.

示例地,所述第一种类信息可以为拼音,也可以为英文,在此不做限定,本公开的下述方法中主要以拼音为例进行阐述。For example, the first type of information may be pinyin or English, which is not limited herein. The following methods of the present disclosure mainly take pinyin as an example for description.

S1033,构建所述搜索信息与所述搜索信息对应的汉字在所述搜索字段中的位置的第一映射。S1033: Construct a first mapping between the search information and the positions of the Chinese characters corresponding to the search information in the search field.

示例地,在搜索信息为拼音的情况下,比如用户输入的搜索信息为“zhao sh”,对应的搜索字段为“赵胜”,那么“zhao”对应的“赵”在“赵胜”中的起始和结束位置为[0,0],则构建“zhao”和[0,0]的第一映射。本实施方式中,假设搜索字段中汉字的位置是从0开始,比如“赵”在“赵胜”中的起始和结束位置为[0,0],“胜”在“赵胜”中的起始和结束位置为[1,1],“赵胜”在“赵胜”中的起始和结束位置为[0,1]。在其他实施方式中,搜索字段中汉字的位置还可以以其他方式定义,在此不做限定。For example, in the case where the search information is Pinyin, for example, the search information input by the user is "zhao sh", and the corresponding search field is "Zhao Sheng", then "Zhao" corresponding to "zhao" is in "Zhao Sheng". The start and end positions are [0, 0], and the first mapping of "zhao" and [0, 0] is constructed. In this embodiment, it is assumed that the position of the Chinese character in the search field starts from 0, for example, the start and end positions of "Zhao" in "Zhao Sheng" are [0, 0], and the "sheng" in "Zhao Sheng" The starting and ending positions are [1, 1], and the starting and ending positions of "Zhao Sheng" in "Zhao Sheng" are [0, 1]. In other implementation manners, the positions of Chinese characters in the search field may also be defined in other ways, which are not limited herein.

S1034,基于所述第一映射,确定所述搜索信息在所述搜索字段中对应的第一起始位置和第一结束位置。S1034, based on the first mapping, determine a first start position and a first end position corresponding to the search information in the search field.

示例地,搜索信息“zhao”在搜索字段“赵胜”中的第一起始位置和第一结束位置即为[0,0],搜索信息“sh”在搜索字段“赵胜”中的第一起始位置和第一结束位置即为[1,1]。For example, the first starting position and the first ending position of the search information "zhao" in the search field "Zhao Sheng" are [0, 0], and the search information "sh" in the search field "Zhao Sheng" is the first starting position and the first ending position. The start position and the first end position are [1, 1].

在一些实施方式中,在搜索信息存在多个搜索关键字的情况下,可能存在第一个搜索关键字包含第二个搜索关键字的情况,比如搜索信息为“zhao zh”,第一个搜索关键字“zhao”包含了第二个搜索关键字“zh”,此时需要将“zhao”的结束位置加1作为“zh”的起始位置,比如“zhao”的位置下标为[0,0],则“zh”的位置下标为[1,1]。如此,可以避免重复高亮,减少处理步骤。In some implementations, when there are multiple search keywords in the search information, there may be a situation where the first search keyword includes the second search keyword. For example, when the search information is "zhao zh", the first search keyword The keyword "zhao" contains the second search keyword "zh". At this time, it is necessary to add 1 to the end position of "zhao" as the starting position of "zh". For example, the position subscript of "zhao" is [0, 0], the position subscript of "zh" is [1, 1]. In this way, repeated highlighting can be avoided and processing steps can be reduced.

S1035,遍历所述搜索字段,根据所述第一起始位置和所述第一结束位置确定所述第一目标文本,并将所述第一目标文本进行所述第一高亮显示。S1035, traverse the search field, determine the first target text according to the first start position and the first end position, and perform the first highlight display on the first target text.

示例地,比如搜索信息为“zhao sh”,通讯录中搜索到两个搜索字段“赵胜”和“赵升阳”,那么“zhao sh”在搜索字段“赵胜”中的第一目标文本即为“赵胜”,“zhao sh”在搜索字段“赵升阳”中的第一目标文本即为“赵升”,则搜索界面将会对“赵胜”和“赵升”进行高亮显示。For example, if the search information is "zhao sh", and two search fields "Zhao Sheng" and "Zhao Shengyang" are found in the address book, then the first target text of "zhao sh" in the search field "Zhao Sheng" is "Zhao Sheng", "zhao sh" in the search field "Zhao Shengyang", the first target text is "Zhao Sheng", then the search interface will highlight "Zhao Sheng" and "Zhao Sheng".

本公开实施方式中,通过将搜索信息与搜索信息对应的汉字在搜索字段中的位置形成映射进行高亮显示,提高了高亮显示的准确率,能够处理多种情形的搜索方式。In the embodiment of the present disclosure, by mapping the search information and the position of the Chinese character corresponding to the search information in the search field for highlight display, the accuracy of highlight display is improved, and various search methods can be handled.

S1036,确定所述搜索信息在所述搜索字段中对应的第二起始位置和第二结束位置。S1036: Determine a second start position and a second end position corresponding to the search information in the search field.

示例地,比如搜索信息为汉字的情况下,由于此种情况不需要构建拼音与拼音对应的汉字所在搜索字段中的位置的映射,可以通过预设方法直接获取汉字在搜索字段中对应的第二起始位置和第二结束位置。比如搜索信息为“李小”,搜索字段为“李小明”,此时能够直接获取“李小”在搜索字段“李小明”的第二起始位置和第二结束位置为[0,1]。所述预设方法可以是java方法或者其他方法,在此不做限定。Illustratively, for example, when the search information is a Chinese character, because in this case, it is not necessary to construct a mapping of the position in the search field of the Chinese character corresponding to the pinyin and the pinyin, the second corresponding to the Chinese character in the search field can be directly obtained by a preset method. start position and second end position. For example, the search information is "Li Xiaoming" and the search field is "Li Xiaoming". At this time, the second starting position and second ending position of "Li Xiao" in the search field "Li Xiaoming" can be directly obtained as [0, 1]. The preset method may be a java method or other methods, which are not limited herein.

S1037,遍历所述搜索字段,根据所述第二起始位置和所述第二结束位置确定第一目标文本,并将所述第一目标文本进行第一高亮显示。S1037, traverse the search field, determine the first target text according to the second start position and the second end position, and first highlight the first target text.

示例地,比如步骤S1036中的例子,此时[0,1]对应的第一目标文本为“李小”,则将“李小”进行高亮显示。For example, such as the example in step S1036, at this time, the first target text corresponding to [0, 1] is "Li Xiao", then "Li Xiao" is highlighted.

本公开实施方式中,在搜索信息不是第一种类信息的情况下,也能将第一目标文本进行高亮显示,使得搜索方式和高亮显示方法更加全面,扩大应用范围。In the embodiment of the present disclosure, in the case where the search information is not the first type of information, the first target text can also be highlighted, so that the search method and the highlight display method are more comprehensive and the application scope is expanded.

针对上述S1033,参见图4所示,为本公开实施例所提供的一种构建搜索信息与搜索信息对应的汉字在搜索字段中的位置的第一映射的方法流程图,包括以下S10331~S10333:For the above S1033, referring to FIG. 4 , a flowchart of a method for constructing a first mapping between search information and the position of a Chinese character corresponding to the search information in a search field provided by an embodiment of the present disclosure includes the following S10331 to S10333:

S10331,将所述搜索字段转换为拼音,并构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射。S10331. Convert the search field into pinyin, and construct a second mapping between each Chinese character in the search field and the pinyin corresponding to each Chinese character.

可以理解,在搜索信息为拼音的情况下,为了构建所述第一映射,首先需要将搜索字段转换为拼音,并构建搜索字段中每个汉字与每个汉字对应的拼音之间的映射关系,同时可能存在多音字的情况,一个汉字可能映射多个拼音,创建数据结构为Map<String,List<String>>wordPinyinMap,用于存储搜索字段每个汉字与拼音的映射。It can be understood that in the case where the search information is pinyin, in order to construct the first mapping, the search field needs to be converted into pinyin at first, and the mapping relationship between each Chinese character in the search field and the corresponding pinyin of each Chinese character is constructed, At the same time, there may be polyphonic words. One Chinese character may map to multiple pinyin. The created data structure is Map<String,List<String>>wordPinyinMap, which is used to store the mapping between each Chinese character and pinyin in the search field.

本实施例中,由于是模糊匹配搜索,搜索信息不只一个搜索关键字,第一个搜索关键字的拼音必须以汉字的首字母开始,但是之后的其他搜索关键字可以不以汉字的首字母开始,因此需要将第一个搜索关键字和之后的其他搜索关键字分别处理。首先,针对第一个搜索关键字,构建搜索字段中汉字与汉字对应的以首字母开始的拼音之间的映射关系,比如搜索字段为“李小明”,构建“李”与“li”的映射。针对第一个搜索关键字之后的其他关键字,构建搜索字段中汉字与汉字对应的以任意字母开始的拼音之间的映射关系,比如构建“小”与“ao”的映射,也可以是“小”与“iao”的映射。然后将上述两种映射存储到wordPinyinMap中。In this embodiment, since it is a fuzzy matching search, the search information is more than one search keyword, and the pinyin of the first search keyword must start with the first letter of a Chinese character, but other search keywords after that may not start with the first letter of a Chinese character , so the first search keyword and other search keywords after that need to be processed separately. First, for the first search keyword, build a mapping relationship between Chinese characters in the search field and their corresponding pinyin starting with the first letter. For example, if the search field is "Li Xiaoming", build a mapping between "Li" and "li". For other keywords after the first search keyword, construct the mapping relationship between Chinese characters in the search field and their corresponding pinyin starting with any letter, such as constructing the mapping between "small" and "ao", or " The mapping between "small" and "iao". Then store the above two mappings into wordPinyinMap.

在一些实施方式中,针对模糊匹配搜索情况下的第一个搜索关键字和其他搜索关键字,在获取起始位置和结束位置的时候,存在其他搜索关键字的起始位置小于等于第一个搜索关键字的结束位置的情况,比如“chen”对应的起始和结束位置为[0,0],“enli”对应的起始和结束位置为[0,1],此时为了避免重复高亮,可以将“chen”的结束位置和“enli”的起始位置合并,也即将上述两个下标合并为[0,1],如此,可以避免重复高亮,减少处理步骤。In some embodiments, for the first search keyword and other search keywords in the case of fuzzy matching search, when acquiring the start position and the end position, there are other search keywords whose start positions are less than or equal to the first search keyword. In the case of the end position of the search keyword, for example, the start and end positions corresponding to "chen" are [0, 0], and the start and end positions corresponding to "enli" are [0, 1]. At this time, in order to avoid repeated high To highlight, you can combine the end position of "chen" and the start position of "enli", that is, combine the above two subscripts into [0, 1], so that repeated highlighting can be avoided and processing steps are reduced.

在一些实施方式中,在将搜索字段转换为拼音之前,可能存在搜索字段中存在表情的情况,判断方式为表情和汉字的长度不同,此时需要判断搜索字段中的字符是否为表情。如果为表情,则不需要转换,直接存储到wordPinyinMap中;如果为汉字,则需要将汉字转换为拼音之后存储到wordPinyinMap中。如此,可以提高转换效率,提高转换精度。In some embodiments, before the search field is converted into pinyin, there may be expressions in the search field, and the judgment method is that the lengths of the expressions and Chinese characters are different. In this case, it is necessary to judge whether the characters in the search field are expressions. If it is an expression, it does not need to be converted and is directly stored in wordPinyinMap; if it is a Chinese character, it needs to be converted into pinyin and stored in wordPinyinMap. In this way, the conversion efficiency can be improved and the conversion accuracy can be improved.

在一些实施方式中,在搜索信息为拼音的情况下,用户的搜索类型可以是拼音的全拼,比如“lixiaoming”,也可以是拼音的首字母,比如“lxm”。相应的,在将搜索字段转换为拼音的时候,可以将搜索字段转换为拼音的全拼并存储到全拼集合Set<String>quanpin,然后构建搜索字段中汉字与汉字对应的全拼之间的第二映射,比如“李”映射“li”;也可以将搜索字段转换为拼音对应的汉字首字母并存储到首字母集合Set<String>shouzimu,然后构建搜索字段中汉字与汉字对应的首字母之间的第二映射,比如“李”映射“l”。如此,不仅可以对用户输入的全拼对应的目标文本进行高亮显示,还可以对用户输入的首字母对应的目标文本进行高亮显示,提高了搜索范围。In some embodiments, when the search information is pinyin, the user's search type may be the full pinyin of pinyin, such as "lixiaoming", or the first letter of pinyin, such as "lxm". Correspondingly, when the search field is converted into Pinyin, the search field can be converted into the Quanpin of Pinyin and stored in the Quanpin set Set<String>quanpin, and then the relationship between the Chinese character in the search field and the corresponding Quanpin of the Chinese character can be constructed. The second mapping, such as "Li" mapping "li"; you can also convert the search field into the initials of Chinese characters corresponding to pinyin and store them in the initial set Set<String>shouzimu, and then construct the Chinese characters in the search field and the corresponding initials of Chinese characters A second mapping between , such as "Li" mapping "l". In this way, not only the target text corresponding to Quanpin input by the user can be highlighted, but also the target text corresponding to the first letter input by the user can be highlighted, thereby increasing the search range.

S10332,构建所述搜索字段中每个汉字与所述每个汉字在所述搜索字段中位置之间的第三映射。S10332: Build a third mapping between each Chinese character in the search field and the position of each Chinese character in the search field.

示例地,在构建搜索字段中每个汉字与每个汉字对应的拼音之间的映射之后,还需要构建每个汉字与每个汉字在搜索字段中位置之间的映射关系,比如搜索字段“李小明”中,“李”与[0,0]形成映射,“小”与[1,1]形成映射,“李小”与[0,1]形成映射,创建数据结构为Map<Integer,String>indexWordMap,用于存储搜索字段中每个汉字与每个汉字在搜索字段中位置之间的映射关系。For example, after constructing the mapping between each Chinese character in the search field and the pinyin corresponding to each Chinese character, it is also necessary to construct the mapping relationship between each Chinese character and the position of each Chinese character in the search field, such as the search field "Li Xiaoming". ", "Li" forms a mapping with [0, 0], "Little" forms a mapping with [1, 1], "Li Xiao" forms a mapping with [0, 1], and creates a data structure as Map<Integer, String> indexWordMap is used to store the mapping relationship between each Chinese character in the search field and the position of each Chinese character in the search field.

S10333,基于所述搜索信息、所述第二映射和所述第三映射,构建所述第一映射。S10333. Construct the first map based on the search information, the second map and the third map.

示例地,基于上述步骤中的所述第二映射和所述第三映射,就可以构建拼音与拼音对应的汉字在搜索字段中位置的映射关系,创建数据结构为Map<String,wordIndex>pinyinIndexMap,用于存储拼音与拼音对应的汉字在搜索字段中位置的映射关系。比如“李小强”,转换成拼音之后为“lixiaoqiang”,“l”、“li”都是“李”字拼音的一部分,所以这两个字符串所对应的起始和结束位置都为[0,0],“lix”所对应的起始和结束位置则为[0,1],“x”对应的起始和结束位置为[1,1]。此外,需要说明的是,每个拼音的起始字母只能为搜索字段中任意一个汉字的第一个字母,比如“ix”不会出现。然后基于此映射关系,就可以获取到搜索信息在搜索字段中的起始和结束位置以确定目标文本,进而将目标文本进行高亮显示。Exemplarily, based on the second mapping and the third mapping in the above steps, it is possible to construct the mapping relationship between the pinyin and the Chinese character corresponding to the pinyin in the search field, and the created data structure is Map<String, wordIndex>pinyinIndexMap, It is used to store the mapping relationship between pinyin and pinyin-corresponding Chinese characters in the search field. For example, "Li Xiaoqiang" is converted into Pinyin as "lixiaoqiang", "l" and "li" are both part of the pinyin of "Li", so the corresponding start and end positions of these two strings are [0, 0], the start and end positions corresponding to "lix" are [0,1], and the start and end positions corresponding to "x" are [1,1]. In addition, it should be noted that the starting letter of each pinyin can only be the first letter of any Chinese character in the search field, for example, "ix" will not appear. Then, based on this mapping relationship, the starting and ending positions of the search information in the search field can be obtained to determine the target text, and then the target text can be highlighted.

本公开实施方式中,通过构建第二映射和第三映射进而构建第一映射,实现了搜索信息中的搜索关键字与搜索关键字在搜索字段中位置的对应关系,保证了目标文本高亮显示方法的准确性。In the embodiment of the present disclosure, by constructing the second mapping and the third mapping and then constructing the first mapping, the corresponding relationship between the search keywords in the search information and the positions of the search keywords in the search field is realized, and the highlighted display of the target text is ensured. accuracy of the method.

参见图5所示,为本公开实施例所提供的一种高亮显示方法的逻辑流程图,包括以下S110~S123:Referring to FIG. 5 , a logic flowchart of a highlighting method provided by an embodiment of the present disclosure includes the following S110 to S123:

S111,判断搜索方式是精确匹配搜索还是模糊匹配搜索,若是精确匹配,则执行S112;若是模糊匹配,则执行S116。S111 , determine whether the search mode is an exact match search or a fuzzy match search, if it is an exact match, execute S112 ; if it is a fuzzy match, execute S116 .

S112,判断是否通过拼音搜索,若是,则执行S113;若否,则执行S114。S112, determine whether to search through pinyin, if yes, execute S113; if not, execute S114.

S113,构建首字母起始的拼音与拼音对应的汉字在搜索字段中位置的映射。S113 , constructing a mapping between the pinyin starting with the first letter and the position of the Chinese character corresponding to the pinyin in the search field.

S114,获取搜索关键字在搜索字段中的位置。S114, obtain the position of the search keyword in the search field.

S115,将搜索关键字对应的第二目标文本进行第二高亮显示。S115, secondly highlight the second target text corresponding to the search keyword.

S116,判断是否通过拼音搜索,若是,则执行S117;若否,则执行S121。S116, determine whether to search through pinyin, if yes, execute S117; if not, execute S121.

S117,判断是否为第一个搜索关键字,若是,则执行S118;若否,则执行S119。S117, determine whether it is the first search keyword, if yes, execute S118; if not, execute S119.

S118,构建首字母起始的拼音与拼音对应的汉字在搜索字段中位置的映射。S118 , construct a mapping between the pinyin starting with the first letter and the position of the Chinese character corresponding to the pinyin in the search field.

S119,构建任意字母起始的拼音与拼音对应的汉字在搜索字段中位置的映射。S119 , constructing a mapping between the pinyin starting with any letter and the position of the Chinese character corresponding to the pinyin in the search field.

S120,获取搜索关键字在搜索字段中的位置并对重合的位置进行合并。S120: Acquire the position of the search keyword in the search field and combine the overlapping positions.

S121,获取搜索关键字在搜索字段中的位置。S121, obtain the position of the search keyword in the search field.

S122,将搜索关键字对应的第一目标文本进行第一高亮显示。S122: Perform a first highlight display on the first target text corresponding to the search keyword.

本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的撰写顺序并不意味着严格的执行顺序而对实施过程构成任何限定,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。Those skilled in the art can understand that in the above method of the specific implementation, the writing order of each step does not mean a strict execution order but constitutes any limitation on the implementation process, and the specific execution order of each step should be based on its function and possible Internal logic is determined.

基于同一技术构思,本公开实施例中还提供了与文本搜索方法对应的文本搜索装置,由于本公开实施例中的装置解决问题的原理与本公开实施例上述文本搜索方法相似,因此装置的实施可以参见方法的实施,重复之处不再赘述。Based on the same technical concept, the embodiments of the present disclosure also provide a text search device corresponding to the text search method. Reference may be made to the implementation of the method, and repeated descriptions will not be repeated.

参照图6所示,为本公开实施例提供的一种文本搜索装置的结构示意图,所述装置500包括:Referring to FIG. 6, which is a schematic structural diagram of a text search apparatus according to an embodiment of the present disclosure, the apparatus 500 includes:

获取模块501,用于获取用户输入的搜索信息;an obtaining module 501, configured to obtain search information input by a user;

判断模块502,用于判断所述搜索信息的搜索方式是精确匹配搜索还是模糊匹配搜索;其中,所述模糊匹配搜索是指所述搜索信息中存在分隔符,且所述精确匹配搜索是指所述搜索信息中不存在分隔符;The judgment module 502 is used for judging whether the search method of the search information is an exact match search or a fuzzy match search; wherein, the fuzzy match search refers to the existence of a separator in the search information, and the exact match search refers to all There is no delimiter in the search information;

第一显示模块503,用于在所述搜索信息的搜索方式为所述模糊匹配搜索的情况下,将所述分隔符两端的搜索信息对应的第一目标文本进行第一高亮显示;A first display module 503, configured to first highlight the first target text corresponding to the search information at both ends of the separator when the search method of the search information is the fuzzy matching search;

第二显示模块504,用于在所述搜索信息的搜索方式为所述精确匹配搜索的情况下,将所述搜索信息对应的第二目标文本进行第二高亮显示;其中,所述第二高亮显示与所述第一高亮显示的显示方式不同。The second display module 504 is configured to perform a second highlight display on the second target text corresponding to the search information when the search method of the search information is the exact match search; wherein the second The highlighting is displayed differently from the first highlighting.

在一种可能的实施方式中,所述第一显示模块503具体用于:In a possible implementation manner, the first display module 503 is specifically used for:

获取与所述搜索信息关联的搜索字段;obtaining a search field associated with the search information;

判断所述搜索信息是否为第一种类信息,所述第一种类信息包括拼音;Determine whether the search information is the first type of information, and the first type of information includes pinyin;

在所述搜索信息为第一种类信息的情况下,构建所述搜索信息与所述搜索信息对应的汉字在所述搜索字段中的位置的第一映射;In the case that the search information is the first type of information, constructing a first mapping of the positions of the search information and the Chinese characters corresponding to the search information in the search field;

基于所述第一映射,确定所述搜索信息在所述搜索字段中对应的第一起始位置和第一结束位置;determining, based on the first mapping, a first start position and a first end position corresponding to the search information in the search field;

遍历所述搜索字段,根据所述第一起始位置和所述第一结束位置确定所述第一目标文本,并将所述第一目标文本进行所述第一高亮显示。Traverse the search field, determine the first target text according to the first start position and the first end position, and perform the first highlighting on the first target text.

在一种可能的实施方式中,所述第一显示模块503还用于:In a possible implementation manner, the first display module 503 is further used for:

在所述搜索信息不是所述第一种类信息的情况下,确定所述搜索信息在所述搜索字段中对应的第二起始位置和第二结束位置;In the case that the search information is not the first type of information, determining a second start position and a second end position corresponding to the search information in the search field;

遍历所述搜索字段,根据所述第二起始位置和所述第二结束位置确定第一目标文本,并将所述第一目标文本进行第一高亮显示。The search field is traversed, the first target text is determined according to the second start position and the second end position, and the first target text is first highlighted.

在一种可能的实施方式中,所述第一显示模块503具体用于:In a possible implementation manner, the first display module 503 is specifically used for:

将所述搜索字段转换为拼音,并构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射;Converting the search field into Pinyin, and constructing a second mapping between each Chinese character in the search field and the corresponding Pinyin of each Chinese character;

构建所述搜索字段中每个汉字与所述每个汉字在所述搜索字段中位置之间的第三映射;constructing a third mapping between each Chinese character in the search field and the position of each Chinese character in the search field;

基于所述搜索信息、所述第二映射和所述第三映射,构建所述第一映射。The first map is constructed based on the search information, the second map and the third map.

在一种可能的实施方式中,所述第一显示模块503具体用于:In a possible implementation manner, the first display module 503 is specifically used for:

针对所述搜索信息的第一个关键字,构建所述搜索字段中每个汉字与所述每个汉字对应的以首字母开始的拼音之间的第四映射;For the first keyword of the search information, construct a fourth mapping between each Chinese character in the search field and the pinyin corresponding to the first letter of each Chinese character;

针对所述搜索信息的第一个关键字之外的其他关键字,构建所述搜索字段中每个汉字与所述每个汉字对应的以任意字母开始的拼音之间的第五映射;For other keywords other than the first keyword of the search information, construct a fifth mapping between each Chinese character in the search field and the pinyin starting with any letter corresponding to each Chinese character;

基于所述搜索信息、所述第四映射及所述第五映射构建所述第二映射。The second map is constructed based on the search information, the fourth map, and the fifth map.

在一种可能的实施方式中,所述第一显示模块503还用于:In a possible implementation manner, the first display module 503 is further used for:

在所述其他关键字的起始位置小于等于所述第一个关键字的结束位置的情况下,将所述第一个关键字的起始位置和所述其他关键字的结束位置确定为第三起始位置和第三结束位置;In the case that the starting position of the other keywords is less than or equal to the ending position of the first keyword, the starting position of the first keyword and the ending position of the other keywords are determined as the first keyword. Three starting positions and third ending positions;

遍历所述搜索字段,根据所述第三起始位置和所述第三结束位置确定所述第一目标文本,并将所述第一目标文本进行所述第一高亮显示。Traverse the search field, determine the first target text according to the third start position and the third end position, and perform the first highlighting on the first target text.

在一种可能的实施方式中,所述第一显示模块503还用于:In a possible implementation manner, the first display module 503 is further used for:

判断所述搜索字段中的字符是否为表情;Determine whether the characters in the search field are expressions;

在所述搜索字段中的字符不是表情的情况下,将所述搜索字段转换为拼音,并构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射;In the case that the characters in the search field are not expressions, converting the search field into pinyin, and constructing a second mapping between each Chinese character in the search field and the corresponding pinyin of each Chinese character;

在所述搜索字段中的字符是表情的情况下,则不转换。In the case where the characters in the search field are expressions, no conversion is made.

在一种可能的实施方式中,所述第一显示模块503具体用于:In a possible implementation manner, the first display module 503 is specifically used for:

将转换后的拼音对应的全拼存储到全拼集合,并构建所述搜索字段中每个汉字与所述每个汉字对应的全拼之间的第二映射;和/或,The full spelling corresponding to the converted pinyin is stored in the full spelling set, and the second mapping between each Chinese character and the corresponding full spelling of each Chinese character in the search field is constructed; and/or,

将转换后的拼音对应的汉字首字母存储到首字母集合,并构建所述搜索字段中每个汉字与所述每个汉字对应的首字母之间的第二映射。The first letter of the Chinese character corresponding to the converted pinyin is stored in the initial letter set, and a second mapping between each Chinese character in the search field and the initial letter corresponding to each Chinese character is constructed.

关于装置中的各模块的处理流程、以及各模块之间的交互流程的描述可以参照上述方法实施例中的相关说明,这里不再详述。For the description of the processing flow of each module in the apparatus and the interaction flow between the modules, reference may be made to the relevant descriptions in the foregoing method embodiments, which will not be described in detail here.

基于同一技术构思,本公开实施例还提供了一种电子设备。参照图7所示,为本公开实施例提供的电子设备700的结构示意图,包括处理器701、存储器702、和总线703。其中,存储器702用于存储执行指令,包括内存7021和外部存储器7022;这里的内存7021也称内存储器,用于暂时存放处理器701中的运算数据,以及与硬盘等外部存储器7022交换的数据,处理器701通过内存7021与外部存储器7022进行数据交换。Based on the same technical concept, an embodiment of the present disclosure also provides an electronic device. Referring to FIG. 7 , a schematic structural diagram of an electronic device 700 provided by an embodiment of the present disclosure includes aprocessor 701 , amemory 702 , and a bus 703 . Among them, thememory 702 is used to store the execution instructions, including the memory 7021 and the external memory 7022; the memory 7021 here is also called the internal memory, which is used to temporarily store the operation data in theprocessor 701 and the data exchanged with the external memory 7022 such as the hard disk, Theprocessor 701 exchanges data with the external memory 7022 through the memory 7021 .

本申请实施例中,存储器702具体用于存储执行本申请方案的应用程序代码,并由处理器701来控制执行。也即,当电子设备700运行时,处理器701与存储器702之间通过总线703通信,使得处理器701执行存储器702中存储的应用程序代码,进而执行前述任一实施例中所揭示的方法。In this embodiment of the present application, thememory 702 is specifically used to store the application program code for executing the solution of the present application, and the execution is controlled by theprocessor 701 . That is, when the electronic device 700 is running, theprocessor 701 communicates with thememory 702 through the bus 703, so that theprocessor 701 executes the application code stored in thememory 702, thereby executing the method disclosed in any of the foregoing embodiments.

其中,存储器702可以是,但不限于,随机存取存储器(Random Access Memory,RAM),只读存储器(Read Only Memory,ROM),可编程只读存储器(Programmable Read-Only Memory,PROM),可擦除只读存储器(Erasable Programmable Read-Only Memory,EPROM),电可擦除只读存储器(Electric Erasable Programmable Read-Only Memory,EEPROM)等。Wherein, thememory 702 may be, but not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read only memory (Programmable Read-Only Memory, PROM), or Erasable Programmable Read-Only Memory (EPROM), Electrical Erasable Programmable Read-Only Memory (EEPROM), etc.

处理器701可能是一种集成电路芯片,具有信号的处理能力。上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(NetworkProcessor,NP)等;还可以是数字信号处理器(DSP)、专用集成电路(ASIC)、现场可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。Theprocessor 701 may be an integrated circuit chip with signal processing capability. The above-mentioned processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), Field Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. Various methods, steps, and logical block diagrams disclosed in the embodiments of the present invention can be implemented or executed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.

可以理解的是,本申请实施例示意的结构并不构成对电子设备700的具体限定。在本申请另一些实施例中,电子设备700可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 700 . In other embodiments of the present application, the electronic device 700 may include more or less components than shown, or combine some components, or separate some components, or arrange different components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述方法实施例中的文本搜索方法。其中,该存储介质可以是易失性或非易失的计算机可读取存储介质。Embodiments of the present disclosure further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, the text search method in the above method embodiment is executed. Wherein, the storage medium may be a volatile or non-volatile computer-readable storage medium.

本公开实施例还提供一种计算机程序产品,该计算机程序产品载有程序代码,所述程序代码包括的指令可用于执行上述方法实施例中的文本搜索方法,具体可参见上述方法实施例,在此不再赘述。An embodiment of the present disclosure further provides a computer program product, the computer program product is loaded with program code, and the instructions included in the program code can be used to execute the text search method in the foregoing method embodiment. For details, please refer to the foregoing method embodiment. This will not be repeated here.

其中,上述计算机程序产品可以具体通过硬件、软件或其结合的方式实现。在一个可选实施例中,所述计算机程序产品具体体现为计算机存储介质,在另一个可选实施例中,计算机程序产品具体体现为软件产品,例如软件开发包(Software Development Kit,SDK)等等。Wherein, the above-mentioned computer program product can be specifically implemented by means of hardware, software or a combination thereof. In an optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK), etc. Wait.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统和装置的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。在本公开所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。Those skilled in the art can clearly understand that, for the convenience and brevity of description, for the specific working process of the system and device described above, reference may be made to the corresponding process in the foregoing method embodiments, which will not be repeated here. In the several embodiments provided by the present disclosure, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. The apparatus embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces, indirect coupling or communication connection of devices or units, which may be in electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.

另外,在本公开各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.

所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个处理器可执行的非易失的计算机可读取存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本公开各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-OnlyMemory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The functions, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a processor-executable non-volatile computer-readable storage medium. Based on such understanding, the technical solutions of the present disclosure can be embodied in the form of software products in essence, or the parts that contribute to the prior art or the parts of the technical solutions. The computer software products are stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes.

最后应说明的是:以上所述实施例,仅为本公开的具体实施方式,用以说明本公开的技术方案,而非对其限制,本公开的保护范围并不局限于此,尽管参照前述实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本公开实施例技术方案的精神和范围,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应所述以权利要求的保护范围为准。Finally, it should be noted that the above-mentioned embodiments are only specific implementations of the present disclosure, and are used to illustrate the technical solutions of the present disclosure rather than limit them. The protection scope of the present disclosure is not limited thereto, although referring to the foregoing The embodiments describe the present disclosure in detail, and those skilled in the art should understand that: any person skilled in the art can still modify the technical solutions described in the foregoing embodiments within the technical scope disclosed by the present disclosure. Changes can be easily thought of, or equivalent replacements are made to some of the technical features; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be covered in the present disclosure. within the scope of protection. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims (11)

Translated fromChinese
1.一种文本搜索方法,其特征在于,包括:1. a text search method, is characterized in that, comprises:获取用户输入的搜索信息;Get the search information entered by the user;判断所述搜索信息的搜索方式是精确匹配搜索还是模糊匹配搜索;其中,所述模糊匹配搜索是指所述搜索信息中存在分隔符,且所述精确匹配搜索是指所述搜索信息中不存在分隔符;Determine whether the search method of the search information is an exact match search or a fuzzy match search; wherein, the fuzzy match search means that there is a separator in the search information, and the exact match search means that the search information does not exist separator;在所述搜索信息的搜索方式为所述模糊匹配搜索的情况下,将所述分隔符两端的搜索信息对应的第一目标文本进行第一高亮显示;When the search method of the search information is the fuzzy matching search, first highlight the first target text corresponding to the search information at both ends of the separator;在所述搜索信息的搜索方式为所述精确匹配搜索的情况下,将所述搜索信息对应的第二目标文本进行第二高亮显示;其中,所述第二高亮显示与所述第一高亮显示的显示方式不同。In the case where the search method of the search information is the exact match search, second highlighting is performed on the second target text corresponding to the search information; wherein the second highlighting is the same as the first highlighting Highlights are displayed differently.2.根据权利要求1所述的方法,其特征在于,所述将所述分隔符两端的搜索信息对应的第一目标文本进行第一高亮显示,包括:2. The method according to claim 1, wherein the first highlighting of the first target text corresponding to the search information at both ends of the separator comprises:获取与所述搜索信息关联的搜索字段;obtaining a search field associated with the search information;判断所述搜索信息是否为第一种类信息,所述第一种类信息包括拼音;Determine whether the search information is the first type of information, and the first type of information includes pinyin;在所述搜索信息为第一种类信息的情况下,构建所述搜索信息与所述搜索信息对应的汉字在所述搜索字段中的位置的第一映射;In the case that the search information is the first type of information, constructing a first mapping of the positions of the search information and the Chinese characters corresponding to the search information in the search field;基于所述第一映射,确定所述搜索信息在所述搜索字段中对应的第一起始位置和第一结束位置;determining, based on the first mapping, a first start position and a first end position corresponding to the search information in the search field;遍历所述搜索字段,根据所述第一起始位置和所述第一结束位置确定所述第一目标文本,并将所述第一目标文本进行所述第一高亮显示。Traverse the search field, determine the first target text according to the first start position and the first end position, and perform the first highlighting on the first target text.3.根据权利要求2所述的方法,其特征在于,所述方法还包括:3. The method according to claim 2, wherein the method further comprises:在所述搜索信息不是所述第一种类信息的情况下,确定所述搜索信息在所述搜索字段中对应的第二起始位置和第二结束位置;In the case that the search information is not the first type of information, determining a second start position and a second end position corresponding to the search information in the search field;遍历所述搜索字段,根据所述第二起始位置和所述第二结束位置确定第一目标文本,并将所述第一目标文本进行所述第一高亮显示。Traverse the search field, determine the first target text according to the second start position and the second end position, and perform the first highlighting on the first target text.4.根据权利要求2所述的方法,其特征在于,所述构建所述搜索信息与所述搜索信息对应的汉字在所述搜索字段中的位置的第一映射,包括:4. The method according to claim 2, wherein the construction of the first mapping of the positions of the Chinese characters corresponding to the search information and the search information in the search field comprises:将所述搜索字段转换为拼音,并构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射;Converting the search field into Pinyin, and constructing a second mapping between each Chinese character in the search field and the corresponding Pinyin of each Chinese character;构建所述搜索字段中每个汉字与所述每个汉字在所述搜索字段中位置之间的第三映射;constructing a third mapping between each Chinese character in the search field and the position of each Chinese character in the search field;基于所述搜索信息、所述第二映射和所述第三映射,构建所述第一映射。The first map is constructed based on the search information, the second map and the third map.5.根据权利要求4所述的方法,其特征在于,所述构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射,包括:5. method according to claim 4, is characterized in that, described constructing the second mapping between each Chinese character in described search field and the corresponding pinyin of described each Chinese character, comprising:针对所述搜索信息的第一个关键字,构建所述搜索字段中每个汉字与所述每个汉字对应的以首字母开始的拼音之间的第四映射;For the first keyword of the search information, construct a fourth mapping between each Chinese character in the search field and the pinyin corresponding to the first letter of each Chinese character;针对所述搜索信息的第一个关键字之外的其他关键字,构建所述搜索字段中每个汉字与所述每个汉字对应的以任意字母开始的拼音之间的第五映射;For other keywords other than the first keyword of the search information, construct a fifth mapping between each Chinese character in the search field and the pinyin starting with any letter corresponding to each Chinese character;基于所述搜索信息、所述第四映射及所述第五映射构建所述第二映射。The second map is constructed based on the search information, the fourth map, and the fifth map.6.根据权利要求5所述的方法,其特征在于,所述构建所述搜索字段中每个汉字与所述每个汉字对应的以任意字母开始的拼音之间的第五映射之后,所述方法还包括:6. method according to claim 5, is characterized in that, after described constructing the fifth mapping between each Chinese character in described search field and the pinyin corresponding to each Chinese character starting with any letter, described Methods also include:在所述其他关键字的起始位置小于等于所述第一个关键字的结束位置的情况下,将所述第一个关键字的起始位置和所述其他关键字的结束位置确定为第三起始位置和第三结束位置;In the case that the starting position of the other keywords is less than or equal to the ending position of the first keyword, the starting position of the first keyword and the ending position of the other keywords are determined as the first keyword. Three starting positions and third ending positions;遍历所述搜索字段,根据所述第三起始位置和所述第三结束位置确定所述第一目标文本,并将所述第一目标文本进行所述第一高亮显示。Traverse the search field, determine the first target text according to the third start position and the third end position, and perform the first highlighting on the first target text.7.根据权利要求4所述的方法,其特征在于,所述将所述搜索字段转换为拼音之前,所述方法还包括:7. The method according to claim 4, wherein before converting the search field into Pinyin, the method further comprises:判断所述搜索字段中的字符是否为表情;Determine whether the characters in the search field are expressions;在所述搜索字段中的字符不是表情的情况下,将所述搜索字段转换为拼音,并构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射;In the case that the characters in the search field are not expressions, converting the search field into pinyin, and constructing a second mapping between each Chinese character in the search field and the corresponding pinyin of each Chinese character;在所述搜索字段中的字符是表情的情况下,则不转换。In the case where the characters in the search field are expressions, no conversion is made.8.根据权利要求4所述的方法,其特征在于,所述将所述搜索字段转换为拼音,并构建所述搜索字段中每个汉字与所述每个汉字对应的拼音之间的第二映射,包括:8. The method according to claim 4, characterized in that, converting the search field into Pinyin, and constructing a second sentence between each Chinese character in the search field and the corresponding Pinyin of each Chinese character. mapping, including:将转换后的拼音对应的全拼存储到全拼集合,并构建所述搜索字段中每个汉字与所述每个汉字对应的全拼之间的第二映射;和/或,The full spelling corresponding to the converted pinyin is stored in the full spelling set, and the second mapping between each Chinese character and the corresponding full spelling of each Chinese character in the search field is constructed; and/or,将转换后的拼音对应的汉字首字母存储到首字母集合,并构建所述搜索字段中每个汉字与所述每个汉字对应的首字母之间的第二映射。The first letter of the Chinese character corresponding to the converted pinyin is stored in the initial letter set, and a second mapping between each Chinese character in the search field and the initial letter corresponding to each Chinese character is constructed.9.一种文本搜索装置,其特征在于,包括:9. A text search device, comprising:获取模块,用于获取用户输入的搜索信息;The acquisition module is used to acquire the search information input by the user;判断模块,用于判断所述搜索信息的搜索方式是精确匹配搜索还是模糊匹配搜索;其中,所述模糊匹配搜索是指所述搜索信息中存在分隔符,且所述精确匹配搜索是指所述搜索信息中不存在分隔符;a judging module for judging whether the search method of the search information is an exact match search or a fuzzy match search; wherein, the fuzzy match search refers to the existence of a separator in the search information, and the exact match search refers to the There is no delimiter in the search information;第一显示模块,用于在所述搜索信息的搜索方式为所述模糊匹配搜索的情况下,将所述分隔符两端的搜索信息对应的第一目标文本进行第一高亮显示;a first display module, configured to first highlight the first target text corresponding to the search information at both ends of the separator when the search method of the search information is the fuzzy matching search;第二显示模块,用于在所述搜索信息的搜索方式为所述精确匹配搜索的情况下,将所述搜索信息对应的第二目标文本进行第二高亮显示;其中,所述第二高亮显示与所述第一高亮显示的显示方式不同。The second display module is configured to perform a second highlight display on the second target text corresponding to the search information when the search method of the search information is the exact match search; The highlight display is displayed differently from the first highlight display.10.一种电子设备,其特征在于,包括:处理器、存储器和总线,所述存储器存储有所述处理器可执行的机器可读指令,当电子设备运行时,所述处理器与所述存储器之间通过总线通信,所述机器可读指令被所述处理器执行时执行如权利要求1至8任一所述的文本搜索方法。10. An electronic device, comprising: a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device operates, the processor and the The memory communicates with each other through a bus, and the machine-readable instruction executes the text search method according to any one of claims 1 to 8 when the machine-readable instruction is executed by the processor.11.一种计算机可读存储介质,其特征在于,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行如权利要求1至8任意一项所述的文本搜索方法。11. A computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to execute the text search method according to any one of claims 1 to 8 .
CN202111613097.XA2021-12-272021-12-27Text searching method and device, electronic equipment and storage mediumActiveCN114296606B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202111613097.XACN114296606B (en)2021-12-272021-12-27Text searching method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202111613097.XACN114296606B (en)2021-12-272021-12-27Text searching method and device, electronic equipment and storage medium

Publications (2)

Publication NumberPublication Date
CN114296606Atrue CN114296606A (en)2022-04-08
CN114296606B CN114296606B (en)2024-05-03

Family

ID=80969949

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202111613097.XAActiveCN114296606B (en)2021-12-272021-12-27Text searching method and device, electronic equipment and storage medium

Country Status (1)

CountryLink
CN (1)CN114296606B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN115033663A (en)*2022-06-152022-09-09上海柯林布瑞信息技术有限公司 Medical data search method and device based on conditional expression
CN118820446A (en)*2024-09-192024-10-22天津金城银行股份有限公司 A keyword tagging method, system, computer device and readable storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN1206883A (en)*1997-07-011999-02-03株式会社日立制作所 Structured document retrieval display method and device
CN101178737A (en)*2006-12-122008-05-14北京搜狗科技发展有限公司Method and system for publishing information related to internet key character
US20120150861A1 (en)*2010-12-102012-06-14Microsoft CorporationHighlighting known answers in search results
CN105956047A (en)*2016-04-262016-09-21北京橙鑫数据科技有限公司Search method and device
JP2019109703A (en)*2017-12-182019-07-04トッパン・フォームズ株式会社Document search apparatus, document search method, and program
CN111079036A (en)*2019-11-252020-04-28罗靖涛Field type searching method
CN111767451A (en)*2020-01-152020-10-13北京沃东天骏信息技术有限公司Searching method, electronic equipment and computer readable storage medium
CN112380420A (en)*2020-11-112021-02-19Vidaa美国公司Searching method and display device
CN113449069A (en)*2020-03-262021-09-28华为技术有限公司Method for searching contact and related equipment

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN1206883A (en)*1997-07-011999-02-03株式会社日立制作所 Structured document retrieval display method and device
CN101178737A (en)*2006-12-122008-05-14北京搜狗科技发展有限公司Method and system for publishing information related to internet key character
US20120150861A1 (en)*2010-12-102012-06-14Microsoft CorporationHighlighting known answers in search results
CN105956047A (en)*2016-04-262016-09-21北京橙鑫数据科技有限公司Search method and device
JP2019109703A (en)*2017-12-182019-07-04トッパン・フォームズ株式会社Document search apparatus, document search method, and program
CN111079036A (en)*2019-11-252020-04-28罗靖涛Field type searching method
CN111767451A (en)*2020-01-152020-10-13北京沃东天骏信息技术有限公司Searching method, electronic equipment and computer readable storage medium
CN113449069A (en)*2020-03-262021-09-28华为技术有限公司Method for searching contact and related equipment
WO2021190309A1 (en)*2020-03-262021-09-30华为技术有限公司Method for finding contact, and related device
CN112380420A (en)*2020-11-112021-02-19Vidaa美国公司Searching method and display device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
单纯的心: "elasticsearch搜索中文分词理解、类似SQL语句中的_LIKE"条件的模糊搜索以及忽略大小写搜索_elasticsearch like 不分词", pages 1 - 16, Retrieved from the Internet <URL:https://blog.csdn.net/zhangqiang_accp/article/details/80422820>*
博客人: "如何用SQL语句实现精确搜索以及模糊搜索", pages 1 - 2, Retrieved from the Internet <URL:https://www.cnblogs.com/BoKeRen/archive/2006/03/08/345755.html>*

Cited By (3)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN115033663A (en)*2022-06-152022-09-09上海柯林布瑞信息技术有限公司 Medical data search method and device based on conditional expression
CN118820446A (en)*2024-09-192024-10-22天津金城银行股份有限公司 A keyword tagging method, system, computer device and readable storage medium
CN118820446B (en)*2024-09-192025-01-28天津金城银行股份有限公司 A keyword tagging method, system, computer device and readable storage medium

Also Published As

Publication numberPublication date
CN114296606B (en)2024-05-03

Similar Documents

PublicationPublication DateTitle
CN104584003B (en)Word detection and domain dictionary recommendation
JP6007088B2 (en) Question answering program, server and method using a large amount of comment text
KR101116547B1 (en)Apparatus, method and system for a data entry interface
CN101375581B (en) Information positioning method and device
US20170076181A1 (en)Converting text strings into number strings, such as via a touchscreen input
US20090150322A1 (en)Predicting Candidates Using Information Sources
CN112559672B (en)Information detection method, electronic device and computer storage medium
CN114296606B (en)Text searching method and device, electronic equipment and storage medium
CN110941694A (en)Knowledge graph searching and positioning method and system, electronic equipment and storage medium
CN101131706A (en) A query correction method and system
US20100121870A1 (en)Methods and systems for processing complex language text, such as japanese text, on a mobile device
WO2014190795A1 (en)Method and device for searching for contact object, and storage medium
WO2022083750A1 (en)Text display method and apparatus and electronic device
US20230017449A1 (en)Method and apparatus for processing natural language text, device and storage medium
JP2007334534A (en)Apparatus and method for inputting character string, and program
CN112149403A (en)Method and device for determining confidential text
JP6538563B2 (en) INPUT SUPPORT DEVICE, INPUT SUPPORT METHOD, AND PROGRAM
CN114638218A (en)Symbol processing method, device, electronic equipment and storage medium
CN102024026A (en)Method and system for processing query terms
CN103186247A (en)Formula input method and system
TW200947241A (en)Database indexing algorithm and method and system for database searching using the same
CN112528600B (en) Text data processing method, related device and computer program product
JP4004060B1 (en) Character search method
CN110083817B (en) A naming disambiguation method, device and computer-readable storage medium
CN112346578A (en)Input method and device

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant
TR01Transfer of patent right
TR01Transfer of patent right

Effective date of registration:20250717

Address after:610000 Sichuan Province, Chengdu City, Jinjiang District, Tongbao Street No. 360, 1st Floor, Fuyi 1542A (Self-numbered)

Patentee after:Chengdu Yuexuebang Network Technology Co.,Ltd.

Country or region after:China

Address before:430073 Hubei Province, Wuhan City, Donghu New Technology Development Zone, No. 8 Xiongzhuang Road, Shuiguangxingcheng D Area [APP Square Project] 3# 17F-19F

Patentee before:Wuhan yuexuebang Network Technology Co.,Ltd.

Country or region before:China


[8]ページ先頭

©2009-2025 Movatter.jp