External Link File Reading Method, Device, Computer Equipment and Storage Medium
By reading text paragraphs in DCC files and using regular expressions to match storage path rules, the problem of complex obtaining external link file paths is solved, and quick and easy access to path information is achieved, avoiding software installation and license acquisition.
Patent Information
- Application Number
- CN202210350436.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-02
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2042-04-02
AI Technical Summary
In film and television and game production, it is complicated to obtain the storage path information of external link files in DCC files, and requires software installation and permission to be obtained. The time to open large scene files is long, making it difficult to obtain external link files.
Read text paragraphs in the DCC file through text, use regular expressions to match the storage path rules of the external link file, and directly obtain storage path information without opening the DCC file.
It realizes quick and easy access to storage path information of external link files, avoids the steps of installing software and obtaining licenses, and improves efficiency.
Smart Images

Figure CN114691623B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of file processing, and particularly to an external link file reading method, device, computer device and storage medium. Background Art
[0002] In film and television and game production, a large number of DCC (Digital Content Creation) files need to be transferred between various users to achieve synchronous production. For example, DCC files can be files produced by software such as Maya, Nuke, Arnold, etc. DCC files usually have corresponding external link files (such as texture files, cache, etc. required in DCC files). When achieving synchronous production, it is necessary to transfer the DCC file and the corresponding external link file between various users. Since the storage path information of the external link file is recorded in the DCC file, to obtain the external link file, it is necessary to open the DCC file through the corresponding software of the DCC file, write a specific script to obtain the recorded storage path information of the external link file, and then obtain the external link file. However, opening the DCC file requires installing the corresponding software and obtaining a software license, or when the DCC file to be opened is a large scene file, the time to open the DCC file is long, resulting in a more complex process of obtaining the storage path information of the external link file, and thus it is difficult to obtain the external link file. Summary of the Invention
[0003] Embodiments of this application provide an external link file reading method, device, computer device and storage medium, which can conveniently and quickly obtain the storage path information of the external link file in the target file, and then simply obtain the external link file.
[0004] Embodiments of this application provide an external link file reading method, including:
[0005] Obtain a target file, where an external link file is linked to the target file;
[0006] Read the text paragraph in the target file in text mode;
[0007] Match the text in the text paragraph based on the storage path matching rule of the external link file;
[0008] If the match is successful, obtain the storage path information of the external link file based on the successfully matched text;
[0009] Read the external link file based on the storage path information.
[0010] Correspondingly, embodiments of this application also provide an external link file reading device, including:
[0011] A file acquisition unit for acquiring a target file, where an external link file is linked to the target file;
[0012] A paragraph reading unit for reading text paragraphs in the target file in text form;
[0013] A matching unit for matching the text in the text paragraphs based on the storage path matching rule of the external link file;
[0014] A path acquisition unit for, if the matching is successful, acquiring the storage path information of the external link file based on the successfully matched text;
[0015] A file reading unit for reading the external link file based on the storage path information.
[0016] Optionally, the paragraph reading unit is further configured to:
[0017] Acquire a first regular expression corresponding to the paragraph feature of the text paragraph in the target file;
[0018] Read the text in the target file in text form, and match the read text with the first regular expression;
[0019] If the matching is successful, read the text paragraph in the target file based on the successfully matched text.
[0020] Optionally, the first regular expression corresponding to the paragraph feature includes the start identifier and the end identifier of the text paragraph;
[0021] The paragraph reading unit is further configured to:
[0022] Read the text lines in the target file in text form, and match each text line with the start identifier and the end identifier in the first regular expression;
[0023] If the matching is successful, determine a first target character that matches the start identifier and a second target character that matches the end identifier in the text line;
[0024] Determine the text paragraph in the target file based on the first target character and the second target character.
[0025] Optionally, the paragraph reading unit is further configured to:
[0026] Divide the target file into several text blocks of a preset size, and read each text block in a preset order;
[0027] After the current text block is read, determine the already read text blocks that were read before the current text block based on the preset order;
[0028] Obtain the text other than the text paragraph of the target file in the read text block as candidate text;
[0029] Obtain the text paragraph in the text formed by merging the candidate text and the current text block until all text blocks are read in the preset order.
[0030] Optionally, the path obtaining unit is further configured to:
[0031] Obtain the text paragraph to which the successfully matched text belongs as the target text paragraph;
[0032] Obtain the location information of the target text paragraph in the target file;
[0033] Based on the location information of the target text paragraph, obtain the location information of the storage path information in the target file;
[0034] Generate data location record information based on the location information of the target text paragraph and the location information of the storage path information.
[0035] Optionally, the path obtaining unit is further configured to:
[0036] Obtain the target text block to which the target text paragraph belongs in the text block;
[0037] Determine the first position identifier of the target text paragraph in the target text block and the position offset of the target text block in the target file;
[0038] Calculate the location information of the target text paragraph based on the first position identifier and the position offset.
[0039] Optionally, the path obtaining unit is further configured to:
[0040] Obtain the second position identifier of the storage path information in the target text paragraph;
[0041] Calculate the location information of the storage path information based on the second position identifier and the location information of the target text paragraph.
[0042] Optionally, the path obtaining unit is further configured to:
[0043] Obtain the new storage path information of the target external link file whose path needs to be modified;
[0044] Obtain the location information of the target storage path information of the target external link file in the data location record information;
[0045] Based on the location information of the target storage path information, modify the target storage path information of the target external link file in the target file to the new storage path information, and generate a modified file.
[0046] Optionally, the path acquisition unit is further configured to:
[0047] Determine the target position of the target storage path information in the target file according to the location information of the target storage path information;
[0048] Obtain the first text between the start position of the text in the target file and the target position, and the second text between the target position and the end position of the text in the target file;
[0049] Concatenate the first text, the second text, and the new storage path information to generate the modified file.
[0050] Optionally, the matching unit is further configured to:
[0051] Obtain a second regular expression corresponding to the path feature of the storage path information of the external link file;
[0052] Match the text in the text paragraph with the second regular expression.
[0053] Similarly, an embodiment of the present application further provides a computer device, including:
[0054] A memory for storing a computer program;
[0055] A processor for executing the steps of any one of the external link file reading methods.
[0056] In addition, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of any one of the external link file reading methods are implemented.
[0057] An embodiment of the present application provides an external link file reading method, device, computer device, and storage medium. Through the storage path matching rule of the external link file, it is possible to directly match in the text paragraph of the target file without opening the target file such as a DCC file, so as to conveniently and quickly obtain the storage path information of the external link file recorded in the target file, and then simply obtain the external link file through the storage path information. In addition, it is possible to avoid installing software for opening DCC files and avoid obtaining permission for software for opening DCC files. Description of the Drawings
[0058] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings required for implementation in the embodiment descriptions. Obviously, the accompanying drawings in the following descriptions are only some embodiments of the present invention. For those skilled in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0059] Figure 1 It is a system schematic diagram of an external link file reading device provided by an embodiment of the present application;
[0060] Figure 2 It is a flowchart schematic diagram of an external link file reading method provided by an embodiment of the present application;
[0061] Figure 3 It is a schematic diagram of a text paragraph provided by an embodiment of the present application;
[0062] Figure 4 It is a schematic diagram of data position record information provided by an embodiment of the present application;
[0063] Figure 5 It is a structural schematic diagram of an external link file reading device provided by an embodiment of the present application;
[0064] Figure 6 It is a structural schematic diagram of a computer device provided by an embodiment of the present application. Specific implementation manners
[0065] The following will clearly and completely describe the technical solutions in the embodiments of the present application in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present invention.
[0066] The embodiments of the present application provide a method, apparatus, computer device, and storage medium for reading external link files. Specifically, the method for reading external link files in the embodiments of the present application can be executed by a computer device, where the computer device can be a terminal or a server, etc. The terminal can be a smart phone, a tablet computer, a notebook computer, a touch screen, a game console, a personal computer (PC), a personal digital assistant (PDA), and other terminal devices. The terminal can also include a client, and the client can be a game application client, a front-end browser client with a game program, or an instant messaging client, etc. The server can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution network services, and big data and artificial intelligence platforms.
[0067] Please refer to Figure 1 , Figure 1 which is a system schematic diagram of the external link file reading apparatus provided by the embodiments of the present application. The system can include at least two terminals, namely, terminal 101 for sending the target file and the external link file, and terminal 102 for receiving the target file and the external link file. Terminal 101 can be connected to terminal 102 through a network. For example, the network can be a wireless network or a wired network. The wireless network can be a wireless local area network (WLAN), a local area network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, etc. Terminal 101 is used to obtain the target file, and the external link file is linked to the target file; read the text paragraph in the target file in text mode; match the text in the text paragraph based on the storage path matching rule of the external link file; if the match is successful, obtain the storage path information of the external link file based on the successfully matched text; read the external link file based on the storage path information. And further send the target file and the external link file to terminal 102.
[0068] Terminal 102 is used to receive the target file and the external link file sent by terminal 101.
[0069] The following will be described in detail respectively. It should be noted that the description order of the following embodiments does not limit the preferred order of the embodiments.
[0070] This embodiment will be described from the perspective of the external link file reading apparatus. The external link file reading apparatus can be specifically integrated in a terminal device, and the terminal device can include devices such as smart phones, notebook computers, tablet computers, and personal computers.
[0071] An external link file reading method provided by an embodiment of the present application can be executed by a processor of a terminal. For example, Figure 2 As shown, the specific process of the external link file reading method mainly includes steps 201 to 205, which are described in detail as follows:
[0072] Step 201: Obtain a target file, and an external link file is linked to the target file.
[0073] In an embodiment of the present application, the target file can be a DCC (Digital Content Creation) file, that is, a file made by software such as Maya, Nuke, Arnold, etc. For example, the target file can be a file with a file suffix such as ma, nk, and ass.
[0074] In an embodiment of the present application, the external link file can be a file linked in the target file, that is, the storage path information of the external link file in the terminal can be recorded in the target file. For example, the external link file can be a texture file, cache, etc. required to form the target file.
[0075] Step 202: Read the text paragraphs in the target file in text mode.
[0076] In an embodiment of the present application, DCC files such as Maya and Nuke are all composed of multiple text paragraphs. To obtain the storage path information of the external link file recorded in the target file, the content of the target file can be read in units of text paragraphs. In addition, to avoid opening the DCC file through DCC software, the target file can be read in text mode through python.
[0077] In an embodiment of the present application, since the text paragraphs of the DCC file all have obvious paragraph features, multiple text paragraphs in the target file can be read according to the paragraph features. Specifically, "reading the text paragraphs in the target file in text mode" in step 202 above can be:
[0078] Obtain a first regular expression corresponding to the paragraph feature of the text paragraph in the target file;
[0079] Read the text in the target file in text mode, and match the read text with the first regular expression;
[0080] If the match is successful, read the text paragraph in the target file based on the text where the match is successful.
[0081] In the embodiment of the present application, the first regular expression corresponding to the paragraph feature may include a start identifier and an end identifier of the text paragraph. The start and end characters corresponding to the text paragraph in the target file can be identified through the start identifier and the end identifier, so as to determine the text paragraph. Specifically, the above step of "reading the text in the target file in text mode and matching the read text with the first regular expression" may be: reading the text lines in the target file in text mode and matching each text line with the start identifier and the end identifier in the first regular expression. At this time, the above step of "if the match is successful, read the text paragraph in the target file based on the successfully matched text" may be: if the match is successful, determine the first target character that matches the start identifier and the second target character that matches the end identifier in the text line; determine the text paragraph in the target file based on the first target character and the second target character.
[0082] In the embodiment of the present application, after determining the first target character that matches the start identifier and the second target character that matches the end identifier, determine the first target character and the second target character corresponding to the start and end, and then determine the text between the first target character and the second target character corresponding to the start and end as the text paragraph.
[0083] For example, if the text paragraphs of the target file all start with "nodeType{", then the content of the text paragraph is on a new line, and finally end with "}" immediately, it can be determined that the paragraph feature of the text paragraph of the target file is nodeType{……}, and then the paragraph feature is converted into the first regular expression according to the conversion rules of the regular expression as (?<=\n)([\S]+){(.*?)\n}\n, where (?<=\n)([\S]+) represents nodeType, the parentheses "{" and "}" represent the two parentheses in the paragraph feature respectively, (.*?) represents the content in the text paragraph, and \n represents a line break. Read the text in the target file according to the first regular expression converted from the paragraph feature, determine the first target character corresponding to (?<=\n)([\S]+) and the second target character corresponding to \n}\n, so as to determine the text paragraph according to the corresponding relationship of the parentheses. Please refer to Figure 3 The schematic diagram of the text paragraph shown. The character corresponding to label 1 in the figure is the first target character corresponding to the start identifier, the character corresponding to label 2 is the second target character corresponding to the end identifier, and the partial characters corresponding to label 3 are the text content included in the text paragraph.
[0084] In the embodiments of the present application, reading the text and determining whether there is a text paragraph are single-threaded, that is, it is necessary to first read the text and then determine whether there is a text paragraph in the read text. When the target file is relatively large, if the entire text is read and then it is analyzed whether there is a text paragraph in the read text block, it takes a long time. Therefore, the target file is read in chunks, and each chunk is analyzed after being read. Specifically, "reading the text paragraph in the target file in text mode" in step 202 above may be:
[0085] Dividing the target file into several text blocks of a preset size and reading each text block in a preset order;
[0086] After the current text block is read, determining the already-read text blocks that have been read before the current text block based on the preset order;
[0087] Obtaining the text other than the text paragraph of the target file in the already-read text blocks as candidate text;
[0088] Obtaining the text paragraph in the text formed by merging the candidate text and the current text block until all the text blocks are read in the preset order.
[0089] In the embodiments of the present application, the specific value of the preset size is not limited and can be flexibly set according to the actual situation. For example, the preset size can be set to 10 megabytes, that is, the target file is divided into multiple text blocks of 10 megabytes. Among them, the way of dividing the text can be set arbitrarily, that is, each text block is divided in turn according to the offset of the text in the target file. In addition, the preset order of reading each text block is not limited and can be flexibly set according to the actual situation. For example, the preset order can be determined according to the offset of the text included in each text block in the target file.
[0090] Specifically, if the target file is 50 megabytes, the text in the target file is sequentially divided into 5 text blocks each with a size of 10 megabytes in the order from the front to the back, and each text block is read sequentially in the order from the front to the back in the target file. After the first text block is read, an iterator of the first regular expression is used to match the text in the first text block to determine the characters in the first text block that match the first regular expression, and other unmatched characters are skipped to determine the text paragraphs in the first text block. Then, the text in the first text block except for the text paragraphs is used as candidate text. After the second text block is read, the candidate text corresponding to the first text block is merged with the second text block for analysis to obtain the text paragraphs included after the merge. Then, the text in the merged text except for the text paragraphs is continued to be used as candidate text and merged with the third read text block to analyze whether there are text paragraphs until all the text blocks in the target file are read. Merging the text in each text block except for the text paragraphs with other unread text to analyze whether there are text paragraphs can ensure that no partial text paragraphs are missed because the random reading point is not at the end position of the text paragraph.
[0091] Step 203: Match the text in the text paragraphs based on the storage path matching rule of the external link file.
[0092] In the embodiment of the present application, the storage path matching rule of the external link file may be the path feature for determining the storage path information of the external link file, and the text matching the path feature is determined in the text of each text paragraph. Specifically, "matching the text in the text paragraphs based on the storage path matching rule of the external link file" in the above step 203 may be:
[0093] Obtain the second regular expression corresponding to the path feature of the storage path information of the external link file;
[0094] Match the text in the text paragraph with the second regular expression.
[0095] In the embodiment of the present application, it is determined that the path feature of the storage path information is that the file character is followed by a link character, which is the path feature of the storage path information. For example, as Figure 3 shown, it is determined that the character corresponding to label 4 is the storage path information of the external link file.
[0096] Step 204: If the match is successful, obtain the storage path information of the external link file based on the successfully matched text.
[0097] In an embodiment of the present application, after obtaining the storage path information of the external link file, the storage path information can be modified. To obtain the storage path information of the external link file from the target file more quickly, the position of the storage path information in the target file can be recorded. Specifically, after the above step 204 "obtain the storage path information of the external link file based on the text with successful matching", the following steps can be included:
[0098] Obtain the text paragraph to which the text with successful matching belongs as the target text paragraph;
[0099] Obtain the position information of the target text paragraph in the target file;
[0100] Based on the position information of the target text paragraph, obtain the position information of the storage path information in the target file;
[0101] Generate data position record information based on the position information of the target text paragraph and the position information of the storage path information.
[0102] In an embodiment of the present application, the position information of the target text paragraph is used to identify the position of the target text paragraph in the target file, and the position information of the storage path information is used to identify the position of the storage path information in the target file.
[0103] In an implementation manner of the present application, the above step "obtain the position information of the target text paragraph in the target file" can be:
[0104] Obtain the target text block to which the target text paragraph belongs in the text block;
[0105] Determine the first position identifier of the target text paragraph in the target text block, and the position offset of the target text block in the target file;
[0106] Calculate the position information of the target text paragraph based on the first position identifier and the position offset.
[0107] Specifically, after matching the target text paragraph with the iterator of the first regular expression, obtain the first position identifier of the target text paragraph in the target text block to which it belongs from the iterator. Since the target text paragraph includes the first target character at the beginning of the paragraph and the second target character at the end of the paragraph, the first position identifier of the first target character in the target text block and the first position identifier of the second target character in the target text block can be determined respectively. For example, according to the iterator, the first position identifier of the target text paragraph a in the target text block A is [Astart, AEnd]. According to the division order of the target text block A in the target file, determine that the position offset of the target text block A in the target file is OffsetA, then the position information of the target text paragraph in the target file can be determined as [OffsetA + Astart, OffsetA + AEnd].
[0108] In an embodiment of the present application, the first position identifier may be the position offsets of the first target character and the second target character in the target text block, that is, the number of bits by which the positions of the first target character and the second target character in the target text block are offset relative to the characters at the beginning of the target text block.
[0109] In an embodiment of the present application, since the storage path information is located in the target text paragraph, the position information of the storage path information can be determined according to the position information of the target text paragraph. Specifically, the above step of "obtaining the position information of the storage path information in the target file based on the position information of the target text paragraph" may be:
[0110] Obtain a second position identifier of the storage path information in the target text paragraph;
[0111] Calculate the position information of the storage path information based on the second position identifier and the position information of the target text paragraph.
[0112] In an embodiment of the present application, the second position identifier of the storage path information in the target text paragraph may be the position offset of the storage path information in the target text paragraph, or the positional relationship between the storage path information and the target text paragraph, etc.
[0113] For example, it is determined that the position offset of the first character (i.e., the character corresponding to label 1 in Figure 3 ) included in the text paragraph Read shown in the target file is 1912, and it is determined that the position offset of the last character (i.e., the character corresponding to label 2 in Figure 3 ) in the target file is 2186. It is determined that the position offset of the external link file (i.e., the character corresponding to label 4 in Figure 3 ) included in the text paragraph Read in the target file is from 1950 to 1996. Then, the data position record information of the text paragraph Read shown in Figure 3 can be formed by combining the format of the text paragraph and the external link file, that is, Figure 4 the character corresponding to label 4 in Figure 4 is the position offset of the character corresponding to label 1 in Figure 3 in the target file, the character corresponding to label 5 is the position offset of the character corresponding to label 2 in Figure 3 in the target file, and the character corresponding to label 6 is the position offset of the character corresponding to label 4 in Figure 3 in the target file.
[0114] In an embodiment of the present application, the storage path information of the external link file can be modified to form a modified file containing the new storage path information. Specifically, after the above step of "generating data position record information based on the position information of the target text paragraph and the position information of the storage path information", the following steps are further included:
[0115] Obtain the new storage path information of the target external link file whose path needs to be modified;
[0116] Obtain the position information of the target storage path information of the target external link file in the data position record information;
[0117] Based on the position information of the target storage path information, modify the target storage path information of the target external link file to the new storage path information in the target file, and generate a modified file.
[0118] In the embodiment of the present application, the above step "Based on the position information of the target storage path information, modify the target storage path information of the target external link file to the new storage path information in the target file, and generate a modified file" may be:
[0119] Determine the target position of the target storage path information in the target file according to the position information of the target storage path information;
[0120] Obtain the first text between the start position of the text in the target file and the target position, and the second text between the target position and the end position of the text in the target file;
[0121] Concatenate the first text, the second text and the new storage path information to generate a modified file.
[0122] For example, as Figure 4 shown, if the storage path information of the external link file recorded in Figure 4 K: / G10_GuanYu / Comp / shot03 / sucai / ID / ID_#.exr is to be modified to the new storage path information D: / newPath / ID_#.exr, the content to be generated is the data from the 0th bit to the 1950th bit of the original target file, plus the new storage path information D: / newPath / ID_#.exr, plus the data from the 1997th bit to the end bit of the original target file.
[0123] In the embodiment of the present application, by re-copying the text in the target file except the storage path information and combining it with the new storage path information to form a modified file, it is possible to quickly modify the file information, and at the same time, without destroying the structure of the original file, so that the modified file still maintains the file framework of the original target file, avoiding affecting the reading of the modified file.
[0124] Step 205: Read the external link file based on the storage path information.
[0125] In the embodiments of the present application, since the storage path information is used to identify the storage location of the external link file in the terminal, after obtaining the storage path information, the external link file can be obtained. In addition, when the storage path information is updated, the external link file is read according to the updated new storage path information.
[0126] Any combination of the above technical solutions can form an optional embodiment of the present application, which will not be elaborated here one by one.
[0127] The method for reading an external link file provided by the embodiments of the present application can directly match in the text paragraph of the target file without opening the target file such as a DCC file through the storage path matching rule of the external link file, so as to conveniently and quickly obtain the storage path information of the external link file recorded in the target file, and then simply obtain the external link file through the storage path information. In addition, it is possible to avoid installing software for opening DCC files and avoid obtaining permission for software for opening DCC files.
[0128] To facilitate better implementation of the method for reading an external link file in the embodiments of the present application, the embodiments of the present application also provide an external link file reading device. Please refer to Figure 5 , Figure 5 which is a schematic structural diagram of the external link file reading device provided by the embodiments of the present application. The external link file reading device may include a file acquisition unit 501, a paragraph reading unit 502, a matching unit 503, a path acquisition unit 504, and a file reading unit 505.
[0129] Among them, the file acquisition unit 501 is used to acquire a target file, and an external link file is linked to the target file;
[0130] The paragraph reading unit 502 is used to read the text paragraph in the target file in text mode;
[0131] The matching unit 503 is used to match the text in the text paragraph based on the storage path matching rule of the external link file;
[0132] The path acquisition unit 504 is used to, if the matching is successful, acquire the storage path information of the external link file based on the successfully matched text;
[0133] The file reading unit 505 is used to read the external link file based on the storage path information.
[0134] Optionally, the paragraph reading unit 502 is further used to:
[0135] acquire a first regular expression corresponding to the paragraph feature of the text paragraph in the target file;
[0136] read the text in the target file in text mode, and match the read text with the first regular expression;
[0137] If the match is successful, read the text paragraph in the target file based on the successfully matched text.
[0138] Optionally, the first regular expression corresponding to the paragraph feature includes the start identifier and the end identifier of the text paragraph.
[0139] The paragraph reading unit 502 is further configured to:
[0140] Read the text lines in the target file in text mode, and match each text line with the start identifier and the end identifier in the first regular expression.
[0141] If the match is successful, determine the first target character that matches the start identifier and the second target character that matches the end identifier in the text line.
[0142] Determine the text paragraph in the target file based on the first target character and the second target character.
[0143] Optionally, the paragraph reading unit 502 is further configured to:
[0144] Divide the target file into several text blocks of a preset size, and read each text block in a preset order.
[0145] After the current text block is read, determine the already read text blocks that have been read before the current text block based on the preset order.
[0146] Obtain the text other than the text paragraph of the target file in the already read text blocks as candidate text.
[0147] Obtain the text paragraph in the text formed by merging the candidate text and the current text block until all the text blocks are read in the preset order.
[0148] Optionally, the path obtaining unit 504 is further configured to:
[0149] Obtain the text paragraph to which the successfully matched text belongs as the target text paragraph.
[0150] Obtain the location information of the target text paragraph in the target file.
[0151] Obtain the location information of the location storing the path information in the target file based on the location information of the target text paragraph.
[0152] Generate data location record information based on the location information of the target text paragraph and the location information of the location storing the path information.
[0153] Optionally, the path obtaining unit 504 is further configured to:
[0154] Get the target text block to which the target text paragraph belongs in the text block;
[0155] Determining a first position identifier of a target text paragraph in a target text block and a position offset of the target text block in a target file;
[0156] The position information of the target text paragraph is calculated based on the first position identifier and the position offset.
[0157] Optionally, the path acquisition unit 504 is further configured to:
[0158] Obtaining a second position identifier of the storage path information in the target text paragraph;
[0159] The location information of the storage path information is calculated based on the second location identifier and the location information of the target text paragraph.
[0160] Optionally, the path acquisition unit 504 is further configured to:
[0161] Get the new storage path information of the target external link file whose path needs to be modified;
[0162] Obtaining location information of target storage path information of the target external link file in the data location record information;
[0163] Based on the location information of the target storage path information, the target storage path information of the target external link file is modified to the new storage path information in the target file to generate a modified file.
[0164] Optionally, the path acquisition unit 504 is further configured to:
[0165] Determine the target location of the target storage path information in the target file according to the location information of the target storage path information;
[0166] Obtain the first text between the start position and the target position of the text in the target file, and the second text between the target position and the end position of the text in the target file;
[0167] The first text, the second text and the new storage path information are concatenated to generate a modified file.
[0168] Optionally, the matching unit 503 is further configured to:
[0169] Obtain a second regular expression corresponding to the path feature of the storage path information of the external link file;
[0170] Matches text within a text paragraph against the second regular expression.
[0171] All of the above technical solutions can be combined in any way to form optional embodiments of the present application, and will not be described in detail here.
[0172] The external link file reading device provided by the embodiment of the present application obtains a target file through the file acquisition unit 501. An external link file is linked to the target file. Then, the text paragraph in the target file is read in text mode through the paragraph reading unit 502. Next, the text in the text paragraph is matched by the matching unit 503 based on the storage path matching rule of the external link file. After that, if the matching is successful, the path acquisition unit 504 determines the storage path information of the external link file based on the successfully matched text. Finally, the external link file is read by the file reading unit 505 based on the storage path information. It is possible to directly perform matching in the text paragraph of the target file without opening the target file such as a DCC file, so as to conveniently and quickly obtain the storage path information of the external link file recorded in the target file, and then simply obtain the external link file through the storage path information. In addition, it is possible to avoid installing software for opening DCC files and avoid obtaining permission for software for opening DCC files.
[0173] Correspondingly, the embodiment of the present application further provides a computer device. The computer device may be a terminal, and the terminal may be a smart phone, a tablet computer, a notebook computer, a touch screen, a game console, a personal computer, a personal digital assistant and other terminal devices. As Figure 6 shown, Figure 6 is a schematic structural diagram of the computer device provided by the embodiment of the present application. The computer device 600 includes a processor 601 with one or more processing cores, a memory 602 with one or more computer-readable storage media, and a computer program stored in the memory 602 and executable on the processor. Among them, the processor 601 is electrically connected to the memory 602. Those skilled in the art can understand that the structure of the computer device shown in the figure does not limit the computer device, and may include more or fewer components than shown, or combine some components, or arrange different components.
[0174] The processor 601 is the control center of the computer device 600, connects various parts of the entire computer device 600 through various interfaces and lines, and executes various functions of the computer device 600 and processes data by running or loading software programs and / or modules stored in the memory 602, and calling data stored in the memory 602, thereby performing overall monitoring of the computer device 600.
[0175] In the embodiment of the present application, the processor 601 in the computer device 600 will load the instructions corresponding to the processes of one or more application programs into the memory 602 according to the following steps, and the processor 601 will run the application programs stored in the memory 602 to implement various functions:
[0176] Obtain a target file, and an external link file is linked to the target file;
[0177] Read the text paragraph in the target file in text mode;
[0178] Match the text in the text paragraph based on the storage path matching rule of the external link file;
[0179] If the match is successful, obtain the storage path information of the external link file based on the successfully matched text;
[0180] Read the external link file based on the storage path information.
[0181] In the embodiment of the present application, reading the text paragraph in the target file in text mode includes:
[0182] Obtain the first regular expression corresponding to the paragraph feature of the text paragraph in the target file;
[0183] Read the text in the target file in text mode, and match the read text with the first regular expression;
[0184] If the match is successful, read the text paragraph in the target file based on the successfully matched text.
[0185] In the embodiment of the present application, the first regular expression corresponding to the paragraph feature includes the start identifier and the end identifier of the text paragraph;
[0186] Reading the text in the target file in text mode and matching the read text with the first regular expression includes:
[0187] Read the text line in the target file in text mode, and match each text line with the start identifier and the end identifier in the first regular expression;
[0188] If the match is successful, reading the text paragraph in the target file based on the successfully matched text includes:
[0189] If the match is successful, determine the first target character that matches the start identifier and the second target character that matches the end identifier in the text line;
[0190] Determine the text paragraph in the target file based on the first target character and the second target character.
[0191] In the embodiment of the present application, reading the text paragraph in the target file in text mode includes:
[0192] Divide the target file into several text blocks of a preset size, and read each text block in a preset order;
[0193] After the current text block is read, determine the read text blocks that have been read before the current text block based on a preset order;
[0194] Obtain the text other than the text paragraph of the target file in the read text blocks as candidate text;
[0195] Obtain text paragraphs in the text formed by merging the candidate text and the current text block until all text blocks are read in the preset order.
[0196] In an embodiment of the present application, if the matching is successful, after obtaining the storage path information of the external link file based on the successfully matched text, it further includes:
[0197] Obtain the text paragraph to which the successfully matched text belongs as the target text paragraph;
[0198] Obtain the position information of the target text paragraph in the target file;
[0199] Based on the position information of the target text paragraph, obtain the position information of the storage path information in the target file;
[0200] Generate data position record information based on the position information of the target text paragraph and the position information of the storage path information.
[0201] In an embodiment of the present application, obtaining the position information of the target text paragraph in the target file includes:
[0202] Obtain the target text block to which the target text paragraph belongs in the text block;
[0203] Determine the first position identifier of the target text paragraph in the target text block and the position offset of the target text block in the target file;
[0204] Calculate the position information of the target text paragraph based on the first position identifier and the position offset.
[0205] In an embodiment of the present application, obtaining the position information of the storage path information in the target file based on the position information of the target text paragraph includes:
[0206] Obtain the second position identifier of the storage path information in the target text paragraph;
[0207] Calculate the position information of the storage path information based on the second position identifier and the position information of the target text paragraph.
[0208] In an embodiment of the present application, after generating the data position record information based on the position information of the target text paragraph and the position information of the storage path information, it further includes:
[0209] Obtain the new storage path information of the target external link file whose path needs to be modified;
[0210] Obtain the location information of the target storage path information of the target external link file in the data location record information;
[0211] Based on the location information of the target storage path information, modify the target storage path information of the target external link file to the new storage path information in the target file, and generate a modified file.
[0212] In the embodiment of the present application, based on the location information of the target storage path information, modifying the target storage path information of the target external link file to the new storage path information in the target file and generating a modified file includes:
[0213] Determine the target position of the target storage path information in the target file according to the location information of the target storage path information;
[0214] Obtain the first text between the start position of the text in the target file and the target position, and the second text between the target position and the end position of the text in the target file;
[0215] Concatenate the first text, the second text, and the new storage path information to generate a modified file.
[0216] In the embodiment of the present application, based on the storage path matching rule of the external link file, match the text in the text paragraph, including:
[0217] Obtain the second regular expression corresponding to the path feature of the storage path information of the external link file;
[0218] Match the text in the text paragraph with the second regular expression.
[0219] For the specific implementation of each of the above operations, reference may be made to the previous embodiments, which will not be elaborated here.
[0220] Optionally, as Figure 6 shown, the computer device 600 further includes: a touch display screen 603, a radio frequency circuit 604, an audio circuit 605, an input unit 606, and a power supply 607. Among them, the processor 601 is electrically connected to the touch display screen 603, the radio frequency circuit 604, the audio circuit 605, the input unit 606, and the power supply 607 respectively. Those skilled in the art can understand that Figure 6 the computer device structure shown in
[0221] The touch display screen 603 can be used to display a graphical user interface and receive operation instructions generated by a user's interaction with the graphical user interface. The touch display screen 603 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the computer device. These graphical user interfaces can be composed of graphics, text, icons, videos, and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. The touch panel can be used to collect touch operations of the user on or near it (such as operations of the user using any suitable object or accessory such as a finger or a stylus on or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute the corresponding program. Optionally, the touch panel can include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the touch position of the user and detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 601, and can receive and execute the commands sent by the processor 601. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 601 to determine the type of touch event. Subsequently, the processor 601 provides a corresponding visual output on the display panel according to the type of touch event. In the embodiments of the present application, the touch panel and the display panel can be integrated into the touch display screen 603 to implement input and output functions. However, in some embodiments, the touch panel and the touch panel can be implemented as two independent components to implement input and output functions. That is, the touch display screen 603 can also be used as part of the input unit 606 to implement the input function.
[0222] In the embodiments of the present application, the processor 601 obtains the target file stored in the computer device 600, reads the text paragraph in the target file based on the paragraph features of the text paragraph, and determines the storage path information in the text paragraph based on the storage path matching rule.
[0223] The radio frequency circuit 604 can be used to transmit and receive radio frequency signals to establish wireless communication with a network device or other computer devices through wireless communication, and transmit and receive signals with the network device or other computer devices.
[0224] The audio circuit 605 can be used to provide an audio interface between the user and the computer device through a speaker and a microphone. The audio circuit 605 can convert the received audio data into an electrical signal and transmit it to the speaker, which converts it into a sound signal for output. On the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 605, converted into audio data, and then the audio data is output to the processor 601 for processing. After that, it is sent through the radio frequency circuit 604 to, for example, another computer device, or the audio data is output to the memory 602 for further processing. The audio circuit 605 may also include an earphone jack to provide communication between the peripheral earphone and the computer device.
[0225] The input unit 606 can be used to receive input digital, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
[0226] The power supply 607 is used to supply power to each component of the computer device 600. Optionally, the power supply 607 can be logically connected to the processor 601 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 607 may also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.
[0227] Although Figure 6 not shown in the figure, the computer device 600 may also include a camera, a sensor, a Wi-Fi module, a Bluetooth module, etc., which will not be elaborated here.
[0228] In the above embodiments, the descriptions of each embodiment have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0229] As can be seen from the above, the computer device provided in this embodiment can directly match in the text paragraphs of the target file without opening the target file such as a DCC file through the storage path matching rule of the external link file, so as to conveniently and quickly obtain the storage path information of the external link file recorded in the target file, and then simply obtain the external link file through the storage path information. In addition, it is possible to avoid installing software for opening DCC files and avoid obtaining the permission to open the software for opening DCC files.
[0230] Those of ordinary skill in the art can understand that all or part of the steps in the above methods of each embodiment can be completed by instructions or by controlling relevant hardware through instructions. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0231] To this end, an embodiment of the present application provides a computer-readable storage medium, which stores multiple computer programs that can be loaded by a processor to execute the steps in any of the external link file reading methods provided by the embodiments of the present application. For example, the computer program can execute the following steps:
[0232] Obtain a target file, and an external link file is linked to the target file;
[0233] Read the text paragraph in the target file in text mode;
[0234] Match the text in the text paragraph based on the storage path matching rule of the external link file;
[0235] If the match is successful, obtain the storage path information of the external link file based on the successfully matched text;
[0236] Read the external link file based on the storage path information.
[0237] In the embodiment of the present application, reading the text paragraph in the target file in text mode includes:
[0238] Obtain the first regular expression corresponding to the paragraph feature of the text paragraph in the target file;
[0239] Read the text in the target file in text mode, and match the read text with the first regular expression;
[0240] If the match is successful, read the text paragraph in the target file based on the successfully matched text.
[0241] In the embodiment of the present application, the first regular expression corresponding to the paragraph feature includes the start identifier and the end identifier of the text paragraph;
[0242] Reading the text in the target file in text mode and matching the read text with the first regular expression includes:
[0243] Read the text line in the target file in text mode, and match each text line with the start identifier and the end identifier in the first regular expression;
[0244] If the match is successful, reading the text paragraph in the target file based on the successfully matched text includes:
[0245] If the match is successful, determine the first target character that matches the start identifier and the second target character that matches the end identifier in the text line;
[0246] Determine the text paragraph in the target file based on the first target character and the second target character.
[0247] In an embodiment of the present application, reading a text paragraph in a target file in text mode includes:
[0248] Dividing the target file into several text blocks of a preset size and reading each text block in a preset order;
[0249] After the current text block is read, determining the read text blocks that have been read and completed before the current text block based on the preset order;
[0250] Obtaining the text other than the text paragraph of the target file in the read text blocks as candidate text;
[0251] Obtaining a text paragraph in the text formed by merging the candidate text and the current text block until all text blocks are read in the preset order.
[0252] In an embodiment of the present application, if the matching is successful, after obtaining the storage path information of the external link file based on the successfully matched text, it further includes:
[0253] Obtaining the text paragraph to which the successfully matched text belongs as the target text paragraph;
[0254] Obtaining the position information of the target text paragraph in the target file;
[0255] Obtaining the position information of the storage path information in the target file based on the position information of the target text paragraph;
[0256] Generating data position record information based on the position information of the target text paragraph and the position information of the storage path information.
[0257] In an embodiment of the present application, obtaining the position information of the target text paragraph in the target file includes:
[0258] Obtaining the target text block to which the target text paragraph belongs in the text block;
[0259] Determining the first position identifier of the target text paragraph in the target text block and the position offset of the target text block in the target file;
[0260] Calculating the position information of the target text paragraph based on the first position identifier and the position offset.
[0261] In an embodiment of the present application, obtaining the position information of the storage path information in the target file based on the position information of the target text paragraph includes:
[0262] Obtaining the second position identifier of the storage path information in the target text paragraph;
[0263] Calculating the position information of the storage path information based on the second position identifier and the position information of the target text paragraph.
[0264] In an embodiment of the present application, after generating data location record information based on the location information of the target text paragraph and the location information of the storage path information, the following steps are further included:
[0265] Obtain the new storage path information of the target external link file that needs to modify the path;
[0266] Obtain the location information of the target storage path information of the target external link file in the data location record information;
[0267] Based on the location information of the target storage path information, modify the target storage path information of the target external link file to the new storage path information in the target file to generate a modified file.
[0268] In an embodiment of the present application, based on the location information of the target storage path information, modifying the target storage path information of the target external link file to the new storage path information in the target file to generate a modified file includes:
[0269] Determine the target location of the target storage path information in the target file according to the location information of the target storage path information;
[0270] Obtain the first text between the start position of the text in the target file and the target position, and the second text between the target position and the end position of the text in the target file;
[0271] Concatenate the first text, the second text, and the new storage path information to generate a modified file.
[0272] In an embodiment of the present application, matching the text in the text paragraph based on the storage path matching rule of the external link file includes:
[0273] Obtain the second regular expression corresponding to the path feature of the storage path information of the external link file;
[0274] Match the text in the text paragraph with the second regular expression.
[0275] For the specific implementation of each of the above operations, reference can be made to the previous embodiments, which will not be elaborated here.
[0276] Among them, the storage medium may include: Read Only Memory (ROM), Random Access Memory (RAM), magnetic disk, optical disc, etc.
[0277] Since the computer program stored in the storage medium can execute the steps in any of the external link file reading methods provided by the embodiments of the present application, the beneficial effects achievable by any of the external link file reading methods provided by the embodiments of the present application can be realized. For details, refer to the previous embodiments and will not be elaborated here.
[0278] In the above embodiments, the descriptions of the respective embodiments have their own focuses. For parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0279] The above has introduced in detail an external link file reading method, device, computer device, and storage medium provided by the embodiments of the present application. Specific examples are used herein to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the technical solution and its core idea of the present invention; those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An external link file reading method, characterized in that, Including: Obtain a target file, and an external link file is linked to the target file; Read the text paragraph in the target file in text mode; Match the text in the text paragraph based on the storage path matching rule of the external link file; If the match is successful, obtain the storage path information of the external link file based on the successfully matched text; Read the external link file based on the storage path information; Wherein, the reading the text paragraph in the target file in text mode includes: Divide the target file into several text blocks of a preset size, and read each text block in a preset order; After the current text block is read, determine the already read text blocks that have been read before the current text block based on the preset order; Obtain the text other than the text paragraph of the target file in the already read text blocks as candidate text; Obtain the text paragraph in the text formed by merging the candidate text and the current text block until all text blocks are read in the preset order.
2. The method according to claim 1, characterized in that The reading the text paragraph in the target file in text mode includes: Obtain a first regular expression corresponding to the paragraph feature of the text paragraph in the target file; Read the text in the target file in text mode, and match the read text with the first regular expression; If the match is successful, read the text paragraph in the target file based on the successfully matched text.
3. The method according to claim 2, wherein The first regular expression corresponding to the paragraph feature includes the start identifier and the end identifier of the text paragraph; The reading the text in the target file in text mode and matching the read text with the first regular expression includes: Read the text lines in the target file in text mode, and match each text line with the start identifier and the end identifier in the first regular expression; The if the match is successful, reading the text paragraph in the target file based on the successfully matched text includes: If the match is successful, determine a first target character that matches the start identifier and a second target character that matches the end identifier in the text line; Determine the text paragraph in the target file based on the first target character and the second target character.
4. The method according to claim 1, characterized in that After the if the match is successful, obtaining the storage path information of the external link file based on the successfully matched text, further includes: Obtain the text paragraph to which the successfully matched text belongs as the target text paragraph; Obtain the position information of the target text paragraph in the target file; Obtain the position information of the storage path information in the target file based on the position information of the target text paragraph; Generate data position record information based on the position information of the target text paragraph and the position information of the storage path information.
5. The method according to claim 4, characterized in that The obtaining the position information of the target text paragraph in the target file includes: Obtain the target text block to which the target text paragraph belongs in the text block; Determine the first position identifier of the target text paragraph in the target text block and the position offset of the target text block in the target file; Calculate the position information of the target text paragraph based on the first position identifier and the position offset.
6. The method according to claim 5, characterized in that The obtaining the position information of the storage path information in the target file based on the position information of the target text paragraph includes: Obtain a second position identifier of the storage path information in the target text paragraph; Calculate the position information of the storage path information based on the second position identifier and the position information of the target text paragraph.
7. The method according to any one of claims 4 to 6, characterized in that After generating the data position record information based on the position information of the target text paragraph and the position information of the storage path information, it further includes: Obtain the new storage path information of the target external link file whose path needs to be modified; Obtain the position information of the target storage path information of the target external link file in the data position record information; Based on the position information of the target storage path information, modify the target storage path information of the target external link file to the new storage path information in the target file to generate a modified file.
8. The method according to claim 7, characterized in that The modifying the target storage path information of the target external link file to the new storage path information in the target file based on the position information of the target storage path information to generate a modified file includes: Determine the target position of the target storage path information in the target file according to the position information of the target storage path information; Obtain a first text between the start position of the text in the target file and the target position, and a second text between the target position and the end position of the text in the target file; Concatenate the first text, the second text, and the new storage path information to generate the modified file.
9. The method according to claim 1, wherein The matching the text in the text paragraph based on the storage path matching rule of the external link file includes: Obtain a second regular expression corresponding to the path feature of the storage path information of the external link file; Match the text in the text paragraph with the second regular expression.
10. An external link file reading device, characterized in that, It includes: A file acquisition unit for acquiring a target file, and an external link file is linked to the target file; A paragraph reading unit for reading the text paragraph in the target file in text mode; A matching unit for matching the text in the text paragraph based on the storage path matching rule of the external link file; A path acquisition unit for, if the matching is successful, acquiring the storage path information of the external link file based on the successfully matched text; A file reading unit for reading the external link file based on the storage path information; Wherein, the paragraph reading unit is further used for: Dividing the target file into several text blocks of a preset size and reading each text block in a preset order; After the current text block is read, determine the already read text blocks that have been read before the current text block based on the preset order; Obtain the text other than the text paragraph of the target file in the already read text blocks as candidate text; Obtain the text paragraph in the text formed by merging the candidate text and the current text block until all the text blocks are read in the preset order.
11. A computer device, characterized in that, It includes: A memory for storing a computer program; A processor for implementing the steps in the external link file reading method according to any one of claims 1 to 9 when executing the computer program.
12. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by the processor, the steps in the external link file reading method according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Front-end static resource managing method and device, computer equipment and storage medium
CN108920691A
Text comparison method, contract review method and review system
CN112926299A