WO2022257455A1 - 一种相似文本的确定方法、装置、终端设备及存储介质 - Google Patents

一种相似文本的确定方法、装置、终端设备及存储介质 Download PDF

Info

Publication number
WO2022257455A1
WO2022257455A1 PCT/CN2022/071432 CN2022071432W WO2022257455A1 WO 2022257455 A1 WO2022257455 A1 WO 2022257455A1 CN 2022071432 W CN2022071432 W CN 2022071432W WO 2022257455 A1 WO2022257455 A1 WO 2022257455A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
key information
key
similarity
information
Prior art date
Application number
PCT/CN2022/071432
Other languages
English (en)
French (fr)
Inventor
郭怀宇
徐冰
汪伟
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2022257455A1 publication Critical patent/WO2022257455A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Definitions

  • the present application relates to the technical field of text data processing, and in particular to a method, device, terminal device, and storage medium for determining similar text.
  • the method for determining similar texts is often based on the cosine similarity of the texts, and two texts whose cosine similarity is greater than a threshold are regarded as similar texts.
  • the inventor realized that there are a large number of similar texts determined by the above method, and among the similar texts there are texts that are quite different from the content they want to find, and the user needs to spend a lot of time screening the required text content when viewing.
  • One of the purposes of the embodiments of the present application is to provide a method, device, terminal device, and storage medium for determining similar texts.
  • a method for determining similar texts including:
  • a device for determining similar text including:
  • a text acquisition module configured to acquire key information of the first text and key information of the second text
  • a quantity acquisition module configured to acquire the key information of the first text and the key information of the second text if the same key information exists in the key information of the first text and the key information of the second text There is a first quantity of the same key information
  • a similarity acquisition module configured to acquire a first similarity between the first text and the second text
  • a first judging module configured to determine whether the first text is similar to the second text based on the first quantity and the first similarity.
  • a terminal device including: a memory, a processor, and a computer program stored in the memory and operable on the processor, wherein, when the processor executes the computer program, the above-mentioned The method for determining similar texts described in any one of the first aspects.
  • an embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, wherein, when the computer program is executed by a processor, any one of the above-mentioned first aspects is implemented The method for determining similar texts described.
  • the embodiment of the present application provides a computer program product, which, when the computer program product is run on the terminal device, enables the terminal device to execute the method for determining similar texts described in any one of the above-mentioned first aspects.
  • the beneficial effect of a method for determining similar texts is: first obtain the key information of the first text and the key information of the second text, and determine whether the key information of the first text and the key information of the second text exist The first quantity of the same key information, and then obtain the first similarity between the first text and the second text, and finally determine whether the first text and the second text are similar based on the first quantity and the first similarity; in this application, through the first The first quantity of the same key information existing in the first text and the second text and the first degree of similarity between the first text and the second text jointly determine whether the two texts are similar.
  • FIG. 1 is a schematic diagram of an application scenario of a method for determining similar texts provided by an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a method for determining similar texts provided by an embodiment of the present application
  • FIG. 3 is a schematic flowchart of a method for determining similar texts provided in another embodiment of the present application.
  • FIG. 4 is a schematic flowchart of a method for determining a second text provided by an embodiment of the present application
  • FIG. 5 is a schematic flowchart of a method for judging that a candidate text satisfies a first preset condition provided by an embodiment of the present application
  • FIG. 6 is a schematic structural diagram of an apparatus for determining similar texts provided by an embodiment of the present application.
  • Fig. 7 is a schematic structural diagram of a terminal device provided by an embodiment of the present application.
  • FIG. 1 is a schematic diagram of an application scenario of a method for determining similar texts provided in an embodiment of the present application.
  • the above method for determining similar texts can be used to determine whether two texts are similar.
  • the first text and the second text are stored in the storage device 10, and the processor 20 is configured to acquire the first text and the second text from the storage device 10, and analyze the first text and the second text to determine the first text and the second text. Whether the second text is similar.
  • FIG. 2 shows a schematic flow chart of the method for determining similar text provided by the present application. With reference to Figure 2, the method is described in detail as follows:
  • the first text may be a title, a sentence, or a piece of text.
  • the second text can be a title, a sentence or a paragraph of text, etc.
  • the first text and the second text may be texts obtained from a storage device or a database.
  • the first text and the second text may also be human-input texts.
  • the acquisition methods of the first text and the second text may be the same or different.
  • key information of the first text may be acquired from a storage device.
  • key information of the first text may also be obtained from a key information extraction model.
  • the first text may be obtained first, and the first text may be input into a key information extraction model to obtain key information of the first text.
  • the key information extraction model may be a neural network model or the like.
  • the method for obtaining the key information of the second text is similar to the method for obtaining the key information of the first text, and reference may be made to the above method for obtaining the key information of the first text.
  • the method for obtaining the key information of the second text may be the same as or different from the method for obtaining the key information of the first text.
  • the key information may include key phrases and/or text classification information.
  • the key phrase of the first text may be a phrase extracted from the first text.
  • the key phrase of the second text may be a phrase extracted from the second text.
  • the classification information of the first text represents the category to which the content in the first text belongs.
  • the classification information of the second text represents the category to which the content in the second text belongs.
  • the classification information of the first text may be economics.
  • the quantity of the same key information existing in the key information of the first text and the key information of the second text can be compared. is recorded as the first quantity. If the key information includes key phrases and classification information, the key phrases of the first text need to be compared with the key phrases of the second text, and the classification information of the first text needs to be compared with the classification information of the second text.
  • the key information of the first text includes value-added tax, increasing year by year.
  • the key information of the second text includes sales tax, increasing year by year.
  • the first quantity of the same key information existing in the first text and the second text is 1.
  • the first similarity may be obtained from a similarity calculation model, or may be obtained from a storage device.
  • the first text and the second text may be input into the similarity calculation model to obtain the first similarity between the first text and the second text.
  • the first similarity may be a similarity between the word vectors of the first text and the word vectors of the second text.
  • the first similarity between the first text and each second text may be obtained.
  • the first number is greater than a first preset value and the first similarity is greater than a second preset value, it is determined that the first text is similar to the second text.
  • the first preset value and the second preset value can be set as required.
  • the first number is less than or equal to a first preset value, and/or the first degree of similarity is less than or equal to a second preset value, it is determined that the first text is not similar to the second text.
  • calculate the first product of the first quantity and the weight corresponding to the first quantity calculate the second product of the first similarity and the weight corresponding to the first similarity, and calculate the sum of the first product and the second product. If the sum of the first product and the second product is greater than a third preset value, it is determined that the first text and the second text are similar. The third preset value can be set as required. If the sum of the first product and the second product is less than or equal to a third preset value, it is determined that the first text and the second text are not similar.
  • the first text and the second text may be associated for subsequent viewing.
  • the first quantity of the same key information existing in the first text and the second text is obtained; the first similarity between the first text and the second text is obtained; based on the first quantity and the first similarity, It is determined whether the first text and the second text are similar.
  • the present application also uses the first quantity of the same key information existing in the first text and the second text to judge the two texts Whether it is a similar text, so that the similar text judged is more accurate.
  • step S102 may include:
  • the key information includes: key phrases, key phrases of the first text and key phrases of the second text are acquired;
  • the key information includes: classification information, obtaining the classification information of the first text and the classification information of the second text;
  • a third quantity of the same category information in the category information of the first text and the category information of the second text is determined, the first quantity includes the third quantity.
  • the key phrases of the first text may be obtained directly from the storage device.
  • the key phrases of the first text can be obtained from the key phrase extraction model.
  • the key phrase of the first text is obtained by inputting the first text into the key phrase extraction model.
  • the key phrase extraction method of the second text is similar to the key phrase extraction method of the first text, please refer to the key phrase extraction method of the first text, the key phrase acquisition method of the first text is the same as the key phrase extraction method of the second text
  • the acquisition methods can be the same or different.
  • the classification information to which the first text belongs may be obtained from a database, and the classification information of the first text may also be obtained by inputting the first text into a classification model.
  • the method for obtaining the classification information of the second text may be the same as or different from the method for obtaining the classification information of the first text.
  • the first quantity may include the second quantity and/or the third quantity. That is, the number of identical key phrases in the first text and the second text may be counted, and/or the amount of identical classification information in the classification information to which the first text belongs and the classification information to which the second text belongs may be counted.
  • the classification information of the first text is finance and politics
  • the classification information of the second text is finance. Then the number of the same classification information in the classification information to which the first text belongs and the classification information to which the second text belongs is 1.
  • the minimum value of the second quantity and the third quantity may be selected as the first quantity.
  • an average value of the second quantity and the third quantity may be calculated, and the calculated average value may be used as the first quantity.
  • the third amount of information can provide a plurality of reference data for the subsequent calculation of whether the first text and the second text are similar, making the similarity judgment between the first text and the second text more accurate.
  • step S103 may include:
  • the key information includes: a key phrase, calculating a first distance between the key phrase of the first text and the key phrase of the second text, and the first similarity includes the first distance.
  • the WMD algorithm model includes:
  • c(i,j) is the Euclidean distance between key phrase i in the first text and key phrase j in the second text; T ij is the ratio when key phrase i is transferred to key phrase j; d i is the The weight of key phrase i in a text in the first text; d' j is the weight of key phrase j in the second text in the second text.
  • step S103 may include:
  • the complete first text and the second text are divided into independent word sets; the union set (word bag) of the two word sets is obtained; the word frequency of each word set is calculated and the word frequency is vectorized, By substituting the cosine formula, the text cosine similarity can be calculated.
  • step S103 may include:
  • the useless information may include the institution that issued the document, the verb, and the number of the document, such as about, forward, and notice.
  • useless information in the text can be removed to obtain effective information in the text.
  • useless information may be removed by inputting the first text into the information query model to obtain valid information of the first text.
  • the second text can be input into the information query model to remove useless information to obtain valid information of the second text.
  • the cosine similarity of the two effective information can be calculated, which is recorded as the second cosine similarity in this application.
  • the first similarity may include at least one of the first distance, the first cosine similarity and the second cosine similarity.
  • an average of the above three can be calculated, and the above three average is recorded as the first similarity.
  • the minimum value among the first distance, the first cosine similarity and the second cosine similarity may be used as the first similarity.
  • the first number includes the second number and the third number
  • the first similarity includes the first distance
  • the implementation process of step S104 may include:
  • a total similarity can be calculated based on the second quantity, the third quantity, the first distance, the first cosine similarity, the second cosine similarity, and their corresponding weights. is the target similarity. Use target similarity to evaluate whether two texts are similar.
  • a first preset threshold can be set, and if the target similarity is greater than or equal to the first preset threshold, the first text and the second text are regarded as similar texts, and the first text and the second text are associated . Otherwise, it is determined that the first text and the second text are not similar.
  • the first preset threshold can be set as required.
  • the target similarity can be sorted from large to small, and the first preset
  • the second text corresponding to the number of target similarities is regarded as the target text similar to the first text.
  • the first preset number can be set as required.
  • the 5 second texts are A, B, C, D and E respectively, and the target similarities obtained by the 5 second texts are A is a, B is b, C is c, D is d, E is e, and the order of target similarity from large to small is d, b, e, a, c, and the second text corresponding to the first three target similarities can be regarded as similar to the first text
  • the second text similar to the first text includes D, B, and E.
  • the second cosine similarity between the effective information of the first text and the effective information of the second text is used, and the first cosine similarity between the first text and the second text is used to jointly determine the first text and the second text.
  • Whether the second text is a similar text is because: if only valid information is used to judge whether the two texts are similar, it may be due to the limited matching of the topics of the two texts, and no text similar to the first text can be found. Therefore, in order to avoid the above situation, adding With the first cosine similarity, even if there is no text similar to the first text, it can be used to find the text of the same organization or the same text structure when querying similar texts.
  • multiple indicators are used to judge whether the first text and the second text are similar, and it is possible to judge whether the first text and the second text are similar from multiple perspectives, which can make the judgment angle more comprehensive, and then make the judgment of the two texts Whether similar is more accurate.
  • the second text can be obtained from candidate texts through screening.
  • the candidate text may be a text in a database or a storage device, and the second text may also be a text input by a user.
  • the above method may further include:
  • the key information of the candidate text can be obtained from a storage device, and can also be obtained from a key information extraction model.
  • the key information of the candidate text can be obtained by inputting the candidate text into the key information extraction model.
  • the first preset condition may be set as required, for example, the first preset condition may include that the number of identical key information is greater than a preset value, and the like. Preset values can be set as desired.
  • step S202 may include:
  • the same key information may include the same key phrase and/or the same classification information.
  • the key information includes key phrases and classification information
  • the same key phrase and/or the same classification information exist in the first text and the candidate text, it is determined that the candidate text satisfies the first preset condition, otherwise It is determined that the candidate text does not meet the first preset condition.
  • TF-IDF term frequency-inverse document frequency
  • IDF Inverse Document Frequency
  • the candidate text may be used as the second text.
  • the second preset threshold can be set as required.
  • the tf-idf values of each candidate text and the first text can be calculated to obtain multiple tf-idf value. Sort the multiple tf-idf values from large to small, and take the candidate text corresponding to the second preset tf-idf value as the second text.
  • the second preset number can be set as required.
  • the tf-idf values of the 200 candidate texts and the first text can be arranged from large to small, and the candidate texts corresponding to the first 100 tf-idf values can be selected as the second text.
  • the number of the same key information of the key information of the first text and the key information of the candidate text is preliminarily screened out the candidate texts satisfying the first preset condition, and then the texts satisfying the first preset condition are calculated.
  • the tf-idf value of the candidate text and the first text is used to determine the second text through the tf-idf value; through the above method, the candidate text can be preliminarily screened, and then judge whether the screened second text is similar to the first text.
  • the judging result may be verified.
  • the above method may further include:
  • the actual result can be retrieved from the storage device.
  • the real result may be a result of whether the first text and the second text are similar texts after human judgment.
  • the method for determining the above-mentioned similar texts is accurate.
  • the method for determining the above similar texts is not accurate.
  • the accuracy of the above method can be verified to provide a basis for optimizing the above method.
  • FIG. 6 shows a structural block diagram of an apparatus for determining similar texts provided in the embodiments of the present application. part.
  • the device 300 may include: a text acquisition module 310 , a quantity acquisition module 320 , a similarity degree acquisition module 330 and a first judgment module 340 .
  • the text obtaining module 310 is used to obtain the key information of the first text and the key information of the second text;
  • a quantity acquisition module 320 configured to acquire the key information of the first text and the key information of the second text if the same key information exists in the key information of the first text and the key information of the second text The first quantity of the same key information exists in;
  • a similarity acquisition module 330 configured to acquire a first similarity between the first text and the second text
  • the first judging module 340 is configured to determine whether the first text is similar to the second text based on the first quantity and the first similarity.
  • the quantity acquisition module 320 may specifically be used for:
  • the key information includes: key phrases, key phrases of the first text and key phrases of the second text are acquired;
  • the key information includes: classification information, obtaining the classification information of the first text and the classification information of the second text;
  • a third quantity of the same category information in the category information of the first text and the category information of the second text is determined, the first quantity includes the third quantity.
  • the similarity acquisition module 330 can be specifically used for:
  • the key information includes: a key phrase, calculating a first distance between the key phrase of the first text and the key phrase of the second text, and the first similarity includes the first distance;
  • the similarity acquisition module 330 can be specifically used for:
  • the first judging module 340 can specifically be used for:
  • the target similarity is greater than or equal to a first preset threshold, it is determined that the first text is similar to the second text.
  • the text acquisition module 310 also includes:
  • An information acquisition module configured to acquire key information of the first text and key information of candidate texts in the database
  • a second judging module configured to determine whether the candidate text satisfies a first preset condition based on the key information of the first text and the key information of the candidate text;
  • a tf-idf value calculation module configured to calculate the tf-idf values of the first text and the candidate text when the candidate text satisfies the first preset condition
  • a third judging module configured to use the candidate text as the second text when the tf-idf value is greater than a second preset threshold.
  • the second judging module may specifically be used for:
  • the embodiment of the present application also provides a terminal device.
  • the terminal device 400 may include: at least one processor 410, a memory 420, and A running computer program, when the processor 410 executes the computer program, implements the steps in any of the foregoing method embodiments, for example, step S101 to step S104 in the embodiment shown in FIG. 2 .
  • the processor 410 executes the computer program, it realizes the functions of the modules/units in the above-mentioned device embodiments, for example, the functions of the modules 310 to 340 shown in FIG. 6 .
  • the computer program can be divided into one or more modules/units, and one or more modules/units are stored in the memory 420 and executed by the processor 410 to complete the present application.
  • the one or more modules/units may be a series of computer program segments capable of accomplishing specific functions, and the program segments are used to describe the execution process of the computer program in the terminal device 400 .
  • FIG. 7 is only an example of a terminal device, and does not constitute a limitation on the terminal device. It may include more or less components than those shown in the figure, or combine certain components, or different components, such as Input and output devices, network access devices, buses, etc.
  • the processor 410 can be a central processing unit (Central Processing Unit, CPU), and can also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the memory 420 can be an internal storage unit of the terminal device, or an external storage device of the terminal device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash memory card (Flash Card) etc.
  • the memory 420 is used to store the computer program and other programs and data required by the terminal device.
  • the memory 420 can also be used to temporarily store data that has been output or will be output.
  • the bus can be an Industry Standard Architecture (Industry Standard Architecture, ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (Extended Industry Standard Architecture, EISA) bus, etc.
  • ISA Industry Standard Architecture
  • PCI Peripheral Component Interconnect
  • EISA Extended Industry Standard Architecture
  • the bus can be divided into address bus, data bus, control bus and so on.
  • the buses in the drawings of the present application are not limited to only one bus or one type of bus.
  • the method for determining similar text provided in the embodiments of the present application can be applied to terminal devices such as computers, tablet computers, notebook computers, netbooks, and personal digital assistants (PDA). any restrictions.
  • terminal devices such as computers, tablet computers, notebook computers, netbooks, and personal digital assistants (PDA). any restrictions.
  • the embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it can realize the above-mentioned method for determining similar text in each embodiment. step.
  • the computer-readable storage medium may be non-volatile or volatile.
  • An embodiment of the present application provides a computer program product.
  • the computer program product When the computer program product is run on a mobile terminal, the mobile terminal can realize the steps in each embodiment of the above method for determining similar text when executed.
  • the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the procedures in the methods of the above embodiments in the present application can be completed by instructing related hardware through computer programs, and the computer programs can be stored in a computer-readable storage medium.
  • the computer program When executed by a processor, the steps in the above-mentioned various method embodiments can be realized.
  • the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form.
  • the computer-readable medium may at least include: any entity or device capable of carrying computer program codes to the photographing device/terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium.
  • ROM read-only memory
  • RAM random access memory
  • electrical carrier signal telecommunication signal and software distribution medium.
  • U disk mobile hard disk
  • magnetic disk or optical disk etc.
  • computer readable media may not be electrical carrier signals and telecommunication signals under legislation and patent practice.
  • the disclosed device/network device and method may be implemented in other ways.
  • the device/network device embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

Abstract

本申请公开一种相似文本的确定方法、装置、终端设备及存储介质,该方法包括:获取第一文本的关键信息和第二文本的关键信息;若第一文本的关键信息和第二文本的关键信息中存在相同的关键信息,获取第一文本的关键信息和第二文本的关键信息中存在相同的关键信息的第一数量;获取第一文本和第二文本的第一相似度;基于第一数量和第一相似度,确定第一文本和第二文本是否相似;本申请相较于仅使用两个文本的相似度确定两个文本是否相似的方法,本申请使用第一文本和第二文本中存在的相同关键信息的第一数量和第一文本和第二文本的第一相似度共同确定两个文本是否相似,使确定相似文本更准确。

Description

一种相似文本的确定方法、装置、终端设备及存储介质
本申请要求于2021年06月09日提交中国专利局、申请号为202110642144.7、发明名称为“一种相似文本的确定方法、装置、终端设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及文本数据处理技术领域,尤其涉及一种相似文本的确定方法、装置、终端设备及存储介质。
背景技术
用户在搜索信息时往往希望寻找并查看与输入文本相似的文本,例如用户在搜索政策时并不只想搜索某一政策,还希望能够搜索到相关政策。
目前,确定相似文本的方法往往是基于文本的余弦相似度,将两个文本的余弦相似度大于阈值的两个文本作为相似文本。发明人意识到使用上述方法确定的相似文本数量繁多,相似文本中存在与希望查找的内容差异较大的文本,用户在查看时需要耗费大量的时间筛选需要的文本内容。
技术问题
本申请实施例的目的之一在于:提供一种相似文本的确定方法、装置、终端设备及存储介质。
技术解决方案
本申请实施例采用的技术方案是:
第一方面,提供了一种相似文本的确定方法,包括:
获取第一文本的关键信息和第二文本的关键信息;
若所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息,获取所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息的第一数量;
获取所述第一文本和所述第二文本的第一相似度;
基于所述第一数量和所述第一相似度,确定所述第一文本和所述第二文本是否相似。
第二方面,提供了一种相似文本的确定装置,包括:
文本获取模块,用于获取第一文本的关键信息和第二文本的关键信息;
数量获取模块,用于若所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息,获取所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息的第一数量;
相似度获取模块,用于获取所述第一文本和所述第二文本的第一相似度;
第一判断模块,用于基于所述第一数量和所述第一相似度,确定所述第一文本和所述第二文本是否相似。
第三方面,提供一种终端设备,包括:存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其中,所述处理器执行所述计算机程序时实现上述第一方面中任一项所述的相似文本的确定方法。
第四方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其中,所述计算机程序被处理器执行时实现上述第一方面中任一项所述的相似文本的确定方法。
第五方面,本申请实施例提供了一种计算机程序产品,当计算机程序产品在终端 设备上运行时,使得终端设备执行上述第一方面中任一项所述的相似文本的确定方法。
有益效果
本申请实施例提供的一种相似文本的确定方法的有益效果在于:先获取第一文本的关键信息和第二文本的关键信息,确定第一文本的关键信息和第二文本的关键信息中存在相同的关键信息的第一数量,然后获取第一文本和第二文本的第一相似度,最后基于第一数量和第一相似度确定第一文本和第二文本是否相似;本申请中通过第一文本和第二文本中存在的相同关键信息的第一数量和第一文本和第二文本的第一相似度共同确定两个文本是否相似。
可以理解的是,上述第二方面至第五方面的有益效果可以参见上述第一方面中的相关描述,在此不再赘述。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或示范性技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。
图1是本申请一实施例提供的相似文本的确定方法的应用场景示意图;
图2是本申请一实施例提供的相似文本的确定方法的流程示意图;
图3是本申请另一实施例提供的相似文本的确定方法的流程示意图;
图4是本申请一实施例提供的第二文本的确定方法的流程示意图;
图5是本申请一实施例提供的候选文本满足第一预设条件的判断方法的流程示意图;
图6是本申请一实施例提供的相似文本的确定装置的结构示意图;
图7是本申请一实施例提供的终端设备的结构示意图。
本发明的实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。
术语“第一”、“第二”仅用于便于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明技术特征的数量。“多个”的含义是两个或两个以上,除非另有明确具体的限定。
为了说明本申请所提供的技术方案,以下结合具体附图及实施例进行详细说明。
图1为本申请实施例提供的相似文本的确定方法的应用场景示意图,上述相似文本的确定方法可以用于确定两个文本是否相似。其中,存储设备10中存储第一文本和第二文本,处理器20用于从存储设备10中获取第一文本和第二文本,并对第一文本和第二文本进行分析确定第一文本和第二文本是否相似。
以下结合图1对本申请实施例的相似文本的确定方法进行详细说明。
图2示出了本申请提供的相似文本的确定方法的示意性流程图,参照图2,对该方法的详述如下:
S101,获取第一文本的关键信息和第二文本的关键信息。
在本实施例中,第一文本可以是一个标题、一个句子或一段文字等。第二文本可以是一个标题、一个句子或一段文字等。第一文本和第二文本可以是从存储设备或数据库中获取的文本。第一文本和第二文本还可以是人为输入的文本。第一文本和第二文本的获取方式可以相同也可以不同。
在本实施例中,第一文本的关键信息可以从存储设备中获取。
可选的,第一文本的关键信息还可以从关键信息提取模型中获取。具体的,可以先获取第一文本,将第一文本输入关键信息提取模型中得到第一文本的关键信息。关键信息提取模型可以是神经网络模型等。
在本实施例中,第二文本的关键信息的获取方法与第一文本的关键信息的获取方法相似,可以参照上述第一文本的关键信息的获取方法。第二文本的关键信息的获取方法可以与第一文本的关键信息的获取方法可以相同也可以不同。
在本实施例中,关键信息可以包括关键短语和/或文本的分类信息。
具体的,第一文本的关键短语可以是从第一文本中提取出的短语。第二文本的关键短语可以是从第二文本中提取出的短语。第一文本的分类信息表征第一文本中的内容所属的类别。第二文本的分类信息表征第二文本中的内容所属的类别。
作为举例,如果第一文本为A城市的经济在不断变好。第一文本的分类信息可以是经济。
S102,若所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息,获取所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息的第一数量。
在本实施例中,在得到第一文本的关键信息和第二文本的关键信息后,可以比较第一文本的关键信息和第二文本的关键信息中存在的相同的关键信息的数量,本申请中记为第一数量。若关键信息包括关键短语和分类信息,则第一文本的关键短语需要与第二文本的关键短语进行比较,第一文本的分类信息需要与第二文本的分类信息进行比较。
作为举例,如果第一文本的关键信息包括增值税、逐年递增。第二文本的关键信息包括营业税、逐年递增。第一文本和第二文本中存在的相同的关键信息的第一数量为1。
在本实施例中,第二文本可以存在多个。若第二文本存在多个,则可以获取第一文本和每个第二文本的第一数量。
S103,获取所述第一文本和所述第二文本的第一相似度。
在本实施例中,第一相似度可以是从相似度计算模型中获取的,还可以是从存储设备中获取的。具体的,可以将第一文本和第二文本输入相似度计算模型中得到第一文本和第二文本的第一相似度。
可选的,第一相似度可以是第一文本的词向量和第二文本的词向量之间的相似度。
在本实施例中,如果存在多个第二文本,可以获取第一文本分别与每个第二文本的第一相似度。
S104,基于所述第一数量和所述第一相似度,确定所述第一文本和所述第二文本是否相似。
可选的,如果第一数量大于第一预设值、且第一相似度大于第二预设值,则确定第一文本和第二文本相似。第一预设值和第二预设值可以根据需要进行设置。
可选的,如果第一数量小于或等于第一预设值,和/或第一相似度小于或等于第二预设值,则确定第一文本和第二文本不相似。
可选的,计算第一数量与第一数量对应的权重的第一乘积,计算第一相似度和第一相似度对应的权重的第二乘积,计算第一乘积与第二乘积的和。如果第一乘积和第二乘积的和大于第三预设值,则确定第一文本和第二文本相似。第三预设值可以根据需要进行设置。如果第一乘积和第二乘积的和小于或等于第三预设值,则确定第一文本和第二文本不相似。
在本实施例中,如果确定第一文本和第二文本相似,则可以将第一文本和第二文本进行关联,以便于后续查看。
本申请实施例中,获取第一文本和第二文本中存在的相同的关键信息的第一数量; 获取第一文本和第二文本的第一相似度;基于第一数量和第一相似度,确定第一文本和第二文本是否相似。本申请相比于仅仅通过文本的相似度来判断两个文本是否为相似文本的方法,本申请还使用第一文本和第二文本中存在的相同的关键信息的第一数量来判断两个文本是否为相似文本,使判断的相似文本更准确。
在一种可能的实现方式中,步骤S102的实现过程可以包括:
所述关键信息包括:关键短语,获取所述第一文本的关键短语和所述第二文本的关键短语;
确定所述第一文本的关键短语和所述第二文本的关键短语中存在的相同关键短语的第二数量,所述第一数量包括所述第二数量;
和/或,
所述关键信息包括:分类信息,获取所述第一文本的分类信息和所述第二文本的分类信息;
确定所述第一文本的分类信息和所述第二文本的分类信息中相同分类信息的第三数量,所述第一数量包括所述第三数量。
在本实施例中,第一文本的关键短语可以直接从存储设备中获取。
在本实施例中,第一文本的关键短语可以从关键短语提取模型中得到。具体的,将第一文本输入关键短语提取模型得到第一文本的关键短语。第二文本的关键短语的提取方法与第一文本的关键短语的提取方法相似,请参照第一文本的关键短语的提取方法,第一文本的关键短语的获取方法与第二文本的关键短语的获取方法可以相同也可以不同。
在本实施例中,第一文本所属的分类信息可以从数据库中获取,还可以将第一文本输入分类模型中得到第一文本的分类信息。第二文本的分类信息的获取方法与第一文本的分类信息的获取方法可以相同也可以不同。
在本实施例中,第一数量可以包括第二数量和/或第三数量。也就是可以统计第一文本和所述第二文本中存在的相同关键短语的数量,和/或统计第一文本所属的分类信息和所述第二文本所属的分类信息中相同分类信息的数量。
作为举例,如果第一文本的分类信息为金融和政治,第二文本的分类信息金融。则第一文本所属的分类信息和第二文本所属的分类信息中相同的分类信息的数量为1。
可选的,得到第二数量和第三数量后,可以选择第二数量和第三数量中的最小值作为第一数量。
可选的,得到第二数量和第三数量后,可以计算第二数量和第三数量的平均值,将计算的平均值作为第一数量。
本申请实施例中,通过统计第一文本的关键短语和第二文本的关键短语中存在的相同关键短语的第二数量,以及统计第一文本的分类信息和第二文本的分类信息中相同分类信息的第三数量,可以为后续计算第一文本和第二文本是否相似提供多个参考数据,使第一文本和第二文本的相似性判断更准确。
在一种可能的实现方式中,步骤S103的实现过程可以包括:
S1031,所述关键信息包括:关键短语,计算所述第一文本的关键短语和所述第二文本的关键短语之间的第一距离,所述第一相似度包括所述第一距离。
具体的,基于WMD算法模型(Word Mover’s Distance-词移距离),计算所述第一文本的关键短语和所述第二文本的关键短语之间的第一距离。
具体的,WMD算法模型包括:
Figure PCTCN2022071432-appb-000001
Figure PCTCN2022071432-appb-000002
Figure PCTCN2022071432-appb-000003
其中,c(i,j)为第一文本的关键短语i和第二文本中的关键短语j之间的欧式距离;T ij为关键短语i转移为关键短语j时的比例;d i为第一文本中的关键短语i在第一文本中的权重;d' j为第二文本中关键短语j在第二文本中的权重。
和/或,步骤S103的实现过程可以包括:
S1032,计算所述第一文本和所述第二文本的第一余弦相似度,所述第一相似度包括所述第一余弦相似度。
具体的,通过中文分词,把完整的第一文本和第二文本分成独立的词集合;.求出两个词集合的并集(词包);计算各自词集的词频并将词频向量化,代入余弦公式就可以求出文本余弦相似度。
和/或,步骤S103的实现过程可以包括:
S1033,获取所述第一文本的有效信息和所述第二文本的有效信息。
在本实施例中,由于第一文本中可能存在无用信息,无用信息可以包括发文机构、动词和发文号等,例如:关于、转发、通知等。为了计算简便,且计算的相似度更准确,可以去除文本中的无用信息,得到文本中的有效信息。
具体的,可以将第一文本输入信息查询模型中去除无用信息,得到第一文本的有效信息。可以将第二文本输入信息查询模型中去除无用信息,得到第二文本的有效信息。
S1034,计算所述第一文本的有效信息和所述第二文本的有效信息的第二余弦相似度,所述第一相似度包括所述第二余弦相似度。
在本实施例中,在得到第一文本的有效信息和第二文本的有效信息后,可以计算两个有效信息的余弦相似度,本申请中记为第二余弦相似度。
在本实施例中,第一相似度可以包括第一距离、第一余弦相似度和第二余弦相似度中的至少一个。
可选的,在得到第一距离、第一余弦相似度和第二余弦相似度可以计算上述三者的平均值,将上述三者的平均值记为第一相似度。
可选的,可以将第一距离、第一余弦相似度和第二余弦相似度中的最小值作为第一相似度。
本申请实施例中,通过统计第一文本和第二文本的第一距离、第一余弦相似度和第二余弦相似度,可以为后续计算第一文本和第二文本是否相似提供多个参考数据,使第一文本和第二文本的相似性判断更准确。
如图3所示,在一种可能的实现方式中,在所述第一数量包括第二数量和第三数量,所述第一相似度包括第一距离、第一余弦相似度和第二余弦相似度时,步骤S104的实现过程可以包括:
S1041,基于所述第二数量、所述第二数量对应的权重、所述第三数量、所述第三数量对应的权重、所述第一距离、所述第一距离对应的权重、所述第一余弦相似度、所述第一余弦相似度对应的权重、所述第二余弦相似度和所述第二余弦相似度对应的权重,计算所述第一文本和所述第二文本的目标相似度。
在本实施例中,可以基于第二数量、第三数量、第一距离、第一余弦相似度、第二余弦相似度,以及各自对应的权重计算一个总的相似度,本申请中记为目标相似度。利用目标相似度评估两个文本是否相似。
S1042,在所述目标相似度小于第一预设阈值时,确定所述第一文本和所述第二文本不相似。
S1043,在所述目标相似度大于或等于第一预设阈值时,确定所述第一文本和所述第二文本相似。
本实施例中,可以设置第一预设阈值,如果目标相似度大于或等于第一预设阈值,则将第一文本和第二文本作为相似文本,并将第一文本和第二文本进行关联。反之则确定第一文本和第二文本不相似。第一预设阈值可以根据需要进行设置。
在本实施例中,如果存在多个第二文本,还可以在获得第一文本与每个第二文本的目标相似度后,将目标相似度从大到小进行排序,取前边第一预设个数的目标相似度对应的第二文本作为与第一文本相似的目标文本。第一预设个数可以根据需要进行设置。
作为举例,如果存在5个第二文本,5个第二文本分别为A、B、C、D和E,且5个第二文本得到的目标相似度分别为A为a,B为b,C为c,D为d,E为e,目标相似度从大到小的排序为d、b、e、a、c,可以将前三个目标相似度对应的第二文本作为与第一文本相似的文本,因此,与第一文本相似的第二文本包括D、B和E。
本申请实施例中,使用第一文本的有效信息和第二文本的有效信息的第二余弦相似度,以及利用第一文本和第二文本的第一余弦相似度共同判断第一文本和第二文本是否为相似文本是因为:如果仅使用有效信息判断两文本是否相似,可能由于两个文本主题匹配有限,进而找不到与第一文本相似的文本,因此,为了避免上述情况出现加入了第一余弦相似度,即使不存在与第一文本呢主题相似的文本,用于在查询相似文本时也可以找到同一机构或同一行文结构的文本。
本申请实施例中,使用多个指标判断第一文本和第二文本是否相似,可以从多角度入手判断第一文本和第二文本是否相似,可以使判断的角度更全面,进而使判断两文本是否相似更准确。
在一种可能的实现方式中,第二文本可以通过筛选从候选文本得到。候选文本可以是数据库或存储设备中的文本,第二文本还可以是用户输入的文本。
具体的,可以根据第一文本和候选文本的关键信息,以及第一文本和候选文本的tf-idf值确定候选文本是否为第二文本。
如图4所示,在一种可能的实现方式中,在步骤S101之前,上述方法还可以包括:
S201,获取所述第一文本的关键信息和数据库中的候选文本的关键信息。
在本实施例中,候选文本的关键信息可以从存储设备中获取,还可以从关键信息提取模型中获取。将候选文本输入关键信息提取模型中可以得到候选文本的关键信息。
S202,基于所述第一文本的关键信息和所述候选文本的关键信息,确定所述候选文本是否满足第一预设条件。
在本实施例中,第一预设条件可以根据需要进行设置,例如,第一预设条件可以包括关键信息相同的个数大于预设数值等。预设数值可以根据需要进行设置。
如图5所示,具体的,步骤S202的实现过程可以包括:
S2021,确定所述第一文本的关键信息和所述候选文本的关键信息中是否存在相同的关键信息。
在本实施例中,相同的关键信息可以包括相同的关键短语和/或相同的分类信息。
S2022,若所述第一文本的关键信息和所述候选文本的关键信息中存在相同的关键信息,则确定所述候选文本满足所述第一预设条件。
在本实施例中,在关键信息包括关键短语和分类信息时,如果第一文本和候选文本中存在相同的关键短语和/或相同分类信息,则确定候选文本满足第一预设条件,反之则确定候选文本不满足第一预设条件。
S203,在所述候选文本满足所述第一预设条件时,计算所述第一文本与所述候选 文本的tf-idf值。
在本实施例中,TF-IDF(term frequency–inverse document frequency)是一种用于信息检索与数据挖掘的常用加权技术。TF是词频(Term Frequency),IDF是逆文本频率指数(Inverse Document Frequency)。
S204,在所述tf-idf值大于第二预设阈值时,将所述候选文本作为所述第二文本。
在本实施例中,如果tf-idf值大于第二预设阈值时,则可以将候选文本作为第二文本。第二预设阈值可以根据需要进行设置。
在本实施例中,如果存在多个候选文本,且存在多个候选文本均满足第一预设条件,则可以计算每个候选文本与第一文本的tf-idf值,得到多个tf-idf值。将多个tf-idf值从大到小进行排序,取前边第二预设个数的tf-idf值对应的候选文本作为第二文本。第二预设个数可以根据需要进行设置。
作为举例,如果存在200个候选文本满足第一预设条件,可以将200个候选文本与第一文本的tf-idf值从大到小进行排列,取前100个tf-idf值对应的候选文本作为第二文本。
本申请实施例中,通过第一文本的关键信息和候选文本的关键信息的相同的关键信息的个数,初步筛选出满足第一预设条件的候选文本,然后计算满足第一预设条件的候选文本与第一文本的tf-idf值,通过tf-idf值确定第二文本;通过上述方法可以将候选文本进行初步筛选,然后判断筛选出的第二文本是否与第一文本相似。本申请经过初步筛选可以减少工作量,提高工作效率。
在一种可能的实现方式中,在判断出第一文本和第二文本是否为相似文本后,可以对判断的结果进行验证。
具体的,在步骤S104之后,上述方法还可以包括:
将判断的结果与真实结果进行对比,确定上述相似文本的确定方法是否准确。
在本实施例中,真实结果可以从存储设备中获取。真实结果可以是经过人为判断的第一文本和第二文本是否为相似文本的结果。
具体的,如果经过上述方法判断得到第一文本和第二文本是相似文本,且第一文本和第二文本的真实结果为相似文本,则确定上述相似文本的确定方法准确。反之则确定上述相似文本的确定方法不准确。
本申请实施例中,在使用上述方法判断第一文本和第二文本是否相似后,可以通过验证上述方法是否准确,进而对上述方法进行优化提供依据。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
对应于上文实施例所述的相似文本的确定方法,图6示出了本申请实施例提供的相似文本的确定装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。
参照图6,该装置300可以包括:文本获取模块310、数量获取模块320、相似度获取模块330和第一判断模块340。
其中,文本获取模块310,用于获取第一文本的关键信息和第二文本的关键信息;
数量获取模块320,用于若所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息,获取所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息的第一数量;
相似度获取模块330,用于获取所述第一文本和所述第二文本的第一相似度;
第一判断模块340,用于基于所述第一数量和所述第一相似度,确定所述第一文本和所述第二文本是否相似。
在一种可能的实现方式中,数量获取模块320具体可以用于:
所述关键信息包括:关键短语,获取所述第一文本的关键短语和所述第二文本的关键短语;
确定所述第一文本的关键短语和所述第二文本的关键短语中存在的相同关键短语的第二数量,所述第一数量包括所述第二数量;
和/或,
所述关键信息包括:分类信息,获取所述第一文本的分类信息和所述第二文本的分类信息;
确定所述第一文本的分类信息和所述第二文本的分类信息中相同分类信息的第三数量,所述第一数量包括所述第三数量。
在一种可能的实现方式中,相似度获取模块330具体可以用于:
所述关键信息包括:关键短语,计算所述第一文本的关键短语和所述第二文本的关键短语之间的第一距离,所述第一相似度包括所述第一距离;
和/或,
计算所述第一文本和所述第二文本的第一余弦相似度,所述第一相似度包括所述第一余弦相似度;
和/或,
获取所述第一文本的有效信息和所述第二文本的有效信息;
计算所述第一文本的有效信息和所述第二文本的有效信息的第二余弦相似度,所述第一相似度包括所述第二余弦相似度。
在一种可能的实现方式中,相似度获取模块330具体可以用于:
基于WMD算法模型,计算所述第一文本的关键短语和所述第二文本的关键短语之间的第一距离。
在一种可能的实现方式中,在所述第一数量包括第二数量和第三数量,所述第一相似度包括第一距离、第一余弦相似度和第二余弦相似度时,第一判断模块340具体可以用于:
基于所述第二数量、所述第二数量对应的权重、所述第三数量、所述第三数量对应的权重、所述第一距离、所述第一距离对应的权重、所述第一余弦相似度、所述第一余弦相似度对应的权重、所述第二余弦相似度和所述第二余弦相似度对应的权重,计算所述第一文本和所述第二文本的目标相似度;
在所述目标相似度小于第一预设阈值时,确定所述第一文本和所述第二文本不相似;
在所述目标相似度大于或等于第一预设阈值时,确定所述第一文本和所述第二文本相似。
在一种可能的实现方式中,与文本获取模块310相连的还包括:
信息获取模块,用于获取所述第一文本的关键信息和数据库中的候选文本的关键信息;
第二判断模块,用于基于所述第一文本的关键信息和所述候选文本的关键信息,确定所述候选文本是否满足第一预设条件;
tf-idf值计算模块,用于在所述候选文本满足所述第一预设条件时,计算所述第一文本与所述候选文本的tf-idf值;
第三判断模块,用于在所述tf-idf值大于第二预设阈值时,将所述候选文本作为所述第二文本。
在一种可能的实现方式中,第二判断模块具体可以用于:
确定所述第一文本的关键信息和所述候选文本的关键信息中是否存在相同的关键信息;
若所述第一文本的关键信息和所述候选文本的关键信息中存在相同的关键信息, 则确定所述候选文本满足所述第一预设条件。
需要说明的是,上述装置/单元之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
本申请实施例还提供了一种终端设备,参见图7,该终端设备400可以包括:至少一个处理器410、存储器420以及存储在所述存储器420中并可在所述至少一个处理器410上运行的计算机程序,所述处理器410执行所述计算机程序时实现上述任意各个方法实施例中的步骤,例如图2所示实施例中的步骤S101至步骤S104。或者,处理器410执行所述计算机程序时实现上述各装置实施例中各模块/单元的功能,例如图6所示模块310至340的功能。
示例性的,计算机程序可以被分割成一个或多个模块/单元,一个或者多个模块/单元被存储在存储器420中,并由处理器410执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序段,该程序段用于描述计算机程序在终端设备400中的执行过程。
本领域技术人员可以理解,图7仅仅是终端设备的示例,并不构成对终端设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如输入输出设备、网络接入设备、总线等。
处理器410可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
存储器420可以是终端设备的内部存储单元,也可以是终端设备的外部存储设备,例如插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。所述存储器420用于存储所述计算机程序以及终端设备所需的其他程序和数据。所述存储器420还可以用于暂时地存储已经输出或者将要输出的数据。
总线可以是工业标准体系结构(Industry Standard Architecture,ISA)总线、外部设备互连(Peripheral Component,PCI)总线或扩展工业标准体系结构(Extended Industry Standard Architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,本申请附图中的总线并不限定仅有一根总线或一种类型的总线。
本申请实施例提供的相似文本的确定方法可以应用于计算机、平板电脑、笔记本电脑、上网本、个人数字助理(personal digital assistant,PDA)等终端设备上,本申请实施例对终端设备的具体类型不作任何限制。
本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现可实现上述相似文本的确定方法各个实施例中的步骤。所述计算机可读存储介质可以是非易失性,也可以是易失性。
本申请实施例提供了一种计算机程序产品,当计算机程序产品在移动终端上运行时,使得移动终端执行时实现可实现上述相似文本的确定方法各个实施例中的步骤。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质至少可以包括:能够将计算机程序代码携带到拍照装置/终端设备的任何实体或装置、记录介质、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质。例如U盘、移动硬盘、磁碟或者光盘等。在某些司法管辖区,根据立法和专利实践,计算机可读介质不可以是电载波信号和电信信号。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
在本申请所提供的实施例中,应该理解到,所揭露的装置/网络设备和方法,可以通过其它的方式实现。例如,以上所描述的装置/网络设备实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。

Claims (20)

  1. 一种相似文本的确定方法,其中,包括:
    获取第一文本的关键信息和第二文本的关键信息;
    若所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息,获取所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息的第一数量;
    获取所述第一文本和所述第二文本的第一相似度;
    基于所述第一数量和所述第一相似度,确定所述第一文本和所述第二文本是否相似。
  2. 如权利要求1所述的相似文本的确定方法,其中,所述获取所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息的第一数量,包括:
    所述关键信息包括:关键短语,获取所述第一文本的关键短语和所述第二文本的关键短语;
    确定所述第一文本的关键短语和所述第二文本的关键短语中存在的相同关键短语的第二数量,所述第一数量包括所述第二数量;
    和/或,
    所述关键信息包括:分类信息,获取所述第一文本的分类信息和所述第二文本的分类信息;
    确定所述第一文本的分类信息和所述第二文本的分类信息中相同分类信息的第三数量,所述第一数量包括所述第三数量。
  3. 如权利要求2所述的相似文本的确定方法,其中,所述获取所述第一文本和所述第二文本的第一相似度,包括:
    所述关键信息包括:关键短语,计算所述第一文本的关键短语和所述第二文本的关键短语之间的第一距离,所述第一相似度包括所述第一距离;
    和/或,
    计算所述第一文本和所述第二文本的第一余弦相似度,所述第一相似度包括所述第一余弦相似度;
    和/或,
    获取所述第一文本的有效信息和所述第二文本的有效信息;
    计算所述第一文本的有效信息和所述第二文本的有效信息的第二余弦相似度,所述第一相似度包括所述第二余弦相似度。
  4. 如权利要求3所述的相似文本的确定方法,其中,所述计算所述第一文本的关键短语和所述第二文本的关键短语之间的第一距离,包括:
    基于WMD算法模型,计算所述第一文本的关键短语和所述第二文本的关键短语之间的第一距离。
  5. 如权利要求4所述的相似文本的确定方法,其中,在所述第一数量包括第二数量和第三数量,所述第一相似度包括第一距离、第一余弦相似度和第二余弦相似度时,所述基于所述第一数量和所述第一相似度,确定所述第一文本和所述第二文本是否相似,包括:
    基于所述第二数量、所述第二数量对应的权重、所述第三数量、所述第三数量对应的权重、所述第一距离、所述第一距离对应的权重、所述第一余弦相似度、所述第一余弦相似度对应的权重、所述第二余弦相似度和所述第二余弦相似度对应的权重,计算所述第一文本和所述第二文本的目标相似度;
    在所述目标相似度小于第一预设阈值时,确定所述第一文本和所述第二文本不相 似;
    在所述目标相似度大于或等于第一预设阈值时,确定所述第一文本和所述第二文本相似。
  6. 如权利要求1所述的相似文本的确定方法,其中,在所述获取第一文本的关键信息和第二文本的关键信息之前,包括:
    获取所述第一文本的关键信息和数据库中的候选文本的关键信息;
    基于所述第一文本的关键信息和所述候选文本的关键信息,确定所述候选文本是否满足第一预设条件;
    在所述候选文本满足所述第一预设条件时,计算所述第一文本与所述候选文本的tf-idf值;
    在所述tf-idf值大于第二预设阈值时,将所述候选文本作为所述第二文本。
  7. 如权利要求6所述的相似文本的确定方法,其中,所述基于所述第一文本的关键信息和候选文本的关键信息,确定所述候选文本是否满足第一预设条件,包括:
    确定所述第一文本的关键信息和所述候选文本的关键信息中是否存在相同的关键信息;
    若所述第一文本的关键信息和所述候选文本的关键信息中存在相同的关键信息,则确定所述候选文本满足所述第一预设条件。
  8. 如权利要求4所述的相似文本的确定方法,其中,所述WMD算法模型包括:
    Figure PCTCN2022071432-appb-100001
    Figure PCTCN2022071432-appb-100002
    Figure PCTCN2022071432-appb-100003
    其中,c(i,j)为第一文本的关键短语i和第二文本中的关键短语j之间的欧式距离;T ij为关键短语i转移为关键短语j时的比例;d i为第一文本中的关键短语i在第一文本中的权重;d' j为第二文本中关键短语j在第二文本中的权重。
  9. 如权利要求6所述的相似文本的确定方法,其中,在所述候选文本满足所述第一预设条件时,计算所述第一文本与所述候选文本的tf-idf值之后,还包括:
    若存在多个tf-idf值,将多个tf-idf值从大到小进行排序,从最大的tf-idf值开始,取第二预设个数的tf-idf值对应的候选文本作为第二文本。
  10. 一种相似文本的确定装置,其中,包括:
    文本获取模块,用于获取第一文本的关键信息和第二文本的关键信息;
    数量获取模块,用于若所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息,获取所述第一文本的关键信息和所述第二文本的关键信息中存在相同的关键信息的第一数量;
    相似度获取模块,用于获取所述第一文本和所述第二文本的第一相似度;
    第一判断模块,用于基于所述第一数量和所述第一相似度,确定所述第一文本和所述第二文本是否相似。
  11. 如权利要求10所述的相似文本的确定装置,其中,所述数量获取模块用于:
    所述关键信息包括:关键短语,获取所述第一文本的关键短语和所述第二文本的关键短语;
    确定所述第一文本的关键短语和所述第二文本的关键短语中存在的相同关键短语的第二数量,所述第一数量包括所述第二数量;
    和/或,
    所述关键信息包括:分类信息,获取所述第一文本的分类信息和所述第二文本的分类信息;
    确定所述第一文本的分类信息和所述第二文本的分类信息中相同分类信息的第三数量,所述第一数量包括所述第三数量。
  12. 如权利要求11所述的相似文本的确定装置,其中,所述相似度获取模块用于:
    所述关键信息包括:关键短语,计算所述第一文本的关键短语和所述第二文本的关键短语之间的第一距离,所述第一相似度包括所述第一距离;
    和/或,
    计算所述第一文本和所述第二文本的第一余弦相似度,所述第一相似度包括所述第一余弦相似度;
    和/或,
    获取所述第一文本的有效信息和所述第二文本的有效信息;
    计算所述第一文本的有效信息和所述第二文本的有效信息的第二余弦相似度,所述第一相似度包括所述第二余弦相似度。
  13. 如权利要求12所述的相似文本的确定装置,其中,所述相似度获取模块用于:
    基于WMD算法模型,计算所述第一文本的关键短语和所述第二文本的关键短语之间的第一距离。
  14. 如权利要求13所述的相似文本的确定装置,其中,在所述第一数量包括第二数量和第三数量,所述第一相似度包括第一距离、第一余弦相似度和第二余弦相似度时,所述第一判断模块用于:
    基于所述第二数量、所述第二数量对应的权重、所述第三数量、所述第三数量对应的权重、所述第一距离、所述第一距离对应的权重、所述第一余弦相似度、所述第一余弦相似度对应的权重、所述第二余弦相似度和所述第二余弦相似度对应的权重,计算所述第一文本和所述第二文本的目标相似度;
    在所述目标相似度小于第一预设阈值时,确定所述第一文本和所述第二文本不相似;
    在所述目标相似度大于或等于第一预设阈值时,确定所述第一文本和所述第二文本相似。
  15. 如权利要求10所述的相似文本的确定装置,其中,与文本获取模块相连,所述装置还包括:
    信息获取模块,用于获取所述第一文本的关键信息和数据库中的候选文本的关键信息;
    第二判断模块,用于基于所述第一文本的关键信息和所述候选文本的关键信息,确定所述候选文本是否满足第一预设条件;
    tf-idf值计算模块,用于在所述候选文本满足所述第一预设条件时,计算所述第一文本与所述候选文本的tf-idf值;
    第三判断模块,用于在所述tf-idf值大于第二预设阈值时,将所述候选文本作为所述第二文本。
  16. 如权利要求15所述的相似文本的确定装置,其中,第二判断模块还用于:
    确定所述第一文本的关键信息和所述候选文本的关键信息中是否存在相同的关键信息;
    若所述第一文本的关键信息和所述候选文本的关键信息中存在相同的关键信息,则确定所述候选文本满足所述第一预设条件。
  17. 如权利要求13所述的相似文本的确定装置,其中,所述WMD算法模型包括:
    Figure PCTCN2022071432-appb-100004
    Figure PCTCN2022071432-appb-100005
    Figure PCTCN2022071432-appb-100006
    其中,c(i,j)为第一文本的关键短语i和第二文本中的关键短语j之间的欧式距离;T ij为关键短语i转移为关键短语j时的比例;d i为第一文本中的关键短语i在第一文本中的权重;d' j为第二文本中关键短语j在第二文本中的权重。
  18. 如权利要求15所述的相似文本的确定装置,其中,所述第三判断模块还用于:
    若存在多个tf-idf值,将多个tf-idf值从大到小进行排序,从最大的tf-idf值开始,取第二预设个数的tf-idf值对应的候选文本作为第二文本。
  19. 一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其中,所述处理器执行所述计算机程序时实现如权利要求1至9任一项所述的相似文本的确定方法。
  20. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其中,所述计算机程序被处理器执行时实现如权利要求1至9任一项所述的相似文本的确定方法。
PCT/CN2022/071432 2021-06-09 2022-01-11 一种相似文本的确定方法、装置、终端设备及存储介质 WO2022257455A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110642144.7A CN113392184A (zh) 2021-06-09 2021-06-09 一种相似文本的确定方法、装置、终端设备及存储介质
CN202110642144.7 2021-06-09

Publications (1)

Publication Number Publication Date
WO2022257455A1 true WO2022257455A1 (zh) 2022-12-15

Family

ID=77620007

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/071432 WO2022257455A1 (zh) 2021-06-09 2022-01-11 一种相似文本的确定方法、装置、终端设备及存储介质

Country Status (2)

Country Link
CN (1) CN113392184A (zh)
WO (1) WO2022257455A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113392184A (zh) * 2021-06-09 2021-09-14 平安科技(深圳)有限公司 一种相似文本的确定方法、装置、终端设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190265970A1 (en) * 2018-02-28 2019-08-29 Fujitsu Limited Automatic identification of relevant software projects for cross project learning
CN111144112A (zh) * 2019-12-30 2020-05-12 广州广电运通信息科技有限公司 文本相似度分析方法、装置和存储介质
CN111611371A (zh) * 2020-06-17 2020-09-01 厦门快商通科技股份有限公司 基于wide and deep网络的FAQ匹配方法、装置、设备和存储介质
CN112507198A (zh) * 2020-12-18 2021-03-16 北京百度网讯科技有限公司 用于处理查询文本的方法、装置、设备、介质和程序
WO2021072850A1 (zh) * 2019-10-15 2021-04-22 平安科技(深圳)有限公司 特征词提取方法、文本相似度计算方法、装置和设备
CN113392184A (zh) * 2021-06-09 2021-09-14 平安科技(深圳)有限公司 一种相似文本的确定方法、装置、终端设备及存储介质

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11816135B2 (en) * 2019-02-26 2023-11-14 Greyb Research Private Limited Method, system, and computer program product for retrieving relevant documents
CN110348539B (zh) * 2019-07-19 2021-05-07 知者信息技术服务成都有限公司 短文本相关性判别方法

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190265970A1 (en) * 2018-02-28 2019-08-29 Fujitsu Limited Automatic identification of relevant software projects for cross project learning
WO2021072850A1 (zh) * 2019-10-15 2021-04-22 平安科技(深圳)有限公司 特征词提取方法、文本相似度计算方法、装置和设备
CN111144112A (zh) * 2019-12-30 2020-05-12 广州广电运通信息科技有限公司 文本相似度分析方法、装置和存储介质
CN111611371A (zh) * 2020-06-17 2020-09-01 厦门快商通科技股份有限公司 基于wide and deep网络的FAQ匹配方法、装置、设备和存储介质
CN112507198A (zh) * 2020-12-18 2021-03-16 北京百度网讯科技有限公司 用于处理查询文本的方法、装置、设备、介质和程序
CN113392184A (zh) * 2021-06-09 2021-09-14 平安科技(深圳)有限公司 一种相似文本的确定方法、装置、终端设备及存储介质

Also Published As

Publication number Publication date
CN113392184A (zh) 2021-09-14

Similar Documents

Publication Publication Date Title
CN110162695B (zh) 一种信息推送的方法及设备
CN107463605B (zh) 低质新闻资源的识别方法及装置、计算机设备及可读介质
WO2021072885A1 (zh) 识别文本的方法、装置、设备及存储介质
US20200081899A1 (en) Automated database schema matching
CN108664574B (zh) 信息的输入方法、终端设备及介质
WO2019218473A1 (zh) 一种字段匹配方法、装置、终端设备及介质
WO2022142027A1 (zh) 基于知识图谱的模糊匹配方法、装置、计算机设备和存储介质
WO2021164231A1 (zh) 公文摘要提取方法、装置、设备及计算机可读存储介质
US20180181646A1 (en) System and method for determining identity relationships among enterprise data entities
WO2019242124A1 (zh) 金额信息的提取方法、装置、终端设备及介质
CN112668320B (zh) 基于词嵌入的模型训练方法、装置、电子设备及存储介质
CN111753048B (zh) 文档检索方法、装置、设备及存储介质
WO2021047373A1 (zh) 基于大数据的列数据处理方法、设备及介质
WO2021143299A1 (zh) 语义纠错方法、电子设备及存储介质
WO2020248379A1 (zh) 一种相似网络页面的搜索方法及设备
WO2021196934A1 (zh) 一种基于字段相似度计算的问题推荐方法、装置和服务器
CN112395875A (zh) 一种关键词提取方法、装置、终端以及存储介质
CN112632261A (zh) 智能问答方法、装置、设备及存储介质
CN110019474B (zh) 异构数据库中的同义数据自动关联方法、装置及电子设备
WO2022257455A1 (zh) 一种相似文本的确定方法、装置、终端设备及存储介质
WO2021027149A1 (zh) 基于画像相似性的信息检索推荐方法、装置及存储介质
CN111814481B (zh) 购物意图识别方法、装置、终端设备及存储介质
WO2023151576A1 (zh) 搜索推荐方法、搜索推荐系统、计算机设备及存储介质
CN109462635B (zh) 一种信息推送方法、计算机可读存储介质及服务器
CN115905885A (zh) 数据识别方法、设备、存储介质及程序产品

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22819063

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE