WO2020098098A1 - 基于语义解析的文本准确率计算方法、装置、计算机设备 - Google Patents
基于语义解析的文本准确率计算方法、装置、计算机设备 Download PDFInfo
- Publication number
- WO2020098098A1 WO2020098098A1 PCT/CN2018/124398 CN2018124398W WO2020098098A1 WO 2020098098 A1 WO2020098098 A1 WO 2020098098A1 CN 2018124398 W CN2018124398 W CN 2018124398W WO 2020098098 A1 WO2020098098 A1 WO 2020098098A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- text
- distance matrix
- characters
- value
- edit distance
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G10—MUSICAL INSTRUMENTS; ACOUSTICS
- G10L—SPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
- G10L15/00—Speech recognition
- G10L15/26—Speech to text systems
Definitions
- the present application relates to the technical field of semantic parsing, in particular to a method, device, and computer equipment for calculating text accuracy based on semantic parsing.
- the commonly used algorithm is the edit distance algorithm.
- the algorithm calculates the similarity between the transferred text and the template text by counting the minimum edit operations (the edit operations include: replacing a character with another character, inserting a character, and deleting a character) times. Degree (transfer accuracy).
- the calculation result of the algorithm is not satisfactory.
- the inventor realized that because the algorithm always compares the text that has been transferred with the entire text of the template text, when only part of the text is transferred, the algorithm cannot accurately calculate this part of the transfer The accuracy of transliteration of written text. Therefore, the editing distance is not applicable in the scenario where the real-time transfer accuracy of the ASR engine is concerned.
- this application proposes a method, device, and computer equipment for calculating text accuracy based on semantic analysis, which aims to solve the existing text transfer accuracy algorithm and convert the text that has been transferred and the template text Compare all the texts, and when some texts are transferred, the accuracy of the text transfer cannot be accurately calculated.
- a text accuracy calculation method based on semantic analysis includes:
- the length of the template text characters is increased by two characters as the number of columns, and the length of the partially transferred text characters is increased by two characters as the number of lines, and an editing distance matrix is established;
- the present application also provides a text accuracy calculation device based on semantic analysis.
- the device includes:
- the first obtaining module is used to obtain part of the transferred text that has been transferred from the starting point of the template text;
- a first calculation module configured to calculate the value of each element in the edit distance matrix according to the partially transferred text and the template text
- a generating module used to record the calculated trajectory of each element in the edit distance matrix, and generate a trajectory matrix corresponding to the edit distance matrix;
- the screening module is used to calculate the similarity of each trajectory in the trajectory matrix, filter a trajectory with the highest similarity between the partially transferred text and the template text, and obtain a first trajectory;
- An obtaining module configured to determine the corresponding end point of the partially transferred text on the template text according to the first trajectory, and obtain a first end point
- a second obtaining module configured to obtain a new template text from the template text according to the starting point of the template text and the first end point;
- the second calculation module is used to compare the partially transferred text with the new template text, and calculate the accuracy of the partially transferred text through an edit distance algorithm.
- the present application also provides a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the steps of any one of the above methods are implemented.
- the present application also provides a computer non-volatile readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method described in any one of the above are implemented.
- the present application has a beneficial effect: when the starting point of the template text is transferred, the edit distance matrix is established, the values of the elements in the edit distance matrix are calculated, and the trajectory is generated based on the calculation of the values of the elements in the edit distance matrix
- the trajectory matrix calculate the similarity of each trajectory in the trajectory matrix, filter the trajectory with the highest similarity to obtain the first trajectory, and obtain the corresponding end point of the part of the transferred text on the template text according to the first trajectory, so as to obtain the new template text, and then Partially transferred text is compared with the new template text, and the accuracy rate of the partially transferred text is calculated, which aims to solve the existing text transfer accuracy algorithm, and compares the text that has been transferred with the entire text of the template text. When some texts are transferred, the accuracy of text transfer cannot be accurately calculated.
- FIG. 1 is a flowchart of applying a text resolution calculation method based on semantic analysis provided by an embodiment of the present application
- FIG. 2 is a functional block diagram of a text accuracy calculation device based on semantic analysis provided by an embodiment of the present application
- FIG. 3 is a schematic block diagram of a structure of a computer device provided by using an embodiment of the present application.
- an embodiment of the present application provides a method for calculating text accuracy based on semantic analysis.
- the method includes the following steps:
- Step S101 Acquire a part of the transferred text that has been transferred from the beginning of the template text.
- the template text is a correct text and is used to compare the text with the part of the transliterated text.
- the above-mentioned transliteration refers to transcribing speech into text through an ASR (speech recognition) engine.
- step S102 the length of the template text characters is increased by two characters as the number of columns, and the length of the partially transferred text characters is increased by two characters as the number of rows to establish an edit distance matrix.
- the template text is text text excluding punctuation marks.
- Part of the transliterated text is text with punctuation marks removed.
- Get the length of partially transferred text characters increase the length of two characters according to the length of partially transferred text characters, as the number of lines, and then increase the length of the two characters of the template text characters as the number of columns, and partially transfer
- the length of the text characters is increased by the length of two characters to the number of lines, and an edit distance matrix is established.
- the length of the template text characters is increased by two characters as the number of columns, and the length of the partially transferred text characters is increased by two characters as the number of rows.
- the purpose is to enter the template text on the first row and the first column, Partially transfer text, and enter the initial value in the second row and second column.
- step S102 after step S102 and before step S103, it includes:
- the value of each element in the second column of the edit distance matrix is sequentially incremented by a value of 1 to initialize the value of each element in the second column of the edit distance matrix.
- the characters of the template text in the first row of the editing distance matrix specifically, the characters of the template text starting from the third element of the first row of the editing distance matrix.
- the characters of the partially transferred text are input in the first column of the edit distance matrix, specifically, the characters of the partially transferred text are input starting from the third element of the first column of the edit distance matrix.
- the first row of the edit distance matrix and the third element of the first column start to input the characters of the template text and the characters of the partially transferred text, so that each character of the template text and the characters of the partially transferred text exist in the edit distance matrix
- the corresponding relationship is also to provide a corresponding positional relationship for the initial values of the second row and the second column.
- the value of the second element in the second row of the edit distance matrix as 0.
- increment the value 1 by the value of the second element in the second row of the edit distance matrix as 0 to initialize the edit distance matrix
- the values of the elements in the second row of, for example, the values of the second, third, fourth, and fifth elements in the second row of the edit distance matrix are 0, 1, 2, and 3, respectively.
- the value of the second element in the second row of the edit distance matrix is defined as 0.
- the value of the second element in the second column of the edit distance matrix is also defined as 0, because the second row of the edit distance matrix
- the second element in the editing distance matrix is in the same position as the second element in the second column of the edit distance matrix, even if the same element, the second element in the second column of the editing distance matrix is in order of 0
- the values of the second, third, fourth, and fifth elements in the second column of the edit distance matrix are 0, 1, 2, and 3, respectively. . After initializing the values in the second column and second row of the edit distance matrix, it is possible to calculate the values of the elements in the edit distance matrix.
- Step S103 Calculate the value of each element in the edit distance matrix according to the partially transferred text and the template text.
- the calculation method of the value of each element in the edit distance matrix is determined, and then the edit distance matrix is calculated The value of each element in.
- the value of each element in the edit distance matrix that has not been initialized is determined by the value of one of the elements on the left, top left, and top.
- step S103 it includes:
- the value of the third element in the third column of the edit distance matrix is the value of the element in the upper left corner
- the value of the third element in the third column of the edit distance matrix is the minimum value of the left, upper left, and upper elements plus 1;
- each element in the editing distance matrix that has not been initialized is determined by the value of one of its left, upper left, and upper elements, at the beginning of the calculation, there are values for the elements that match the left, upper left, and upper sides. Is only the third element in the third column of the edit distance matrix, or the third element in the third column of the edit distance matrix.
- the third element in the third column of the edit distance matrix is calculated Elements, identifying the number of columns and rows of the third element in the third column of the edit distance matrix, after obtaining the number of columns and rows of the third element in the third column of the edit distance matrix , Identify the number of columns in the third element of the third column of the edit distance matrix corresponding to the characters of the template text, and the number of rows in the third element of the third column of the edit distance matrix corresponding to the part of the transferred text character.
- the number of columns in the third element of the third column of the edit distance matrix corresponds to the number of characters in the template text corresponds to the number of rows in the third element of the third column of the edit distance matrix Whether the characters of the partially transferred text are equal, according to whether the characters of the template text of the third element in the third column of the edit distance matrix are equal to the characters of the corresponding partially transferred text, used to determine the third column of the edit distance matrix
- the value of the third element in the if the number of columns where the third element in the third column of the edit distance matrix corresponds to the character of the template text and the third element in the third column of the edit distance matrix is in the row If the characters corresponding to the number corresponding to the transferred text are equal, the value of the third element in the third column of the edit distance matrix is the value of the element in the upper left corner.
- the value of the third element in the third column of the edit distance matrix is the minimum value of the left, upper left, and upper elements plus one.
- the value of the fourth element in the third column of the edit distance matrix is calculated in turn until the value of each element in the edit distance matrix is completed, That is, then calculate the value of the fourth element in the third column of the edit distance matrix, after calculating the value of each element in the third column of the edit distance matrix, and then calculate the value of each element in the fourth column of the edit distance matrix Until the calculation of the value of each element in the last column of the edit distance matrix is completed, the calculation of the value of each element in the edit distance matrix is completed.
- Step S104 Record the calculated trajectory of the value of each element in the edit distance matrix, and generate a trajectory matrix corresponding to the edit distance matrix.
- step S104 it includes:
- the step of marking the origin of the value of each element in the edit distance matrix in the calculation trajectory according to the value of each element in the edit distance matrix includes:
- the origin of the value of the element in the editing distance matrix is immediately marked, that is, the editing distance matrix is marked while recording the calculation track of the value of each element in the editing distance matrix The origin of the value of each element in.
- the step of marking the origin of the value of each element in the edit distance matrix in the calculation trajectory according to the value of each element in the edit distance matrix includes:
- the value of each element in the editing distance matrix is marked according to the calculation trajectory of the value of each element in the editing distance matrix.
- the origin of the value of each element in the mark edit distance matrix will be triggered until the origin of the value of each element in the mark edit distance matrix is completed. That is, the calculation trajectory of the value of each element in the unedited edit distance matrix does not cause the origin of the value of each element in the edited edit distance matrix.
- Step S105 Calculate the similarity of each trajectory in the trajectory matrix, filter a trajectory with the highest similarity between the partially transferred text and the template text, and obtain a first trajectory.
- the trajectory matrix After generating the trajectory matrix, calculate the similarity of each trajectory in the trajectory matrix. After calculating the similarity of each trajectory, filter the trajectory with the highest similarity between the partially transferred text and the template text to obtain the first trajectory It is considered that the partially transferred text corresponds to the track on the template text.
- the step of calculating the similarity of each trajectory in the trajectory matrix includes:
- the ratio of the number of equal characters of each track in the track matrix to the total number of corresponding characters is calculated to obtain the similarity of each track in the track matrix.
- the trajectory matrix After generating the trajectory matrix, identify the number of characters of partially transferred text in each trajectory of the trajectory matrix equal to the characters of the corresponding template text to obtain the equal number of characters, after obtaining the equal number of characters in each trajectory in the trajectory matrix , Compare the character length of the partially transferred text in each track in the track matrix with the length of the character of the corresponding template text, and select the long length as the total number of characters, if the length of the part of the transferred text in a track in the track matrix is greater than Corresponding to the length of the characters of the template text, the length of the characters selected as part of the transferred text in a track in the track matrix is the total number of characters.
- the length of the characters of the partially transferred text in a track in the track matrix is less than the length of the characters of the corresponding template text
- the length of the characters of the template text selected in a track in the track matrix is the total number of characters. After the long length is selected as the total number of characters, the ratio of the number of equal characters of each track in the track matrix to the corresponding total number of characters is calculated, and after the calculation of the ratio is completed, the similarity of each track in the track matrix is obtained.
- Step S106 Determine the corresponding end point of the partially transferred text on the template text according to the first trajectory, and obtain a first end point.
- the end point corresponding to the partially transferred text on the template text is determined, thereby obtaining the first end point.
- step S106 it includes:
- Step S107 Acquire a new template text from the template text according to the starting point of the template text and the first end point.
- the text between the two points is obtained according to the start point and the first end point of the template text, including the characters corresponding to the start point of the template text and the first end point, respectively, thereby obtaining the new template text from the template text.
- step S107 it includes:
- Intercept characters between the starting point of the template text and the first end point wherein the characters between the starting point of the template text and the first end point include the characters corresponding to the starting point of the template text and the first The character corresponding to the end point;
- the first end point After the first end point is obtained, mark the first character of the template text in the template text as the starting point, and intercept the characters between the starting point of the template text and the first end point, where the characters between the starting point of the template text and the first end point include The character corresponding to the start point of the template text and the character corresponding to the first end point.
- the text in the same format as the template text is generated to obtain the new template text.
- Step S108 Compare the partially transferred text with the new template text, and calculate an accuracy rate of the partially transferred text through an edit distance algorithm.
- part of the transferred text is compared with the new template text, not the template text.
- the accuracy of the part of the transferred text is calculated by the edit distance algorithm, thereby solving the accuracy of the existing text.
- the rate algorithm compares the text that has been transferred to the entire text of the template text. When part of the text is transferred, the problem of the accuracy of the text transfer cannot be accurately calculated.
- the editing distance matrix is established, the value of each element in the editing distance matrix is calculated, the trajectory matrix is generated according to the calculated trajectory of the value of each element in the editing distance matrix, and the trajectory matrix is calculated Similarity of each track in the screen, select the track with the highest similarity to obtain the first track, obtain the corresponding end point of the part of the transferred text on the template text according to the first track, so as to obtain the new template text, and then transfer the part of the transferred text to the new
- the template text is compared to calculate the accuracy of part of the transferred text. It is designed to solve the existing text transfer accuracy algorithm.
- the text that has been transferred is compared with the entire text of the template text, and part of the text is transferred. When it came out, it was impossible to accurately calculate the accuracy of text transfer.
- an embodiment of the present application proposes a device 1 for calculating text accuracy based on semantic analysis.
- the device 1 includes a first acquiring module 11, a establishing module 12, a first calculating module 13, a generating module 14, and a filtering module 15 , An acquisition module 16, a second acquisition module 17, and a second calculation module 18.
- the first acquiring module 11 is configured to acquire the partially transferred text that has been transferred from the beginning of the template text.
- the template text is a correct text and is used to compare the text with the part of the transliterated text.
- the above-mentioned transliteration refers to transcribing speech into text through an ASR (speech recognition) engine.
- the establishment module 12 is used to establish the editing distance matrix by using the length of the template text characters to increase the length of two characters as the number of columns, and the length of the partially transferred text characters to increase the length of the two characters as the number of lines.
- the template text is text text excluding punctuation marks.
- Part of the transliterated text is text with punctuation marks removed.
- Get the length of partially transferred text characters increase the length of two characters according to the length of partially transferred text characters, as the number of lines, and then increase the length of the two characters of the template text characters as the number of columns, and partially transfer
- the length of the text characters is increased by the length of two characters to the number of lines, and an edit distance matrix is established.
- the length of the template text characters is increased by two characters as the number of columns, and the length of the partially transferred text characters is increased by two characters as the number of rows.
- the purpose is to enter the template text on the first row and the first column, Partially transfer text, and enter the initial value in the second row and second column.
- the device 1 includes:
- a first input module for inputting characters of the template text starting from the third element of the first row of the editing distance matrix
- a second input module for inputting characters of the partially transferred text starting from the third element of the first column of the editing distance matrix
- a definition module used to define the value of the second element in the second row of the edit distance matrix as 0;
- the first initialization module is used to sequentially increment the value 1 by the value of the second element in the second row of the edit distance matrix to initialize the value of each element of the second row of the edit distance matrix;
- a second initialization module is used to sequentially increment the value 1 by the value of the second element in the second column of the edit distance matrix to initialize the value of each element of the second column of the edit distance matrix.
- the characters of the template text in the first row of the editing distance matrix specifically, the characters of the template text starting from the third element of the first row of the editing distance matrix.
- the characters of the partially transferred text are input in the first column of the edit distance matrix, specifically, the characters of the partially transferred text are input starting from the third element of the first column of the edit distance matrix.
- the first row of the edit distance matrix and the third element of the first column start to input the characters of the template text and the characters of the partially transferred text, so that each character of the template text and the characters of the partially transferred text exist in the edit distance matrix
- the corresponding relationship is also to provide a corresponding positional relationship for the initial values of the second row and the second column.
- the value of the second element in the second row of the edit distance matrix as 0.
- increment the value 1 by the value of the second element in the second row of the edit distance matrix as 0 to initialize the edit distance matrix
- the values of the elements in the second row of, for example, the values of the second, third, fourth, and fifth elements in the second row of the edit distance matrix are 0, 1, 2, and 3, respectively.
- the value of the second element in the second row of the edit distance matrix is defined as 0.
- the value of the second element in the second column of the edit distance matrix is also defined as 0, because the second row of the edit distance matrix
- the second element in the editing distance matrix is in the same position as the second element in the second column of the edit distance matrix, even if the same element, the second element in the second column of the editing distance matrix is in order of 0
- the values of the second, third, fourth, and fifth elements in the second column of the edit distance matrix are 0, 1, 2, and 3, respectively. . After initializing the values in the second column and second row of the edit distance matrix, it is possible to calculate the values of the elements in the edit distance matrix.
- the first calculation module 13 is configured to calculate the value of each element in the edit distance matrix according to the partially transferred text and the template text.
- the calculation method of the value of each element in the edit distance matrix is determined, and then the edit distance matrix is calculated The value of each element in.
- the first calculation module 13 includes:
- a first identification module used to identify the number of columns and rows of the third element in the third column of the editing distance matrix
- a second recognition module used to recognize the number of columns and rows where the third element in the third column of the edit distance matrix corresponds to the characters of the template text and the characters of the partially transferred text, respectively;
- the first judgment module is used to judge the number of columns where the third element in the third column of the edit distance matrix corresponds to the character of the template text and the third element in the third column of the edit distance matrix Whether the number of rows of elements corresponds to whether the characters of the partially transferred text are equal; if the number of columns of the third element in the third column of the editing distance matrix corresponds to the characters of the template text and the editing distance If the number of rows of the third element in the third column of the matrix is equal to the characters of the partially transferred text, the value of the third element in the third column of the edit distance matrix is the element at the upper left corner If the number of columns where the third element in the third column of the edit distance matrix corresponds to the character of the template text and the third element in the third column of the edit distance matrix are in the row The numbers corresponding to the characters of the partially transferred text are not equal, then the value of the third element in the third column of the edit distance matrix is the minimum value of the left, upper left, and upper elements plus 1;
- the first sub-calculation module is used to sequentially calculate the value of the fourth element in the third column of the edit distance matrix until the calculation of the value of each element in the edit distance matrix is completed.
- each element in the editing distance matrix that has not been initialized is determined by the value of one of its left, upper left, and upper elements, at the beginning of the calculation, there are values for the elements that match the left, upper left, and upper sides. Is only the third element in the third column of the edit distance matrix, or the third element in the third column of the edit distance matrix.
- the third element in the third column of the edit distance matrix is calculated Elements, identifying the number of columns and rows of the third element in the third column of the edit distance matrix, after obtaining the number of columns and rows of the third element in the third column of the edit distance matrix , Identify the number of columns in the third element of the third column of the edit distance matrix corresponding to the characters of the template text, and the number of rows in the third element of the third column of the edit distance matrix corresponding to the part of the transferred text character.
- the number of columns in the third element of the third column of the edit distance matrix corresponds to the number of characters in the template text corresponds to the number of rows in the third element of the third column of the edit distance matrix Whether the characters of the partially transferred text are equal, according to whether the characters of the template text of the third element in the third column of the edit distance matrix are equal to the characters of the corresponding partially transferred text, used to determine the third column of the edit distance matrix
- the value of the third element in the if the number of columns where the third element in the third column of the edit distance matrix corresponds to the character of the template text and the third element in the third column of the edit distance matrix is in the row If the characters corresponding to the number corresponding to the transferred text are equal, the value of the third element in the third column of the edit distance matrix is the value of the element in the upper left corner.
- the value of the third element in the third column of the edit distance matrix is the minimum value of the left, upper left, and upper elements plus one.
- the value of the fourth element in the third column of the edit distance matrix is calculated in turn until the value of each element in the edit distance matrix is completed, That is, then calculate the value of the fourth element in the third column of the edit distance matrix, after calculating the value of each element in the third column of the edit distance matrix, and then calculate the value of each element in the fourth column of the edit distance matrix Until the calculation of the value of each element in the last column of the edit distance matrix is completed, the calculation of the value of each element in the edit distance matrix is completed.
- the generating module 14 is configured to record the calculated trajectory of each element in the edit distance matrix and generate a trajectory matrix corresponding to the edit distance matrix.
- the generation module 14 includes:
- the first recording module is used to record the calculation track of the values of each element in the editing distance matrix
- the first marking module is used to mark the origin of the value of each element in the editing distance matrix according to the calculation trajectory of the value of each element in the editing distance matrix;
- the first generating module is used to generate a trajectory matrix corresponding to the editing distance matrix after the marking is completed.
- the first marking module includes:
- the first sub-marking module is used to mark the origin of the value of the element in the edit distance matrix each time the calculation track of the value of an element in the edit distance matrix is recorded;
- the first sub-marking completion module is used to mark the origin of the value of each element in the editing distance matrix.
- the origin of the value of the element in the editing distance matrix is immediately marked, that is, the editing distance matrix is marked while recording the calculation track of the value of each element in the editing distance matrix The origin of the value of each element in.
- the first marking module includes:
- the second sub-marking module is used to mark each element in the editing distance matrix according to the calculation track of the value of each element in the editing distance matrix after completing the calculation of the track for calculating the value of each element in the editing distance matrix The origin of the value.
- the origin of the value of each element in the distance edit matrix will be triggered to start, until the value of each element in the distance edit matrix is completed. That is, the calculation trajectory of the value of each element in the unedited edit distance matrix does not cause the origin of the value of each element in the edited edit distance matrix.
- the filtering module 15 is configured to calculate the similarity of each trajectory in the trajectory matrix, filter a trajectory with the highest similarity between the partially transferred text and the template text, and obtain a first trajectory.
- the trajectory matrix After generating the trajectory matrix, calculate the similarity of each trajectory in the trajectory matrix. After calculating the similarity of each trajectory, filter the trajectory with the highest similarity between the partially transferred text and the template text to obtain the first trajectory It is considered that the partially transferred text corresponds to the track on the template text.
- the screening module 15 includes:
- a third recognition module used to recognize the number of characters of the partially transferred text in each track in the track matrix equal to the corresponding characters of the template text to obtain an equal number of characters
- the first comparison module is used to compare the length of the characters of the partially transferred text in each trajectory of the trajectory matrix with the corresponding length of the characters of the template text, and select the length as the total number of characters
- a third calculation module is used to calculate the ratio of the number of equal characters of each track in the track matrix to the total number of corresponding characters, to obtain the similarity of each track in the track matrix.
- the trajectory matrix After generating the trajectory matrix, identify the number of characters of partially transferred text in each trajectory of the trajectory matrix equal to the characters of the corresponding template text to obtain the equal number of characters, after obtaining the equal number of characters in each trajectory in the trajectory matrix , Compare the character length of the partially transferred text in each track in the track matrix with the length of the character of the corresponding template text, and select the long length as the total number of characters, if the length of the part of the transferred text in a track in the track matrix is greater than Corresponding to the length of the characters of the template text, the length of the characters selected as part of the transferred text in a track in the track matrix is the total number of characters.
- the length of the characters of the partially transferred text in a track in the track matrix is less than the length of the characters of the corresponding template text
- the length of the characters of the template text selected in a track in the track matrix is the total number of characters. After the long length is selected as the total number of characters, the ratio of the number of equal characters of each track in the track matrix to the corresponding total number of characters is calculated, and after the calculation of the ratio is completed, the similarity of each track in the track matrix is obtained.
- the obtaining module 16 is configured to determine the corresponding end point of the partially transferred text on the template text according to the first trajectory, and obtain the first end point.
- the end point corresponding to the partially transferred text on the template text is determined, thereby obtaining the first end point.
- the obtaining module 16 includes:
- a second marking module used to mark the last element in the first track
- the first obtaining module is used to mark the characters of the template text corresponding to the last element in the first track to obtain the first end point.
- the second obtaining module 17 is configured to obtain a new template text from the template text according to the starting point of the template text and the first end point.
- the text between the two points is obtained according to the start point and the first end point of the template text, including the characters corresponding to the start point of the template text and the first end point, respectively, thereby obtaining the new template text from the template text.
- the second acquisition module 17 includes:
- a third marking module used to mark the first character of the template text as the starting point in the template text
- An interception module for intercepting characters between the starting point of the template text and the first end point, wherein the characters between the starting point of the template text and the first end point include characters corresponding to the starting point of the template text The character corresponding to the first end point;
- the second sub-acquisition module is used for generating text according to the intercepted characters and acquiring the new template text.
- the first end point After the first end point is obtained, mark the first character of the template text in the template text as the starting point, and intercept the characters between the starting point of the template text and the first end point, where the characters between the starting point of the template text and the first end point include The character corresponding to the start point of the template text and the character corresponding to the first end point.
- the text in the same format as the template text is generated to obtain the new template text.
- the second calculation module 18 is used to compare the partially transferred text with the new template text, and calculate the accuracy of the partially transferred text through an edit distance algorithm.
- part of the transferred text is compared with the new template text, not the template text.
- the accuracy of the part of the transferred text is calculated by the edit distance algorithm, thereby solving the accuracy of the existing text.
- the rate algorithm compares the text that has been transferred to the entire text of the template text. When part of the text is transferred, the problem of the accuracy of the text transfer cannot be accurately calculated.
- a computer device is also provided in an embodiment of the present application.
- the computer device may be a server, and its internal structure may be as shown in FIG.
- the computer device includes a processor, memory, network interface, and database connected by a system bus. Among them, the processor designed by the computer is used to provide computing and control capabilities.
- the memory of the computer device includes a non-volatile storage medium and an internal memory.
- the non-volatile storage medium stores an operating system, a computer program, and a database.
- the memory device provides an environment for operating systems and computer programs in non-volatile storage media.
- the database of the computer device is used to store data such as a model of a text accuracy calculation method based on semantic analysis.
- the network interface of the computer device is used to communicate with external terminals through a network connection.
- the computer program is executed by the processor to realize a text accuracy calculation method based on semantic analysis.
- the above-mentioned processor executes the steps of the above-mentioned semantic analysis-based text accuracy calculation method: obtaining part of the transferred text from the beginning of the template text; taking the length of the template text characters plus two characters as the number of columns 2. Build an edit distance matrix by adding the length of two characters to the length of the partially transferred text characters as the number of lines; calculate the value of each element in the edit distance matrix according to the partially transferred text and the template text ; Record the calculated trajectory of the values of each element in the edit distance matrix to generate a trajectory matrix corresponding to the edit distance matrix; calculate the similarity of each trajectory in the trajectory matrix, and screen the partially transferred text and the A track with the highest similarity of template text obtains a first track; according to the first track, determines the corresponding end point of the partially transferred text on the template text to obtain a first end point; according to the starting point of the template text And the first end point, obtain a new template text from the template text; compare the partially transferred text with the new template text, and calculate an accuracy rate of the partially transferred text
- FIG. 3 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied.
- An embodiment of the present application also provides a computer non-volatile readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, a text accuracy calculation method based on semantic analysis is implemented, specifically: acquiring The part of the transferred text starting from the starting point of the template text; the length of the template text character increases by two characters as the number of columns, and the length of the partial text character increases by two characters The number of lines is used to establish an edit distance matrix; based on the partially transferred text and the template text, the value of each element in the edit distance matrix is calculated; the calculation track of the value of each element in the edit distance matrix is recorded to generate and A trajectory matrix corresponding to the editing distance matrix; calculating the similarity of each trajectory in the trajectory matrix, filtering a trajectory with the highest degree of similarity between the partially transferred text and the template text, to obtain a first trajectory; A track to determine the corresponding end point of the partially transferred text on the template text to obtain a first end point; based on the starting point of the template text and the first end
Landscapes
- Engineering & Computer Science (AREA)
- Computational Linguistics (AREA)
- Health & Medical Sciences (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- Acoustics & Sound (AREA)
- Multimedia (AREA)
- Machine Translation (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本申请涉及一种基于语义解析的文本准确率计算方法、装置、计算机设备。在模板文本的始点开始被转写时,根据编辑距离矩阵中各元素的值的计算轨迹生成轨迹矩阵,计算轨迹矩阵中各轨迹的相似度,筛选相似度最高的一条轨迹获得第一轨迹,获得新模板文本,再将部分转写文本与新模板文本进行对比,计算部分转写文本的准确率。
Description
本申请要求于2018年11月13日提交中国专利局、申请号为2018113485831,申请名称为“基于语义解析的文本准确率计算方法、装置、计算机设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及语义解析技术领域,特别涉及一种基于语义解析的文本准确率计算方法、装置、计算机设备。
在统计ASR(语音识别)引擎转写准确率的时候,常用的算法是编辑距离算法。该算法通过统计转写文本转成模板文本所需的最少编辑操作(编辑操作包括:将一个字符替换成另外一个字符,插入一个字符,删除一个字符)次数来计算转写文本与模板文本的相似度(转写准确率)。但在关注ASR引擎的实时转写准确率的场景下,该算法的计算结果并不能令人满意。发明人意识到,由于该算法总是拿已经转写出来的文本与模板文本的全部文本进行对比,因此,当只有部分文本被转写出来的时候,该算法并不能准确地计算出这部分转写出来的文本的转写准确率。因此,编辑距离在关注ASR引擎实时转写准确率的场景下并不适用。
针对现有技术不足,本申请提出一种基于语义解析的文本准确率计算方法、装置、计算机设备,旨在解决现有的文本的转写准确率算法,将已经转写出来的文本与模板文本的全部文本进行对比,在部分文本被转写出来的时候,不能准确计算文本的转写准确率的问题。
本申请提出的技术方案是:
一种基于语义解析的文本准确率计算方法,所述方法包括:
获取从模板文本的始点开始被转写的部分转写文本;
以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵;
根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值;
记录所述编辑距离矩阵中各元素的值的计算轨迹,生成与所述编辑距离矩阵对应的轨迹矩阵;
计算所述轨迹矩阵中各轨迹的相似度,筛选所述部分转写文本与所述模板文本相似度最高的一条轨迹,获得第一轨迹;
根据所述第一轨迹,确定所述部分转写文本在所述模板文本上对应的终点,获得第一终点;
根据所述模板文本的始点和所述第一终点,从所述模板文本中获取新模板文本;
将所述部分转写文本与所述新模板文本进行对比,通过编辑距离算法计算所述部分转写文本的准确率。
本申请还提供一种基于语义解析的文本准确率计算装置,所述装置包括:
第一获取模块,用于获取从模板文本的始点开始被转写的部分转写文本;
建立模块,用于以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵;
第一计算模块,用于根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值;
生成模块,用于记录所述编辑距离矩阵中各元素的值的计算轨迹,生成与所述编辑距离矩阵对应的轨迹矩阵;
筛选模块,用于计算所述轨迹矩阵中各轨迹的相似度,筛选所述部分转写文本与所述模板文本相似度最高的一条轨迹,获得第一轨迹;
获得模块,用于根据所述第一轨迹,确定所述部分转写文本在所述模板文本上对应的终点,获得第一终点;
第二获取模块,用于根据所述模板文本的始点和所述第一终点,从所述模板文本中获取新模板文本;
第二计算模块,用于将所述部分转写文本与所述新模板文本进行对比,通过编辑距离算法计算所述部分转写文本的准确率。
本申请还提供一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现上述任一项所述的方法的步骤。
本申请还提供一种计算机非易失性可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现上述任一项所述的方法的步骤。
根据上述的技术方案,本申请有益效果:在模板文本的始点开始被转写时,建立编辑距离矩阵,计算编辑距离矩阵中各元素的值,根据编辑距离矩阵中各元素的值的计算轨迹生成轨迹矩阵,计算轨迹矩阵中 各轨迹的相似度,筛选相似度最高的一条轨迹获得第一轨迹,根据第一轨迹获得部分转写文本在模板文本上对应的终点,从而获得新模板文本,再将部分转写文本与新模板文本进行对比,计算部分转写文本的准确率,旨在解决现有的文本的转写准确率算法,将已经转写出来的文本与模板文本的全部文本进行对比,在部分文本被转写出来的时候,不能准确计算文本的转写准确率的问题。
图1是应用本申请实施例提供的基于语义解析的文本准确率计算方法的流程图;
图2是应用本申请实施例提供的基于语义解析的文本准确率计算装置的功能模块图;
图3是应用本申请实施例提供的计算机设备的结构示意框图。
如图1所示,本申请实施例提出一种基于语义解析的文本准确率计算方法,所述方法包括以下步骤:
步骤S101、获取从模板文本的始点开始被转写的部分转写文本。
从模板文本的始点开始被转写,且模板文本未全部被转写,也就是从模板文本的第一个字符开始被转写,但是转写的结束点不是在模板文本的最后一个字符,而是在除了模板文本的最后一个字符之外,在模板文本中任意一个字符。由于不是对模板文本全部的字符的转写,为此,从模板文本的始点开始被转写所得到文本称为部分转写文本。
模板文本是一个正确的文本,用于与部分转写文本进行对比的文本。
上述的转写是指通过ASR(语音识别)引擎将语音转写为文本。
步骤S102、以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵。
在本实施例中,模板文本为剔除标点符号的文字文本。部分转写文本为剔除标点符号的文字文本。
获取模板文本字符的长度,根据模板文本字符长度再增加两个字符的长度,作为列数。获取部分转写文本字符的长度,根据部分转写文本字符的长度再增加两个字符的长度,作为行数,然后以模板文本字符的长度增加两个字符的长度为列数、以部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵。模板文本字符长度再增加两个字符的长度作为列数、部分转写文本字符的长度再增加两个字符的长度作为行数的目的是为了在第一行、第一列上分别输入模板文本、部分转写文本,以及在第二行、第二列输入初始化的值。
具体地,在步骤S102之后,且在步骤S103之前,包括:
从所述编辑距离矩阵的第一行的第三个元素开始输入所述模板文本的字符;
从所述编辑距离矩阵的第一列的第三个元素开始输入所述部分转写文本的字符;
定义所述编辑距离矩阵的第二行中的第二个元素的值为0;
以所述编辑距离矩阵的第二行中的第二个元素的值为0依次递增数值1,初始化所述编辑距离矩阵 的第二行的各元素的值;
以所述编辑距离矩阵的第二列中的第二个元素的值为0依次递增数值1,初始化所述编辑距离矩阵的第二列的各元素的值。
在编辑距离矩阵的第一行中输入模板文本的字符,具体地,从编辑距离矩阵的第一行的第三个元素开始输入模板文本的字符。对应地,在编辑距离矩阵的第一列中输入部分转写文本的字符,具体地,从编辑距离矩阵的第一列的第三个元素开始输入部分转写文本的字符。编辑距离矩阵的第一行、第一列的第三个元素分别开始输入模板文本的字符、部分转写文本的字符,使模板文本的各字符与部分转写文本各字符都在编辑距离矩阵存在对应关系,另外,也是为了对第二行、第二列的初始化的数值提供对应的位置关系。首先,定义编辑距离矩阵的第二行中的第二个元素的值为0,然后,以编辑距离矩阵的第二行中的第二个元素的值为0依次递增数值1,初始化编辑距离矩阵的第二行的各元素的值,例如,编辑距离矩阵的第二行中的第二、三、四、五个元素的值分别为0、1、2、3。定义编辑距离矩阵的第二行中的第二个元素的值为0,实质上,也定义编辑距离矩阵的第二列中的第二个元素的值为0,因为编辑距离矩阵的第二行中的第二个元素与编辑距离矩阵的第二列中的第二个元素是在同一个位置,即使同一个元素,以编辑距离矩阵的第二列中的第二个元素的值为0依次递增数值1,初始化编辑距离矩阵的第二列的各元素的值,例如,编辑距离矩阵的第二列中的第二、三、四、五个元素的值分别为0、1、2、3。在初始化编辑距离矩阵的第二列、第二行的数值之后,可能进行计算编辑距离矩阵中各元素的值。
步骤S103、根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值。
根据部分转写文本、模板文本,也就是,在编辑距离矩阵中,部分转写文本的字符对应模板文本的字符是否相等,决定编辑距离矩阵中各元素的值的计算方式,进而计算编辑距离矩阵中各元素的值。
在本实施例中,编辑距离矩阵中未被初始化的各元素的值由其左方、左上角、上方中的某一个元素的值来确定。在步骤S103中,包括:
识别所述编辑距离矩阵的第三列中的第三个元素所处于的列数、行数;
识别所述编辑距离矩阵的第三列中的第三个元素所处于的列数、行数分别对应所述模板文本的字符、所述部分转写文本的字符;
判断所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符是否相等;
若所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符相等,则所述编辑距离矩阵的第三列中的第三个元素的值为其左上角的元素的值;
若所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符不相等,则所述编辑距离矩 阵的第三列中的第三个元素的值为其左方、左上角、上方的元素中最小值加1得到;
依次计算所述编辑距离矩阵的第三列中的第四个元素的值,直至完成计算所述编辑距离矩阵中各元素的值。
由于编辑距离矩阵中未被初始化的各元素的值由其左方、左上角、上方中的某一个元素的值来确定,在开始计算时,符合左方、左上角、上方的元素都存在数值的只有编辑距离矩阵的第三列中的第三个元素,或者说编辑距离矩阵的第三列中的第三个元素,在本实施例中,计算编辑距离矩阵的第三列中的第三个元素,识别编辑距离矩阵的第三列中的第三个元素所处于的列数、行数,在获得编辑距离矩阵的第三列中的第三个元素所处于的列数、行数之后,识别编辑距离矩阵的第三列中的第三个元素所处于的列数对应模板文本的字符,编辑距离矩阵的第三列中的第三个元素所处于的行数对应部分转写文本的字符。在获得对应的字符之后,判断编辑距离矩阵的第三列中的第三个元素所处于的列数对应模板文本的字符与编辑距离矩阵的第三列中的第三个元素所处于行数对应部分转写文本的字符是否相等,根据编辑距离矩阵的第三列中的第三个元素的模板文本的字符与对应的部分转写文本的字符是否相等,用于确定编辑距离矩阵的第三列中的第三个元素的值,若编辑距离矩阵的第三列中的第三个元素所处于的列数对应模板文本的字符与编辑距离矩阵的第三列中的第三个元素所处于行数对应部分转写文本的字符相等,则编辑距离矩阵的第三列中的第三个元素的值为其左上角的元素的值。若编辑距离矩阵的第三列中的第三个元素所处于的列数对应模板文本的字符与编辑距离矩阵的第三列中的第三个元素所处于行数对应部分转写文本的字符不相等,则编辑距离矩阵的第三列中的第三个元素的值为其左方、左上角、上方的元素中最小值加1得到。在计算完编辑距离矩阵的第三列中的第三个元素的值之后,依次计算编辑距离矩阵的第三列中的第四个元素的值,直至完成计算编辑距离矩阵中各元素的值,也就是,接着计算编辑距离矩阵的第三列中的第四个元素的值,在计算完编辑距离矩阵的第三列各元素的值,再计算编辑距离矩阵的第四列中各元素的值,直至计算完成编辑距离矩阵的最后一列中各元素的值,才完成计算编辑距离矩阵中各元素的值。
步骤S104、记录所述编辑距离矩阵中各元素的值的计算轨迹,生成与所述编辑距离矩阵对应的轨迹矩阵。
在计算编辑距离矩阵中各元素的值的过程中,记录编辑距离矩阵中各元素的值的计算轨迹,也就是,编辑距离矩阵中各元素的值是由哪一个元素的值决定的。在完成计算编辑距离矩阵中各元素的值之后,记录编辑距离矩阵中各元素的值的计算轨迹也完成,从而生成与编辑距离矩阵对应的轨迹矩阵。
在本实施例中,在步骤S104中,包括:
记录所述编辑距离矩阵中各元素的值的计算轨迹;
根据所述编辑距离矩阵中各元素的值的计算轨迹,标记所述编辑距离矩阵中各元素的值产生由来;
在完成标记后,生成与所述编辑距离矩阵对应的轨迹矩阵。
记录编辑距离矩阵中各元素的值的计算轨迹,根据编辑距离矩阵中各元素的值的计算轨迹,标记编辑距离矩阵中各元素的值产生由来,在本实施例中,用lt表示该元素通过左上方的元素计算而来,用l表示该元素通过左方的元素计算而来,用t表示该元素通过上方的元素计算而来,例如,若编辑距离矩阵的第三列中的第三个元素是由编辑距离矩阵的第二列中的第二个元素确定的,则在编辑距离矩阵的第三列中的第三个元素输入lt,若编辑距离矩阵的第三列中的第三个元素是由编辑距离矩阵的第二列中的第三个元素确定的,则在编辑距离矩阵的第三列中的第三个元素输入l,若编辑距离矩阵的第三列中的第三个元素是由编辑距离矩阵的第三列中的第二个元素确定的,则在编辑距离矩阵的第三列中的第三个元素输入t,从而标记编辑距离矩阵的第三列中的第三个元素的产生由来。在完成标记后,生成与编辑距离矩阵对应的轨迹矩阵。
在本实施例中,在所述根据所述编辑距离矩阵中各元素的值的计算轨迹,标记所述编辑距离矩阵中各元素的值产生由来的步骤中,包括:
在每记录所述编辑距离矩阵中一个元素的值的计算轨迹时,标记所述编辑距离矩阵中该元素的值产生由来;
直至标记所述编辑距离矩阵中各元素的值产生由来。
每记录编辑距离矩阵中一个元素的值的计算轨迹,就立刻标记编辑距离矩阵中该元素的值产生由来,也就是,一边记录编辑距离矩阵中各元素的值的计算轨迹,一边标记编辑距离矩阵中各元素的值产生由来。
在一些实施例中,在所述根据所述编辑距离矩阵中各元素的值的计算轨迹,标记所述编辑距离矩阵中各元素的值产生由来的步骤中,包括:
在完成记录所述编辑距离矩阵中各元素的值的计算轨迹之后,根据所述编辑距离矩阵中各元素的值的计算轨迹,标记所述编辑距离矩阵中各元素的值产生由来。
在完成编辑距离矩阵中各元素的值的计算轨迹之后,才会触发开始执行标记编辑距离矩阵中各元素的值产生由来,直至完成标记编辑距离矩阵中各元素的值产生由来。也就是,在未完成编辑距离矩阵中各元素的值的计算轨迹,不会进行标记编辑距离矩阵中各元素的值产生由来。
步骤S105、计算所述轨迹矩阵中各轨迹的相似度,筛选所述部分转写文本与所述模板文本相似度最高的一条轨迹,获得第一轨迹。
在生成轨迹矩阵之后,计算轨迹矩阵中各轨迹的相似度,在完成计算各轨迹的相似度之后,筛选部分转写文本与模板文本相似度最高的一条轨迹,获得第一轨迹,该第一轨迹认为是部分转写文本在模板文本上对应轨迹。
在本实施例中,在所述计算所述轨迹矩阵中各轨迹的相似度的步骤中,包括:
识别所述轨迹矩阵中各轨迹中所述部分转写文本的字符与对应的所述模板文本的字符相等的个数, 获得相等字符个数;
比较所述轨迹矩阵中各轨迹中所述部分转写文本的字符的长度与对应的所述模板文本的字符的长度,选取长度长的作为字符总数;
计算所述轨迹矩阵中各轨迹的相等字符个数与对应的字符总数的比值,获得所述轨迹矩阵中各轨迹的相似度。
在生成轨迹矩阵之后,识别轨迹矩阵中各轨迹中部分转写文本的字符与对应的模板文本的字符相等的个数,获得相等字符个数,在获得轨迹矩阵中各轨迹中相等字符个数之后,比较轨迹矩阵中各轨迹中部分转写文本的字符的长度与对应的模板文本的字符的长度,选取长度长的作为字符总数,若轨迹矩阵中一轨迹中部分转写文本的字符的长度大于对应的模板文本的字符的长度,则在轨迹矩阵中一轨迹中选取部分转写文本的字符的长度为字符总数。若轨迹矩阵中一轨迹中部分转写文本的字符的长度小于对应的模板文本的字符的长度,则在轨迹矩阵中一轨迹中选取模板文本的字符的长度为字符总数。在选取长度长的作为字符总数之后,计算轨迹矩阵中各轨迹的相等字符个数与对应的字符总数的比值,在完成计算比值之后,获得轨迹矩阵中各轨迹的相似度。
步骤S106、根据所述第一轨迹,确定所述部分转写文本在所述模板文本上对应的终点,获得第一终点。
在获得第一轨迹之后,根据第一轨迹,由于第一轨迹在轨迹矩阵中存在终点,确定部分转写文本在模板文本上对应的终点,从而获得第一终点。
在本实施例中,在步骤S106中,包括:
标记所述第一轨迹中最后一个元素;
根据所述第一轨迹中最后一个元素,标记对应的所述模板文本的字符,获得第一终点。
在获得第一轨迹之后,标记第一轨迹中最后一个元素,根据第一轨迹中最后一个元素,获得第一轨迹中最后一个元素对应列上的模板文本的字符,标记对应的模板文本的字符,从而获得第一终点。
步骤S107、根据所述模板文本的始点和所述第一终点,从所述模板文本中获取新模板文本。
在获得第一终点之后,根据模板文本的始点和第一终点,获得两点之间的文本,包括模板文本的始点、第一终点分别对应的字符,从而从模板文本中获取新模板文本。
在本实施例中,在步骤S107中,包括:
在所述模板文本中标记所述模板文本的第一个字符为始点;
截取所述模板文本的始点与所述第一终点之间的字符,其中所述模板文本的始点与所述第一终点之间的字符包括所述模板文本的始点对应的字符和所述第一终点对应的字符;
根据截取到的字符生成文本,获取所述新模板文本。
在得到第一终点之后,在模板文本中标记模板文本的第一个字符为始点,截取模板文本的始点与第 一终点之间的字符,其中模板文本的始点与第一终点之间的字符包括模板文本的始点对应的字符和第一终点对应的字符。在截取到的字符之后,根据截取到的字符,生成与模板文本同样格式的文本,获得新模板文本。
步骤S108、将所述部分转写文本与所述新模板文本进行对比,通过编辑距离算法计算所述部分转写文本的准确率。
在获得新模板文本之后,将部分转写文本与新模板文本进行对比,并不是与模板文本进行对比,通过编辑距离算法计算部分转写文本的准确率,从而解决现有的文本的转写准确率算法,将已经转写出来的文本与模板文本的全部文本进行对比,在部分文本被转写出来的时候,不能准确计算文本的转写准确率的问题。
综上所述,在模板文本的始点开始被转写时,建立编辑距离矩阵,计算编辑距离矩阵中各元素的值,根据编辑距离矩阵中各元素的值的计算轨迹生成轨迹矩阵,计算轨迹矩阵中各轨迹的相似度,筛选相似度最高的一条轨迹获得第一轨迹,根据第一轨迹获得部分转写文本在模板文本上对应的终点,从而获得新模板文本,再将部分转写文本与新模板文本进行对比,计算部分转写文本的准确率,旨在解决现有的文本的转写准确率算法,将已经转写出来的文本与模板文本的全部文本进行对比,在部分文本被转写出来的时候,不能准确计算文本的转写准确率的问题。
如图2所示,本申请实施例提出一种基于语义解析的文本准确率计算装置1,装置1包括第一获取模块11、建立模块12、第一计算模块13、生成模块14、筛选模块15、获得模块16、第二获取模块17和第二计算模块18。
第一获取模块11,用于获取从模板文本的始点开始被转写的部分转写文本。
从模板文本的始点开始被转写,且模板文本未全部被转写,也就是从模板文本的第一个字符开始被转写,但是转写的结束点不是在模板文本的最后一个字符,而是在除了模板文本的最后一个字符之外,在模板文本中任意一个字符。由于不是对模板文本全部的字符的转写,为此,从模板文本的始点开始被转写所得到文本称为部分转写文本。
模板文本是一个正确的文本,用于与部分转写文本进行对比的文本。
上述的转写是指通过ASR(语音识别)引擎将语音转写为文本。
建立模块12,用于以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵。
在本实施例中,模板文本为剔除标点符号的文字文本。部分转写文本为剔除标点符号的文字文本。
获取模板文本字符的长度,根据模板文本字符长度再增加两个字符的长度,作为列数。获取部分转写文本字符的长度,根据部分转写文本字符的长度再增加两个字符的长度,作为行数,然后以模板文本字符的长度增加两个字符的长度为列数、以部分转写文本字符的长度增加两个字符的长度为行数,建立 编辑距离矩阵。模板文本字符长度再增加两个字符的长度作为列数、部分转写文本字符的长度再增加两个字符的长度作为行数的目的是为了在第一行、第一列上分别输入模板文本、部分转写文本,以及在第二行、第二列输入初始化的值。
具体地,装置1包括:
第一输入模块,用于从所述编辑距离矩阵的第一行的第三个元素开始输入所述模板文本的字符;
第二输入模块,用于从所述编辑距离矩阵的第一列的第三个元素开始输入所述部分转写文本的字符;
定义模块,用于定义所述编辑距离矩阵的第二行中的第二个元素的值为0;
第一初始化模块,用于以所述编辑距离矩阵的第二行中的第二个元素的值为0依次递增数值1,初始化所述编辑距离矩阵的第二行的各元素的值;
第二初始化模块,用于以所述编辑距离矩阵的第二列中的第二个元素的值为0依次递增数值1,初始化所述编辑距离矩阵的第二列的各元素的值。
在编辑距离矩阵的第一行中输入模板文本的字符,具体地,从编辑距离矩阵的第一行的第三个元素开始输入模板文本的字符。对应地,在编辑距离矩阵的第一列中输入部分转写文本的字符,具体地,从编辑距离矩阵的第一列的第三个元素开始输入部分转写文本的字符。编辑距离矩阵的第一行、第一列的第三个元素分别开始输入模板文本的字符、部分转写文本的字符,使模板文本的各字符与部分转写文本各字符都在编辑距离矩阵存在对应关系,另外,也是为了对第二行、第二列的初始化的数值提供对应的位置关系。首先,定义编辑距离矩阵的第二行中的第二个元素的值为0,然后,以编辑距离矩阵的第二行中的第二个元素的值为0依次递增数值1,初始化编辑距离矩阵的第二行的各元素的值,例如,编辑距离矩阵的第二行中的第二、三、四、五个元素的值分别为0、1、2、3。定义编辑距离矩阵的第二行中的第二个元素的值为0,实质上,也定义编辑距离矩阵的第二列中的第二个元素的值为0,因为编辑距离矩阵的第二行中的第二个元素与编辑距离矩阵的第二列中的第二个元素是在同一个位置,即使同一个元素,以编辑距离矩阵的第二列中的第二个元素的值为0依次递增数值1,初始化编辑距离矩阵的第二列的各元素的值,例如,编辑距离矩阵的第二列中的第二、三、四、五个元素的值分别为0、1、2、3。在初始化编辑距离矩阵的第二列、第二行的数值之后,可能进行计算编辑距离矩阵中各元素的值。
第一计算模块13,用于根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值。
根据部分转写文本、模板文本,也就是,在编辑距离矩阵中,部分转写文本的字符对应模板文本的字符是否相等,决定编辑距离矩阵中各元素的值的计算方式,进而计算编辑距离矩阵中各元素的值。
在本实施例中,编辑距离矩阵中未被初始化的各元素的值由其左方、左上角、上方中的某一个元素的值来确定。第一计算模块13包括:
第一识别模块,用于识别所述编辑距离矩阵的第三列中的第三个元素所处于的列数、行数;
第二识别模块,用于识别所述编辑距离矩阵的第三列中的第三个元素所处于的列数、行数分别对应所述模板文本的字符、所述部分转写文本的字符;
第一判断模块,用于判断所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符是否相等;若所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符相等,则所述编辑距离矩阵的第三列中的第三个元素的值为其左上角的元素的值;若所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符不相等,则所述编辑距离矩阵的第三列中的第三个元素的值为其左方、左上角、上方的元素中最小值加1得到;
第一子计算模块,用于依次计算所述编辑距离矩阵的第三列中的第四个元素的值,直至完成计算所述编辑距离矩阵中各元素的值。
由于编辑距离矩阵中未被初始化的各元素的值由其左方、左上角、上方中的某一个元素的值来确定,在开始计算时,符合左方、左上角、上方的元素都存在数值的只有编辑距离矩阵的第三列中的第三个元素,或者说编辑距离矩阵的第三列中的第三个元素,在本实施例中,计算编辑距离矩阵的第三列中的第三个元素,识别编辑距离矩阵的第三列中的第三个元素所处于的列数、行数,在获得编辑距离矩阵的第三列中的第三个元素所处于的列数、行数之后,识别编辑距离矩阵的第三列中的第三个元素所处于的列数对应模板文本的字符,编辑距离矩阵的第三列中的第三个元素所处于的行数对应部分转写文本的字符。在获得对应的字符之后,判断编辑距离矩阵的第三列中的第三个元素所处于的列数对应模板文本的字符与编辑距离矩阵的第三列中的第三个元素所处于行数对应部分转写文本的字符是否相等,根据编辑距离矩阵的第三列中的第三个元素的模板文本的字符与对应的部分转写文本的字符是否相等,用于确定编辑距离矩阵的第三列中的第三个元素的值,若编辑距离矩阵的第三列中的第三个元素所处于的列数对应模板文本的字符与编辑距离矩阵的第三列中的第三个元素所处于行数对应部分转写文本的字符相等,则编辑距离矩阵的第三列中的第三个元素的值为其左上角的元素的值。若编辑距离矩阵的第三列中的第三个元素所处于的列数对应模板文本的字符与编辑距离矩阵的第三列中的第三个元素所处于行数对应部分转写文本的字符不相等,则编辑距离矩阵的第三列中的第三个元素的值为其左方、左上角、上方的元素中最小值加1得到。在计算完编辑距离矩阵的第三列中的第三个元素的值之后,依次计算编辑距离矩阵的第三列中的第四个元素的值,直至完成计算编辑距离矩阵中各元素的值,也就是,接着计算编辑距离矩阵的第三列中的第四个元素的值,在计算完编辑距离矩阵的第三列各元素的值,再计算编辑距离矩阵的第四列中各元素的值,直至计算完成编辑距离矩阵的最后一列中各元素的值,才完成计算编辑距 离矩阵中各元素的值。
生成模块14,用于记录所述编辑距离矩阵中各元素的值的计算轨迹,生成与所述编辑距离矩阵对应的轨迹矩阵。
在计算编辑距离矩阵中各元素的值的过程中,记录编辑距离矩阵中各元素的值的计算轨迹,也就是,编辑距离矩阵中各元素的值是由哪一个元素的值决定的。在完成计算编辑距离矩阵中各元素的值之后,记录编辑距离矩阵中各元素的值的计算轨迹也完成,从而生成与编辑距离矩阵对应的轨迹矩阵。
在本实施例中,生成模块14包括:
第一记录模块,用于记录所述编辑距离矩阵中各元素的值的计算轨迹;
第一标记模块,用于根据所述编辑距离矩阵中各元素的值的计算轨迹,标记所述编辑距离矩阵中各元素的值产生由来;
第一生成模块,用于在完成标记后,生成与所述编辑距离矩阵对应的轨迹矩阵。
记录编辑距离矩阵中各元素的值的计算轨迹,根据编辑距离矩阵中各元素的值的计算轨迹,标记编辑距离矩阵中各元素的值产生由来,在本实施例中,用lt表示该元素通过左上方的元素计算而来,用l表示该元素通过左方的元素计算而来,用t表示该元素通过上方的元素计算而来,例如,若编辑距离矩阵的第三列中的第三个元素是由编辑距离矩阵的第二列中的第二个元素确定的,则在编辑距离矩阵的第三列中的第三个元素输入lt,若编辑距离矩阵的第三列中的第三个元素是由编辑距离矩阵的第二列中的第三个元素确定的,则在编辑距离矩阵的第三列中的第三个元素输入l,若编辑距离矩阵的第三列中的第三个元素是由编辑距离矩阵的第三列中的第二个元素确定的,则在编辑距离矩阵的第三列中的第三个元素输入t,从而标记编辑距离矩阵的第三列中的第三个元素的产生由来。在完成标记后,生成与编辑距离矩阵对应的轨迹矩阵。
在本实施例中,第一标记模块包括:
第一子标记模块,用于在每记录所述编辑距离矩阵中一个元素的值的计算轨迹时,标记所述编辑距离矩阵中该元素的值产生由来;
第一子标记完成模块,用于直至标记所述编辑距离矩阵中各元素的值产生由来。
每记录编辑距离矩阵中一个元素的值的计算轨迹,就立刻标记编辑距离矩阵中该元素的值产生由来,也就是,一边记录编辑距离矩阵中各元素的值的计算轨迹,一边标记编辑距离矩阵中各元素的值产生由来。
在一些实施例中,第一标记模块包括:
第二子标记模块,用于在完成记录所述编辑距离矩阵中各元素的值的计算轨迹之后,根据所述编辑距离矩阵中各元素的值的计算轨迹,标记所述编辑距离矩阵中各元素的值产生由来。
在完成编辑距离矩阵中各元素的值的计算轨迹之后,才会触发开始执行标记编辑距离矩阵中各元素 的值产生由来,直至完成标记编辑距离矩阵中各元素的值产生由来。也就是,在未完成编辑距离矩阵中各元素的值的计算轨迹,不会进行标记编辑距离矩阵中各元素的值产生由来。
筛选模块15,用于计算所述轨迹矩阵中各轨迹的相似度,筛选所述部分转写文本与所述模板文本相似度最高的一条轨迹,获得第一轨迹。
在生成轨迹矩阵之后,计算轨迹矩阵中各轨迹的相似度,在完成计算各轨迹的相似度之后,筛选部分转写文本与模板文本相似度最高的一条轨迹,获得第一轨迹,该第一轨迹认为是部分转写文本在模板文本上对应轨迹。
在本实施例中,筛选模块15包括:
第三识别模块,用于识别所述轨迹矩阵中各轨迹中所述部分转写文本的字符与对应的所述模板文本的字符相等的个数,获得相等字符个数;
第一比较模块,用于比较所述轨迹矩阵中各轨迹中所述部分转写文本的字符的长度与对应的所述模板文本的字符的长度,选取长度长的作为字符总数;
第三计算模块,用于计算所述轨迹矩阵中各轨迹的相等字符个数与对应的字符总数的比值,获得所述轨迹矩阵中各轨迹的相似度。
在生成轨迹矩阵之后,识别轨迹矩阵中各轨迹中部分转写文本的字符与对应的模板文本的字符相等的个数,获得相等字符个数,在获得轨迹矩阵中各轨迹中相等字符个数之后,比较轨迹矩阵中各轨迹中部分转写文本的字符的长度与对应的模板文本的字符的长度,选取长度长的作为字符总数,若轨迹矩阵中一轨迹中部分转写文本的字符的长度大于对应的模板文本的字符的长度,则在轨迹矩阵中一轨迹中选取部分转写文本的字符的长度为字符总数。若轨迹矩阵中一轨迹中部分转写文本的字符的长度小于对应的模板文本的字符的长度,则在轨迹矩阵中一轨迹中选取模板文本的字符的长度为字符总数。在选取长度长的作为字符总数之后,计算轨迹矩阵中各轨迹的相等字符个数与对应的字符总数的比值,在完成计算比值之后,获得轨迹矩阵中各轨迹的相似度。
获得模块16,用于根据所述第一轨迹,确定所述部分转写文本在所述模板文本上对应的终点,获得第一终点。
在获得第一轨迹之后,根据第一轨迹,由于第一轨迹在轨迹矩阵中存在终点,确定部分转写文本在模板文本上对应的终点,从而获得第一终点。
在本实施例中,获得模块16包括:
第二标记模块,用于标记所述第一轨迹中最后一个元素;
第一获得模块,用于根据所述第一轨迹中最后一个元素,标记对应的所述模板文本的字符,获得第一终点。
在获得第一轨迹之后,标记第一轨迹中最后一个元素,根据第一轨迹中最后一个元素,获得第一轨 迹中最后一个元素对应列上的模板文本的字符,标记对应的模板文本的字符,从而获得第一终点。
第二获取模块17,用于根据所述模板文本的始点和所述第一终点,从所述模板文本中获取新模板文本。
在获得第一终点之后,根据模板文本的始点和第一终点,获得两点之间的文本,包括模板文本的始点、第一终点分别对应的字符,从而从模板文本中获取新模板文本。
在本实施例中,第二获取模块17包括:
第三标记模块,用于在所述模板文本中标记所述模板文本的第一个字符为始点;
截取模块,用于截取所述模板文本的始点与所述第一终点之间的字符,其中所述模板文本的始点与所述第一终点之间的字符包括所述模板文本的始点对应的字符和所述第一终点对应的字符;
第二子获取模块,用于根据截取到的字符生成文本,获取所述新模板文本。
在得到第一终点之后,在模板文本中标记模板文本的第一个字符为始点,截取模板文本的始点与第一终点之间的字符,其中模板文本的始点与第一终点之间的字符包括模板文本的始点对应的字符和第一终点对应的字符。在截取到的字符之后,根据截取到的字符,生成与模板文本同样格式的文本,获得新模板文本。
第二计算模块18,用于将所述部分转写文本与所述新模板文本进行对比,通过编辑距离算法计算所述部分转写文本的准确率。
在获得新模板文本之后,将部分转写文本与新模板文本进行对比,并不是与模板文本进行对比,通过编辑距离算法计算部分转写文本的准确率,从而解决现有的文本的转写准确率算法,将已经转写出来的文本与模板文本的全部文本进行对比,在部分文本被转写出来的时候,不能准确计算文本的转写准确率的问题。
如图3所示,本申请实施例中还提供一种计算机设备,该计算机设备可以是服务器,其内部结构可以如图3所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设计的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的数据库用于存储基于语义解析的文本准确率计算方法的模型等数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种基于语义解析的文本准确率计算方法。
上述处理器执行上述基于语义解析的文本准确率计算方法的步骤:获取从模板文本的始点开始被转写的部分转写文本;以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵;根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值;记录所述编辑距离矩阵中各元素的值的计算轨迹,生成与所述编辑距 离矩阵对应的轨迹矩阵;计算所述轨迹矩阵中各轨迹的相似度,筛选所述部分转写文本与所述模板文本相似度最高的一条轨迹,获得第一轨迹;根据所述第一轨迹,确定所述部分转写文本在所述模板文本上对应的终点,获得第一终点;根据所述模板文本的始点和所述第一终点,从所述模板文本中获取新模板文本;将所述部分转写文本与所述新模板文本进行对比,通过编辑距离算法计算所述部分转写文本的准确率。
本领域技术人员可以理解,图3中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定。
本申请一实施例还提供一种计算机非易失性可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现一种基于语义解析的文本准确率计算方法,具体为:获取从模板文本的始点开始被转写的部分转写文本;以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵;根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值;记录所述编辑距离矩阵中各元素的值的计算轨迹,生成与所述编辑距离矩阵对应的轨迹矩阵;计算所述轨迹矩阵中各轨迹的相似度,筛选所述部分转写文本与所述模板文本相似度最高的一条轨迹,获得第一轨迹;根据所述第一轨迹,确定所述部分转写文本在所述模板文本上对应的终点,获得第一终点;根据所述模板文本的始点和所述第一终点,从所述模板文本中获取新模板文本;将所述部分转写文本与所述新模板文本进行对比,通过编辑距离算法计算所述部分转写文本的准确率。
Claims (20)
- 一种基于语义解析的文本准确率计算方法,其特征在于,所述方法包括:获取从模板文本的始点开始被转写的部分转写文本;以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵;根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值;记录所述编辑距离矩阵中各元素的值的计算轨迹,生成与所述编辑距离矩阵对应的轨迹矩阵;计算所述轨迹矩阵中各轨迹的相似度,筛选所述部分转写文本与所述模板文本相似度最高的一条轨迹,获得第一轨迹;根据所述第一轨迹,确定所述部分转写文本在所述模板文本上对应的终点,获得第一终点;根据所述模板文本的始点和所述第一终点,从所述模板文本中获取新模板文本;将所述部分转写文本与所述新模板文本进行对比,通过编辑距离算法计算所述部分转写文本的准确率。
- 根据权利要求1所述的基于语义解析的文本准确率计算方法,其特征在于,在所述以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵的步骤之后,在所述根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值的步骤之前,包括:从所述编辑距离矩阵的第一行的第三个元素开始输入所述模板文本的字符;从所述编辑距离矩阵的第一列的第三个元素开始输入所述部分转写文本的字符;定义所述编辑距离矩阵的第二行中的第二个元素的值为0;以所述编辑距离矩阵的第二行中的第二个元素的值为0依次递增数值1,初始化所述编辑距离矩阵的第二行的各元素的值;以所述编辑距离矩阵的第二列中的第二个元素的值为0依次递增数值1,初始化所述编辑距离矩阵的第二列的各元素的值。
- 根据权利要求2所述的基于语义解析的文本准确率计算方法,其特征在于,所述编辑距离矩阵中未被初始化的各元素的值由其左方、左上角、上方中的某一个元素的值来确定,在所述根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值的步骤中,包括:识别所述编辑距离矩阵的第三列中的第三个元素所处于的列数、行数;识别所述编辑距离矩阵的第三列中的第三个元素所处于的列数、行数分别对应所述模板文本的字符、所述部分转写文本的字符;判断所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符是否相等;若所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符相等,则所述编辑距离矩阵的第三列中的第三个元素的值为其左上角的元素的值;若所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符不相等,则所述编辑距离矩阵的第三列中的第三个元素的值为其左方、左上角、上方的元素中最小值加1得到;依次计算所述编辑距离矩阵的第三列中的第四个元素的值,直至完成计算所述编辑距离矩阵中各元素的值。
- 根据权利要求1所述的基于语义解析的文本准确率计算方法,其特征在于,在所述记录所述编辑距离矩阵中各元素的值的计算轨迹,生成与所述编辑距离矩阵对应的轨迹矩阵的步骤中,包括:记录所述编辑距离矩阵中各元素的值的计算轨迹;根据所述编辑距离矩阵中各元素的值的计算轨迹,标记所述编辑距离矩阵中各元素的值产生由来;在完成标记后,生成与所述编辑距离矩阵对应的轨迹矩阵。
- 根据权利要求1所述的基于语义解析的文本准确率计算方法,其特征在于,在所述计算所述轨迹矩阵中各轨迹的相似度的步骤中,包括:识别所述轨迹矩阵中各轨迹中所述部分转写文本的字符与对应的所述模板文本的字符相等的个数,获得相等字符个数;比较所述轨迹矩阵中各轨迹中所述部分转写文本的字符的长度与对应的所述模板文本的字符的长度,选取长度长的作为字符总数;计算所述轨迹矩阵中各轨迹的相等字符个数与对应的字符总数的比值,获得所述轨迹矩阵中各轨迹的相似度。
- 根据权利要求1所述的基于语义解析的文本准确率计算方法,其特征在于,在所述根据所述第一轨迹,确定所述部分转写文本在所述模板文本上对应的终点,获得第一终点的步骤中,包括:标记所述第一轨迹中最后一个元素;根据所述第一轨迹中最后一个元素,标记对应的所述模板文本的字符,获得第一终点。
- 根据权利要求6所述的基于语义解析的文本准确率计算方法,其特征在于,在所述根据所述模板文本的始点和所述第一终点,从所述模板文本中获取新模板文本的步骤中,包括:在所述模板文本中标记所述模板文本的第一个字符为始点;截取所述模板文本的始点与所述第一终点之间的字符,其中所述模板文本的始点与所述第一终点之间的字符包括所述模板文本的始点对应的字符和所述第一终点对应的字符;根据截取到的字符生成文本,获得所述新模板文本。
- 一种基于语义解析的文本准确率计算装置,其特征在于,所述装置包括:第一获取模块,用于获取从模板文本的始点开始被转写的部分转写文本;建立模块,用于以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵;第一计算模块,用于根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值;生成模块,用于记录所述编辑距离矩阵中各元素的值的计算轨迹,生成与所述编辑距离矩阵对应的轨迹矩阵;筛选模块,用于计算所述轨迹矩阵中各轨迹的相似度,筛选所述部分转写文本与所述模板文本相似度最高的一条轨迹,获得第一轨迹;获得模块,用于根据所述第一轨迹,确定所述部分转写文本在所述模板文本上对应的终点,获得第一终点;第二获取模块,用于根据所述模板文本的始点和所述第一终点,从所述模板文本中获取新模板文本;第二计算模块,用于将所述部分转写文本与所述新模板文本进行对比,通过编辑距离算法计算所述部分转写文本的准确率。
- 根据权利要求8所述的基于语义解析的文本准确率计算装置,其特征在于,所述装置包括:第一输入模块,用于从所述编辑距离矩阵的第一行的第三个元素开始输入所述模板文本的字符;第二输入模块,用于从所述编辑距离矩阵的第一列的第三个元素开始输入所述部分转写文本的字符;定义模块,用于定义所述编辑距离矩阵的第二行中的第二个元素的值为0;第一初始化模块,用于以所述编辑距离矩阵的第二行中的第二个元素的值为0依次递增数值1,初始化所述编辑距离矩阵的第二行的各元素的值;第二初始化模块,用于以所述编辑距离矩阵的第二列中的第二个元素的值为0依次递增数值1,初始化所述编辑距离矩阵的第二列的各元素的值。
- 根据权利要求9所述的基于语义解析的文本准确率计算装置,其特征在于,所述第一计算模块包括:第一识别模块,用于识别所述编辑距离矩阵的第三列中的第三个元素所处于的列数、行数;第二识别模块,用于识别所述编辑距离矩阵的第三列中的第三个元素所处于的列数、行数分别对应所述模板文本的字符、所述部分转写文本的字符;第一判断模块,用于判断所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符是否相等;若所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑 距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符相等,则所述编辑距离矩阵的第三列中的第三个元素的值为其左上角的元素的值;若所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符不相等,则所述编辑距离矩阵的第三列中的第三个元素的值为其左方、左上角、上方的元素中最小值加1得到;第一子计算模块,用于依次计算所述编辑距离矩阵的第三列中的第四个元素的值,直至完成计算所述编辑距离矩阵中各元素的值。
- 根据权利要求8所述的基于语义解析的文本准确率计算装置,其特征在于,所述生成模块包括:第一记录模块,用于记录所述编辑距离矩阵中各元素的值的计算轨迹;第一标记模块,用于根据所述编辑距离矩阵中各元素的值的计算轨迹,标记所述编辑距离矩阵中各元素的值产生由来;第一生成模块,用于在完成标记后,生成与所述编辑距离矩阵对应的轨迹矩阵。
- 根据权利要求8所述的基于语义解析的文本准确率计算装置,其特征在于,所述筛选模块包括:第三识别模块,用于识别所述轨迹矩阵中各轨迹中所述部分转写文本的字符与对应的所述模板文本的字符相等的个数,获得相等字符个数;第一比较模块,用于比较所述轨迹矩阵中各轨迹中所述部分转写文本的字符的长度与对应的所述模板文本的字符的长度,选取长度长的作为字符总数;第三计算模块,用于计算所述轨迹矩阵中各轨迹的相等字符个数与对应的字符总数的比值,获得所述轨迹矩阵中各轨迹的相似度。
- 根据权利要求8所述的基于语义解析的文本准确率计算装置,其特征在于,所述获得模块包括:第二标记模块,用于标记所述第一轨迹中最后一个元素;第一获得模块,用于根据所述第一轨迹中最后一个元素,标记对应的所述模板文本的字符,获得第一终点。
- 根据权利要求13所述的基于语义解析的文本准确率计算装置,其特征在于,所述第二获取模块包括:第三标记模块,用于在所述模板文本中标记所述模板文本的第一个字符为始点;截取模块,用于截取模块,用于截取所述模板文本的始点与所述第一终点之间的字符,其中所述模板文本的始点与所述第一终点之间的字符包括所述模板文本的始点对应的字符和所述第一终点对应的字符;第二子获取模块,用于根据截取到的字符生成文本,获得所述新模板文本。
- 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,其特征在于,所述处理器执行所述计算机程序时实现基于语义解析的文本准确率计算方法,所述方法包括:获取从模板文本的始点开始被转写的部分转写文本;以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵;根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值;记录所述编辑距离矩阵中各元素的值的计算轨迹,生成与所述编辑距离矩阵对应的轨迹矩阵;计算所述轨迹矩阵中各轨迹的相似度,筛选所述部分转写文本与所述模板文本相似度最高的一条轨迹,获得第一轨迹;根据所述第一轨迹,确定所述部分转写文本在所述模板文本上对应的终点,获得第一终点;根据所述模板文本的始点和所述第一终点,从所述模板文本中获取新模板文本;将所述部分转写文本与所述新模板文本进行对比,通过编辑距离算法计算所述部分转写文本的准确率。
- 根据权利要求15所述的计算机设备,其特征在于,在所述以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵的步骤之后,在所述根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值的步骤之前,包括:从所述编辑距离矩阵的第一行的第三个元素开始输入所述模板文本的字符;从所述编辑距离矩阵的第一列的第三个元素开始输入所述部分转写文本的字符;定义所述编辑距离矩阵的第二行中的第二个元素的值为0;以所述编辑距离矩阵的第二行中的第二个元素的值为0依次递增数值1,初始化所述编辑距离矩阵的第二行的各元素的值;以所述编辑距离矩阵的第二列中的第二个元素的值为0依次递增数值1,初始化所述编辑距离矩阵的第二列的各元素的值。
- 根据权利要求16所述的计算机设备,其特征在于,所述编辑距离矩阵中未被初始化的各元素的值由其左方、左上角、上方中的某一个元素的值来确定,在所述根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值的步骤中,包括:识别所述编辑距离矩阵的第三列中的第三个元素所处于的列数、行数;识别所述编辑距离矩阵的第三列中的第三个元素所处于的列数、行数分别对应所述模板文本的字符、所述部分转写文本的字符;判断所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符是否相等;若所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符相等,则所述编辑距离矩阵 的第三列中的第三个元素的值为其左上角的元素的值;若所述编辑距离矩阵的第三列中的第三个元素所处于的列数对应所述模板文本的字符与所述编辑距离矩阵的第三列中的第三个元素所处于行数对应所述部分转写文本的字符不相等,则所述编辑距离矩阵的第三列中的第三个元素的值为其左方、左上角、上方的元素中最小值加1得到;依次计算所述编辑距离矩阵的第三列中的第四个元素的值,直至完成计算所述编辑距离矩阵中各元素的值。
- 根据权利要求15所述的计算机设备,其特征在于,在所述记录所述编辑距离矩阵中各元素的值的计算轨迹,生成与所述编辑距离矩阵对应的轨迹矩阵的步骤中,包括:记录所述编辑距离矩阵中各元素的值的计算轨迹;根据所述编辑距离矩阵中各元素的值的计算轨迹,标记所述编辑距离矩阵中各元素的值产生由来;在完成标记后,生成与所述编辑距离矩阵对应的轨迹矩阵。
- 一种计算机非易失性可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现基于语义解析的文本准确率计算方法,所述方法包括:获取从模板文本的始点开始被转写的部分转写文本;以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵;根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值;记录所述编辑距离矩阵中各元素的值的计算轨迹,生成与所述编辑距离矩阵对应的轨迹矩阵;计算所述轨迹矩阵中各轨迹的相似度,筛选所述部分转写文本与所述模板文本相似度最高的一条轨迹,获得第一轨迹;根据所述第一轨迹,确定所述部分转写文本在所述模板文本上对应的终点,获得第一终点;根据所述模板文本的始点和所述第一终点,从所述模板文本中获取新模板文本;将所述部分转写文本与所述新模板文本进行对比,通过编辑距离算法计算所述部分转写文本的准确率。
- 根据权利要求19所述的计算机非易失性可读存储介质,其特征在于,在所述以所述模板文本字符的长度增加两个字符的长度为列数、以所述部分转写文本字符的长度增加两个字符的长度为行数,建立编辑距离矩阵的步骤之后,在所述根据所述部分转写文本、所述模板文本,计算所述编辑距离矩阵中各元素的值的步骤之前,包括:从所述编辑距离矩阵的第一行的第三个元素开始输入所述模板文本的字符;从所述编辑距离矩阵的第一列的第三个元素开始输入所述部分转写文本的字符;定义所述编辑距离矩阵的第二行中的第二个元素的值为0;以所述编辑距离矩阵的第二行中的第二个元素的值为0依次递增数值1,初始化所述编辑距离矩阵 的第二行的各元素的值;以所述编辑距离矩阵的第二列中的第二个元素的值为0依次递增数值1,初始化所述编辑距离矩阵的第二列的各元素的值。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811348583.1A CN109710904B (zh) | 2018-11-13 | 2018-11-13 | 基于语义解析的文本准确率计算方法、装置、计算机设备 |
| CN201811348583.1 | 2018-11-13 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020098098A1 true WO2020098098A1 (zh) | 2020-05-22 |
Family
ID=66254868
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2018/124398 Ceased WO2020098098A1 (zh) | 2018-11-13 | 2018-12-27 | 基于语义解析的文本准确率计算方法、装置、计算机设备 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN109710904B (zh) |
| WO (1) | WO2020098098A1 (zh) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115410574A (zh) * | 2022-08-09 | 2022-11-29 | 名日之梦(北京)科技有限公司 | 一种文本获取方法、装置、存储介质和计算机设备 |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8001136B1 (en) * | 2007-07-10 | 2011-08-16 | Google Inc. | Longest-common-subsequence detection for common synonyms |
| CN103699591A (zh) * | 2013-12-11 | 2014-04-02 | 湖南大学 | 一种基于示例页面的网页正文提取方法 |
| CN108399163A (zh) * | 2018-03-21 | 2018-08-14 | 北京理工大学 | 结合词聚合与词组合语义特征的文本相似性度量方法 |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2999768B1 (ja) * | 1999-03-04 | 2000-01-17 | 株式会社エイ・ティ・アール音声翻訳通信研究所 | 音声認識誤り訂正装置 |
| CN104464736B (zh) * | 2014-12-15 | 2018-02-02 | 北京百度网讯科技有限公司 | 语音识别文本的纠错方法和装置 |
| CN105653517A (zh) * | 2015-11-05 | 2016-06-08 | 乐视致新电子科技(天津)有限公司 | 一种识别率确定方法及装置 |
| CN106847288B (zh) * | 2017-02-17 | 2020-12-25 | 上海创米科技有限公司 | 语音识别文本的纠错方法与装置 |
-
2018
- 2018-11-13 CN CN201811348583.1A patent/CN109710904B/zh active Active
- 2018-12-27 WO PCT/CN2018/124398 patent/WO2020098098A1/zh not_active Ceased
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8001136B1 (en) * | 2007-07-10 | 2011-08-16 | Google Inc. | Longest-common-subsequence detection for common synonyms |
| CN103699591A (zh) * | 2013-12-11 | 2014-04-02 | 湖南大学 | 一种基于示例页面的网页正文提取方法 |
| CN108399163A (zh) * | 2018-03-21 | 2018-08-14 | 北京理工大学 | 结合词聚合与词组合语义特征的文本相似性度量方法 |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115410574A (zh) * | 2022-08-09 | 2022-11-29 | 名日之梦(北京)科技有限公司 | 一种文本获取方法、装置、存储介质和计算机设备 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109710904A (zh) | 2019-05-03 |
| CN109710904B (zh) | 2023-11-14 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| TWI621077B (zh) | 理賠單據的字元識別方法及伺服器 | |
| JP5175206B2 (ja) | 草稿文書における編集パターンの自動検出及び適用 | |
| WO2022142613A1 (zh) | 训练语料扩充方法及装置、意图识别模型训练方法及装置 | |
| WO2021135910A1 (zh) | 基于机器阅读理解的信息抽取方法、及其相关设备 | |
| WO2021164301A1 (zh) | 医学文本结构化方法、装置、计算机设备及存储介质 | |
| CN110399800B (zh) | 基于深度学习vgg16框架的车牌检测方法及系统、存储介质 | |
| CN109657675B (zh) | 图像标注方法、装置、计算机设备和可读存储介质 | |
| CN115391322A (zh) | 数据检核方法、装置、设备、存储介质及程序产品 | |
| WO2019153587A1 (zh) | 用户身份验证方法、装置、计算机设备和存储介质 | |
| WO2020155486A1 (zh) | 人脸识别优化方法、装置、计算机设备和存储介质 | |
| CN113869320B (zh) | 一种基于模板的键值对提取方法及系统 | |
| CN111626046A (zh) | 一种变电站的遥测文本图元与设备图元位置关联校验方法 | |
| CN114565044B (zh) | 印章识别方法及系统 | |
| WO2020098099A1 (zh) | 基于语义解析的文本准确率计算方法、装置、计算机设备 | |
| WO2020098098A1 (zh) | 基于语义解析的文本准确率计算方法、装置、计算机设备 | |
| KR101449725B1 (ko) | Pdf 문서 파일을 자동 변환하는 장치 및 방법 | |
| CN111626281B (zh) | 基于自适应学习的纸质影像地图中文标注信息识别方法及系统 | |
| CN112418015B (zh) | 一种电力系统二次设备定值核对与修改方法及系统 | |
| CN114254706A (zh) | 一种序列识别模型训练方法、装置、电子设备及存储介质 | |
| CN111291535B (zh) | 剧本处理方法、装置、电子设备及计算机可读存储介质 | |
| CN116362219A (zh) | 信息提取模板生成方法及装置、介质、设备 | |
| CN117827885A (zh) | 数据库语句生成方法、装置、设备及介质 | |
| CN111580823B (zh) | 基于验证图片的代码转换方法、装置和计算机设备 | |
| CN118228690A (zh) | 处理pdf文档中的表格的方法、装置、计算器设备及存储介质 | |
| CN121212295B (zh) | 基于大语言模型的岗位人员知识提取方法、装置及设备 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 25/08/2021) |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 18940000 Country of ref document: EP Kind code of ref document: A1 |