Processing method and electronic equipment
By determining the object analysis method of files and combining natural language processing and computer vision models, the problem of low resolution accuracy of file analysis technology is solved, efficient and accurate analysis of multiple file types is achieved, and the Q&A ability of the personal knowledge base is enhanced .
Patent Information
- Application Number
- CN202411218345.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-31
- Publication Date
- 2024-11-22
AI Technical Summary
Existing file parsing technologies have low parsing accuracy and cannot meet the needs of diversified information files, especially when providing accurate and personalized Q&A functions in personal knowledge bases.
By determining the target analysis method of the file, using text analysis method or picture analysis method, combining natural language processing and computer vision model, using similarity loss function to train text and picture processing models, ensuring the consistency and accuracy of the parsing results, and Format conversion if necessary to improve efficiency.
It realizes accurate analysis of various types of files, improves the accuracy and speed of analysis results, enhances the Q&A capabilities of the personal knowledge base, and improves the user experience.
Smart Images

Figure CN119003464A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of file parsing, and in particular to a processing method and electronic device. Background Art
[0002] With the digitization of information, more and more information is summarized and stored in digital form to facilitate subsequent query and use, for example, storing information in a personal knowledge base (PKB) or other databases. Therefore, file parsing technology is particularly important.
[0003] The current file parsing technology has strong limitations, and the information contained in the files is in various forms, resulting in low parsing accuracy and failure to meet demand. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a processing method and an electronic device.
[0005] In a first aspect, an embodiment of the present application provides a processing method, including:
[0006] Obtaining a first file, where the first file is a file to be parsed;
[0007] Based on the first file, obtaining description information corresponding to the first file;
[0008] Determine, according to the description information, a target parsing method corresponding to the first file;
[0009] Parsing the first file based on the target parsing method to obtain a parsing result corresponding to the first file;
[0010] The target parsing method is one or more of a first parsing method and a second parsing method. The first parsing method and the second parsing method have different parsing methods for objects of the same format. The object is part of or all of the information included in the file.
[0011] In a possible implementation, determining, according to the description information, a target parsing mode corresponding to the first file includes:
[0012] If it is determined according to the description information that the file format of the first file belongs to the text type, or the proportion of objects in the first file in the text format exceeds a first preset proportion, then confirming that the target parsing method is the first parsing method;
[0013] If it is determined according to the description information that the file format of the first file belongs to the image type, or the proportion of objects in the image format in the first file exceeds a second preset proportion, then confirming that the target parsing method is the second parsing method;
[0014] The first parsing method is a text parsing method, and the second parsing method is a picture parsing method.
[0015] In a possible implementation, the parsing result includes parsed content and tag information corresponding to the parsed content;
[0016] The processing method also includes:
[0017] The tag information obtained by parsing the same object or the same file in the first parsing method and the second parsing method meets a similar condition.
[0018] In a possible implementation, the first parsing method adopts a text processing model, and the second parsing method adopts an image processing model;
[0019] The processing method also includes:
[0020] The text processing model and the image processing model are trained in advance using a training data set based on a similarity loss function, so that the similarity of the parsing results obtained by the trained text processing model and the image processing model is greater than a similarity threshold.
[0021] In a possible implementation manner, the first file includes link information for obtaining the second file;
[0022] The processing method also includes:
[0023] Based on the link information, obtaining the second file;
[0024] Obtaining description information corresponding to the second file;
[0025] Determine, according to the description information, a parsing method corresponding to the second file;
[0026] The second file is parsed based on the parsing method corresponding to the second file to obtain a parsing result corresponding to the second file.
[0027] In one possible implementation,
[0028] taking the parsing result corresponding to the second file and the parsing result corresponding to the first file together as the parsing result of the first file; or
[0029] The parsing result of the second file is not associated with the first file or with the parsing result of the first file.
[0030] In a possible implementation manner, the first file includes a plurality of sub-files;
[0031] The obtaining of the first file comprises:
[0032] Each subfile in the first file is obtained.
[0033] In a possible implementation, parsing the first file based on the target parsing mode at least includes: performing format conversion on some objects in the first file.
[0034] In a second aspect, an embodiment of the present application further provides an electronic device, including:
[0035] A first obtaining module, configured to obtain a first file, where the first file is a file to be parsed;
[0036] A second obtaining module, configured to obtain description information corresponding to the first file based on the first file;
[0037] A determination module configured to determine a target parsing method corresponding to the first file according to the description information;
[0038] A first parsing module, configured to parse the first file based on the target parsing method to obtain a parsing result corresponding to the first file;
[0039] The target parsing method is one or more of a first parsing method and a second parsing method. The first parsing method and the second parsing method have different parsing methods for objects of the same format. The object is part of or all of the information included in the file.
[0040] In a possible implementation manner, the determination module is specifically configured as follows:
[0041] If it is determined according to the description information that the file format of the first file belongs to the text type, or the proportion of objects in the first file in the text format exceeds a first preset proportion, then confirming that the target parsing method is the first parsing method;
[0042] If it is determined according to the description information that the file format of the first file belongs to the image type, or the proportion of objects in the image format in the first file exceeds a second preset proportion, then confirming that the target parsing method is the second parsing method;
[0043] The first parsing method is a text parsing method, and the second parsing method is a picture parsing method. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0045] Figure 1 A flowchart of a processing method provided by the present application is shown;
[0046] Figure 2 A flowchart showing another processing method provided by the present application is shown;
[0047] Figure 3 A schematic diagram of the structure of an electronic device provided by the present application is shown;
[0048] Figure 4 A structural schematic diagram of another electronic device provided by the present application is shown. DETAILED DESCRIPTION
[0049] Various aspects and features of the present application are described herein with reference to the accompanying drawings.
[0050] It should be understood that various modifications may be made to the embodiments of the present application. Therefore, the above description should not be considered as limiting, but only as an example of an embodiment. Other modifications within the scope and spirit of the present application will occur to those skilled in the art.
[0051] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present application and, together with the general description of the present application given above and the detailed description of the embodiments given below, serve to explain the principles of the present application.
[0052] These and other characteristics of the present application will become apparent from the following description of a preferred form of embodiment given as a non-limiting example with reference to the accompanying drawings.
[0053] It should also be understood that, although the present application has been described with reference to some specific examples, those skilled in the art will be able to realize many other equivalent forms of the present application that have the features described in the claims and are therefore within the scope of protection defined thereby.
[0054] The above and other aspects, features and advantages of the present application will become more apparent in view of the following detailed description when taken in conjunction with the accompanying drawings.
[0055] Specific embodiments of the present application are described hereinafter with reference to the accompanying drawings; however, it should be understood that the embodiments applied for are merely examples of the present application, which may be implemented in a variety of ways. Well-known and / or repeated functions and structures are not described in detail to avoid unnecessary or redundant details that obscure the present application. Therefore, the specific structural and functional details applied for herein are not intended to be limiting, but merely serve as a basis and representative basis for the claims to teach those skilled in the art to use the present application in a variety of ways with substantially any suitable detailed structure.
[0056] This specification may use the phrases "in one embodiment," "in another embodiment," "in yet another embodiment," or "in other embodiments," all of which may refer to one or more of the same or different embodiments according to the present application.
[0057] The embodiment of the present application is elaborated in detail by taking the scenario of building a personal knowledge base (PKB) combined with an artificial intelligence personal computer (AIPC) as an example. Of course, those skilled in the art should know that the present application is not limited to this scenario, and it can be applied to any scenario related to file parsing. Specifically, for AIPC, the personal knowledge base is a key link in realizing its intelligent question and answer function. It can store and manage users' personal files, and combine with the end-side large model so that AIPC can provide more accurate and personalized question and answer capabilities. In order to give full play to the role of personal knowledge base in AIPC, file parsing technology is particularly important. File parsing refers to the use of basic software tools or neural networks, especially natural language processing and computer vision models, to process files of various formats and format them for output, such as text files, scanned files, Microsoft files, pictures, web page screenshots, etc., and extract, summarize and integrate information from them.
[0058] The processing method provided in the embodiment of the present application can accurately parse files and is applicable to various types of files without format conversion, while ensuring the accuracy and speed of the parsing results. Next, a processing method provided in the present application is introduced in detail.
[0059] Figure 1 A flowchart of a processing method provided in an embodiment of the present application is shown, wherein specific steps include S101-S104.
[0060] S101, obtaining a first file, where the first file is a file to be parsed.
[0061] Alternatively, the first file may be determined based on a selection operation of a user.
[0062] In other optional embodiments, some files may be selected from an electronic device such as a computer according to certain screening conditions to determine them as first files, thereby obtaining the first file. The screening conditions may include files edited by a user, files recording user behavior, etc., that is, the first file can characterize the user's behavior characteristics in a certain dimension.
[0063] In a specific implementation, the first file obtained is the file to be parsed. By parsing the first file and constructing a knowledge base or database based on the parsing result of the first file, AIPC can be supported to provide more accurate and personalized question-and-answer capabilities.
[0064] S102: Based on the first file, obtain description information corresponding to the first file.
[0065] After obtaining the first file, the first file is identified and analyzed to obtain description information corresponding to the first file, wherein the description information at least includes the attributes, size, creation time, access time, owner information, object information, etc. of the first file, and the object information at least includes text and pictures.
[0066] The description information may be a metafile of the first file.
[0067] S103: Determine a target parsing method corresponding to the first file according to the description information.
[0068] After obtaining the description information corresponding to the first file, the target parsing method corresponding to the first file is determined according to the description information. Optionally, the embodiment of the present application provides two parsing methods, namely, a first parsing method and a second parsing method. The first parsing method and the second parsing method have different parsing methods for objects of the same format, and the objects are part of the information or all of the information included in the file. Among them, the target parsing method is one or more of the first parsing method and the second parsing method.
[0069] That is to say, for the first file, the first parsing method can be used for parsing, the first parsing method can be used for parsing, or the first parsing method and the second parsing method can be used for parsing. Moreover, when parsing the first file, there is information without substantial features included in the first file. Therefore, part of the information in the first file can be parsed to avoid the situation where resources are wasted by parsing information without substantial features; of course, for the completeness of the parsing result, all the information included in the first file can be parsed. The embodiments of the present application do not specifically limit this.
[0070] Optionally, when determining the target parsing method corresponding to the first file according to the description information, if it is determined that the file format of the first file belongs to the text class, or the proportion of objects in the first file in the text format exceeds a first preset proportion according to the description information, then the target parsing method is confirmed to be the first parsing method, wherein the first parsing method is the text parsing method. For example, when the file format of the first file is PDF 1.5 or above, Microsoft Word, PPT Excel, etc., it is determined that the file format of the first file belongs to the text class; when the proportion of objects in the first file in the text format exceeds 0.75, it is determined that the file format of the first file belongs to the text class.
[0071] Accordingly, when determining the target parsing method corresponding to the first file according to the description information, if it is determined according to the description information that the file format of the first file belongs to the picture class, or the proportion of objects in the first file in the picture format exceeds the second preset proportion, then the target parsing method is confirmed to be the second parsing method, wherein the second parsing method is the picture parsing method. For example, when the file format of the first file is PDF 1.5 or below, BMP, JPF, TIF, etc., it is determined that the file format of the first file belongs to the picture class; when the proportion of objects in the first file in the picture format exceeds 0.75, it is determined that the file format of the first file belongs to the picture class.
[0072] Optionally, the file format is determined using a file signature (Magic Numbers) method and a file extension, or the Apache Tika toolkit is used to obtain an object built into the first file to determine the file format.
[0073] Furthermore, the first preset ratio and the second preset ratio may be the same or different. Optionally, the preset ratio is calculated by the following formula (1).
[0074]
[0075] Among them, x1 represents the proportion of pictures in the file; x2 represents the proportion of text in the file; P(C) represents the prior probability of CV flow, which can be obtained from the label of the test data, or it can be replaced by the frequency of occurrence of the picture file; P(x1|C) represents the likelihood probability of x1 given that the label is CV flow, which can also be obtained by statistical frequency; P(x2|C) represents the likelihood probability of x2, which can also be obtained by statistical frequency.
[0076] Of course, the preset ratio can also be set manually.
[0077] It should be noted that when calculating the proportion of objects in the first file in the form of text or the proportion of objects in the first file in the form of pictures, the total number of characters in the target text is calculated first, wherein the number of characters corresponding to each picture can be determined according to the conversion relationship between pictures and characters. Afterwards, the proportion of objects in the first file in the form of text is calculated using the number of text characters corresponding to the text and the total number of characters, and the proportion of objects in the first file in the form of pictures is calculated using the number of picture characters corresponding to the pictures and the total number of characters.
[0078] S104, parsing the first file based on the target parsing method to obtain a parsing result corresponding to the first file.
[0079] After determining the target parsing method corresponding to the first file, the first file is parsed based on the target parsing method to obtain a parsing result corresponding to the first file, wherein the parsing result includes parsed content and tag information corresponding to the parsed content.
[0080] As an example, the first parsing method is a parsing flow based on a traditional method combined with natural language processing. When parsing the first file based on the first parsing method, firstly, for the first file, an open source software package such as Apache POI, Apache PDF Box and other toolkits are used to parse the first file to obtain the parsed content, specifically, the text in the first file and the structure corresponding to the text. Then, an NLP language segmentation model (such as a BERT model) is used to segment the long text of each page to obtain multiple text blocks, and further determine the label of each text block, so as to obtain the label information corresponding to the parsed content, wherein the label of the text block includes at least formulas, tables, titles, paragraphs, and quotations.
[0081] Furthermore, since the objects included in the first file correspond to multiple tags, when parsing the first file, some objects in the first file are formatted to improve parsing efficiency and parsing result accuracy. Optionally, for text blocks with different tags, regular matching technology is used to perform syntax conversion on the text blocks respectively, for example, converting text with a table tag into HTML format, converting text with a formula tag into LaTeX format, etc. Of course, syntax conversion can be performed only on text blocks with some tags.
[0082] Afterwards, the parsed content and the label information corresponding to the parsed content are standardized based on the structure corresponding to the parsed text. The structure corresponding to the text can represent the sorting sequence corresponding to the text. When the parsed content and the label information corresponding to the parsed content are standardized, all the parsed texts are arranged according to the sorting sequence of each text, thereby obtaining standardized data.
[0083] In another example, the second parsing method is a parsing flow based on computer vision. When parsing the first file based on the second parsing method, firstly, for the first file, a layout analysis technology (such as networks including CTPN, YOLO, Pico Det, etc.) is used to determine the coordinate positions of objects labeled as titles, paragraphs, citations, tables, formulas, and other objects, and mark the labels of objects in the picture. After obtaining the positions and labels of objects in the first file, an OCR text recognition model (such as networks including CRNN, CTC, etc.) is used to parse objects labeled as titles, paragraphs, and citations, a TCR table recognition model (such as including an FPN network) is used to parse objects labeled as tables, and an FCR formula recognition model (such as including a Seq2Seq network) is used to parse objects labeled as formulas, thereby obtaining the parsed content for the first file.
[0084] Afterwards, based on the coordinate position of the object, the parsed content is arranged to obtain standardized data.
[0085] In the embodiment of the present application, the standardized data is in the form of a vector, that is, the parsed content in the parsing result and the label information corresponding to the parsed content are represented by a vector, for example, the parsed content includes a vector corresponding to the text and a vector corresponding to the image, etc. The standardized data is stored in a personal knowledge base, so that accurate and personalized question-and-answer services can be provided to users through the personal knowledge base, which greatly improves the user experience.
[0086] here, Figure 2 A flowchart of another processing method provided by an embodiment of the present application is shown, wherein: Figure 2 The specific analysis process is shown in more detail. Figure 2 First, the file to be parsed, i.e., the first file, is obtained. Then, metadata analysis is performed on the first file to obtain description information corresponding to the first file. The description information at least includes the attributes, size, creation time, access time, owner information, object information, etc. of the first file. The object information at least includes text and pictures.
[0087] After obtaining the description information corresponding to the first file, determine the target parsing method corresponding to the first file according to the description information. Specifically, if the file format of the first file belongs to the text category, such as its format is PDF 1.5 version or above, Microsoft Word, PPT Excel, etc., or the proportion of objects in the first file in the format of text exceeds 0.75, at this time, the first file is parsed based on the traditional method combined with the natural language processing parsing flow (NLP flow). If the file format of the first file belongs to the image category, such as its format is PDF 1.5 version or below, BMP, JPF, TIF, etc., or the proportion of objects in the first file in the format of images exceeds 0.75, at this time, the first file is parsed based on the computer vision parsing flow (CV flow).
[0088] Under the NLP flow, an open source software package such as Apache POI, Apache PDF Box and other toolkits are used to parse the first file to obtain the parsed content, specifically the text in the first file and the structure corresponding to the text, and then the NLP language segmentation model is used to segment the long text of each page to obtain multiple text blocks, and further determine the label of each text block. Furthermore, different processing is performed on objects corresponding to different labels, wherein the text labeled as a table is converted into the html format, the text labeled as a formula is converted into the latex format, etc. It is worth noting that objects labeled as titles, paragraphs, and references can be directly processed. Afterwards, the parsed content and the label information corresponding to the parsed content are standardized based on the structure corresponding to the parsed text, and then standardized data is obtained. In the embodiment of the present application, the parsed result, i.e., standardized data, is output in the json string format.
[0089] Under CV flow, layout analysis technology is used to determine the coordinate positions of objects labeled as titles, paragraphs, citations, tables, formulas, and other objects, and the labels of objects in the image are marked. Afterwards, different processing models are used according to the object labels and coordinate positions, wherein the FCR formula recognition model is used to parse objects labeled as formulas, the TCR table recognition model is used to parse objects labeled as tables, and the OCR text recognition model is used to parse objects labeled as titles, paragraphs, and citations, thereby obtaining the parsed content for the first file. Afterwards, based on the coordinate positions, the parsed content obtained by parsing is arranged to obtain standardized data. In the embodiment of the present application, the parsed results, i.e., standardized data, are output in the json string format.
[0090] As another example, the target parsing method may be both the first parsing method and the second parsing method. In this scenario, the tag information obtained by parsing the same object or the same file by the first parsing method and the second parsing method satisfies similar conditions.
[0091] Specifically, the text object in the first file can be parsed based on the first parsing method, and the image object in the first file can be parsed based on the second parsing method to obtain two parsing results. Of course, the first file can also be parsed based on the first parsing method and the second parsing method can be used to parse the first file, and two parsing results can be obtained. Afterwards, the two parsing results are merged.
[0092] When the first file is parsed based on the first parsing method and the second parsing method at the same time, in order to achieve alignment of labels such as formulas, tables, titles, paragraphs, references, etc. in the first parsing method and the second parsing method, a method based on a vector space model in a Siamese network can be used to achieve label alignment.
[0093] In practical applications, the first parsing method uses a text processing model, and the second parsing method uses an image processing model. Optionally, the text processing model and the image processing model are trained in advance based on a similarity loss function using a training data set, so that the similarity of the parsing results obtained by the trained text processing model and the image processing model is greater than a similarity threshold. Specifically, two identical subnetworks are pre-constructed, the two subnetworks have the same structure and weights, and the two subnetworks are used to process the vectors corresponding to the text and the vectors corresponding to the pictures in the training data set, respectively, wherein the text and the pictures both have corresponding labels. If the labels of a pair of texts and pictures are aligned (that is, the text and the picture belong to the same category), the two subnetworks output high similarity; if the labels of a pair of texts and pictures are not aligned, the two subnetworks output low similarity. Afterwards, the network weights are adjusted by back propagation and gradient descent algorithms to minimize the difference between the predicted similarity and the true label. Finally, the trained network is used to adjust the labels corresponding to the text processing model and the labels corresponding to the image processing model to ensure the consistency of the labels of the text processing model and the image processing model. That is, the similarity of the parsing results obtained by the trained text processing model and the image processing model is greater than the similarity threshold, which effectively ensures the consistency of the two parsing results.
[0094] The embodiment of the present application determines the corresponding target parsing method through the description information of the first file, and thus can accurately parse the first file. Moreover, the models used in the parsing process are all lightweight models, which greatly improves the parsing speed. Moreover, the text processing model and the image processing model are trained through the similarity loss function, which ensures the consistency of the parsing results obtained by the first parsing method and the second parsing method, thereby ensuring the accuracy of the parsing results in another dimension.
[0095] As one example, there is a situation where the first file includes link information, and the link information is used to obtain the second file. The link information may include a hyperlink, and the second file locally or in the cloud can be obtained based on the hyperlink.
[0096] Based on this, a regular expression is created in advance to match hyperlinks. Taking local hyperlinks as an example, local hyperlinks usually start with file: / / / , followed by the absolute path or relative path of the file. For example, the regular expression is: \bfile:\ / \ / \ / [^\s"]+\b, which matches a string of characters starting with file: / / / , followed by any string that does not contain blank characters or quotation marks.
[0097] Specifically, when the regular expression is actually applied, a text processing tool (such as Python's re module) is used to apply the regular expression in the first file, so that all local hyperlinks in the first file can be found.
[0098] After obtaining the link information, the second file is obtained based on the link information. Optionally, the absolute path list of the hyperlink document is pre-recorded and stored. After obtaining the link information, for each matched hyperlink, the part after file: / / / , i.e., the path of the file, is extracted. Furthermore, if the path is a relative path, it needs to be converted to an absolute path, for example, the current working directory or the directory where the file is located is determined, and the relative path is combined with it; if the path is an absolute path, it is used directly to obtain the file corresponding to the hyperlink, i.e., the second file.
[0099] Among them, all converted absolute paths are recorded in a list. After obtaining the hyperlink path list, if multiple hyperlinks are involved in the first file, the parallel quantity can be determined according to the device performance to perform parallel calls, thereby increasing the speed of obtaining the second file and improving the parsing speed of the first file.
[0100] Accordingly, after obtaining the second file, referring to the above steps, for the second file, the description information corresponding to the second file is obtained, and then the parsing method corresponding to the second file is determined according to the description information, and then the second file is parsed based on the parsing method corresponding to the second file to obtain the parsing result corresponding to the second file. The specific parsing process will not be described in detail.
[0101] After obtaining the parsing result corresponding to the second file, the parsing result corresponding to the second file and the parsing result corresponding to the first file can be used together as the parsing result of the first file, and the parsing result corresponding to the second file and the parsing result corresponding to the first file can be stored at the same address; the parsing result of the second file can also be not associated with the first file or not associated with the parsing result of the first file, that is, the parsing result of the second file is stored separately at one address, and the parsing result of the first file is stored at another address, and the two addresses can be associated with each other to represent the association between the first file and the second file. Of course, the two addresses can be independent of each other, and the embodiment of the present application does not make specific limitations on this.
[0102] In another example, there is a situation where the first file includes a subfile, that is, the first file is a folder. Based on this, when obtaining the first file, each subfile in the first file is obtained, and the subfile can be a document or a folder. Optionally, a recursive technique is used to obtain all subfiles in the first file.
[0103] Specifically, after obtaining the first file, the first file is traversed to obtain the document-type files and folders included in the first file. For the document, the document is parsed according to the above steps to obtain the corresponding parsing result; for the folder, the project is traversed again to obtain the documents and / or subfolders included in the folder.
[0104] In actual applications, for each folder, the above traversal steps are recursively executed until there is no subfolder in the traversal result, and the recursion ends.
[0105] For example, the name of the first file is a1, and the structure of a1 is as follows:
[0106] a1
[0107] ├──1.docx
[0108] ├──1.pptx
[0109] └──a2
[0110] ├──2.docx
[0111] └──2.pptx
[0112] According to the above traversal steps, traverse a1 and obtain that a1 includes 1.docx, 1.pptx and a2, and determine that 1.docx and 1.pptx belong to document files, and a2 belongs to a folder. Based on this, for 1.docx and 1.pptx, obtain their corresponding description information, and then determine their corresponding target parsing methods based on the description information, and parse them based on the target parsing method to obtain their corresponding parsing results. For a2, traverse a2 and obtain that a2 includes 2.docx and 2.pptx, and determine that 2.docx and 2.pptx belong to document files, that is, there are no subfolders in a2, and the recursion ends at this time. Similarly, 2.docx and 2.pptx are parsed respectively to obtain their corresponding parsing results.
[0113] The parsing results obtained by the parsing are stored. Similarly, the parsing results corresponding to 1.docx, 1.pptx, 2.docx, and 2.pptx can be used as the parsing results of a1; the parsing results corresponding to 1.docx and 1.pptx can also be used as the parsing results of a1, and the parsing results corresponding to 2.docx and 2.pptx can be used as the parsing results of a2. The parsing results of a1 can be associated with the parsing results of a2.
[0114] Based on the same inventive concept, the second aspect of the present application also provides an electronic device corresponding to a processing method. Since the principle of solving the problem by the electronic device in the present application is similar to the above-mentioned processing method of the present application, the implementation of the electronic device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0115] Figure 3 A schematic diagram of an electronic device provided in an embodiment of the present application is shown, specifically comprising:
[0116] A first obtaining module 301 is configured to obtain a first file, where the first file is a file to be parsed;
[0117] A second obtaining module 302, configured to obtain description information corresponding to the first file based on the first file;
[0118] A determination module 303 is configured to determine a target parsing method corresponding to the first file according to the description information;
[0119] A first parsing module 304, configured to parse the first file based on the target parsing method to obtain a parsing result corresponding to the first file;
[0120] The target parsing method is one or more of a first parsing method and a second parsing method. The first parsing method and the second parsing method have different parsing methods for objects of the same format. The object is part of or all of the information included in the file.
[0121] In yet another embodiment, the determination module 303 is specifically configured as follows:
[0122] If it is determined according to the description information that the file format of the first file belongs to the text type, or the proportion of objects in the first file in the text format exceeds a first preset proportion, then confirming that the target parsing method is the first parsing method;
[0123] If it is determined according to the description information that the file format of the first file belongs to the image type, or the proportion of objects in the image format in the first file exceeds a second preset proportion, then confirming that the target parsing method is the second parsing method;
[0124] The first parsing method is a text parsing method, and the second parsing method is a picture parsing method.
[0125] In yet another embodiment, the parsing result includes parsed content and tag information corresponding to the parsed content;
[0126] In the electronic device:
[0127] The tag information obtained by parsing the same object or the same file in the first parsing method and the second parsing method meets a similar condition.
[0128] In yet another embodiment, the first parsing method uses a text processing model, and the second parsing method uses an image processing model;
[0129] The electronic device further comprises a training module 305, which is configured as follows:
[0130] The text processing model and the image processing model are trained in advance using a training data set based on a similarity loss function, so that the similarity of the parsing results obtained by the trained text processing model and the image processing model is greater than a similarity threshold.
[0131] In yet another embodiment, the first file includes link information for obtaining the second file;
[0132] The electronic device further includes a second parsing module 306, which is configured as follows:
[0133] Based on the link information, obtaining the second file;
[0134] Obtaining description information corresponding to the second file;
[0135] Determine, according to the description information, a parsing method corresponding to the second file;
[0136] The second file is parsed based on the parsing method corresponding to the second file to obtain a parsing result corresponding to the second file.
[0137] In yet another embodiment,
[0138] taking the parsing result corresponding to the second file and the parsing result corresponding to the first file together as the parsing result of the first file; or
[0139] The parsing result of the second file is not associated with the first file or with the parsing result of the first file.
[0140] In yet another embodiment, the first file includes a plurality of sub-files;
[0141] The first obtaining module 301 is specifically configured as follows:
[0142] Each subfile in the first file is obtained.
[0143] In yet another embodiment, the first parsing module 304 is specifically configured as follows:
[0144] At least includes: converting the format of some objects in the first file.
[0145] The embodiment of the present application determines the corresponding target parsing method through the description information of the first file, and thus can accurately parse the first file. Moreover, the models used in the parsing process are all lightweight models, which greatly improves the parsing speed. Moreover, the text processing model and the image processing model are trained through the similarity loss function, which ensures the consistency of the parsing results obtained by the first parsing method and the second parsing method, thereby ensuring the accuracy of the parsing results in another dimension.
[0146] The present application also provides an electronic device. The structural diagram of the electronic device can be as follows: Figure 4 As shown, at least a memory 401 and a processor 402 are included, the memory 401 stores a computer program, and the processor 402 implements the method provided by any embodiment of the present application when executing the computer program on the memory 401. Exemplarily, the steps of the electronic device computer program are as follows S11-S14:
[0147] S11, obtaining a first file, where the first file is a file to be parsed;
[0148] S12, based on the first file, obtaining description information corresponding to the first file;
[0149] S13, determining a target parsing method corresponding to the first file according to the description information;
[0150] S14, parsing the first file based on the target parsing method to obtain a parsing result corresponding to the first file;
[0151] The target parsing method is one or more of a first parsing method and a second parsing method, the first parsing method and the second parsing method have different parsing methods for objects of the same format, and the objects are part of or all of the information included in the file;
[0152] The embodiment of the present application determines the corresponding target parsing method through the description information of the first file, and thus can accurately parse the first file. Moreover, the models used in the parsing process are all lightweight models, which greatly improves the parsing speed. Moreover, the text processing model and the image processing model are trained through the similarity loss function, which ensures the consistency of the parsing results obtained by the first parsing method and the second parsing method, thereby ensuring the accuracy of the parsing results in another dimension.
[0153] An embodiment of the present application provides a storage medium, which is a computer-readable medium and stores a computer program. When the computer program is executed by a processor, the method provided in any embodiment of the present application is implemented, including the following steps S21-S24:
[0154] S21, obtaining a first file, where the first file is a file to be parsed;
[0155] S22, based on the first file, obtaining description information corresponding to the first file;
[0156] S23, determining a target parsing method corresponding to the first file according to the description information;
[0157] S24, parsing the first file based on the target parsing method to obtain a parsing result corresponding to the first file;
[0158] The target parsing method is one or more of a first parsing method and a second parsing method. The first parsing method and the second parsing method have different parsing methods for objects of the same format. The object is part of or all of the information included in the file.
[0159] The embodiment of the present application determines the corresponding target parsing method through the description information of the first file, and thus can accurately parse the first file. Moreover, the models used in the parsing process are all lightweight models, which greatly improves the parsing speed. Moreover, the text processing model and the image processing model are trained through the similarity loss function, which ensures the consistency of the parsing results obtained by the first parsing method and the second parsing method, thereby ensuring the accuracy of the parsing results in another dimension.
[0160] Optionally, in this embodiment, the above-mentioned storage medium may include, but is not limited to, various media that can store program codes, such as a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk. Optionally, in this embodiment, the processor executes the method steps recorded in the above-mentioned embodiment according to the program code stored in the storage medium. Optionally, the specific examples in this embodiment can refer to the examples described in the above-mentioned embodiment and the optional implementation mode, and this embodiment is not repeated here. Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present application can be implemented with a general computing device, which can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices. Optionally, they can be implemented with executable program codes of computing devices, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from here, or they can be made into individual integrated circuit modules respectively, or multiple modules or steps in them can be made into a single integrated circuit module to implement. In this way, the present application is not limited to any specific combination of hardware and software.
[0161] In addition, although exemplary embodiments have been described herein, the scope includes any and all embodiments based on the present application with equivalent elements, modifications, omissions, combinations (e.g., various embodiments intersecting schemes), adaptations or changes. The elements in the claims will be interpreted broadly based on the language adopted in the claims, and are not limited to the examples described in this specification or during the implementation of the application, and the examples will be interpreted as non-exclusive. Therefore, this specification and examples are intended to be considered as examples only, and the true scope and spirit are indicated by the following claims and the full scope of their equivalents.
[0162] The above description is intended to be illustrative rather than restrictive. For example, the above examples (or one or more of them) can be used in combination with each other. For example, those of ordinary skill in the art can use other embodiments when reading the above description. In addition, in the above-mentioned specific embodiments, various features can be grouped together to simplify the application. This should not be interpreted as an intention that a disclosed feature that does not require protection is necessary for any claim. On the contrary, the subject matter of the present application may be less than all the features of a specific disclosed embodiment. Thus, the following claims are incorporated into the specific embodiments as examples or embodiments, wherein each claim is independently used as a separate embodiment, and it is considered that these embodiments can be combined with each other in various combinations or arrangements. The scope of the present application should be determined with reference to the attached claims and the full scope of equivalent forms granted by these claims.
[0163] Multiple embodiments of the present application are described in detail above, but the present application is not limited to these specific embodiments. Those skilled in the art can make various variations and modifications to the embodiments based on the concept of the present application, and these variations and modifications should all fall within the scope of protection required by the present application.
Claims
1. A processing method comprising: Obtaining a first file, where the first file is a file to be parsed; Based on the first file, obtaining description information corresponding to the first file; Determine, according to the description information, a target parsing method corresponding to the first file; Parsing the first file based on the target parsing method to obtain a parsing result corresponding to the first file; The target parsing method is one or more of a first parsing method and a second parsing method. The first parsing method and the second parsing method have different parsing methods for objects of the same format. The object is part of or all of the information included in the file.
2. According to the processing method of claim 1, determining the target parsing mode corresponding to the first file according to the description information comprises: If it is determined according to the description information that the file format of the first file belongs to the text type, or the proportion of objects in the first file in the text format exceeds a first preset proportion, then confirming that the target parsing method is the first parsing method; If it is determined according to the description information that the file format of the first file belongs to the image type, or the proportion of objects in the image format in the first file exceeds a second preset proportion, then confirming that the target parsing method is the second parsing method; The first parsing method is a text parsing method, and the second parsing method is a picture parsing method.
3. The processing method according to claim 2, wherein the parsing result includes parsed content and tag information corresponding to the parsed content; The processing method also includes: The tag information obtained by parsing the same object or the same file in the first parsing method and the second parsing method meets a similar condition.
4. The processing method according to any one of claim 3, wherein the first parsing method adopts a text processing model, and the second parsing method adopts an image processing model; The processing method also includes: The text processing model and the image processing model are trained in advance using a training data set based on a similarity loss function, so that the similarity of the parsing results obtained by the trained text processing model and the image processing model is greater than a similarity threshold.
5. The processing method according to claim 1, wherein the first file includes link information for obtaining the second file; The processing method also includes: Based on the link information, obtaining the second file; Obtaining description information corresponding to the second file; Determine, according to the description information, a parsing method corresponding to the second file; The second file is parsed based on the parsing method corresponding to the second file to obtain a parsing result corresponding to the second file.
6. The processing method according to claim 5, taking the parsing result corresponding to the second file and the parsing result corresponding to the first file together as the parsing result of the first file; or The parsing result of the second file is not associated with the first file or with the parsing result of the first file.
7. The processing method according to claim 1, wherein the first file includes a plurality of sub-files; The obtaining of the first file comprises: Each subfile in the first file is obtained.
8. The processing method according to any one of claims 1 to 7, wherein parsing the first file based on the target parsing mode at least comprises: Format conversion is performed on some objects in the first file.
9. An electronic device, comprising: A first obtaining module, configured to obtain a first file, where the first file is a file to be parsed; A second obtaining module, configured to obtain description information corresponding to the first file based on the first file; A determination module configured to determine a target parsing method corresponding to the first file according to the description information; A first parsing module, configured to parse the first file based on the target parsing method to obtain a parsing result corresponding to the first file; The target parsing method is one or more of a first parsing method and a second parsing method. The first parsing method and the second parsing method have different parsing methods for objects of the same format. The object is part of or all of the information included in the file.
10. The electronic device according to claim 9, wherein the determining module is specifically configured as follows: If it is determined according to the description information that the file format of the first file belongs to the text type, or the proportion of objects in the first file in the text format exceeds a first preset proportion, then confirming that the target parsing method is the first parsing method; According to the description information, if it is determined that the file format of the first file belongs to the image type, or If the proportion of objects in the first file in the form of pictures exceeds a second preset proportion, then confirming that the target parsing method is the second parsing method; The first parsing method is a text parsing method, and the second parsing method is a picture parsing method.
Citation Information
Patent Citations
File reading processing system, device, apparatus and method
CN106445899A
Emotion recognition method and device based on video electroencephalogram signals and computer equipment
CN112220455A
Document analysis method and device
CN116484833A
Image processing and model training method and device, equipment and storage medium
CN116977775A
Electronic document processing method and device, equipment and storage medium
CN116992853A
