Sentence segmentation method and device, storage medium, processor and terminal device
Through the sentence segmentation model based on word alignment relationships, the problem of inaccurate sentence segmentation in machine translation is solved, and effective segmentation and translation of long and short sentences and sentences without punctuation are achieved, significantly improving the translation accuracy.
Patent Information
- Application Number
- CN201910376312.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-05-07
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2039-05-07
AI Technical Summary
The existing technology cannot effectively segment long and short sentence pairs during machine translation, resulting in large translation deviations, especially when it is unable to process overly long sentences in the absence of punctuation.
By obtaining training data based on word alignment relationships, a sentence segmentation model is constructed, and the model is used to segment the sentences to be segmented to achieve accurate segmentation and translation of sentences in any form.
It improves the accuracy of translation, can effectively handle long and short sentences, sentences without punctuation, etc., and significantly reduces translation deviations.
Smart Images

Figure CN111914571B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a sentence segmentation method and apparatus, a storage medium, a processor and a terminal device. Background Art
[0002] In the relevant technology, machine translation refers to the translation of text from one natural language to another natural language by computer programs. At present, machine translation usually includes two steps: 1) firstly segment the original text and the translation of the bilingual sentence pair according to punctuation marks to form clauses respectively; 2) align the clauses to obtain bilingual clause pairs that can be translated into each other. However, this translation method has obvious defects, namely, 1) after segmentation according to punctuation marks, it may not be possible to find clause pairs that can be completely translated into each other; 2) it cannot handle sentences that do not have punctuation marks but are still very long.
[0003] Especially when the length of the corpus sentence pairs is too long during translation training and decoding, it is often impossible to effectively segment and process them. Therefore, it is currently necessary to achieve reasonable segmentation of long and short sentences during the translation process, especially for overly long training corpora, to perform appropriate sentence pair synchronization segmentation so that they can be used by the NMT model.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present invention provide a sentence segmentation method and apparatus, a storage medium, a processor and a terminal device, so as to at least solve the technical problem in the related art that sentences and / or sentence pairs cannot be effectively segmented when translating text, resulting in large translation deviations.
[0006] According to one aspect of an embodiment of the present invention, a sentence segmentation method is provided, comprising: acquiring training data, wherein the training data is bilingual sentence pairs to be used formed by segmenting initial bilingual sentence pairs based at least on word alignment relationships; obtaining a sentence segmentation model by training the training data; and segmenting sentences to be segmented using the sentence segmentation model.
[0007] According to another aspect of an embodiment of the present invention, a sentence segmentation device is also provided, including: an acquisition unit, used to acquire training data, wherein the training data is a bilingual sentence pair to be used formed by segmenting an initial bilingual sentence pair based at least on a word alignment relationship; a training unit, used to obtain a sentence segmentation model through training with the training data; and a segmentation unit, used to segment the sentence to be segmented using the sentence segmentation model.
[0008] According to another aspect of an embodiment of the present invention, a storage medium is further provided, wherein the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute any one of the statement segmentation methods described above.
[0009] According to another aspect of an embodiment of the present invention, a processor is further provided, the processor being used to run a program, wherein the program executes any one of the statement segmentation methods described above when the program is run.
[0010] According to another aspect of an embodiment of the present invention, a terminal device is also provided, including: a processor; and a memory connected to the processor, for providing the processor with instructions for processing the following processing steps: Step 1, obtaining training data, wherein the training data is a bilingual sentence pair to be used formed by segmenting an initial bilingual sentence pair based at least on a word alignment relationship; Step 2, obtaining a sentence segmentation model by training the training data; Step 3, segmenting the sentences to be segmented using the sentence segmentation model.
[0011] The following embodiment of the present invention proposes a sentence segmentation method, which can accurately, efficiently and widely apply the sentence alignment sentence segmentation method based on the word alignment relationship. In this scheme, training data is obtained by segmentation, and a sentence segmentation model for single sentence (such as long sentence) or sentence pair segmentation is constructed, thereby completing the accurate segmentation of various sentences and / or sentence pairs, providing effective guarantee for subsequent accurate translation.
[0012] In an embodiment of the present invention, training data is obtained, wherein the training data is at least based on the word alignment relationship, and after segmenting the initial bilingual sentence pairs, the bilingual sentence pairs to be used are formed, and a sentence segmentation model is obtained by training the training data, and finally the sentence segmentation model is used to segment the sentences to be segmented. In this embodiment, the sentence segmentation model is used to effectively segment the sentences (such as reasonably segmenting the bilingual pairs and / or the longer monolingual sentences), so as to ensure that the short sentences after segmentation can be reasonably translated into each other, without completely relying on punctuation segmentation, and can achieve segmentation of sentences of any form, so that not only short sentences can be effectively segmented and translated, but also other sentences (such as long sentences, bilingual sentence pairs, sentences without punctuation, etc.) can be effectively segmented and translated. After the sentence segmentation is reasonably implemented, the translation accuracy will also be significantly improved, thereby solving the technical problem that in the related art, when performing text translation, sentences and / or sentence pairs cannot be effectively segmented, resulting in a large translation deviation. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0014] Figure 1 A hardware structure block diagram of a computer terminal for implementing a sentence segmentation method is shown;
[0015] Figure 2 A schematic diagram of a network terminal of a sentence segmentation method is shown;
[0016] Figure 3 is a flow chart of a sentence segmentation method according to Embodiment 1 of the present invention;
[0017] Figure 4 is a schematic diagram of an optional sentence segmentation according to an embodiment of the present invention;
[0018] Figure 5 is a schematic diagram of an optional sentence segmentation device according to an embodiment of the present invention;
[0019] Figure 6 is a structural block diagram of a terminal device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0020] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0021] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0022] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:
[0023] Neural machine translation, referred to as NMT, is the current mainstream machine translation technology. It uses deep neural networks and attention mechanisms to achieve machine translation based on a large amount of high-quality bilingual corpus.
[0024] Bilingual corpus: a corpus of texts that are translated into each other.
[0025] Example 1
[0026] According to an embodiment of the present invention, a method embodiment of statement segmentation is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0027] The sentence segmentation method embodiment provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing a sentence segmentation method. Figure 1 As shown, the computer terminal 10 (or mobile device 10) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a microprocessor MCU or a programmable logic device FPGA and other processing devices), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0028] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0029] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the sentence segmentation method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the above-mentioned sentence segmentation method is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0030] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0031] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0032] Figure 1 The hardware structure block diagram shown can be used not only as an exemplary block diagram of the above-mentioned computer terminal 10 (or mobile device), but also as an exemplary block diagram of the above-mentioned server. In an optional embodiment, Figure 2 A schematic diagram of a network terminal of a sentence segmentation method is shown, Figure 2 As shown, the computer terminal 10 (or mobile device) can be connected to one or more servers (e.g., security servers, resource servers, game servers, etc.) via a data network connection or electronic connection. In an optional embodiment, the above-mentioned computer terminal 10 (or mobile device) can be any mobile computing device, etc. The data network connection can be a local area network connection, a wide area network connection, an Internet connection, or other types of data network connections. The computer terminal 10 (or mobile device) can be executed to connect to a network service performed by a server (e.g., a security server) or a group of servers. A network server is a network-based user service, such as a social network, cloud resources, email, online payment or other online applications.
[0033] Under the above operating environment, this application provides Figure 3 The flowchart of the statement segmentation method is shown. Figure 3 is a flow chart of a sentence segmentation method according to Embodiment 1 of the present invention. Figure 3 As shown, the method comprises the following steps:
[0034] Step S302, obtaining training data, wherein the training data is the bilingual sentence pairs to be used formed by segmenting the initial bilingual sentence pairs based at least on the word alignment relationship;
[0035] Step S304, obtaining a sentence segmentation model through training data;
[0036] Step S306: Use the sentence segmentation model to segment the sentence to be segmented.
[0037] Through the above steps, training data can be obtained, wherein the training data is at least based on the word alignment relationship, and after segmenting the initial bilingual sentence pairs, the bilingual sentence pairs to be used are formed, and the sentence segmentation model is obtained by training the training data, and finally the sentence segmentation model is used to segment the sentences to be segmented. In this embodiment, the sentence segmentation model can be used to effectively segment the sentences, ensuring that the short sentences after segmentation can be reasonably translated into each other, without completely relying on punctuation segmentation, and can achieve segmentation of sentences of any form, so that not only short sentences can be effectively segmented and translated, but also other sentences (such as long sentences, bilingual sentence pairs, sentences without punctuation, etc.) can be effectively segmented and translated. After the sentence segmentation is reasonably implemented, the translation accuracy will also be significantly improved, thereby solving the technical problem that in the related art, when performing text translation, sentences and / or sentence pairs cannot be effectively segmented, resulting in a large translation deviation.
[0038] The following embodiments of the present invention can be applied to terminal devices using machine translation, especially to devices using neural network machine translation. For example, reasonable and accurate sentence segmentation can be achieved for bilingual sentence pairs, longer single sentences, paragraph sentences, etc. For longer bilingual sentence pairs, short sentence pairs that are accurately translated and semantically complete can be obtained. For longer single sentences, they can be segmented into multiple short sentences with complete semantics. When subsequently translated through a semantic library, the accuracy of the translation will be significantly improved.
[0039] Optionally, the embodiment of the present invention is applied to one of the following scenarios: segmenting an initial bilingual sentence pair into bilingual sentence pairs to be used; segmenting sentences to be segmented into sentences to be used for machine translation.
[0040] The present application is described below in conjunction with each step.
[0041] Step S302, obtaining training data, wherein the training data is bilingual sentence pairs to be used formed by segmenting initial bilingual sentence pairs based at least on word alignment relationships.
[0042] In the embodiment of the present invention, the training data refers to the sentence pairs to be used obtained by initial segmentation using the existing sentence pairs to be translated, and the sentence pairs include: bilingual sentence pairs, and the embodiment of the present invention uses the bilingual sentence pairs as an example. Through this step S302 and the following step S304, training can be performed to obtain a sentence segmentation model.
[0043] In an optional embodiment of the present invention, obtaining training data includes: performing word alignment processing on an initial bilingual sentence pair to obtain a bilingual sentence pair containing a word alignment result, wherein the word alignment result uses a word alignment line to represent the word alignment relationship; determining a plurality of candidate segmentation points in the bilingual sentence pair containing the word alignment result, wherein the segmentation lines obtained by the plurality of candidate segmentation points do not intersect with the word alignment line; selecting some segmentation points from the plurality of candidate segmentation points according to a preset rule; determining the segmentation points to be finally used from the some segmentation points by constructing a language model, performing segmentation processing on the bilingual sentence pair containing the word alignment result using the segmentation points to obtain segmented bilingual sentences, and determining the segmented bilingual sentences as training data.
[0044] Among them, performing word alignment processing on the initial bilingual sentence pairs to obtain bilingual sentence pairs containing word alignment results may refer to performing word segmentation and word alignment processing on the segmented bilingual pairs (the length is not limited, and in this application, it mainly refers to the longer bilingual pairs). Optionally, word segmentation refers to splitting the sentence into individual words; and word alignment processing refers to translating words with the same or similar meanings between at least two natural languages. For example, in the process of translating from Chinese to English, the Chinese "Australia is one of a few countries that has diplomatic relations with North Korea" is translated into "Australia is one of a few countries that has relations with Democratic People's Republic of Korea". In this translation, the English word corresponding to the Chinese "Australia" is "Australia", the English word corresponding to the Chinese "is" is "is", the English sentence corresponding to the Chinese "minority" is "one of a few", the English word corresponding to the Chinese "established diplomatic relations" is "relationship", the English word corresponding to the Chinese "country" is "countries", and the English word corresponding to the Chinese "Korea" is "Democrat ic People's Republic". ic of Korea”.
[0045] Optionally, the corresponding words in the word alignment result include one-to-one, one-to-many, many-to-one, many-to-many, etc. After obtaining the word alignment result, an alternative segmentation point can be determined on the sentence pair containing the word alignment result. The candidate segmentation line position determined by the segmentation point will not cross the word alignment line, so as to ensure that the segmented clauses are mutually translated.
[0046] After determining a plurality of candidate segmentation points, reasonable and accurate partial segmentation points can be screened out, through which the bilingual sentence pairs can be accurately segmented. Figure 4 is a schematic diagram of an optional sentence segmentation according to an embodiment of the present invention, such as Figure 4 As shown in the figure, the sentence is divided into two parts, the upper part is Chinese, and the lower part is English. After segmentation, multiple segmentation points can be determined. For example, there is a segmentation point after the words "Australia", "is", "a few", and "with", which corresponds to the English words "Australia", "is", "one of a few", and "countries that has". These segmentation points can be determined as the above-mentioned partial segmentation points. The line between each two corresponding segmentation points can be understood as a word alignment line, and the word alignment result can be determined after the line is connected.
[0047] When selecting some segmentation points, segmentation can be performed according to preset rules, and the preset rules include at least one of the following: there is at least one word on both sides of each segmentation point; there is at least one word on one side of each segmentation point, and there is a punctuation mark on the other side of the segmentation point; the number of words between each two adjacent segmentation points is greater than the first preset threshold. That is, when selecting segmentation points, it is required that there must be words on both sides of the segmentation line. If there are punctuation marks, symbols, etc. next to the segmentation line, the segmentation line can be selected. Finally, when selecting short sentences, short sentences with a number of words exceeding the first preset threshold can be selected. The first preset threshold can be set by users, developers, etc. For example, the first preset threshold is set to 3. By using the first preset threshold, it is possible to avoid segmenting the sentence too fragmented.
[0048] Another optional embodiment includes: by constructing a language model, determining the finally used segmentation points from partial segmentation points, using the finally used segmentation points to segment the bilingual sentence pair containing word alignment results to obtain segmented bilingual sentences, and determining the segmented bilingual sentences as training data, including: selecting a first segmentation point and a second segmentation point belonging to the same segmentation line from the partial segmentation points, where the first segmentation point is used to segment the first sentence in the initial bilingual sentence pair, and the second segmentation point is used to segment the second sentence in the initial bilingual sentence pair; calculating a first score of the context words segmented by the first segmentation point through a first language model constructed for the first sentence, and calculating a second score of the context words segmented by the second segmentation point through a second language model constructed for the second sentence; determining the finally used segmentation point by using the sum of the first score and the second score, using the finally used segmentation point to segment the bilingual sentence pair containing word alignment results to obtain segmented bilingual sentences, and determining the segmented bilingual sentences as training data.
[0049] Optionally, the language model is a language model of the source text and the translation. For example, in Figure 4 , the source text can be the above Chinese text, and the translation can be the following English text. Then, the language model is trained through the Figure 4 mutual translation results.
[0050] In the embodiments of the present invention, the first segmentation point can be a segmentation point corresponding to the source text sentence, and the second segmentation point is a segmentation point corresponding to the translation sentence. As Figure 4 shown, there can be a segmentation point after "Australia", "is", "one of a few", and "and", and these segmentation points can be understood as the first segmentation points; while there will be a segmentation point after "Austral ia", "is", "one of a few", and "countries that has", and this segmentation point can be understood as the second segmentation point. After connecting the Chinese segmentation points and the English segmentation points, there can be multiple segmentation lines obtained by connecting the two segmentation points between "Australia" and "Austral ia", "is" and "is", "one of a few" and "one of a few", and "and" and "countries that has" (such as the dotted lines in Figure 4 indicating the segmentation lines); each segmentation line corresponds to two segmentation points. When segmenting, accumulate the sum of the scores of every two segmentation points (that is, accumulate the sum of the first score and the second score) to determine the finally used segmentation point, and use the finally used segmentation point to segment the bilingual sentence pair containing word alignment results to obtain segmented bilingual sentences.
[0051] In the embodiment of the present invention, the language types of the first sentence and the second sentence are not limited. For example, the first sentence includes but is not limited to: Chinese, English, Russian, Japanese, Chinese, and Spanish; the second sentence can be a sentence with a natural language different from that of the first sentence; for example, the first sentence is Chinese and the second sentence is English; such as the first sentence is English and the second sentence is Russian.
[0052] In an optional embodiment of the present invention, a first language model is constructed for the first sentence and a second language model is constructed for the second sentence. After the first sentence and the second sentence are segmented in the above manner, a first score between each word after the first sentence is segmented by the first segmentation point can be determined, and a second score between each word after the second sentence is segmented by the second segmentation point can be determined. In the embodiment of the present invention, a lower score indicates a lower closeness between words, and the segmentation point may be the final segmentation point.
[0053] When selecting the split lines, you can select all the split lines with scores below a certain threshold, or select the N split lines with the lowest scores.
[0054] In the above manner, the first score and the second score can be determined respectively, and then the two scores are accumulated to determine the training data, and the segmented sentences are combined to form new mutually translated sentence pairs, which are put into the corpus for sentence segmentation model training.
[0055] In an embodiment of the present invention, when segmenting a sentence, in addition to the above-mentioned method of determining the segmentation line through preset rules and sentence segmentation models, there may also be other methods, such as building a classifier to determine whether it is a suitable segmentation line, and manually annotating training data to determine the classification method of the classifier and then obtain the segmentation line.
[0056] Step S304, obtaining a sentence segmentation model through training data.
[0057] Another optional embodiment, obtaining a sentence segmentation model through training data includes: setting the context words segmented by each segmentation point in the training data, the language model, and the sum of the first score and the second score as features of the sentence segmentation model, and training the sentence segmentation model.
[0058] In the embodiment of the present invention, after segmenting and translating a bilingual pair each time, the result can be formed into training data. Figure 4 After the sentences in are translated and segmented, the results are put into the training library for sentence segmentation model training.
[0059] Step S306: Use the sentence segmentation model to segment the sentence to be segmented.
[0060] When segmenting sentences, the embodiments of the present invention may first segment them according to punctuation rules. We believe that phrases segmented by punctuation are generally semantically complete and can be translated independently. Then, for sentences that are still too long after punctuation segmentation, a sentence segmentation model may be used to segment these longer sentences.
[0061] Optionally, the sentences to be segmented in the embodiment of the present invention are mainly sentences that are still too long after segmentation at punctuation points (ie, single sentences that are longer after segmentation).
[0062] In an optional embodiment, after the sentence segmentation model is trained, the sentence segmentation model is used to perform sentence segmentation, and then accurate translation of the sentence is achieved to ensure the semantic accuracy of the sentence.
[0063] Optionally, the sentence types of the sentence to be segmented include but are not limited to: long sentences and short sentences.
[0064] Another optional method is to segment the sentences to be segmented using a sentence segmentation model, including: a segmentation step, segmenting the sentences to be segmented using a sentence segmentation model to obtain multiple segmentation points to be confirmed; a selection step, selecting unconfirmed segmentation points from multiple segmentation points to be confirmed; a confirmation step, if the number of words contained in the context short sentences segmented by the currently selected segmentation points is less than the second preset threshold, then merging the context short sentences segmented by the currently selected segmentation points into new short sentences; returning to the selection step, until all the multiple segmentation points to be confirmed are confirmed, so as to obtain the segmentation result of the sentence to be segmented. That is, the sentence segmentation model can be used to segment the new sentence, and after the segmentation is completed, it is confirmed whether the word data contained between two consecutive short sentences is less than the set second preset threshold. If it is less than, the two sentences can be merged, so that the long sentence can be prevented from being segmented too fragmented, thereby ensuring that the segmented sentence conforms to the actual output semantics.
[0065] When segmenting sentences, the embodiment of the present invention can use a classifier for segmentation. First, the segmented sentences in the above-mentioned bilingual sentence pairs are used as training data for the classifier. The classifier adopts a traditional statistical classification model, such as BGDT or SVM, etc. The training features of the classifier include but are not limited to: context words at the segmentation point, and context language model scores. Then use the trained classifier to segment the new sentence to be segmented. After the classifier segmentation is completed, if the lengths of two consecutive clauses are less than the set second preset threshold N (for example, 5), then the two sentences are merged to complete the long sentence segmentation.
[0066] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0067] Through the description of the above implementation methods, those skilled in the art can clearly understand that the sentence segmentation method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of various embodiments of the present invention.
[0068] Example 2
[0069] According to an embodiment of the present invention, a sentence segmentation device for implementing the above-mentioned sentence segmentation method is also provided. Figure 5 is a schematic diagram of an optional sentence segmentation device according to an embodiment of the present invention, such as Figure 5 As shown, the device includes: an acquisition unit 51, a training unit 53, and a segmentation unit 55, wherein:
[0070] An acquisition unit 51 is used to acquire training data, wherein the training data is a bilingual sentence pair to be used formed by segmenting the initial bilingual sentence pair based on at least a word alignment relationship;
[0071] A training unit 53, used for obtaining a sentence segmentation model through training data;
[0072] The segmentation unit 55 is used to segment the sentences to be segmented by using the sentence segmentation model.
[0073] The above-mentioned sentence segmentation can adopt the acquisition unit 51 to acquire training data, wherein the training data is at least based on the word alignment relationship, and the training unit 53 is used to segment the initial bilingual sentence pairs to form the bilingual sentence pairs to be used, and the sentence segmentation model is obtained by training the training data, and finally the sentence segmentation model is used to segment the sentences to be segmented by the segmentation unit 55. In this embodiment, the sentence segmentation model can be used to effectively segment the sentences to ensure that the short sentences after segmentation can be reasonably translated into each other, without completely relying on punctuation segmentation, and can achieve segmentation of sentences of any form, so that not only short sentences can be effectively segmented and translated, but also other sentences (such as long sentences, bilingual sentence pairs, sentences without punctuation, etc.) can be effectively segmented and translated. After the sentence segmentation is reasonably implemented, the translation accuracy will also be significantly improved, thereby solving the technical problem in the related art that when performing text translation, sentences and / or sentence pairs cannot be effectively segmented, resulting in a large translation deviation.
[0074] In an optional embodiment, the acquisition unit includes: an alignment module, which is used to perform word alignment processing on the initial bilingual sentence pair to obtain a bilingual sentence pair containing the word alignment result, wherein the word alignment result uses a word alignment line to represent the word alignment relationship; a first determination module, which is used to determine multiple candidate segmentation points in the bilingual sentence pair containing the word alignment result, wherein the segmentation lines obtained by the multiple candidate segmentation points do not intersect with the word alignment line; a screening module, which is used to screen out some segmentation points from the multiple candidate segmentation points according to preset rules; a second determination module, which is used to determine the segmentation points to be finally used from the some segmentation points by constructing a language model, and use the segmentation points to segment the bilingual sentence pair containing the word alignment result to obtain segmented bilingual sentences, and determine the segmented bilingual sentences as training data.
[0075] In an optional embodiment, the preset rules include at least one of the following: there is at least one word on both sides of each segmentation point; there is at least one word on one side of each segmentation point, and there is a punctuation mark on the other side of the segmentation point; the number of words between each two adjacent segmentation points is greater than a first preset threshold.
[0076] In an embodiment of the present invention, the second determination module includes: a first selection submodule, which is used to select a first segmentation point and a second segmentation point belonging to the same segmentation line from some segmentation points, wherein the first segmentation point is used to segment the first sentence in the initial bilingual sentence pair, and the second segmentation point is used to segment the second sentence in the initial bilingual sentence pair; a first calculation submodule, which is used to calculate a first score of a context word segmented by the first segmentation point through a first language model constructed for the first sentence, and to calculate a second score of a context word segmented by the second segmentation point through a second language model constructed for the second sentence; a first determination submodule, which is used to determine the segmentation point finally used by using the sum of the first score and the second score, and to segment the bilingual sentence pair containing the word alignment result using the segmentation point finally used to obtain a segmented bilingual sentence, and to determine the segmented bilingual sentence as training data.
[0077] In another optional embodiment of the present invention, the training unit includes: a training module, used to set the context words segmented by each segmentation point in the training data, the language model, and the sum of the first score and the second score as features of the sentence segmentation model, and train the sentence segmentation model.
[0078] In another optional embodiment of the present invention, the segmentation unit includes: a first segmentation module, which is used to segment the sentence to be segmented using a sentence segmentation model to obtain multiple segmentation points to be confirmed; a second selection module, which is used to select unconfirmed segmentation points from multiple segmentation points to be confirmed; a confirmation module, which is used to merge the context sentences segmented by the currently selected segmentation points into new sentences if the number of words contained in the context sentences segmented by the currently selected segmentation points is less than a second preset threshold; and return to the selection step until all the multiple segmentation points to be confirmed are confirmed to obtain the segmentation result of the sentence to be segmented.
[0079] In another optional embodiment of the present invention, the above-mentioned sentence segmentation device is applied to one of the following scenarios: segmenting the initial bilingual sentence pairs into the bilingual sentence pairs to be used; segmenting the sentences to be segmented into sentences to be used for machine translation.
[0080] It should be noted that the acquisition unit 51, training unit 53, and segmentation unit 55 correspond to steps S302 to S306 in Example 1, and the three units and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above-mentioned Example 1. It should be noted that the above-mentioned units, as part of the device, can be run in the computer terminal 10 provided in Example 1.
[0081] Example 3
[0082] The embodiment of the present invention can provide a computer terminal, which can be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal can also be replaced by a terminal device such as a mobile terminal.
[0083] Optionally, in this embodiment, the computer terminal may be located in at least one network device among a plurality of network devices of the computer network.
[0084] Optionally, the above-mentioned computer device includes: a processor; and a memory, connected to the processor, for providing the processor with instructions for processing the following processing steps: obtaining training data, wherein the training data is a bilingual sentence pair to be used formed by segmenting an initial bilingual sentence pair based at least on a word alignment relationship; obtaining a sentence segmentation model by training the training data; and using the sentence segmentation model to segment the sentences to be segmented.
[0085] In this embodiment, the computer device may also execute the program code of the following steps in the sentence segmentation method: performing word alignment processing on the initial bilingual sentence pairs to obtain bilingual sentence pairs containing word alignment results, wherein the word alignment results use word alignment lines to represent word alignment relationships; determining multiple candidate segmentation points in the bilingual sentence pairs containing the word alignment results, wherein the segmentation lines obtained by the multiple candidate segmentation points do not intersect with the word alignment lines; selecting some segmentation points from the multiple candidate segmentation points according to preset rules; determining the segmentation points that are finally used from the some segmentation points by constructing a language model, and performing segmentation processing on the bilingual sentence pairs containing the word alignment results using the segmentation points that are finally used to obtain segmented bilingual sentences, and determining the segmented bilingual sentences as training data.
[0086] Optionally, the preset rules include at least one of the following: there is at least one word on both sides of each segmentation point; there is at least one word on one side of each segmentation point, and there is a punctuation mark on the other side of the segmentation point; the number of words between each two adjacent segmentation points is greater than a first preset threshold.
[0087] In this embodiment, the computer device may also execute the program code of the following steps in the sentence segmentation method: selecting a first segmentation point and a second segmentation point belonging to the same segmentation line from some segmentation points, wherein the first segmentation point is used to segment the first sentence in the initial bilingual sentence pair, and the second segmentation point is used to segment the second sentence in the initial bilingual sentence pair; calculating a first score of context words segmented by the first segmentation point by using a first language model constructed for the first sentence, and calculating a second score of context words segmented by the second segmentation point by using a second language model constructed for the second sentence; determining the segmentation point finally used by using the sum of the first score and the second score, segmenting the bilingual sentence pair containing the word alignment result by using the segmentation point finally used to obtain segmented bilingual sentences, and determining the segmented bilingual sentences as training data.
[0088] In this embodiment, the above-mentioned computer device can also execute the program code of the following steps in the sentence segmentation method: setting the context words, language model and the sum of the first score and the second score segmented by each segmentation point in the training data as features of the sentence segmentation model, and training to obtain the sentence segmentation model.
[0089] Optionally, the sentence segmentation method executed by the above-mentioned computer device can be applied to one of the following scenarios: segmenting the initial bilingual sentence pairs into the bilingual sentence pairs to be used; segmenting the sentences to be segmented into sentences to be used for machine translation.
[0090] In this embodiment, the above-mentioned computer device can also execute the program code of the following steps in the sentence segmentation method: a segmentation step, using a sentence segmentation model to segment the sentence to be segmented to obtain multiple segmentation points to be confirmed; a selection step, selecting an unconfirmed segmentation point from multiple segmentation points to be confirmed; a confirmation step, if the number of words contained in the context short sentences segmented by the currently selected segmentation point is less than the second preset threshold, then the context short sentences segmented by the currently selected segmentation point are merged into a new short sentence; return to the selection step until all the multiple segmentation points to be confirmed are confirmed to obtain the segmentation result of the sentence to be segmented.
[0091] In this embodiment, the above-mentioned computer terminal can execute the program code of the following steps in the sentence segmentation method: obtaining training data, wherein the training data is a bilingual sentence pair to be used formed by segmenting the initial bilingual sentence pair based at least on word alignment relationship; obtaining a sentence segmentation model by training with the training data; and using the sentence segmentation model to segment the sentence to be segmented.
[0092] Optionally, Figure 6 is a structural block diagram of a terminal device according to an embodiment of the present invention. Figure 6As shown, the terminal device A may include: one or more processors, memories, and a network interface, an input / output interface, a keyboard, and a display.
[0093] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the sentence segmentation method and device in the embodiment of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, the above-mentioned sentence segmentation method is realized. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories can be connected to the terminal A via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0094] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: obtain training data, wherein the training data is based on at least word alignment relationships, and is formed by segmenting the initial bilingual sentence pairs to be used; obtain a sentence segmentation model by training the training data; and use the sentence segmentation model to segment the sentences to be segmented.
[0095] Optionally, the processor may also execute the following steps of program code: performing word alignment processing on the initial bilingual sentence pairs to obtain bilingual sentence pairs containing word alignment results, wherein the word alignment results use word alignment lines to represent word alignment relationships; determining multiple candidate segmentation points in the bilingual sentence pairs containing the word alignment results, wherein segmentation lines obtained by the multiple candidate segmentation points do not intersect with the word alignment lines; selecting some segmentation points from the multiple candidate segmentation points according to preset rules; determining the segmentation points that are ultimately used from the some segmentation points by constructing a language model, performing segmentation processing on the bilingual sentence pairs containing the word alignment results using the segmentation points that are ultimately used to obtain segmented bilingual sentences, and determining the segmented bilingual sentences as training data.
[0096] Optionally, the processor may also execute the following steps of program code: selecting a first segmentation point and a second segmentation point belonging to the same segmentation line from some segmentation points, wherein the first segmentation point is used to segment the first sentence in the initial bilingual sentence pair, and the second segmentation point is used to segment the second sentence in the initial bilingual sentence pair; calculating a first score of context words segmented by the first segmentation point by using a first language model constructed for the first sentence, and calculating a second score of context words segmented by the second segmentation point by using a second language model constructed for the second sentence; determining the segmentation point finally used by using the sum of the first score and the second score, segmenting the bilingual sentence pair containing the word alignment result using the segmentation point finally used to obtain segmented bilingual sentences, and determining the segmented bilingual sentences as training data.
[0097] Optionally, the processor may also execute the following program code: setting the context words segmented by each segmentation point in the training data, the language model, and the sum of the first score and the second score as features of the sentence segmentation model, and training to obtain the sentence segmentation model.
[0098] Optionally, the processor may also execute the program code of the following steps: a segmentation step, using a sentence segmentation model to segment the sentence to be segmented to obtain a plurality of segmentation points to be confirmed; a selection step, selecting a segmentation point that has not yet been confirmed from the plurality of segmentation points to be confirmed; a confirmation step, if the number of words contained in the context sentences segmented by the currently selected segmentation point is less than a second preset threshold, merging the context sentences segmented by the currently selected segmentation point into a new sentence; returning to the selection step, until all the plurality of segmentation points to be confirmed are confirmed, so as to obtain the segmentation result of the sentence to be segmented.
[0099] Optionally, the program code executed by the processor is applied to one of the following scenarios: segmenting the initial bilingual sentence pairs into the bilingual sentence pairs to be used; segmenting the sentences to be segmented into sentences to be used for machine translation.
[0100] The embodiment of the present invention provides a solution for sentence segmentation. By acquiring training data, wherein the training data is at least based on word alignment relationships, and is formed by segmenting the initial bilingual sentence pairs to be used; a sentence segmentation model is obtained by training the training data; and the sentence segmentation model is used to segment the sentences to be segmented, thereby achieving the goal of obtaining the sentence segmentation model by training the training data, and using the model to complete the segmentation of long sentences, ensuring the semantics of the segmented sentences, and improving the translation accuracy, thereby solving the technical problem in the related art that when performing text translation, sentences and / or sentence pairs cannot be effectively segmented, resulting in a large translation deviation.
[0101] It can be understood by those skilled in the art that Figure 6The structure shown is for illustration only, and the terminal device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Figure 6 It does not limit the structure of the above electronic device. For example, the terminal device A may also include Figure 6 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 6 Different configurations are shown.
[0102] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0103] Example 4
[0104] The embodiment of the present invention further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the statement segmentation method provided in the first embodiment.
[0105] Optionally, in this embodiment, the above storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.
[0106] Optionally, in this embodiment, the storage medium is configured to store program code for executing the following steps: obtaining training data, wherein the training data is bilingual sentence pairs to be used formed by segmenting initial bilingual sentence pairs based at least on word alignment relationships; obtaining a sentence segmentation model by training the training data; and segmenting sentences to be segmented using the sentence segmentation model.
[0107] The embodiment of the present invention further provides a processor. Optionally, in this embodiment, the processor can be used to process the program code executed by the sentence segmentation method provided in the first embodiment above.
[0108] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0109] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0110] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0111] 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 distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0112] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0113] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0114] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A sentence segmentation method, characterized in that: include: Performing word alignment processing on the initial bilingual sentence pairs to obtain bilingual sentence pairs containing word alignment results, wherein the word alignment results use word alignment lines to represent word alignment relationships; Determining a plurality of candidate segmentation points in the bilingual sentence pair containing the word alignment result, wherein segmentation lines obtained by the plurality of candidate segmentation points do not intersect with the word alignment line; Selecting some of the split points from the plurality of candidate split points according to a preset rule; Selecting a first segmentation point and a second segmentation point belonging to the same segmentation line from the partial segmentation points, wherein the first segmentation point is used to segment the first sentence in the initial bilingual sentence pair, and the second segmentation point is used to segment the second sentence in the initial bilingual sentence pair; Calculating a first score of context words segmented by the first segmentation point by using a first language model constructed for the first sentence, and calculating a second score of context words segmented by the second segmentation point by using a second language model constructed for the second sentence; The final segmentation point is determined by the sum of the first score and the second score, and the bilingual sentence pair containing the word alignment result is segmented by the final segmentation point to obtain segmented bilingual sentences, and the segmented bilingual sentences are determined as training data; A sentence segmentation model is obtained by training the training data; The sentence segmentation model is used to segment the sentences to be segmented.
2. The method according to claim 1, characterized in that The preset rules include at least one of the following: There is at least one word on both sides of each split point; There is at least one word on one side of each split point, and there is a punctuation mark on the other side of the split point; The number of words between every two adjacent segmentation points is greater than a first preset threshold.
3. The method according to claim 1, characterized in that The sentence segmentation model obtained by training the training data includes: The context words segmented by each segmentation point in the training data, the language model, and the sum of the first score and the second score are set as features of the sentence segmentation model, and the sentence segmentation model is obtained through training.
4. The method according to claim 3, characterized in that Using the sentence segmentation model to segment the sentence to be segmented includes: A segmentation step, using the sentence segmentation model to segment the sentence to be segmented, to obtain a plurality of segmentation points to be confirmed; A selection step, selecting a segmentation point that has not yet been confirmed from the plurality of segmentation points to be confirmed; Confirmation step: If the number of words contained in the context sentences segmented by the currently selected segmentation point is less than the second preset threshold, the context sentences segmented by the currently selected segmentation point are merged into new sentences; return to the selection step until all the multiple segmentation points to be confirmed are confirmed to obtain the segmentation result of the sentence to be segmented.
5. The method according to claim 1, characterized in that The method is applied to one of the following scenarios: dividing the initial bilingual sentence pairs into bilingual sentence pairs to be used; The sentences to be segmented are segmented into sentences to be used for machine translation.
6. A sentence segmentation device, characterized in that: include: An acquisition unit is used to perform word alignment processing on the initial bilingual sentence pair to obtain a bilingual sentence pair containing a word alignment result, wherein the word alignment result uses a word alignment line to represent the word alignment relationship; A determination unit, configured to determine a plurality of candidate segmentation points in a bilingual sentence pair containing a word alignment result, wherein a segmentation line obtained by the plurality of candidate segmentation points does not intersect with the word alignment line; The acquisition unit is further used to: select some segmentation points from the multiple candidate segmentation points according to a preset rule; The acquisition unit is further used to: select a first segmentation point and a second segmentation point belonging to the same segmentation line from the partial segmentation points, wherein the first segmentation point is used to segment the first sentence in the initial bilingual sentence pair, and the second segmentation point is used to segment the second sentence in the initial bilingual sentence pair; The determining unit is further configured to: calculate a first score of the context words segmented by the first segmentation point by using a first language model constructed for the first sentence, and calculate a second score of the context words segmented by the second segmentation point by using a second language model constructed for the second sentence; The determining unit is further configured to: determine a final segmentation point by using the sum of the first score and the second score, segment the bilingual sentence pair containing the word alignment result by using the final segmentation point to obtain segmented bilingual sentences, and determine the segmented bilingual sentences as training data; A training unit, used for training a sentence segmentation model through the training data; The segmentation unit is used to segment the sentences to be segmented by using the sentence segmentation model.
7. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the statement segmentation method according to any one of claims 1 to 5.
8. A processor, characterized in that: The processor is used to run a program, wherein the program is executed when it is run. The sentence segmentation method according to any one of claims 1 to 5 is implemented.
9. A terminal device, characterized in that: include: processor; as well as A memory, connected to the processor, configured to provide the processor with instructions for processing the following processing steps: Step 1, performing word alignment processing on the initial bilingual sentence pair to obtain a bilingual sentence pair containing a word alignment result, wherein the word alignment result uses a word alignment line to represent the word alignment relationship; Step 2, determining a plurality of candidate segmentation points in the bilingual sentence pair containing the word alignment result, wherein the segmentation lines obtained by the plurality of candidate segmentation points do not intersect with the word alignment line; Step 3, selecting some split points from the plurality of candidate split points according to preset rules; Step 4, selecting a first segmentation point and a second segmentation point belonging to the same segmentation line from the partial segmentation points, wherein the first segmentation point is used to segment the first sentence in the initial bilingual sentence pair, and the second segmentation point is used to segment the second sentence in the initial bilingual sentence pair; Step 5, calculating a first score of the context words segmented by the first segmentation point by using a first language model constructed for the first sentence, and calculating a second score of the context words segmented by the second segmentation point by using a second language model constructed for the second sentence; Step 6, using the sum of the first score and the second score to determine the final segmentation point, using the final segmentation point to segment the bilingual sentence pair containing the word alignment result to obtain segmented bilingual sentences, and determining the segmented bilingual sentences as training data; Step 7, obtaining a sentence segmentation model through training with the training data; Step 8: Use the sentence segmentation model to segment the sentences to be segmented.
