WO2023142914A1 - 日期识别方法、装置、可读介质及电子设备 - Google Patents

日期识别方法、装置、可读介质及电子设备 Download PDF

Info

Publication number
WO2023142914A1
WO2023142914A1 PCT/CN2023/070269 CN2023070269W WO2023142914A1 WO 2023142914 A1 WO2023142914 A1 WO 2023142914A1 CN 2023070269 W CN2023070269 W CN 2023070269W WO 2023142914 A1 WO2023142914 A1 WO 2023142914A1
Authority
WO
WIPO (PCT)
Prior art keywords
date
text
target
character
preset
Prior art date
Application number
PCT/CN2023/070269
Other languages
English (en)
French (fr)
Inventor
邓冠玉
陈露露
黄灿
王长虎
Original Assignee
北京有竹居网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京有竹居网络技术有限公司 filed Critical 北京有竹居网络技术有限公司
Publication of WO2023142914A1 publication Critical patent/WO2023142914A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • G06F40/295Named entity recognition

Definitions

  • the present disclosure relates to the field of computer technology, and in particular, to a date recognition method, device, readable medium and electronic equipment.
  • OCR Optical Character Recognition
  • Optical Character Recognition is an important branch of computer vision technology. After completing OCR character recognition, it is often accompanied by recognition The extraction of key information in the text, for example, the extraction of date information in the recognition text.
  • the disclosure provides a date recognition method, device, readable medium and electronic equipment.
  • the present disclosure provides a date identification method, the method comprising:
  • the text to be recognized includes date text
  • the preset date recognition model is used to identify the pending date corresponding to the date text, obtain the target entity category corresponding to each character in the date text, and according to the target entity category corresponding to each character in the date text
  • the category and the pending date determine the target date corresponding to the date text
  • the target entity category is used to characterize whether the character is a specified character related to a date number, and if the character is a specified character related to a date number , the characters correspond to the position information of the numbers in the date.
  • the present disclosure provides a date recognition device, the device comprising:
  • the first obtaining module is configured to obtain the text to be recognized, and the text to be recognized includes date text;
  • the second obtaining module is configured to input the text to be recognized into a preset date recognition model, so as to obtain a target date output by the preset date recognition model;
  • the preset date recognition model is used to identify the pending date corresponding to the date text, obtain the target entity category corresponding to each character in the date text, and according to the target entity category corresponding to each character in the date text
  • the category and the pending date determine the target date corresponding to the date text
  • the target entity category is used to characterize whether the character is a specified character related to a date number, and if the character is a specified character related to a date number , the characters correspond to the position information of the numbers in the date.
  • the present disclosure discloses a computer-readable medium on which a computer program is stored, and when the program is executed by a processing device, the steps of the method described in the first aspect above are implemented.
  • an electronic device including:
  • a processing device configured to execute the computer program in the storage device to implement the steps of the method described in the first aspect above.
  • the pending date corresponding to the date text is identified through the preset date recognition model, and the target entity category corresponding to each character in the date text is obtained, and according to the target entity corresponding to each character in the date text
  • the category and the pending date determine the target date corresponding to the date text, the target entity category is used to characterize whether the character is a specified character related to a date number, and if the character is a specified character related to a date number , the character corresponds to the position information of the number in the date.
  • the target date in the text to be recognized can be accurately recognized, so that the recognition rate of the date in the text to be recognized can be effectively guaranteed, and the reliability of the date recognition result can also be effectively improved.
  • Fig. 1 is a flowchart of a date recognition method shown in an exemplary embodiment of the present disclosure
  • Fig. 2 is a structural block diagram of a preset date recognition model shown in an exemplary embodiment of the present disclosure
  • Fig. 3 is a flowchart of a date recognition method shown in the present disclosure according to the embodiment shown in Fig. 1;
  • Fig. 4 is a flowchart of a training method for a preset date recognition model shown in an exemplary embodiment of the present disclosure
  • Fig. 5 is a block diagram of a date recognition device shown in an exemplary embodiment of the present disclosure.
  • Fig. 6 is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure.
  • the term “comprise” and its variations are open-ended, ie “including but not limited to”.
  • the term “based on” is “based at least in part on”.
  • the term “one embodiment” means “at least one embodiment”; the term “another embodiment” means “at least one further embodiment”; the term “some embodiments” means “at least some embodiments.” Relevant definitions of other terms will be given in the description below.
  • the present disclosure provides a date recognition method, device, readable medium and electronic equipment.
  • the method recognizes the pending date corresponding to the date text through the preset date recognition model, and obtains each date in the date text.
  • the target entity category corresponding to the character determine the target date corresponding to the date text according to the target entity category corresponding to each character in the date text and the pending date, and the target entity category is used to indicate whether the character is specified related to the date number character, and when the character is a specified character related to the date number, the position information of the corresponding number in the date, which can effectively identify the date in various date recognition scenarios, and can also effectively ensure the accuracy of the date recognition result Therefore, not only the date recognition rate can be effectively guaranteed, but also the reliability of the date recognition result can be effectively improved.
  • Fig. 1 is a flow chart of a date recognition method shown in an exemplary embodiment of the present disclosure; as shown in Fig. 1, the method may include the following steps:
  • Step 101 acquire text to be recognized, and the text to be recognized includes date text.
  • the text to be recognized may be the target text obtained after performing OCR character recognition on the image, for example, it may be the character text obtained after performing OCR recognition on a scanned copy of a paper document, or it may be a text in a WORD file.
  • the paragraph text can also be the text corresponding to the electronic bill.
  • Step 102 inputting the text to be recognized into a preset date recognition model to obtain a target date output by the preset date recognition model.
  • the preset date recognition model is used to identify the pending date corresponding to the date text, obtain the target entity category corresponding to each character in the date text, and according to the target entity category corresponding to each character in the date text and the pending date
  • the date determines the target date corresponding to the date text
  • the target entity category is used to characterize whether the character is a specified character related to a date number, and when the character is a specified character related to a date number, the corresponding number of the character is in the date location information.
  • the target entity category can be "Other”, “Year-From”, “Year-Middle”, “Year-End”, “Month-From”, “Month-End”, “Month-Single”, “Day -From", “Day-End” or “Day-Single”, the “Other” indicates that the character is a specified character that is not related to the date number, the “Year-From” indicates the first digit in the year data, the “Year-End” represents the last digit in the year data, and “Year-Middle” represents other digits in the year data except the first digit and the last digit of the year.
  • the target entity category corresponding to the first digit "2" (that is, the first number from left to right in the year data) is "year-start”, "8” (that is, the first number from left to right in the year data The last number of ) corresponds to the target entity category "year-end”, and the target entity category corresponding to "0" and "1" is "year-mid”.
  • the “month-start” represents the first digit in the month data when the month data has two digits
  • the “month-end” represents the second digit in the month data when the month data has two digits Number
  • the “month-single” means that the month data is a single digit, for example, when the month data is "12", the target entity category corresponding to the "1” is “month-start”, and the target entity category corresponding to the "2”
  • the entity category is "month-end”, when the month data is "04", the target entity category corresponding to "0” is “month-start”, and the target entity category corresponding to "4" is "month-end", When the month data is "3", the target entity category corresponding to this "3" is "month-separate”.
  • the “day-start” means that when the day data in the date is two digits, the first digit in the day data, and the “day-end” means that when the day data in the date is two digits, the day
  • the second digit in the data, the “day-individual” indicates that the daily data is a single digit, for example, when the daily data is "26", the target entity category corresponding to the "2" is “day-start”, the The target entity category corresponding to "6” is “Day-End”, when the daily data is "05”, the target entity category corresponding to "0” is “Day-Start”, and the target entity category corresponding to "5" is “Day-Stop”, when the day data is "7", the target entity type corresponding to "7” is “Day-Single”.
  • a possible implementation manner is to determine the designated entity type corresponding to the number according to the position of each number in the pending date. For example, when the format of the undetermined date is "undetermined year-pending month-pending day", if the number is the data before the first "-”, then it is determined that the number belongs to the number in the undetermined year, when the number is In the case of the first digit in the undetermined year number, determine that the designated entity category corresponding to the number is "year-starting", and in the case that the number is the last digit in the undetermined year number, determine the number The corresponding designated entity category is "Year-End".
  • the designated entity category corresponding to this number is "Year-Middle"; if the number is between two "-”, it is determined that the number belongs to the number in the undetermined month, and it is determined that the undetermined month only includes one digit.
  • the designated entity category for determining the number corresponding to the pending month is "month-single", and in the case of determining that the pending month includes two digits, if the number is the first digit in the pending month, then determine The designated entity category corresponding to the number is "month-start", if the number is the second digit in the undetermined month, then determine that the designated entity category corresponding to the number is "month-end”; If the data after a "-" is used, it is determined that the number belongs to the number corresponding to the undetermined day.
  • the designated entity category of the number corresponding to the undetermined day is determined to be "day-single" , in the case of determining that the undetermined month includes two digits, if the number is the first digit of the undetermined day, it is determined that the designated entity category corresponding to the number is "day-starting", if the number is the first digit of the undetermined day If the second digit of the day is used, it is determined that the designated entity type corresponding to the number is "day-end".
  • Another possible implementation is: input the pending date into the preset named entity type recognition model, so that the preset named entity recognition model outputs the designated named entity corresponding to each number in the pending date, and the designated named entity Can be "Other”, “Year-From”, “Year-Middle”, “Year-End”, “Month-From”, “Month-End”, “Month-Single”, “Day-From", “Day- One of "stop” and “day-single”, the preset named entity recognition model can be a neural network model, or other machine learning models.
  • the text to be recognized can be the text obtained by OCR character recognition, it can also be the text in other documents, and it can also be the text corresponding to the bill, so it can ensure effective recognition of dates in various date recognition scenarios. , can also effectively guarantee the accuracy of the date recognition result, thereby not only effectively ensuring the date recognition rate, but also effectively improving the reliability of the date recognition result.
  • FIG. 2 is a structural block diagram of a preset date recognition model shown in an exemplary embodiment of the present disclosure.
  • the preset date recognition model includes an encoder 201 and a year classification coupled with the encoder 201 Module 202, month classification module 203, day classification module 204 and character entity classification detection module 205;
  • the year classification module 202 is used to identify the undetermined year in the date text, the year classification module includes a plurality of classifiers, and different classifiers are used to identify numbers in different positions in the undetermined year;
  • the month classification module 203 is used to identify the undetermined month in the date text
  • the day classification module 204 is used to identify the undecided day in the date text
  • the character entity category detection module 205 is configured to acquire the target entity category corresponding to each character in the date text.
  • the encoder 201 can be a BERT (Bidirectional Encoder Representation from Transformers, two-way encoder representation) encoder, and the preset date recognition model can also include a text preprocessing module 206, the output of the text preprocessing module 206 is connected to the The input end of the encoder 201 is coupled to perform word segmentation processing on the text to be recognized, so as to obtain an initial feature sequence applicable to the data input requirements of the encoder 201, wherein the initial feature sequence may include [CLS] and [SEP ], the [CLS] is used to characterize the beginning of embedding, and [SEP] is used between sentences to separate two sentences.
  • the initial feature sequence may include [CLS] and [SEP ]
  • the [CLS] is used to characterize the beginning of embedding
  • [SEP] is used between sentences to separate two sentences.
  • the encoder 201 can input the encoding vector corresponding to the [CLS] symbol to the year classification module 202 as the target text feature corresponding to the text to be recognized, the month classification module 203, the day classification module 204 and the character entity category detection Module 205. In this way, since the coding vector corresponding to the [CLS] symbol contains relatively complete semantic information in the text to be recognized, using the coding vector as the basis data for classification prediction can effectively improve the accuracy of the classification result.
  • the year classification module 202 includes a first classifier 2021, a second classifier 2022, a third classifier 2023 and a fourth classifier 2024
  • the month classification module 203 includes a fifth classifier
  • the day classifier Module 204 includes a sixth classifier
  • the character entity category detection module 205 includes a seventh classifier.
  • FIG. 3 is a flow chart of a date recognition method shown in the present disclosure according to the embodiment shown in FIG. 1 , as shown in FIG. 3 , The preset date recognition model determines the target date in the text to be recognized through the following steps:
  • Step 1021 acquire the target text features corresponding to the text to be recognized through the encoder.
  • the target text feature includes the context semantic information of the date text.
  • the initial feature sequence input to the encoder may be a feature sequence including [CLS] and [SEP], and the target text feature may be an encoding vector corresponding to the symbol [CLS] in the initial feature sequence output by the encoder.
  • Step 1022 using the first classifier to identify the first target number in the year data corresponding to the date text according to the target text feature, and using the second classifier to identify the first target number in the year data corresponding to the date text according to the target text feature
  • Two target numbers the third target number in the year data corresponding to the date text is identified by the third classifier according to the target text feature
  • the third target number in the year data corresponding to the date text is identified by the fourth classifier according to the target text feature
  • the first classifier can output 1*10-dimensional feature data, which are used to represent the probability that the first target number in the year data is each number from 0 to 9;
  • the second classifier can output 1* The 10-dimensional feature data are used to represent the probability that the second target number in the year data is each number from 0 to 9;
  • the third classifier can output 1*10-dimensional feature data, which are respectively used to represent the year The third target number in the data is the probability of each number from 0 to 9;
  • the fourth classifier can output 1*10-dimensional feature data, which are respectively used to represent the fourth target number in the year data from 0 to 9 The probability of each number in 9.
  • Step 1023 according to the first target number, the second target number, the third target number, and the fourth target number, determine the pending year corresponding to the date text.
  • the first classifier recognizes that the first target number is "2”
  • the second classifier recognizes that the second target number is "0”
  • the third classifier recognizes that the third digit
  • the target number is "1”
  • the fourth classifier recognizes that the fourth target number is "8”
  • the pending year is "2018”.
  • Step 1024 using the fifth classifier to identify the undetermined month corresponding to the month data in the date text according to the characteristics of the target text.
  • the fifth classifier can output 1*13-dimensional feature data, which are respectively used to represent the probability that the month data is each number in 0 to 12 (13 numbers).
  • Step 1025 using the sixth classifier to identify the pending day corresponding to the day data in the date text according to the target text feature.
  • the fifth classifier can output 1*32-dimensional feature data, which are respectively used to represent the probability of each number in the daily data being 0 to 31 (32 numbers).
  • Step 1026 obtain the probability that each character in the date text belongs to each preset entity category through the seventh classifier.
  • the default entity category can include “other”, “year-start”, “year-middle”, “year-end”, “month-start”, “month-end”, “month-separate”, “day -From", “Day-End” and “Day-Separate”,
  • the data output by the seventh classifier can be L*10 dimensional data, where L is the preset length of the input data of the encoder.
  • the seventh classifier is used to obtain the first probability that each character in the text to be recognized belongs to "year-starting" (that is, the first digit in the undetermined year) according to the target text feature, and belongs to "year- Middle" (for example, when the year is four digits, it belongs to the second digit in the undetermined year or belongs to the third digit in the undetermined year) the second probability belongs to "year-end” (for example, when the year is four digits time, which is the fourth digit in the undetermined year), the fourth probability belongs to "month-single", the fifth probability belongs to "month-start”, and the sixth probability belongs to "month-end", It belongs to the seventh probability of "day-alone", the eighth probability of "day-start”, the ninth probability of "day-end", and the tenth probability of "other".
  • year-starting that is, the first digit in the undetermined year
  • year- Middle for example, when the year is four digits, it belongs to the second digit in the undetermined year or belongs
  • Step 1027 Determine the target entity category corresponding to the character according to the probability that each character in the date text belongs to each preset entity category.
  • the first to tenth probabilities corresponding to each character may be acquired, and the preset entity category corresponding to the maximum value of the first to tenth probabilities is used as the target entity category.
  • Step 1028 obtain the designated entity category corresponding to each number in the pending date.
  • a possible implementation manner is: according to the position of each number in the pending date, determine the specified entity type corresponding to the number. For example, when the format of the undetermined date is "undetermined year-pending month-pending day", if the number is the data before the first "-”, then it is determined that the number belongs to the number in the undetermined year, when the number is In the case of the first digit in the undetermined year number, determine that the designated entity category corresponding to the number is "year-starting", and in the case that the number is the last digit in the undetermined year number, determine the number The corresponding designated entity category is "Year-End".
  • the designated entity category corresponding to this number is "Year-Middle"; if the number is between two "-”, it is determined that the number belongs to the number in the undetermined month, and it is determined that the undetermined month only includes one digit.
  • the designated entity category for determining the number corresponding to the pending month is "month-single", and in the case of determining that the pending month includes two digits, if the number is the first digit in the pending month, then determine The designated entity category corresponding to the number is "month-start", if the number is the second digit in the pending month, then determine that the designated entity category corresponding to the number is "month-end”; If the data after a "-" is used, it is determined that the number belongs to the number corresponding to the undetermined day.
  • the designated entity category of the number corresponding to the undetermined day is determined to be "day-single" , in the case of determining that the undetermined month includes two digits, if the number is the first digit of the undetermined day, it is determined that the designated entity category corresponding to the number is "day-starting", if the number is the first digit of the undetermined day If the second digit of the day is used, it is determined that the designated entity type corresponding to the number is "day-end".
  • Another possible implementation is: input the pending date into the preset named entity type recognition model, so that the preset named entity recognition model outputs the designated named entity corresponding to each number in the pending date, and the designated named entity Can be "Other”, “Year-From”, “Year-Middle”, “Year-End”, “Month-From”, “Month-End”, “Month-Single”, “Day-From", “Day- One of "stop” and “day-single”, the preset named entity recognition model can be a neural network model, or other machine learning models.
  • Step 1029 if the designated entity category corresponding to each number in the pending date is consistent with the target entity category of the character corresponding to the number in the date text, determine the pending date as the target date.
  • the pending date obtained is "2018-7-4"
  • the designated entity category corresponding to the "2" is “year-start”
  • the designated entity category corresponding to the "0" is "year-mid "
  • the "1” corresponds to the specified entity category as "Year-Middle”
  • the "8” corresponds to the specified entity category as “Year-End”
  • the "-" corresponds to the specified entity category as "Other”
  • the designated entity category corresponding to "7” is “month-separate”
  • the designated entity category corresponding to "4" is “day-separate”.
  • 2018- The target entity category corresponding to each character in 7-4.
  • the undetermined date is determined as the target date, and the specified entity category corresponding to the existing character
  • preset prompt information is output, and the preset prompt information is used to characterize the obtained pending date with low accuracy.
  • the above technical solution can effectively and accurately identify the target date in the text to be recognized by determining the target date corresponding to the date text according to the target entity category corresponding to each character in the date text and the pending date, thereby effectively Ensuring the recognition rate of the date in the text to be recognized can also effectively improve the reliability of the date recognition result.
  • Fig. 4 is a flowchart of a training method for a preset date recognition model shown in an exemplary embodiment of the present disclosure; as shown in Fig. 4, the preset date recognition model can be obtained by training in the following manner:
  • Step 401 generate a plurality of date text samples from the target corpus text in the preset corpus.
  • the date text sample includes a date text label and a named entity label for each character in the date text sample.
  • the target corpus text can be obtained from the preset corpus; by performing a date update operation on the target corpus text, a plurality of undetermined text samples corresponding to the target corpus text are obtained, the date update operation includes a date addition action, And/or, a date replacement action; generating the date text sample according to the pending text sample.
  • the date addition action includes a year addition action, a month addition action, and a day addition action
  • the date replacement action includes a year replacement action, a month replacement action, and a day replacement action.
  • the date update operation is performed on the text to obtain multiple undetermined text samples corresponding to the target corpus text, which may include:
  • the year addition action is performed on the target corpus text, and the added year data is spliced with the target corpus text to obtain a plurality of first text samples;
  • the year replacement action is performed on the target corpus text to obtain a plurality of first text samples;
  • the first text samples include month data and day data , perform the month replacement action on the target corpus text, or perform the day replacement action on the target corpus text to obtain the undetermined text sample;
  • the corpus text performs the adding action of the month, and in the case of determining that the first text sample does not include the daily data, performs the adding action of the day to the target corpus text, and compares the added month data and day data with the target corpus text splicing to obtain the undetermined text sample.
  • this step also includes the step of automatically generating the date text label and the named entity label of each character in the date text sample, specifically as follows:
  • the target location information may include the number before the first "-", or the number It is the number of digits between two "-”, or the number of digits after the second "-".
  • the named entity label corresponding to the number is "year-start"
  • the named entity label corresponding to the number is "year-start”
  • the named entity label corresponding to the number is "year-end”
  • it is determined that the number belongs to the year the middle digit of that is, the digit that belongs to the digit preceding that first "-” but is neither the first digit preceding that first "-” nor the last digit preceding that first "-” number
  • determine that the named entity label corresponding to the number is "year-mid”
  • the named entity tag for determining the number corresponding to the month is "month-single”
  • the month includes two digits
  • the named entity label of the number corresponding to the day is determined to be "day -Single", in the case of determining that the data of the day includes two digits, if the number is the first digit after the second "-", then determine that the named entity tag corresponding to the number is "day-from” , if the number is the second digit after the second "-", then determine that the named entity label corresponding to the number is "day-end".
  • the named entity label of characters other than the corresponding character of the day number is determined to be "other".
  • Step 402 Using the plurality of date text samples as training data, perform model training on the preset initial model to obtain the preset date recognition model, wherein the preset initial model includes an initial year classification module, an initial month classification module, The initial day classification module and the initial character entity category detection module.
  • the preset initial model may include an initial BERT encoder, the initial year classification module, the initial month classification module, the initial day classification module and the initial character entity category detection module are all coupled with the initial BERT encoder, during the model training process , model training can be performed with cross-entropy as the loss function.
  • the above technical solution because it can automatically synthesize multiple date text samples as training data, can effectively avoid the problems of difficult training data acquisition, low labeling efficiency, and time-consuming and laborious labeling process in related technologies.
  • the initial year classification module, the initial month classification module, the initial day classification module, and the initial character entity category detection module can effectively improve the convergence speed of the preset date recognition model, improve the efficiency of model training, and effectively ensure the training results.
  • the generalization ability of the preset date recognition model, and the accuracy of the date recognition results can effectively improve the convergence speed of the preset date recognition model, improve the efficiency of model training, and effectively ensure the training results.
  • Fig. 5 is a block diagram of a date identification device shown in an exemplary embodiment of the present disclosure. As shown in Fig. 5, the device may include:
  • the first acquiring module 501 is configured to acquire text to be recognized, where the text to be recognized includes date text;
  • the second obtaining module 502 is configured to input the text to be recognized into a preset date recognition model, so as to obtain a target date output by the preset date recognition model;
  • the preset date recognition model is used to identify the pending date corresponding to the date text, obtain the target entity category corresponding to each character in the date text, and according to the target entity category corresponding to each character in the date text and the pending date
  • the date determines the target date corresponding to the date text
  • the target entity category is used to characterize whether the character is a specified character related to a date number, and when the character is a specified character related to a date number, the corresponding number of the character is in the date location information.
  • the above technical solution can effectively and accurately identify the target date in the text to be recognized by determining the target date corresponding to the date text according to the target entity category corresponding to each character in the date text and the pending date, thereby effectively Ensuring the recognition rate of the date in the text to be recognized can also effectively improve the reliability of the date recognition result.
  • the preset date recognition model is used to: obtain the designated entity category corresponding to each number in the pending date; If the target entity category of the corresponding characters in is consistent, the undetermined date is determined as the target date.
  • the pending date includes a pending year, a pending month, and a pending day
  • the preset date recognition model includes an encoder, and a year classification module coupled with the encoder, a month classification module, a day classification module and characters Entity category detection module;
  • the year classification module is used to identify the undetermined year in the date text, the year classification module includes a plurality of classifiers, and different classifiers are used to identify numbers in different positions in the undetermined year;
  • the month classification module is used to identify the undetermined month in the date text
  • the day classification module is used to identify the undecided day in the date text
  • the character entity category detection module is used to obtain the target entity category corresponding to each character in the date text.
  • the year classification module includes a first classifier, a second classifier, a third classifier and a fourth classifier
  • the month classification module includes a fifth classifier
  • the day classification module includes a sixth classifier
  • the character entity category detection module includes a seventh classifier
  • the preset date recognition model is used for:
  • the target text feature corresponding to the text to be recognized is obtained by the encoder, and the target text feature includes the context semantic information of the date text;
  • the second target number, the third target number, and the fourth target number determine the pending year corresponding to the date text
  • the target entity category corresponding to the character is determined according to the probability that each character in the date text belongs to each preset entity category.
  • the device also includes a model training module 503, the model training module 503 is used for:
  • the date text samples include a date text label and a named entity label for each character in the date text samples;
  • model training is performed on the preset initial model to obtain the preset date recognition model, wherein the preset initial model includes an initial year classification module, an initial month classification module, and an initial day classification module. module and an initial character entity category detection module.
  • the model training module 503 is configured to: obtain the target corpus text from the preset corpus; obtain a plurality of undetermined text samples corresponding to the target corpus text by performing a date update operation on the target corpus text , the date updating operation includes a date adding action, and/or, a date replacing action; the date text sample is generated according to the pending text sample.
  • the model training module 503 is configured to: acquire preset disturbing text; add the preset disturbing text to the pending text sample; perform simulated character sticking on the pending text sample after adding the preset disturbing text operation to get a sample of the date text.
  • the model training module 503 is also used to: in the case of adding a date to the target corpus text, use the added first date as the date text label; and/or, In the case of performing a date replacement action on the corpus text, the second date after replacement is used as the date text label.
  • the model training module 503 is also used to: obtain the target position information of each number in the date text label; generate the date text sample according to the target position information of each number in the date text label Named entity category labels for each character.
  • the above technical solution because it can automatically synthesize multiple date text samples as training data, can effectively avoid the problems of difficult training data acquisition and time-consuming labeling process in related technologies.
  • the initial year classification module for date recognition because it includes the initial year classification module for date recognition, The initial month classification module, the initial day classification module, and the initial character entity category detection module can effectively improve the convergence speed of the preset date recognition model, improve the model training efficiency, and effectively ensure the preset date recognition obtained by training.
  • the generalization ability of the model, and the accuracy of the date recognition results because it can automatically synthesize multiple date text samples as training data, can effectively avoid the problems of difficult training data acquisition and time-consuming labeling process in related technologies.
  • the initial year classification module for date recognition because it includes the initial year classification module for date recognition, The initial month classification module, the initial day classification module, and the initial character entity category detection module can effectively improve the convergence speed of the preset date recognition model, improve the model training efficiency, and effectively ensure the preset date recognition obtained by training.
  • FIG. 6 it shows a schematic structural diagram of an electronic device 600 suitable for implementing an embodiment of the present disclosure.
  • the terminal equipment in the embodiment of the present disclosure may include but not limited to such as mobile phone, notebook computer, digital broadcast receiver, PDA (personal digital assistant), PAD (tablet computer), PMP (portable multimedia player), vehicle terminal (such as mobile terminals such as car navigation terminals) and fixed terminals such as digital TVs, desktop computers and the like.
  • the electronic device shown in FIG. 6 is only an example, and should not limit the functions and application scope of the embodiments of the present disclosure.
  • an electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which may be randomly accessed according to a program stored in a read-only memory (ROM) 602 or loaded from a storage device 608.
  • a processing device such as a central processing unit, a graphics processing unit, etc.
  • RAM memory
  • various programs and data necessary for the operation of the electronic device 600 are also stored.
  • the processing device 601, ROM 602, and RAM 603 are connected to each other through a bus 604.
  • An input/output (I/O) interface 605 is also connected to the bus 604 .
  • the following devices can be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, a liquid crystal display (LCD), speaker, vibration an output device 607 such as a computer; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609.
  • the communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While FIG. 6 shows electronic device 600 having various means, it is to be understood that implementing or having all of the means shown is not a requirement. More or fewer means may alternatively be implemented or provided.
  • embodiments of the present disclosure include a computer program product, which includes a computer program carried on a non-transitory computer readable medium, where the computer program includes program code for executing the method shown in the flowchart.
  • the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602.
  • the processing device 601 When the computer program is executed by the processing device 601, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are performed.
  • the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two.
  • a computer readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
  • a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave carrying computer-readable program code therein. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • a computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can transmit, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device .
  • Program code embodied on a computer readable medium may be transmitted by any appropriate medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
  • any currently known or future network protocol such as HTTP (HyperText Transfer Protocol, Hypertext Transfer Protocol) can be used to communicate, and can communicate with digital data in any form or medium (for example, communication network) interconnection.
  • Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), internetworks (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network of.
  • the above-mentioned computer-readable medium may be included in the above-mentioned electronic device, or may exist independently without being incorporated into the electronic device.
  • the above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device: acquires the text to be recognized, and the text to be recognized includes date text; Recognition text is input into the preset date recognition model to obtain the target date output by the preset date recognition model; wherein, the preset date recognition model is used to identify the pending date corresponding to the date text and obtain the date text.
  • the target entity category corresponding to each character in the date text determine the target date corresponding to the date text according to the target entity category corresponding to each character in the date text and the pending date, and the target entity category is used to characterize the character Whether it is a specified character related to the date number, and when the character is a specified character related to the date number, the position information of the corresponding number in the date.
  • Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, or combinations thereof, including but not limited to object-oriented programming languages—such as Java, Smalltalk, C++, and Includes conventional procedural programming languages - such as "C" or similar programming languages.
  • the program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server.
  • the remote computer may be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (for example, using an Internet service provider to connected via the Internet).
  • LAN local area network
  • WAN wide area network
  • Internet service provider for example, using an Internet service provider to connected via the Internet.
  • each block in a flowchart or block diagram may represent a module, program segment, or portion of code that contains one or more logical functions for implementing specified executable instructions.
  • the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved.
  • each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations can be implemented by a dedicated hardware-based system that performs the specified functions or operations , or may be implemented by a combination of dedicated hardware and computer instructions.
  • the modules involved in the embodiments described in the present disclosure may be implemented by software or by hardware. Wherein, the name of the module does not constitute a limitation of the module itself under certain circumstances, for example, the first acquisition module may also be described as a "module for acquiring text to be recognized, the text to be recognized includes date text".
  • FPGAs Field Programmable Gate Arrays
  • ASICs Application Specific Integrated Circuits
  • ASSPs Application Specific Standard Products
  • SOCs System on Chips
  • CPLD Complex Programmable Logical device
  • a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device.
  • a machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium.
  • a machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing.
  • machine-readable storage media would include one or more wire-based electrical connections, portable computer discs, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, compact disk read only memory (CD-ROM), optical storage, magnetic storage, or any suitable combination of the foregoing.
  • RAM random access memory
  • ROM read only memory
  • EPROM or flash memory erasable programmable read only memory
  • CD-ROM compact disk read only memory
  • magnetic storage or any suitable combination of the foregoing.
  • Example 1 provides a date recognition method, the method comprising:
  • the text to be recognized includes date text
  • the text to be recognized is input into a preset date recognition model to obtain the target date output by the preset date recognition model;
  • the preset date recognition model is used to identify the pending date corresponding to the date text, obtain the target entity category corresponding to each character in the date text, and according to the target entity category corresponding to each character in the date text
  • the category and the pending date determine the target date corresponding to the date text
  • the target entity category is used to characterize whether the character is a specified character related to a date number, and if the character is a specified character related to a date number , the characters correspond to the position information of the numbers in the date.
  • Example 2 provides the method of Example 1, wherein the target date corresponding to the date text is determined according to the target entity category corresponding to each character in the date text and the pending date ,include:
  • Example 3 provides the method of Example 1, the undetermined date includes an undetermined year, an undetermined month, and an undetermined day, and the preset date recognition model includes an encoder, and the Encoder-coupled year classification module, month classification module, day classification module and character entity category detection module;
  • the year classification module is used to identify the pending year in the date text, the year classification module includes a plurality of classifiers, and different classifiers are used to identify numbers in different positions in the pending year;
  • the month classification module is used to identify the undetermined month in the date text
  • the day classification module is used to identify undecided days in the date text
  • the character entity category detection module is configured to acquire the target entity category corresponding to each character in the date text.
  • Example 4 provides the method of Example 3, the year classification module includes a first classifier, a second classifier, a third classifier and a fourth classifier, and the month classifier
  • the module includes a fifth classifier
  • the day classification module includes a sixth classifier
  • the character entity category detection module includes a seventh classifier
  • the preset date recognition model is used for:
  • the target text feature including the context semantic information of the date text
  • the first target number in the year data corresponding to the date text is identified by the first classifier according to the target text feature
  • the year data corresponding to the date text is identified by the second classifier according to the target text feature
  • the second target number in the third classifier identifies the third target number in the corresponding year data of the date text according to the target text feature through the third classifier, and uses the fourth classifier according to the target text feature Identify the fourth target number in the year data corresponding to the date text;
  • the second target number, the third target number, and the fourth target number determine the pending year corresponding to the date text
  • the target entity category corresponding to the character is determined according to the probability that each character in the date text belongs to each preset entity category.
  • Example 5 provides the method of Example 1, and the preset date recognition model is obtained by training in the following manner:
  • the date text samples include a date text label and a named entity label for each character in the date text samples;
  • the preset initial model includes an initial year classification module, an initial month classification module, The initial day classification module and the initial character entity category detection module.
  • Example 6 provides the method of Example 5, said generating a plurality of date text samples according to the target corpus text in the preset corpus, including:
  • a date update operation By performing a date update operation on the target corpus text, a plurality of undetermined text samples corresponding to the target corpus text are obtained, and the date update operation includes a date addition action, and/or a date replacement action;
  • the date text sample is generated according to the pending text sample.
  • Example 7 provides the method of Example 6, wherein generating the date text sample according to the pending text sample includes:
  • Example 8 provides the method of Example 6, said generating a plurality of date text samples according to the target corpus text in the preset corpus, further comprising:
  • the replaced second date is used as the date text label.
  • Example 9 provides the method of Example 6, said generating a plurality of date text samples according to the target corpus text in the preset corpus, further comprising:
  • a named entity category label for each character in the date text sample is generated according to the target position information of each number in the date text label.
  • Example 10 provides a date identification device, the device comprising:
  • the first obtaining module is configured to obtain the text to be recognized, and the text to be recognized includes date text;
  • the second obtaining module is configured to input the text to be recognized into a preset date recognition model to obtain a target date output by the preset date recognition model;
  • the preset date recognition model is used to identify the pending date corresponding to the date text, obtain the target entity category corresponding to each character in the date text, and according to the target entity category corresponding to each character in the date text
  • the category and the pending date determine the target date corresponding to the date text
  • the target entity category is used to characterize whether the character is a specified character related to a date number, and if the character is a specified character related to a date number , the characters correspond to the position information of the numbers in the date.
  • Example 11 provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processing device, the method described in any one of Examples 1-9 above is implemented. step.
  • Example 12 provides an electronic device, comprising:
  • a processing device configured to execute the computer program in the storage device, so as to implement the steps of the method described in any one of Examples 1-9 above.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Machine Translation (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种日期识别方法、装置、可读介质及电子设备,方法通过预设日期识别模型识别日期文本对应的待定日期,获取日期文本中每个字符对应的目标实体类别,根据日期文本中每个字符对应的目标实体类别和待定日期确定日期文本对应的目标日期,目标实体类别用于表征字符是否为与日期数字相关的指定字符,以及在字符为与日期数字相关的指定字符时,字符对应数字在日期中的位置信息。

Description

日期识别方法、装置、可读介质及电子设备
本公开要求于2022年01月29日提交的,申请名称为“日期识别方法、装置、可读介质及电子设备”的、中国专利申请号为“202210113138.7”的优先权,该中国专利申请的全部内容通过引用结合在本公开中。
技术领域
本公开涉及计算机技术领域,具体地,涉及一种日期识别方法、装置、可读介质及电子设备。
背景技术
随着科技的发展,人类对计算机视觉技术的应用逐渐广泛,OCR(Optical Character Recognition,光学字符识别)字符识别是计算机视觉技术中的一个重要分支,在完成OCR字符识别后,经常伴随着对识别文本中关键信息的提取,例如,对识别文本中日期信息的提取。
目前的日期识别方法通常仅能针对简单的日期文本识别场景(例如,发票,火车票,证件等日期识别场景),做到有效识别,而针对相对复杂的日期文本识别场景(例如针对OCR字符识别结果中日期文本的识别),则存在识别率低,识别结果准确性较差的问题。
发明内容
提供该发明内容部分以便以简要的形式介绍构思,这些构思将在后面的具体实施方式部分被详细描述。该发明内容部分并不旨在标识要求保护的技术方案的关键特征或必要特征,也不旨在用于限制所要求的保护的技术方案的范围。
本公开提供一种日期识别方法、装置、可读介质及电子设备。
第一方面,本公开提供一种日期识别方法,所述方法包括:
获取待识别文本,所述待识别文本包括日期文本;
将所述待识别文本输入预设日期识别模型,以获取所述预设日期识别模型输出的目标日期;
其中,所述预设日期识别模型用于,识别所述日期文本对应的待定日期,获取所述日期文本中每个字符对应的目标实体类别,根据所述日期文本中每个字符对应的目标实体类别和所述待定日期确定所述日期文本对应的目标日期,所述目标实体类别用于表征所述字符是否为与日期数字相关的指定字符,以及在所述字符为与日期数字相关的指定字符时,所述字符对应数字在日期中的位置信息。
第二方面本公开提供一种日期识别装置,所述装置包括:
第一获取模块,被配置为获取待识别文本,所述待识别文本包括日期文本;
第二获取模块,被配置为将所述待识别文本输入预设日期识别模型,以获取所述预设日期识别模型输出的目标日期;
其中,所述预设日期识别模型用于,识别所述日期文本对应的待定日期,获取所述日期文本中每个字符对应的目标实体类别,根据所述日期文本中每个字符对应的目标实体类别和所述待定日期确定所述日期文本对应的目标日期,所述目标实体类别用于表征所述字符是否 为与日期数字相关的指定字符,以及在所述字符为与日期数字相关的指定字符时,所述字符对应数字在日期中的位置信息。
第三方面,本公开一种计算机可读介质,其上存储有计算机程序,该程序被处理装置执行时实现以上第一方面所述方法的步骤。
第四方面,本公开提供一种电子设备,包括:
存储装置,其上存储有计算机程序;
处理装置,用于执行所述存储装置中的所述计算机程序,以实现以上第一方面所述方法的步骤。
上述技术方案,通过所述预设日期识别模型识别所述日期文本对应的待定日期,获取所述日期文本中每个字符对应的目标实体类别,根据所述日期文本中每个字符对应的目标实体类别和所述待定日期确定所述日期文本对应的目标日期,所述目标实体类别用于表征所述字符是否为与日期数字相关的指定字符,以及在所述字符为与日期数字相关的指定字符时,所述字符对应数字在日期中的位置信息,这样,通过根据所述日期文本中每个字符对应的目标实体类别和所述待定日期确定所述日期文本对应的目标日期,能够有效且准确的识别到待识别文本中的目标日期,从而能够有效保证针对待识别文本中日期的识别率,也能够有效提升日期识别结果的可靠性。
本公开的其他特征和优点将在随后的具体实施方式部分予以详细说明。
附图说明
结合附图并参考以下具体实施方式,本公开各实施例的上述和其他特征、优点及方面将变得更加明显。贯穿附图中,相同或相似的附图标记表示相同或相似的元素。应当理解附图是示意性的,原件和元素不一定按照比例绘制。在附图中:
图1是本公开一示例性实施例示出的一种日期识别方法的流程图;
图2是本公开一示例性实施例示出的一种预设日期识别模型的结构框图;
图3是本公开根据图1所示实施例示出的一种日期识别方法的流程图;
图4是本公开一示例性实施例示出的一种预设日期识别模型的训练方法流程图;
图5是本公开一示例性实施例示出的一种日期识别装置的框图;
图6是本公开一示例性实施例示出的一种电子设备的框图。
具体实施方式
下面将参照附图更详细地描述本公开的实施例。虽然附图中显示了本公开的某些实施例,然而应当理解的是,本公开可以通过各种形式来实现,而且不应该被解释为限于这里阐述的实施例,相反提供这些实施例是为了更加透彻和完整地理解本公开。应当理解的是,本公开的附图及实施例仅用于示例性作用,并非用于限制本公开的保护范围。
应当理解,本公开的方法实施方式中记载的各个步骤可以按照不同的顺序执行,和/或并行执行。此外,方法实施方式可以包括附加的步骤和/或省略执行示出的步骤。本公开的范围在此方面不受限制。
本文使用的术语“包括”及其变形是开放性包括,即“包括但不限于”。术语“基于”是“至少 部分地基于”。术语“一个实施例”表示“至少一个实施例”;术语“另一实施例”表示“至少一个另外的实施例”;术语“一些实施例”表示“至少一些实施例”。其他术语的相关定义将在下文描述中给出。
需要注意,本公开中提及的“第一”、“第二”等概念仅用于对不同的装置、模块或单元进行区分,并非用于限定这些装置、模块或单元所执行的功能的顺序或者相互依存关系。
需要注意,本公开中提及的“一个”、“多个”的修饰是示意性而非限制性的,本领域技术人员应当理解,除非在上下文另有明确指出,否则应该理解为“一个或多个”。
本公开实施方式中的多个装置之间所交互的消息或者信息的名称仅用于说明性的目的,而并不是用于对这些消息或信息的范围进行限制。
在详细介绍本公开的具体实施方式之前,首先对本公开的应用场景进行以下说明,本公开可以应用于对图像、文档(PDF文档,Word文档)、或票据(例如,发票、火车票)中日期的识别过程中,目前的日期识别方法大多是基于特定识别场景训练专用的日期识别模型,例如,相关技术中会针对火车票中日期的识别或者发票中日期的识别训练专用模型,由于这些专用模型通常是针对某个单一的场景设计,通常模型的泛化能力较差,因此会存在无法通用,无法对其他日期识别场景中的日期进行有效识别,不能保证日期识别结果的准确性,也不利于提升日期识别率。
为了解决以上技术问题,本公开提供了一种日期识别方法、装置、可读介质及电子设备,该方法通过该预设日期识别模型识别该日期文本对应的待定日期,获取该日期文本中每个字符对应的目标实体类别,根据该日期文本中每个字符对应的目标实体类别和该待定日期确定该日期文本对应的目标日期,该目标实体类别用于表征该字符是否为与日期数字相关的指定字符,以及在该字符为与日期数字相关的指定字符时,该字符对应数字在日期中的位置信息,能够针对多种日期识别场景中的日期进行有效识别,也能够有效保证日期识别结果的准确性,从而不仅能够有效保证日期识别率,也能够有效提升日期识别结果的可靠性。
下面结合具体实施例对本公开的技术方案进行详细阐述。
图1是本公开一示例性实施例示出的一种日期识别方法的流程图;如图1所示,该方法可以包括以下步骤:
步骤101,获取待识别文本,该待识别文本包括日期文本。
其中,该待识别文本可以是对图像进行OCR字符识别之后得到的目标文本,例如,可以是对某纸质文件的扫描件进行OCR识别后,得到的字符文本,也可以是WORD文件中的某段文本,还可以是电子票据对应的文本。
步骤102,将该待识别文本输入预设日期识别模型,以获取该预设日期识别模型输出的目标日期。
其中,该预设日期识别模型用于,识别该日期文本对应的待定日期,获取该日期文本中每个字符对应的目标实体类别,根据该日期文本中每个字符对应的目标实体类别和该待定日期确定该日期文本对应的目标日期,该目标实体类别用于表征该字符是否为与日期数字相关的指定字符,以及在该字符为与日期数字相关的指定字符时,该字符对应数字在日期中的位 置信息。
示例地,该目标实体类别可以是“其他”,“年-起”,“年-中”“年-止”,“月-起”,“月-止”,“月-单独”,“日-起”,“日-止”或者“日-单独”,该“其他”表征该字符为非与日期数字相关的指定字符,该“年-起”表征年份数据中的第一位数字,该“年-止”表征该年份数据中的最后一位数字,该“年-中”表征年份数据中除年第一位数字与最后一位数字之外的其他数字,例如,若年份数据为“2018”,则第一位数字“2”(即年份数据中从左至右的第一个数字)对应的目标实体类别为“年-起”,“8”(即年份数据中从左至右的最后一个数字)对应的目标实体类别为“年-止”,“0”与“1”对应的目标实体类别为“年-中”。该“月-起”表征在月份数据为两位数时,该月份数据中的第一位数字,该“月-止”表征在月份数据为两位数时,该月份数据中的第二位数字,该“月-单独”表征月份数据为一位数,例如,在月份数据为“12”时,该“1”对应的目标实体类别为“月-起”,该“2”对应的目标实体类别为“月-止”,在月份数据为“04”时,该“0”对应的目标实体类别为“月-起”,该“4”对应的目标实体类别为“月-止”,在月份数据为“3”时,该“3”对应的目标实体类别为“月-单独”。该“日-起”表征在日期中的日数据为两位数时,该日数据中的第一位数字,该“日-止”表征在日期中的日数据为两位数时,该日数据中的第二位数字,该“日-单独”表征日数据为一位数,例如,在日数据为“26”时,该“2”对应的目标实体类别为“日-起”,该“6”对应的目标实体类别为“日-止”,在日数据为“05”时,该“0”对应的目标实体类别为“日-起”,该“5”对应的目标实体类别为“日-止”,在日数据为“7”时,该“7”对应的目标实体类别为“日-单独”。
以上所述的根据该日期文本中每个字符对应的目标实体类别和该待定日期确定该日期文本对应的目标日期可以是包括:
获取该待定日期中每个数字对应的指定实体类别;在该待定日期中每个数字对应的该指定实体类别与该数字在该日期文本中对应字符的该目标实体类别一致的情况下,将该待定日期确定为该目标日期。
需要说明的是,在获取该待定日期中每个数字对应的指定实体类别时,一种可能的实施方式为:根据该待定日期中每个数字的位置确定该数字对应的指定实体类型。例如,在该待定日期的格式为“待定年份-待定月份-待定日”时,在该数字为第一个“-”之前的数据,则确定该数字属于待定年份中的数字,在该数字为该待定年份数字中的第一位数字的情况下,确定该数字对应的指定实体类别为“年-起”,在该数字为该待定年份数字中的最后一位数字的情况下,确定该数字对应的指定实体类别为“年-止”,若确定该数字属于待定年份数据,但又不是该待定年份数字中的第一位数字,也不是该待定年份数字中的最后一位数字,则确定该数字对应的指定实体类别为“年-中”;在该数字为两个“-”之间的数据,则确定该数字属于待定月份中的数字,在确定该待定月份仅包括一位数字的情况下,确定该待定月份对应的数字的指定实体类别为“月-单独”,在确定该待定月份包括两位数字的情况下,若该数字为该待定月份中的第一位数字,则确定该数字对应的指定实体类别为“月-起”,若该数字为该待定月份中的第二位数字,则确定该数字对应的指定实体类别为“月-止”; 在该数字为第二个“-”之后的数据,则确定该数字属于待定日对应的数字,在确定该待定日仅包括一位数字的情况下,确定该待定日对应的数字的指定实体类别为“日-单独”,在确定该待定月份包括两位数字的情况下,若该数字为该待定日中的第一位数字,则确定该数字对应的指定实体类别为“日-起”,若该数字为该待定日中的第二位数字,则确定该数字对应的指定实体类别为“日-止”。
另一种可能的实施方式为:将该待定日期输入预设命名实体类型识别模型中,以使该预设命名实体识别模型输出该待定日期中每个数字对应的指定命名实体,该指定命名实体可以是“其他”,“年-起”,“年-中”“年-止”,“月-起”,“月-止”,“月-单独”,“日-起”,“日-止”和“日-单独”中的一种,该预设命名实体识别模型可以是神经网络模型,也可以是其他的机器学习模型。
以上技术方案,由于该待识别文本可以是OCR字符识别得到的文本,也可以是其他文档中的文本,还可以是票据对应的文本,因此能够保证针对多种日期识别场景中的日期进行有效识别,也能够有效保证日期识别结果的准确性,从而不仅能够有效保证日期识别率,也能够有效提升日期识别结果的可靠性。
图2是本公开一示例性实施例示出的一种预设日期识别模型的结构框图,如图2所示,该预设日期识别模型包括编码器201,以及与该编码器201耦合的年分类模块202,月分类模块203,日分类模块204和字符实体类别检测模块205;
该年分类模块202,用于识别该日期文本中的该待定年份,该年分类模块包括多个分类器,不同的分类器用于识别该待定年份中不同位置的数字;
该月分类模块203,用于识别该日期文本中的待定月份;
该日分类模块204,用于识别该日期文本中的待定日;
该字符实体类别检测模块205,用于获取该日期文本中每个字符对应的该目标实体类别。
其中,该编码器201可以是BERT(Bidirectional Encoder Representation from Transformers,双向编码器表示)编码器,预设日期识别模型中还可以包括文本预处理模块206,该文本预处理模块206的输出端与该编码器201的输入端耦合,用于对该待识别文本进行分词处理,以得到适用于该编码器201数据输入要求的初始特征序列,其中,该初始特征序列可以是包括[CLS]和[SEP]的特征序列,该[CLS]用于表征embedding开始,[SEP]用在句子之间,用于隔开两个句子。该编码器201可以将该[CLS]符号对应的编码向量作为该待识别文本对应的目标文本特征输入至该年分类模块202,该月分类模块203,该日分类模块204以及该字符实体类别检测模块205,这样,由于该[CLS]符号对应的编码向量包含了该待识别文本中较完整的语义信息,因此以该编码向量作为分类预测的依据数据,能够有效提升分类结果的准确性。
在一些实施例中,该年分类模块202包括第一分类器2021,第二分类器2022,第三分类器2023以及第四分类器2024,该月分类模块203包括第五分类器,该日分类模块204包括第六分类器,该字符实体类别检测模块205包括第七分类器,图3是本公开根据图1所示实施例示出的一种日期识别方法的流程图,如图3所示,该预设日期识别模型通过以下步骤 确定待识别文本中的目标日期:
步骤1021,通过该编码器获取该待识别文本对应的目标文本特征。
其中,该目标文本特征包括该日期文本的上下文语义信息。
示例地,输入该编码器的初始特征序列可以是包括[CLS]和[SEP]的特征序列,该目标文本特征可以是编码器输出的初始特征序列中[CLS]符号对应的编码向量。
步骤1022,通过该第一分类器根据该目标文本特征识别该日期文本对应年份数据中的第一位目标数字,通过该第二分类器根据该目标文本特征识别该日期文本对应年份数据中的第二位目标数字,通过该第三分类器根据该目标文本特征识别该日期文本对应年份数据中的第三位目标数字,通过该第四分类器根据该目标文本特征识别该日期文本对应年份数据中的第四位目标数字。
其中,该第一分类器可以输出1*10维的特征数据,分别用于表征年份数据中的第一位目标数字为0至9中每个数字的概率;该第二分类器可以输出1*10维的特征数据,分别用于表征年份数据中的第二位目标数字为0至9中每个数字的概率;该第三分类器可以输出1*10维的特征数据,分别用于表征年份数据中的第三位目标数字为0至9中每个数字的概率;该第四分类器可以输出1*10维的特征数据,分别用于表征年份数据中的第四位目标数字为0至9中每个数字的概率。
步骤1023,根据该第一位目标数字,该第二位目标数字,该第三位目标数字,以及该第四位目标数字,确定该日期文本对应的该待定年份。
示例地,若该第一分类器识别到该第一目标数据为“2”,该第二分类器识别到该第二位目标数字为“0”,该第三分类器识别到该第三位目标数字为“1”,该第四分类器识别到该第四位目标数字为“8”,则该待定年份为“2018”。
步骤1024,通过该第五分类器根据该目标文本特征识别该日期文本中月份数据对应的待定月份。
其中,该第五分类器可以输出1*13维的特征数据,分别用于表征月份数据为0至12(13个数字)中每个数字的概率。
步骤1025,通过该第六分类器根据该目标文本特征识别该日期文本中日数据对应的待定日。
其中,该第五分类器可以输出1*32维的特征数据,分别用于表征日数据为0至31(32个数字)中每个数字的概率。
步骤1026,通过该第七分类器获取该日期文本中每个字符分别属于每种预设实体类别的概率。
其中,该预设实体类别可以包括“其他”,“年-起”,“年-中”“年-止”,“月-起”,“月-止”,“月-单独”,“日-起”,“日-止”和“日-单独”,该第七分类器输出的数据可以是L*10维数据,该L为编码器输入数据的预设长度。
本步骤中,通过该第七分类器根据该目标文本特征获取该待识别文本中每个字符属于“年-起”(即属于待定年份中第一位数字)的第一概率,属于“年-中”(例如在年份为四 位数时,属于该待定年份中第二位数字或者属于该待定年份中第三位数字)第二概率,属于“年-止”(例如在年份为四位数时,即该待定年份中第四位数字)的第三概率,属于“月-单独”的第四概率,属于“月-起”的第五概率,属于“月-止”的第六概率,属于“日-单独”的第七概率,属于“日-起”的第八概率,属于“日-止”的第九概率,属于“其他”的第十概率。
步骤1027,根据该日期文本中每个字符分别属于每种预设实体类别的概率确定该字符对应的该目标实体类别。
本步骤中,可以获取每个字符对应的第一概率至第十概率,将第一概率至第十概率中的最大值对应的预设实体类别作为该目标实体类别。
示例地,若字符“2”对应的第一概率至第十概率分别为0.1,0.3,0.13,0.15,0.22,0.31,0.5,0.4,0.90,0.3,则确定该字符“2”对应的目标实体类别为“日-止”。
步骤1028,获取该待定日期中每个数字对应的指定实体类别。
本步骤中,一种可能的实施方式为:根据该待定日期中每个数字的位置确定该数字对应的指定实体类型。例如,在该待定日期的格式为“待定年份-待定月份-待定日”时,在该数字为第一个“-”之前的数据,则确定该数字属于待定年份中的数字,在该数字为该待定年份数字中的第一位数字的情况下,确定该数字对应的指定实体类别为“年-起”,在该数字为该待定年份数字中的最后一位数字的情况下,确定该数字对应的指定实体类别为“年-止”,若确定该数字属于待定年份数据,但既不是该待定年份数字中的第一位数字,也不是该待定年份数字中的最后一位数字,则确定该数字对应的指定实体类别为“年-中”;在该数字为两个“-”之间的数据,则确定该数字属于待定月份中的数字,在确定该待定月份仅包括一位数字的情况下,确定该待定月份对应的数字的指定实体类别为“月-单独”,在确定该待定月份包括两位数字的情况下,若该数字为该待定月份中的第一位数字,则确定该数字对应的指定实体类别为“月-起”,若该数字为该待定月份中的第二位数字,则确定该数字对应的指定实体类别为“月-止”;在该数字为第二个“-”之后的数据,则确定该数字属于待定日对应的数字,在确定该待定日仅包括一位数字的情况下,确定该待定日对应的数字的指定实体类别为“日-单独”,在确定该待定月份包括两位数字的情况下,若该数字为该待定日中的第一位数字,则确定该数字对应的指定实体类别为“日-起”,若该数字为该待定日中的第二位数字,则确定该数字对应的指定实体类别为“日-止”。
另一种可能的实施方式为:将该待定日期输入预设命名实体类型识别模型中,以使该预设命名实体识别模型输出该待定日期中每个数字对应的指定命名实体,该指定命名实体可以是“其他”,“年-起”,“年-中”“年-止”,“月-起”,“月-止”,“月-单独”,“日-起”,“日-止”和“日-单独”中的一种,该预设命名实体识别模型可以是神经网络模型,也可以是其他的机器学习模型。
步骤1029,在该待定日期中每个数字对应的该指定实体类别与该数字在该日期文本中对应字符的该目标实体类别一致的情况下,将该待定日期确定为该目标日期。
示例地,在得到的该待定日期为“2018-7-4”,该“2”对应的该指定实体类别为“年- 起”,该“0”对应的该指定实体类别为“年-中”,该“1”对应的该指定实体类别为“年-中”,该“8”对应的该指定实体类别为“年-止”,“-”对应的指定实体类别为“其他”,该“7”对应的该指定实体类别为“月-单独”,该“4”对应的该指定实体类别为“日-单独”,同样,通过以上步骤1026至步骤1027所示方法,能够得到2018-7-4中每个字符对应的目标实体类别,在每个字符对应的该指定实体类别与该目标实体类别一致的情况下,将该待定日期确定为该目标日期,在存在字符对应的该指定实体类别与该目标实体类别不一致的情况下,输出预设提示信息,该预设提示信息用于表征得到的待定日期的准确性较低。
以上技术方案,能够通过根据该日期文本中每个字符对应的目标实体类别和该待定日期确定该日期文本对应的目标日期,能够有效且准确的识别到待识别文本中的目标日期,从而能够有效保证针对待识别文本中日期的识别率,也能够有效提升日期识别结果的可靠性。
图4是本公开一示例性实施例示出的一种预设日期识别模型的训练方法流程图;如图4所示,该预设日期识别模型可以通过以下方式训练得到:
步骤401,通过预设语料库中的目标语料文本生成多个日期文本样本。
其中,该日期文本样本包括日期文本标签和日期文本样本中每个字符的命名实体标签。
本步骤中,可以从该预设语料库中获取该目标语料文本;通过对该目标语料文本进行日期更新操作,得到该目标语料文本对应的多个待定文本样本,该日期更新操作包括日期添加动作,和/或,日期替换动作;根据该待定文本样本生成该日期文本样本。
需要说明的是,该日期添加动作包括年份添加动作,月份添加动作,以及日添加动作,该日期替换动作包括年份替换动作,月份替换动作,以及日替换动作,以上所述的通过对该目标语料文本进行日期更新操作,得到该目标语料文本对应的多个待定文本样本,可以包括:
在确定该目标语料文本中不包括年份数据的情况下,对该目标语料文本执行该年份添加动作,并将添加的年份数据与该目标语料文本进行拼接,以得到多个第一文本样本;在确定该目标语料文本中包括年份数据的情况下,对该目标语料文本执行该年份替换动作,以得到多个第一文本样本;在确定该第一文本样本中包括月份数据和日数据的情况下,对该目标语料文本执行月份替换动作,或者,对该目标语料文本执行该日替换动作,以得到该待定文本样本;在确定该第一文本样本中不包括月份数据的情况下,对该目标语料文本执行该月份添加动作,并在确定该第一文本样本中不包括日数据的情况下,对目标语料文本执行该日添加动作,并将添加的月份数据和日数据与该目标语料文本进行拼接,以得到该待定文本样本。
另外,本步骤中,还包括自动生成日期文本标签,以及该日期文本样本中每个字符的命名实体标签的步骤,具体如下:
在对该目标语料文本进行日期添加动作的情况下,将添加的第一日期作为该日期文本标签;和/或,在对该目标语料文本进行日期替换动作的情况下,将替换后的第二日期作为该日期文本标签;
获取该日期文本标签中每个数字的目标位置信息;根据该日期文本标签中每个数字的该目标位置信息生成该日期文本样本中每个字符的命名实体类别标签。
需要说明的是,在该日期文本标签的格式为“年份-月份-日”的情况下,该目标位置信 息可以包括该数字为第一个“-”之前的第几位数字,或者,该数字为两个“-”之间的第几位数字,再或者为,在第二个“-”之后的第几位数据。若该数字为第一个“-”之前的数据,则确定该数字属于年份中的数字,在该数字为该第一个“-”之前的第一位数字,确定该数字对应的命名实体标签为“年-起”,在该数字为该第一个“-”之前的最后一位数字的情况下,确定该数字对应的命名实体标签为“年-止”,若确定该数字属于年份中的中间数字,即该数字属于该第一个“-”之前的数字,但既不是该第一个“-”之前的第一位数字,也不是该第一个“-”之前的最后一位数字,则确定该数字对应的命名实体标签为“年-中”;在该数字为两个“-”之间的数据,则确定该数字属于月份中的数字,在确定该月份仅包括一位数字的情况下,确定该月份对应的数字的命名实体标签为“月-单独”,在确定该月份包括两位数字的情况下,若该数字为两个“-”之间的第一位数字,则确定该数字对应的命名实体标签为“月-起”,若该数字为两个“-”之间的第二位数字,则确定该数字对应的命名实体标签为“月-止”;在该数字为第二个“-”之后的数据,则确定该数字属于日对应的数字,在确定该日仅包括一位数字的情况下,确定该日对应的数字的命名实体标签为“日-单独”,在确定该日数据包括两位数字的情况下,若该数字为在第二个“-”之后的第一位数字,则确定该数字对应的命名实体标签为“日-起”,若该数字为在第二个“-”之后的第二位数字,则确定该数字对应的命名实体标签为“日-止”,另外,在该日期文本样本中除年份数字,月份数字,日数字对应字符以外的其他字符的命名实体标签确定为“其他”。
步骤402,以该多个日期文本样本为训练数据,对预设初始模型进行模型训练,以得到该预设日期识别模型,其中,该预设初始模型包括初始年分类模块,初始月分类模块,初始日分类模块以及初始字符实体类别检测模块。
其中,该预设初始模型可以包括初始BERT编码器,该初始年分类模块,初始月分类模块,初始日分类模块以及初始字符实体类别检测模块均与该初始BERT编码器耦合,在模型训练过程中,可以以交叉熵为损失函数进行模型训练。
以上技术方案,由于能够自动合成多个日期文本样本,作为训练数据,能够有效避免相关技术中,训练数据获取难度大,标注效率较低,标注过程费时费力的问题,同时由于包括进行日期识别的初始年分类模块,初始月分类模块,初始日分类模块,还包括初始字符实体类别检测模块,因此能够有效提升该预设日期识别模型的收敛速度,提升模型训练效率,也能够有效保证训练得到的该预设日期识别模型的泛化能力,以及日期识别结果的准确性。
图5是本公开一示例性实施例示出的一种日期识别装置的框图,如图5所示,该装置可以包括:
第一获取模块501,被配置为获取待识别文本,该待识别文本包括日期文本;
第二获取模块502,被配置为将该待识别文本输入预设日期识别模型,以获取该预设日期识别模型输出的目标日期;
其中,该预设日期识别模型用于,识别该日期文本对应的待定日期,获取该日期文本中每个字符对应的目标实体类别,根据该日期文本中每个字符对应的目标实体类别和该待定日期确定该日期文本对应的目标日期,该目标实体类别用于表征该字符是否为与日期数字相关 的指定字符,以及在该字符为与日期数字相关的指定字符时,该字符对应数字在日期中的位置信息。
以上技术方案,能够通过根据该日期文本中每个字符对应的目标实体类别和该待定日期确定该日期文本对应的目标日期,能够有效且准确的识别到待识别文本中的目标日期,从而能够有效保证针对待识别文本中日期的识别率,也能够有效提升日期识别结果的可靠性。
在一些实施例中,该预设日期识别模型用于:获取该待定日期中每个数字对应的指定实体类别;在该待定日期中每个数字对应的该指定实体类别与该数字在该日期文本中对应字符的该目标实体类别一致的情况下,将该待定日期确定为该目标日期。
在一些实施例中,该待定日期包括待定年份,待定月份,以及待定日,该预设日期识别模型包括编码器,以及与该编码器耦合的年分类模块,月分类模块,日分类模块和字符实体类别检测模块;
该年分类模块,用于识别该日期文本中的该待定年份,该年分类模块包括多个分类器,不同的分类器用于识别该待定年份中不同位置的数字;
该月分类模块,用于识别该日期文本中的待定月份;
该日分类模块,用于识别该日期文本中的待定日;
该字符实体类别检测模块,用于获取该日期文本中每个字符对应的该目标实体类别。
在一些实施例中,该年分类模块包括第一分类器,第二分类器,第三分类器以及第四分类器,该月分类模块包括第五分类器,该日分类模块包括第六分类器,该字符实体类别检测模块包括第七分类器,该预设日期识别模型用于:
通过该编码器获取该待识别文本对应的目标文本特征,该目标文本特征包括该日期文本的上下文语义信息;
通过该第一分类器根据该目标文本特征识别该日期文本对应年份数据中的第一位目标数字,通过该第二分类器根据该目标文本特征识别该日期文本对应年份数据中的第二位目标数字,通过该第三分类器根据该目标文本特征识别该日期文本对应年份数据中的第三位目标数字,通过该第四分类器根据该目标文本特征识别该日期文本对应年份数据中的第四位目标数字;
根据该第一位目标数字,该第二位目标数字,该第三位目标数字,以及该第四位目标数字,确定该日期文本对应的该待定年份;
通过该第五分类器根据该目标文本特征识别该日期文本中月份数据对应的待定月份;
通过该第六分类器根据该目标文本特征识别该日期文本中日数据对应的待定日;
通过该第七分类器获取该日期文本中每个字符分别属于每种预设实体类别的概率;
根据该日期文本中每个字符分别属于每种预设实体类别的概率确定该字符对应的该目标实体类别。
在一些实施例中,该装置还包括模型训练模块503,该模型训练模块503,用于:
通过预设语料库中的目标语料文本生成多个日期文本样本,该日期文本样本包括日期文本标签和日期文本样本中每个字符的命名实体标签;
以该多个日期文本样本为训练数据,对预设初始模型进行模型训练,以得到该预设日期识别模型,其中,该预设初始模型包括初始年分类模块,初始月分类模块,初始日分类模块以及初始字符实体类别检测模块。
在一些实施例中,该模型训练模块503,用于:从该预设语料库中获取该目标语料文本;通过对该目标语料文本进行日期更新操作,得到该目标语料文本对应的多个待定文本样本,该日期更新操作包括日期添加动作,和/或,日期替换动作;根据该待定文本样本生成该日期文本样本。
在一些实施例中,该模型训练模块503,用于:获取预设干扰文本;将该预设干扰文本添加至该待定文本样本;对添加该预设干扰文本后的待定文本样本进行模拟字符粘连操作,以得到该日期文本样本。
在一些实施例中,该模型训练模块503,还用于:在对该目标语料文本进行日期添加动作的情况下,将添加的第一日期作为该日期文本标签;和/或,在对该目标语料文本进行日期替换动作的情况下,将替换后的第二日期作为该日期文本标签。
在一些实施例中,该模型训练模块503,还用于:获取该日期文本标签中每个数字的目标位置信息;根据该日期文本标签中每个数字的该目标位置信息生成该日期文本样本中每个字符的命名实体类别标签。
以上技术方案,由于能够自动合成多个日期文本样本,作为训练数据,能够有效避免相关技术中,训练数据获取难度大,标注过程费时费力的问题,同时由于包括进行日期识别的初始年分类模块,初始月分类模块,初始日分类模块,还包括初始字符实体类别检测模块,因此能够有效提升该预设日期识别模型的收敛速度,提升模型训练效率,也能够有效保证训练得到的该预设日期识别模型的泛化能力,以及日期识别结果的准确性。
下面参考图6,其示出了适于用来实现本公开实施例的电子设备600的结构示意图。本公开实施例中的终端设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、PDA(个人数字助理)、PAD(平板电脑)、PMP(便携式多媒体播放器)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端。图6示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。
如图6所示,电子设备600可以包括处理装置(例如中央处理器、图形处理器等)601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储装置608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有电子设备600操作所需的各种程序和数据。处理装置601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。
通常,以下装置可以连接至I/O接口605:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置606;包括例如液晶显示器(LCD)、扬声器、振动器等的输出装置607;包括例如磁带、硬盘等的存储装置608;以及通信装置609。通信装置609可以允许电子设备600与其他设备进行无线或有线通信以交换数据。虽然图6示出了具有各种装置的电子设备600,但是应理解的是,并不要求实施或具备所有示出的装 置。可以替代地实施或具备更多或更少的装置。
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在非暂态计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置609从网络上被下载和安装,或者从存储装置608被安装,或者从ROM 602被安装。在该计算机程序被处理装置601执行时,执行本公开实施例的方法中限定的上述功能。
需要说明的是,本公开上述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。
在一些实施方式中,可以利用诸如HTTP(HyperText Transfer Protocol,超文本传输协议)之类的任何当前已知或未来研发的网络协议进行通信,并且可以与任意形式或介质的数字数据通信(例如,通信网络)互连。通信网络的示例包括局域网(“LAN”),广域网(“WAN”),网际网(例如,互联网)以及端对端网络(例如,ad hoc端对端网络),以及任何当前已知或未来研发的网络。
上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。
上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电子设备执行时,使得该电子设备:获取待识别文本,所述待识别文本包括日期文本;将所述待识别文本输入预设日期识别模型,以获取所述预设日期识别模型输出的目标日期;其中,所述预设日期识别模型用于,识别所述日期文本对应的待定日期,获取所述日期文本中每个字符对应的目标实体类别,根据所述日期文本中每个字符对应的目标实体类别和所述待定日期确定所述日期文本对应的目标日期,所述目标实体类别用于表征所述字符是否为与日期数字相关的指定字符,以及在所述字符为与日期数字相关的指定字符时,所述字符对应数字在日期中 的位置信息。
可以以一种或多种程序设计语言或其组合来编写用于执行本公开的操作的计算机程序代码,上述程序设计语言包括但不限于面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言——诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)——连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。
附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
描述于本公开实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,模块的名称在某种情况下并不构成对该模块本身的限定,例如,第一获取模块还可以被描述为“获取待识别文本,所述待识别文本包括日期文本的模块”。
本文中以上描述的功能可以至少部分地由一个或多个硬件逻辑部件来执行。例如,非限制性地,可以使用的示范类型的硬件逻辑部件包括:现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、片上系统(SOC)、复杂可编程逻辑设备(CPLD)等等。
在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。
根据本公开的一个或多个实施例,示例1提供了一种日期识别方法,所述方法包括:
获取待识别文本,所述待识别文本包括日期文本;
将所述待识别文本输入预设日期识别模型,以获取所述预设日期识别模型输出的目标日 期;
其中,所述预设日期识别模型用于,识别所述日期文本对应的待定日期,获取所述日期文本中每个字符对应的目标实体类别,根据所述日期文本中每个字符对应的目标实体类别和所述待定日期确定所述日期文本对应的目标日期,所述目标实体类别用于表征所述字符是否为与日期数字相关的指定字符,以及在所述字符为与日期数字相关的指定字符时,所述字符对应数字在日期中的位置信息。
根据本公开的一个或多个实施例,示例2提供了示例1的方法,所述根据所述日期文本中每个字符对应的目标实体类别和所述待定日期确定所述日期文本对应的目标日期,包括:
获取所述待定日期中每个数字对应的指定实体类别;
在所述待定日期中每个数字对应的所述指定实体类别与所述数字在所述日期文本中对应字符的所述目标实体类别一致的情况下,将所述待定日期确定为所述目标日期。
根据本公开的一个或多个实施例,示例3提供了示例1的方法,所述待定日期包括待定年份,待定月份,以及待定日,所述预设日期识别模型包括编码器,以及与所述编码器耦合的年分类模块,月分类模块,日分类模块和字符实体类别检测模块;
所述年分类模块,用于识别所述日期文本中的所述待定年份,所述年分类模块包括多个分类器,不同的分类器用于识别所述待定年份中不同位置的数字;
所述月分类模块,用于识别所述日期文本中的待定月份;
所述日分类模块,用于识别所述日期文本中的待定日;
所述字符实体类别检测模块,用于获取所述日期文本中每个字符对应的所述目标实体类别。
根据本公开的一个或多个实施例,示例4提供了示例3的方法,所述年分类模块包括第一分类器,第二分类器,第三分类器以及第四分类器,所述月分类模块包括第五分类器,所述日分类模块包括第六分类器,所述字符实体类别检测模块包括第七分类器,所述预设日期识别模型用于:
通过所述编码器获取所述待识别文本对应的目标文本特征,所述目标文本特征包括所述日期文本的上下文语义信息;
通过所述第一分类器根据所述目标文本特征识别所述日期文本对应年份数据中的第一位目标数字,通过所述第二分类器根据所述目标文本特征识别所述日期文本对应年份数据中的第二位目标数字,通过所述第三分类器根据所述目标文本特征识别所述日期文本对应年份数据中的第三位目标数字,通过所述第四分类器根据所述目标文本特征识别所述日期文本对应年份数据中的第四位目标数字;
根据所述第一位目标数字,所述第二位目标数字,所述第三位目标数字,以及所述第四位目标数字,确定所述日期文本对应的所述待定年份;
通过所述第五分类器根据所述目标文本特征识别所述日期文本中月份数据对应的待定月份;
通过所述第六分类器根据所述目标文本特征识别所述日期文本中日数据对应的待定日;
通过所述第七分类器获取所述日期文本中每个字符分别属于每种预设实体类别的概率;
根据所述日期文本中每个字符分别属于每种预设实体类别的概率确定所述字符对应的所述目标实体类别。
根据本公开的一个或多个实施例,示例5提供了示例1的方法,所述预设日期识别模型通过以下方式训练得到:
通过预设语料库中的目标语料文本生成多个日期文本样本,所述日期文本样本包括日期文本标签和日期文本样本中每个字符的命名实体标签;
以所述多个日期文本样本为训练数据,对预设初始模型进行模型训练,以得到所述预设日期识别模型,其中,所述预设初始模型包括初始年分类模块,初始月分类模块,初始日分类模块以及初始字符实体类别检测模块。
根据本公开的一个或多个实施例,示例6提供了示例5的方法,所述根据预设语料库中的目标语料文本生成多个日期文本样本,包括:
从所述预设语料库中获取所述目标语料文本;
通过对所述目标语料文本进行日期更新操作,得到所述目标语料文本对应的多个待定文本样本,所述日期更新操作包括日期添加动作,和/或,日期替换动作;
根据所述待定文本样本生成所述日期文本样本。
根据本公开的一个或多个实施例,示例7提供了示例6的方法,所述根据所述待定文本样本生成所述日期文本样本,包括:
获取预设干扰文本;
将所述预设干扰文本添加至所述待定文本样本;
对添加所述预设干扰文本后的待定文本样本进行模拟字符粘连操作,以得到所述日期文本样本。
根据本公开的一个或多个实施例,示例8提供了示例6的方法,所述根据预设语料库中的目标语料文本生成多个日期文本样本,还包括:
在对所述目标语料文本进行日期添加动作的情况下,将添加的第一日期作为所述日期文本标签;和/或,
在对所述目标语料文本进行日期替换动作的情况下,将替换后的第二日期作为所述日期文本标签。
根据本公开的一个或多个实施例,示例9提供了示例6的方法,所述根据预设语料库中的目标语料文本生成多个日期文本样本,还包括:
获取所述日期文本标签中每个数字的目标位置信息;
根据所述日期文本标签中每个数字的所述目标位置信息生成所述日期文本样本中每个字符的命名实体类别标签。
根据本公开的一个或多个实施例,示例10提供了一种日期识别装置,所述装置包括:
第一获取模块,被配置为获取待识别文本,所述待识别文本包括日期文本;
第二获取模块,被配置为将所述待识别文本输入预设日期识别模型,以获取所述预设日 期识别模型输出的目标日期;
其中,所述预设日期识别模型用于,识别所述日期文本对应的待定日期,获取所述日期文本中每个字符对应的目标实体类别,根据所述日期文本中每个字符对应的目标实体类别和所述待定日期确定所述日期文本对应的目标日期,所述目标实体类别用于表征所述字符是否为与日期数字相关的指定字符,以及在所述字符为与日期数字相关的指定字符时,所述字符对应数字在日期中的位置信息。
根据本公开的一个或多个实施例,示例11提供了一种计算机可读介质,其上存储有计算机程序,该程序被处理装置执行时实现以上示例1-9中任一项所述方法的步骤。
根据本公开的一个或多个实施例,示例12提供了一种电子设备,包括:
存储装置,其上存储有计算机程序;
处理装置,用于执行所述存储装置中的所述计算机程序,以实现以上示例1-9中任一项所述方法的步骤。
以上描述仅为本公开的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本公开中所涉及的公开范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述公开构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本公开中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。
此外,虽然采用特定次序描绘了各操作,但是这不应当理解为要求这些操作以所示出的特定次序或以顺序次序执行来执行。在一定环境下,多任务和并行处理可能是有利的。同样地,虽然在上面论述中包含了若干具体实现细节,但是这些不应当被解释为对本公开的范围的限制。在单独的实施例的上下文中描述的某些特征还可以组合地实现在单个实施例中。相反地,在单个实施例的上下文中描述的各种特征也可以单独地或以任何合适的子组合的方式实现在多个实施例中。
尽管已经采用特定于结构特征和/或方法逻辑动作的语言描述了本主题,但是应当理解所附权利要求书中所限定的主题未必局限于上面描述的特定特征或动作。相反,上面所描述的特定特征和动作仅仅是实现权利要求书的示例形式。关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。

Claims (12)

  1. 一种日期识别方法,其中,所述方法包括:
    获取待识别文本,所述待识别文本包括日期文本;
    将所述待识别文本输入预设日期识别模型,以获取所述预设日期识别模型输出的目标日期;
    其中,所述预设日期识别模型用于,识别所述日期文本对应的待定日期,获取所述日期文本中每个字符对应的目标实体类别,根据所述日期文本中每个字符对应的目标实体类别和所述待定日期确定所述日期文本对应的目标日期,所述目标实体类别用于表征所述字符是否为与日期数字相关的指定字符,以及在所述字符为与日期数字相关的指定字符时,所述字符对应数字在日期中的位置信息。
  2. 根据权利要求1所述的方法,其中,所述根据所述日期文本中每个字符对应的目标实体类别和所述待定日期确定所述日期文本对应的目标日期,包括:
    获取所述待定日期中每个数字对应的指定实体类别;
    在所述待定日期中每个数字对应的所述指定实体类别与所述数字在所述日期文本中对应字符的所述目标实体类别一致的情况下,将所述待定日期确定为所述目标日期。
  3. 根据权利要求1所述的方法,其中,所述待定日期包括待定年份,待定月份,以及待定日,所述预设日期识别模型包括编码器,以及与所述编码器耦合的年分类模块,月分类模块,日分类模块和字符实体类别检测模块;
    所述年分类模块,用于识别所述日期文本中的所述待定年份,所述年分类模块包括多个分类器,不同的分类器用于识别所述待定年份中不同位置的数字;
    所述月分类模块,用于识别所述日期文本中的待定月份;
    所述日分类模块,用于识别所述日期文本中的待定日;
    所述字符实体类别检测模块,用于获取所述日期文本中每个字符对应的所述目标实体类别。
  4. 根据权利要求3所述的方法,其中,所述年分类模块包括第一分类器,第二分类器,第三分类器以及第四分类器,所述月分类模块包括第五分类器,所述日分类模块包括第六分类器,所述字符实体类别检测模块包括第七分类器,所述预设日期识别模型用于:
    通过所述编码器获取所述待识别文本对应的目标文本特征,所述目标文本特征包括所述日期文本的上下文语义信息;
    通过所述第一分类器根据所述目标文本特征识别所述日期文本对应年份数据中的第一位目标数字,通过所述第二分类器根据所述目标文本特征识别所述日期文本对应年份数据中的第二位目标数字,通过所述第三分类器根据所述目标文本特征识别所述日期文本对应年份数据中的第三位目标数字,通过所述第四分类器根据所述目标文本特征识别所述日期文本对应年份数据中的第四位目标数字;
    根据所述第一位目标数字,所述第二位目标数字,所述第三位目标数字,以及所述第四位目标数字,确定所述日期文本对应的所述待定年份;
    通过所述第五分类器根据所述目标文本特征识别所述日期文本中月份数据对应的待定月份;
    通过所述第六分类器根据所述目标文本特征识别所述日期文本中日数据对应的待定日;
    通过所述第七分类器获取所述日期文本中每个字符分别属于每种预设实体类别的概率;
    根据所述日期文本中每个字符分别属于每种预设实体类别的概率确定所述字符对应的所述目标实体类别。
  5. 根据权利要求1所述的方法,其中,所述预设日期识别模型通过以下方式训练得到:
    通过预设语料库中的目标语料文本生成多个日期文本样本,所述日期文本样本包括日期文本标签和日期文本样本中每个字符的命名实体标签;
    以所述多个日期文本样本为训练数据,对预设初始模型进行模型训练,以得到所述预设日期识别模型,其中,所述预设初始模型包括初始年分类模块,初始月分类模块,初始日分类模块以及初始字符实体类别检测模块。
  6. 根据权利要求5所述的方法,其中,所述根据预设语料库中的目标语料文本生成多个日期文本样本,包括:
    从所述预设语料库中获取所述目标语料文本;
    通过对所述目标语料文本进行日期更新操作,得到所述目标语料文本对应的多个待定文本样本,所述日期更新操作包括日期添加动作,和/或,日期替换动作;
    根据所述待定文本样本生成所述日期文本样本。
  7. 根据权利要求6所述的方法,其中,所述根据所述待定文本样本生成所述日期文本样本,包括:
    获取预设干扰文本;
    将所述预设干扰文本添加至所述待定文本样本;
    对添加所述预设干扰文本后的待定文本样本进行模拟字符粘连操作,以得到所述日期文本样本。
  8. 根据权利要求6所述的方法,其中,所述根据预设语料库中的目标语料文本生成多个日期文本样本,还包括:
    在对所述目标语料文本进行日期添加动作的情况下,将添加的第一日期作为所述日期文本标签;和/或,
    在对所述目标语料文本进行日期替换动作的情况下,将替换后的第二日期作为所述日期文本标签。
  9. 根据权利要求6所述的方法,其中,所述根据预设语料库中的目标语料文本生成多个日期文本样本,还包括:
    获取所述日期文本标签中每个数字的目标位置信息;
    根据所述日期文本标签中每个数字的所述目标位置信息生成所述日期文本样本中每个字符的命名实体类别标签。
  10. 一种日期识别装置,其中,所述装置包括:
    第一获取模块,被配置为获取待识别文本,所述待识别文本包括日期文本;
    第二获取模块,被配置为将所述待识别文本输入预设日期识别模型,以获取所述预设日期识别模型输出的目标日期;
    其中,所述预设日期识别模型用于,识别所述日期文本对应的待定日期,获取所述日期文本中每个字符对应的目标实体类别,根据所述日期文本中每个字符对应的目标实体类别和所述待定日期确定所述日期文本对应的目标日期,所述目标实体类别用于表征所述字符是否为与日期数字相关的指定字符,以及在所述字符为与日期数字相关的指定字符时,所述字符对应数字在日期中的位置信息。
  11. 一种计算机可读介质,其上存储有计算机程序,其中,该程序被处理装置执行时实现权利要求1-9中任一项所述方法的步骤。
  12. 一种电子设备,其包括:
    存储装置,其上存储有计算机程序;
    处理装置,用于执行所述存储装置中的所述计算机程序,以实现权利要求1-9中任一项所述方法的步骤。
PCT/CN2023/070269 2022-01-29 2023-01-04 日期识别方法、装置、可读介质及电子设备 WO2023142914A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210113138.7 2022-01-29
CN202210113138.7A CN114444508A (zh) 2022-01-29 2022-01-29 日期识别方法、装置、可读介质及电子设备

Publications (1)

Publication Number Publication Date
WO2023142914A1 true WO2023142914A1 (zh) 2023-08-03

Family

ID=81371887

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/070269 WO2023142914A1 (zh) 2022-01-29 2023-01-04 日期识别方法、装置、可读介质及电子设备

Country Status (2)

Country Link
CN (1) CN114444508A (zh)
WO (1) WO2023142914A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117725908A (zh) * 2024-02-07 2024-03-19 青岛海尔科技有限公司 一种自然语言处理中的时间解析方法、装置及设备
CN117725908B (zh) * 2024-02-07 2024-05-24 青岛海尔科技有限公司 一种自然语言处理中的时间解析方法、装置及设备

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114444508A (zh) * 2022-01-29 2022-05-06 北京有竹居网络技术有限公司 日期识别方法、装置、可读介质及电子设备

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007128160A (ja) * 2005-11-01 2007-05-24 Toshiba Corp 情報処理装置
US20180101750A1 (en) * 2016-10-11 2018-04-12 Xerox Corporation License plate recognition with low-rank, shared character classifiers
CN108491787A (zh) * 2018-03-20 2018-09-04 上海眼控科技股份有限公司 一种用于财务报表的日期检测与识别方法及装置
CN108960233A (zh) * 2018-06-13 2018-12-07 北京小米移动软件有限公司 识别身份证有效期的方法及装置
CN110443159A (zh) * 2019-07-17 2019-11-12 新华三大数据技术有限公司 数字识别方法、装置、电子设备及存储介质
CN113762160A (zh) * 2021-09-08 2021-12-07 深圳前海环融联易信息科技服务有限公司 一种日期提取方法、装置、计算机设备及存储介质
CN114444508A (zh) * 2022-01-29 2022-05-06 北京有竹居网络技术有限公司 日期识别方法、装置、可读介质及电子设备

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007128160A (ja) * 2005-11-01 2007-05-24 Toshiba Corp 情報処理装置
US20180101750A1 (en) * 2016-10-11 2018-04-12 Xerox Corporation License plate recognition with low-rank, shared character classifiers
CN108491787A (zh) * 2018-03-20 2018-09-04 上海眼控科技股份有限公司 一种用于财务报表的日期检测与识别方法及装置
CN108960233A (zh) * 2018-06-13 2018-12-07 北京小米移动软件有限公司 识别身份证有效期的方法及装置
CN110443159A (zh) * 2019-07-17 2019-11-12 新华三大数据技术有限公司 数字识别方法、装置、电子设备及存储介质
CN113762160A (zh) * 2021-09-08 2021-12-07 深圳前海环融联易信息科技服务有限公司 一种日期提取方法、装置、计算机设备及存储介质
CN114444508A (zh) * 2022-01-29 2022-05-06 北京有竹居网络技术有限公司 日期识别方法、装置、可读介质及电子设备

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117725908A (zh) * 2024-02-07 2024-03-19 青岛海尔科技有限公司 一种自然语言处理中的时间解析方法、装置及设备
CN117725908B (zh) * 2024-02-07 2024-05-24 青岛海尔科技有限公司 一种自然语言处理中的时间解析方法、装置及设备

Also Published As

Publication number Publication date
CN114444508A (zh) 2022-05-06

Similar Documents

Publication Publication Date Title
CN111274815B (zh) 用于挖掘文本中的实体关注点的方法和装置
CN111090987A (zh) 用于输出信息的方法和装置
CN111177393A (zh) 一种知识图谱的构建方法、装置、电子设备及存储介质
WO2022166613A1 (zh) 文本中角色的识别方法、装置、可读介质和电子设备
WO2022247562A1 (zh) 多模态数据检索方法、装置、介质及电子设备
WO2022252881A1 (zh) 图像处理方法、装置、可读介质和电子设备
WO2023077995A1 (zh) 信息提取方法、装置、设备、介质及产品
WO2022037419A1 (zh) 音频内容识别方法、装置、设备和计算机可读介质
CN113158656B (zh) 讽刺内容识别方法、装置、电子设备以及存储介质
CN112883968B (zh) 图像字符识别方法、装置、介质及电子设备
WO2021259205A1 (zh) 一种文本序列生成方法、装置、设备和介质
WO2023143016A1 (zh) 特征提取模型的生成方法、图像特征提取方法和装置
WO2023142914A1 (zh) 日期识别方法、装置、可读介质及电子设备
CN116912847A (zh) 一种医学文本识别方法、装置、计算机设备及存储介质
JP2023550211A (ja) テキストを生成するための方法および装置
CN113408507B (zh) 基于履历文件的命名实体识别方法、装置和电子设备
WO2023130925A1 (zh) 字体识别方法、装置、可读介质及电子设备
WO2023143107A1 (zh) 一种字符识别方法、装置、设备及介质
WO2023065895A1 (zh) 文本识别方法、装置、可读介质及电子设备
CN115937888A (zh) 文档比对方法、装置、设备和介质
WO2022206404A1 (zh) 练字格检测方法、装置、可读介质及电子设备
WO2022206091A1 (zh) 用于生成数据的方法和装置
CN113033682B (zh) 视频分类方法、装置、可读介质、电子设备
CN116821327A (zh) 文本数据处理方法、装置、设备、可读存储介质及产品
CN111914535B (zh) 一种单词识别方法、装置、计算机设备和存储介质

Legal Events

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

Ref document number: 23745799

Country of ref document: EP

Kind code of ref document: A1