File content retrieval method and apparatus, electronic device, and readable storage medium
By deploying a scanning program on a server within a local area network, scanning and analyzing accessible files in shared folders, and generating and matching keywords, the problem of being unable to retrieve non-local file content in existing technologies is solved, enabling broader and more efficient file content retrieval.
Patent Information
- Application Number
- CN202311200345.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-15
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2043-09-15
AI Technical Summary
Existing technologies can only retrieve the content of files on the local machine, and cannot retrieve the content of files on non-local machines, resulting in a limited search scope and incomplete results.
Deploy a scanning program on a server within the local area network. Based on a preset scanning time interval, scan accessible files in a shared folder, collect target file information, analyze file content and identifiers, generate a first keyword, and obtain the file content of non-local files by matching the second keyword in the search request.
It enables file content retrieval for files not located on the local machine, expanding the search scope, improving the comprehensiveness and efficiency of search results, saving manpower and time costs, and providing convenient file content viewing and download functions.
Smart Images

Figure CN117271446B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a file content retrieval method and device, electronic equipment and readable storage medium. BACKGROUND
[0002] File content retrieval refers to searching and querying the text content in a file to find the file related to a given condition or keyword.
[0003] In the related art, for local files, file content retrieval technologies such as keyword retrieval can be used to retrieve the file content of the local files, but are limited to local files, resulting in limited file content retrieval range and incomplete retrieval results. Therefore, it is necessary to retrieve the file content of non-local files to expand the retrieval range and make the retrieval results more comprehensive. However, for non-local files, only the file name can be retrieved, and the file content of non-local files cannot be retrieved.
[0004] Therefore, there is an urgent need for a file content retrieval method, device, electronic equipment and readable storage medium to solve the problem of being unable to retrieve the file content of non-local files. SUMMARY
[0005] The present application provides a file content retrieval method, device, electronic equipment and readable storage medium, which can retrieve the file content of non-local files, thereby expanding the file content retrieval range and improving the comprehensiveness of the retrieval results.
[0006] In a first aspect, the present application provides a file content retrieval method applied to a server in a local area network, the method comprising:
[0007] Obtaining all accessible files under a preset shared folder, wherein the preset shared folder stores local files and non-local files in the local area network, and the accessible files refer to files with access permissions under the preset shared folder;
[0008] Deploying a scanning program on the server in the local area network, using the scanning program to scan all the accessible files under the preset shared folder based on a preset scanning time interval, and collecting target file information of all the accessible files, wherein the target file information includes file content and file identification;
[0009] Analyzing the file content and file identification of all the accessible files to obtain a plurality of first keywords of all the accessible files;
[0010] The second keyword in the search request is obtained, the second keyword is matched with the plurality of first keywords, and file content corresponding to the second keyword is obtained.
[0011] By adopting the technical solution, all accessible files under the preset shared folder are obtained, the preset shared folder stores local files and non-local files in the local area network, the accessible files refer to files with access permissions under the preset shared folder, and the time for collecting files in the local area network can be reduced. The scanning program is deployed on the server in the local area network, all accessible files under the preset shared folder are scanned based on a preset scanning time interval, target file information of all accessible files is collected, the target file information includes file content and file identification, and the collection efficiency of file information can be improved. The file content and file identification of all accessible files are analyzed, a plurality of first keywords of all accessible files are obtained, a second keyword in a search request is obtained, the second keyword is matched with the plurality of first keywords, and file content corresponding to the second keyword is obtained, and the search efficiency of file content can be improved. The embodiments of the application can realize the search of file content of non-local files, thereby expanding the range of file content search and improving the comprehensiveness of search results.
[0012] In some embodiments of the application, the scanning program is deployed on the server in the local area network, all accessible files under the preset shared folder are scanned based on a preset scanning time interval, and target file information of all accessible files is collected, including:
[0013] The scanning program is deployed on the server in the local area network;
[0014] All accessible files under the shared folder are scanned based on a preset scanning time interval, and first scanning records are obtained;
[0015] File content and file identification of the first scanning records are collected, first file information is obtained, and the first file information is used as the target file information.
[0016] By adopting the technical solution, the scanning program is deployed on the server in the local area network, all accessible files under the preset shared folder are scanned based on a preset scanning time interval, and first scanning records are obtained, the scanning program can save labor and time costs; file content and file identification of the first scanning records are collected, first file information is obtained, and the first file information is used as the target file information, and the file information can be concentrated and conveniently viewed.
[0017] In some embodiments of the present application, the first scan record comprises a first update time;
[0018] After the file content and the file identifier of the first scan record are collected to obtain the first file information, the method further comprises:
[0019] Based on a preset scan time interval, all accessible files under the shared folder are scanned using the scan program to obtain a second scan record, the second scan record comprising a second update time, the second update time being obtained after the first update time has elapsed for the preset scan time interval;
[0020] The first scan record and the second scan record are compared and analyzed to obtain an analysis result;
[0021] According to the analysis result, the first file information is updated to obtain second file information, and the second file information is taken as the target file information.
[0022] By adopting the above technical solution, based on a preset scan time interval, all accessible files under the shared folder are scanned using the scan program to obtain a second scan record, the second scan record comprising a second update time, the second update time being obtained after the first update time has elapsed for the preset scan time interval, which facilitates subsequent comparison and analysis of scan records; the first scan record and the second scan record are compared and analyzed to obtain an analysis result; according to the analysis result, the first file information is updated to obtain second file information, and the second file information is taken as the target file information, which enables real-time updating of file information.
[0023] In some embodiments of the present application, according to the analysis result, the first file information is updated to obtain second file information, comprising:
[0024] In the case where the file identifier of the first scan record is different from the file identifier of the second scan record, the second scan record is used to replace the first file information, the file content and the file identifier of the second scan record are collected to obtain the second file information;
[0025] In the case where the second scan record has added a file identifier compared with the first scan record, the added file content corresponding to the added file identifier is added to the first file information to obtain the second file information;
[0026] In the case where the second scan record has reduced a file identifier compared with the first scan record, the reduced file content corresponding to the reduced file identifier is deleted from the first file information to obtain the second file information.
[0027] By adopting the technical scheme, in the case that the file identifier recorded in the first scanning is different from the file identifier recorded in the second scanning, the second file information is obtained by replacing the first file information with the second scanning record, collecting the file content and the file identifier of the second scanning record, and obtaining the second file information; in the case that the second scanning record adds a file identifier compared with the first scanning record, the second file information is obtained by adding the file content corresponding to the added file identifier in the first file information; in the case that the second scanning record reduces a file identifier compared with the first scanning record, the second file information is obtained by deleting the file content corresponding to the reduced file identifier in the first file information. The first scanning record and the second scanning record are compared and analyzed, and there are three analysis results, that is, the file identifier changes, the file identifier is added, and the file identifier is reduced. The first file information is updated according to different analysis results to obtain the second file information, and the file information can be accurately updated.
[0028] In some embodiments of the present application, the analysis of the file content and the file identifier of all the accessible files obtains a plurality of first keywords of all the accessible files, including:
[0029] The file content of all the accessible files is read in a text form to obtain content text of all the accessible files;
[0030] A preset word library is obtained, and the content text of all the accessible files is subjected to word segmentation processing based on the preset word library to obtain a word segmentation result of the content text of all the accessible files;
[0031] The word segmentation result is associated with the file identifier of all the accessible files to obtain a plurality of first keywords.
[0032] By adopting the technical scheme, the file content of all the accessible files is read in a text form to obtain content text of all the accessible files, which facilitates the analysis and processing of the file content; a preset word library is obtained, and the content text of all the accessible files is subjected to word segmentation processing based on the preset word library to obtain a word segmentation result of all the accessible files, which ensures the professionalism of the word segmentation result; the word segmentation result of all the accessible files is associated with the file identifier to obtain a plurality of first keywords, which facilitates the retrieval of the file content.
[0033] In some embodiments of the present application, the second keyword in the retrieval request is obtained, and the second keyword and a plurality of first keywords are matched to obtain file content corresponding to the second keyword, including:
[0034] A preset file index is obtained, and the preset file index includes an association relationship between a plurality of first keywords and corresponding file content;
[0035] obtaining a second keyword in the retrieval request;
[0036] matching the second keyword with the plurality of first keywords to obtain a first keyword matched with the second keyword;
[0037] retrieving corresponding file content from the file index according to the first keyword matched with the second keyword to obtain file content corresponding to the second keyword.
[0038] By adopting the technical solution, the preset file index is obtained, the preset file index includes the association relationship between the plurality of first keywords and the corresponding file content, the association relationship between the plurality of first keywords and the corresponding file content can be obtained, and subsequent retrieval and search of the file content are facilitated. The second keyword in the retrieval request is obtained, the second keyword is matched with the plurality of first keywords to obtain the first keyword matched with the second keyword, and the search time of the file content can be reduced. According to the first keyword matched with the second keyword, the corresponding file content is retrieved from the file index to obtain the file content corresponding to the second keyword, the file content corresponding to the second keyword can be quickly located, and the retrieval efficiency of the file content is improved.
[0039] In some embodiments of the present application, after the second keyword in the retrieval request is obtained, the second keyword is matched with the plurality of first keywords to obtain the file content corresponding to the second keyword, the method further comprises:
[0040] deploying a Web page on a server in the local area network, and displaying the file content corresponding to the second keyword on the Web page;
[0041] highlighting the second keyword corresponding to the file content on the Web page according to the second keyword;
[0042] A download button is arranged in the Web page, and the file content is downloaded by triggering the click operation of the user on the download button.
[0043] By adopting the technical solution, the Web page is deployed on the server in the local area network, and the file content corresponding to the second keyword is displayed on the Web page, which can facilitate the user to view the file content. The second keyword corresponding to the file content is highlighted on the Web page according to the second keyword, which can help the user to quickly find the content related to the second keyword. The download button is arranged in the Web page, and the file content is downloaded by triggering the click operation of the user on the download button, which can facilitate the user to save and subsequently process or review the file content.
[0044] In a second aspect, the present application provides a file content retrieval device applied to a server in a local area network, the device comprising:
[0045] a file scanning module configured to acquire all accessible files under a preset shared folder, wherein the preset shared folder stores local files and non-local files in the local area network, and the accessible files refer to files with access rights under the preset shared folder;
[0046] an information collecting module configured to deploy a scanning program on the server in the local area network, use the scanning program to scan all the accessible files under the preset shared folder based on a preset scanning time interval, and collect target file information of all the accessible files, wherein the target file information comprises file content and file identification;
[0047] a keyword acquiring module configured to analyze the file content and the file identification of all the accessible files to obtain a plurality of first keywords of all the accessible files;
[0048] a file content retrieval module configured to acquire a second keyword in a retrieval request, match the second keyword with the plurality of first keywords, and obtain file content corresponding to the second keyword.
[0049] By using the above device, all the accessible files under the preset shared folder are acquired, the preset shared folder stores the local files and the non-local files in the local area network, the accessible files refer to the files with the access rights under the preset shared folder, the time for collecting the files in the local area network can be reduced; the scanning program is deployed on the server in the local area network, the scanning program is used to scan all the accessible files under the preset shared folder based on the preset scanning time interval, and the target file information of all the accessible files is collected, the target file information comprises the file content and the file identification, the collection efficiency of the file information can be improved; the file content and the file identification of all the accessible files are analyzed to obtain the plurality of first keywords of all the accessible files; the second keyword in the retrieval request is acquired, the second keyword is matched with the plurality of first keywords, and the file content corresponding to the second keyword is obtained, the retrieval efficiency of the file content can be improved. The present application can realize the retrieval of the file content of the non-local files, thereby expanding the range of the file content retrieval and improving the comprehensiveness of the retrieval results.
[0050] In a third aspect, an electronic device is provided, which includes a processor, a memory, a user interface, and a network interface. The memory is configured to store instructions. The user interface and the network interface are configured to communicate with other devices. The processor is configured to execute the instructions stored in the memory, so that the electronic device performs any of the methods provided in the first aspect.
[0051] In a fourth aspect, a computer readable storage medium is provided, which stores instructions. When the instructions are executed, any of the methods provided in the first aspect is performed.
[0052] To sum up, the one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:
[0053] 1. All accessible files under the preset shared folder, including local files and non-local files, are obtained, which can reduce the collection time of files in the local area network; a scanning program is deployed on a server in the local area network, all accessible files under the preset shared folder are scanned based on a preset scanning time interval using the scanning program, and file information is collected, which can improve the collection efficiency of file information; the file content and file identifier of all accessible files are analyzed to obtain a plurality of first keywords, a second keyword in a retrieval request is obtained, and the second keyword and the plurality of first keywords are matched to obtain file content corresponding to the second keyword, which can improve the retrieval efficiency of file content.
[0054] 2. All accessible files under the shared folder are scanned using the scanning program, which can save manpower and time cost, the first scanning record and the second scanning record are compared and analyzed, the first file information is updated according to the analysis result to obtain the second file information, and the file information can be updated.
[0055] 3. A preset file index is obtained, a second keyword in a retrieval request is obtained, the second keyword and a plurality of first keywords are matched to obtain file content corresponding to the second keyword, which can narrow the retrieval range, quickly locate the file content corresponding to the second keyword, and improve the retrieval efficiency of file content.
[0056] 4. A Web page is deployed on a server in the local area network, the file content corresponding to the second keyword is displayed on the Web page, all second keywords are highlighted in the file content, and a button for downloading the file content is provided on the Web page, which can facilitate users to view and quickly find the content related to the second keyword, and subsequent file processing and review. BRIEF DESCRIPTION OF DRAWINGS
[0057] Figure 1is one of flow diagrams of a file content retrieval method provided by an embodiment of the present application;
[0058] Figure 2 is Figure 1 is one of flow diagrams of a file content retrieval method provided by an embodiment of the present application;
[0059] Figure 3 is Figure 2 is one of flow diagrams of a file content retrieval method provided by an embodiment of the present application;
[0060] Figure 4 is Figure 1 is one of flow diagrams of a file content retrieval method provided by an embodiment of the present application;
[0061] Figure 5 is Figure 1 is one of flow diagrams of a file content retrieval method provided by an embodiment of the present application;
[0062] Figure 6 is one of flow diagrams of a file content retrieval method provided by an embodiment of the present application;
[0063] Figure 7 is one of flow diagrams of a file content retrieval method provided by an embodiment of the present application;
[0064] Figure 8 is one of flow diagrams of a file content retrieval method provided by an embodiment of the present application; DETAILED DESCRIPTION
[0065] In order to make the skilled in the art better understand the technical solutions in the specification, the technical solutions in the specification will be described clearly and completely in the specification by combining with the drawings in the specification. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments.
[0066] The embodiment of the present application provides a file content retrieval method, device, electronic equipment and readable storage medium. The file content retrieval method obtains all files under a preset shared folder, including local files and non-local files; access permissions of all files are obtained, and files with access permissions are regarded as accessible files. In the case that part of the files under the preset shared folder do not have access permissions, first prompt information is generated and displayed, prompting that part of the files under the preset shared folder do not have access permissions, and the administrator needs to be contacted to obtain the access permissions of the part of the files. After determining the access permissions of all the files under the preset shared folder, all the accessible files under the preset shared folder are obtained. A scanning program is deployed on a server in a local area network. Based on a preset scanning time interval, the scanning program is used to scan all the accessible files under the preset shared folder, and target file information of all the accessible files is collected. File content and file identifiers of all the accessible files are analyzed, and a plurality of first keywords of all the accessible files are obtained. A second keyword in a retrieval request is obtained, the second keyword is matched with the plurality of first keywords, and file content corresponding to the second keyword is obtained. In some scenarios requiring file content retrieval, for example, a document management system, a knowledge base system, electronic factory device information retrieval, multimedia content retrieval, legal and regulatory retrieval, etc. The file content retrieval method can provide a quick and accurate file content retrieval method, realize retrieval of file content of all files in a local area network, and expand the retrieval range of file content.
[0067] The technical solutions provided by the embodiments of the present application are further described below with reference to the drawings.
[0068] Reference Figure 1 , Figure 1 is one of flowcharts of a file content retrieval method provided by the embodiments of the present application. The file content retrieval method comprises steps S1, S2, S3 and S4.
[0069] In step S1, all accessible files under a preset shared folder are obtained. The preset shared folder stores local files and non-local files in a local area network. The accessible files refer to files with access permissions under the preset shared folder.
[0070] In an embodiment, the network settings of the viewing server are checked or a network administrator is contacted to obtain the IP address of the server where the preset shared folder is located. According to the operating system and network protocol used by the server, the server is connected using Windows Explorer, Finder of Mac, etc. After connecting to the server, the server directory is obtained, the path of the preset shared folder is found in the server directory, the preset shared folder is found using the path, and the access rights of all files under the preset shared folder are obtained using a command line tool. All files include local files and non-local files in the local area network. After obtaining the access rights of all files, the files with access rights are used as accessible files, and the os.walk function or API (Application Programming Interface) is used to traverse all accessible files under the shared folder. For each accessible file, the file name and file path are recorded and added to the file list, and all accessible files under the preset shared folder are obtained. All accessible files obtained can be used for subsequent file scanning, which facilitates subsequent scanning operations.
[0071] Possibly, not all files under the preset shared folder have access rights. For files without access rights, an information prompt component is embedded in the server in the local area network. When some files without access rights are found in the process of obtaining access rights of all files, the control information prompt component generates first prompt information, and displays a pop-up window on the application interface or outputs prompt information on the command line interface. The first prompt information is used to prompt the user that some files under the preset shared folder do not have access rights, and the access rights of these files need to be obtained by contacting the administrator.
[0072] Optionally, for files without access rights, a screening program can also be deployed on the server in the local area network. When some files without access rights are found in the process of obtaining access rights of all files, the screening program is used to automatically screen out these files, and these files are not collected.
[0073] Step S2, a scanning program is deployed on the server in the local area network. Based on a preset scanning time interval, all accessible files under the preset shared folder are scanned using the scanning program, and target file information of all accessible files is collected. The target file information includes file content and file identification.
[0074] In an embodiment, the scanning program is written using Python, and is deployed on the server using scripts, services, scheduled tasks, etc. according to the operating system of the server and the Python programming language. The scanning interval of the scanning program is set, and the starting time point of the scanning is set to trigger the starting of the scanning program. After the preset scanning interval, the scanning program traverses all accessible files and collects the file contents and file identifiers of all accessible files to obtain target file information of all accessible files. The obtained target file information can be used for analysis and processing of the file information, facilitating the generation of the first keyword.
[0075] Possibly, the set starting time point of the scanning can be a randomly generated time point, and the preset scanning interval can be set according to actual needs, which can be 1 day, 1 hour, 1 minute, etc. However, if the time interval is 1 minute, 2 minutes, etc., the scanning program is running all the time, which will occupy the processor for a long time and consume a large amount of resources. If the time interval is 1 hour, 2 hours, etc., the scanning interval is too long, and some file information of files can be missed. In order to avoid the above problems, the scanning interval is set to 15 minutes or 20 minutes in the embodiment of the application.
[0076] As shown in Figure 2 The scanning program is deployed on the server in the local area network, and all accessible files under the preset shared folder are scanned using the scanning program based on the preset scanning interval, and target file information of all accessible files is collected to obtain the first scanning record.
[0077] Step S21, the scanning program is deployed on the server in the local area network, and all accessible files under the preset shared folder are scanned using the scanning program based on the preset scanning interval to obtain a first scanning record.
[0078] In a possible embodiment of the application, the scanning program is written using Python, and is deployed on the server using scripts, services, scheduled tasks, etc. according to the operating system of the server and the Python programming language. In the server directory in the local area network, the server directory is traversed to determine the path of the preset shared folder, and the preset shared folder is queried according to the path. All accessible files under the preset shared folder are scanned according to the starting time point of the scanning and the preset scanning interval, and the file information of all accessible files is recorded to obtain a first scanning record recording the file information of all accessible files. The first scanning record includes the starting time point of the scanning, the file contents of all accessible files, the file name and the file path, and the starting time point of the scanning is taken as the first update time. The first scanning record is saved in a dictionary or a database, and the obtained first scanning record can be used for comparison and analysis of subsequent scanning results, facilitating subsequent comparison and analysis.
[0079] Step S22, collect the file content and file identification of the first scanning record to obtain first file information, and take the first file information as target file information.
[0080] In a possible embodiment of the present application, the open function is used to obtain the file content, file name and file path of all accessible files from the first scanning record, and the file name and file path are associated by using key-value pairs, dictionaries, databases, etc. to obtain the file identification of all accessible files. The obtained file content and file identification of all accessible files are taken as the first file information, and the first file information is taken as the target file information. The obtained target file information can be used to store file information, facilitating subsequent viewing of changes in file information.
[0081] Step S23, based on a preset scanning time interval, use a scanning program to scan all accessible files under the preset shared folder to obtain a second scanning record, and the second scanning record includes a second update time, which is obtained after the first update time by the preset scanning time interval.
[0082] In a possible embodiment of the present application, in the server directory in the local area network, the server directory is traversed to determine the path of the preset shared folder, and the preset shared folder is obtained by querying according to the path. According to the preset scanning time interval and the first update time, a second update time is obtained after the first update time by a preset scanning time interval. At the second update time, a scanning program is used to scan all accessible files under the preset shared folder, and the file information of all accessible files is recorded to obtain a second scanning record recording the file information of all accessible files. The file name and file path are associated to obtain the file identification of all accessible files, and the second scanning record includes the second update time, the file identification, the file content of all accessible files, the file name and the file path. The second scanning record is saved in a dictionary or a database, and the obtained second scanning record can be used for comparison and analysis with the first scanning record, facilitating subsequent comparison and analysis.
[0083] Possibly, after the first update time of the first scanning record, in addition to a preset time interval, it can also pass through two, three, etc. multiple preset scanning time intervals, and the number of preset scanning time intervals is determined according to the preset scanning time interval. If the preset scanning time interval is short, a plurality of preset scanning time intervals can be passed through; if the preset scanning time interval is long, one, two, etc. fewer preset scanning time intervals need to be passed through.
[0084] Step S24, compare and analyze the first scanning record and the second scanning record to obtain an analysis result.
[0085] In a possible embodiment of the present application, the first scan record and the second scan record are read out using an information extraction function from the data structure for storing the first scan record and the data structure for storing the second scan record, all accessible file identifiers of the two scan records are compared in a loop traversal manner, the file identifiers of the newly added, deleted and modified files are found, and an analysis result is obtained. The analysis result is stored in a dictionary or a database, and the obtained analysis result can be used for updating the file information, facilitating subsequent file information updating.
[0086] In step S25, the first file information is updated according to the analysis result, the second file information is obtained, and the second file information is taken as the target file information.
[0087] In a possible embodiment of the present application, the update type of the file information is determined according to the analysis result, the first file information is updated according to the update type of the file information, the second file information is obtained, and the second file information is taken as the target file information. The obtained target file information can be used for analysis and processing of the file content, facilitating generation of the first keyword.
[0088] As shown in FIG. 6, the first file information is updated according to the analysis result, the second file information is obtained, and the second file information is taken as the target file information, including but not limited to the following steps: Figure 3
[0089] In step S251, the first file information is replaced by the second scan record in the case where the file identifier of the first scan record is different from the file identifier of the second scan record, the file content and the file identifier of the second scan record are collected, and the second file information is obtained.
[0090] In a possible embodiment of the present application, the first scan record and the second scan record are compared, the files with different file identifiers are found, the second scan record can be traversed and compared with the first scan record, and it is determined whether the file identifiers are the same. If the file identifiers are different, it indicates that the file has changed in the second scan record. For the files with different file identifiers, the file information of the second scan record is used to replace the file information of the first scan record, the second file information is obtained, and the second file information is taken as the target file information. The obtained target file information can be used for analysis and processing of the file content, facilitating generation of the first keyword.
[0091] In step S252, the file content corresponding to the newly added file identifier is added in the first file information in the case where the second scan record newly adds the file identifier, and the second file information is obtained.
[0092] In one possible embodiment of this application, the first scan record and the second scan record are compared to find the newly added file identifier. The second scan record can be traversed and compared with the first scan record to determine if a new file identifier has been added. If a new file identifier has been added, it indicates that the first scan record has changed. For the newly added file identifier, the file content corresponding to the newly added file identifier is added to the first file information. The insert function can be used to insert the newly added file identifier and its corresponding file content into the first file information to obtain the second file information, which is then used as the target file information. The obtained target file information can be used for file content analysis and processing, facilitating the subsequent generation of the first keyword.
[0093] Step S253: If the second scan record has fewer file identifiers than the first scan record, delete the file content corresponding to the reduced file identifiers in the first file information to obtain the second file information.
[0094] In one possible embodiment of this application, the first scan record and the second scan record are compared to find the reduced file identifier. The second scan record can be traversed and compared with the first scan record to determine if the file identifier has been reduced. If the file identifier has been reduced, it indicates that the first scan record has changed. For the reduced file identifier, the file content corresponding to the reduced file identifier is deleted from the first file information. The delete function can be used to delete the reduced file identifier and its corresponding file content from the first file information, obtaining the second file information, which is then used as the target file information. The obtained target file information can be used for file content analysis and processing, facilitating the subsequent generation of the first keyword.
[0095] Step S3: Analyze the file content and file identifier of all accessible files to obtain multiple primary keywords for all accessible files.
[0096] like Figure 4 As shown, the file content and file identifiers of all accessible files are analyzed to obtain multiple primary keys for all accessible files, including but not limited to the following steps:
[0097] Step S31: Read the contents of all accessible files in text form to obtain the text contents of all accessible files.
[0098] In one possible embodiment of this application, the `open` function is used to obtain the file content of each accessible file from the target file information of all accessible files, and the content is stored as a string in text form. String concatenation operations or a string buffer are then used to concatenate the file content of each accessible file into a single string, resulting in the text content of all accessible files. This obtained text content can be used for word segmentation analysis, facilitating the generation of subsequent analysis results.
[0099] Step S32: Obtain a preset dictionary. Based on the preset dictionary, perform word segmentation on the content text of all accessible files to obtain the word segmentation results of the content text of all accessible files.
[0100] In one possible embodiment of this application, a preset thesaurus is obtained. The preset thesaurus is a text file or data structure containing professional terms in fields such as electronic factory equipment information and multimedia content. The preset thesaurus includes a real-time update program that monitors changes in various professional terms, returns the changes to the preset thesaurus, and updates the preset thesaurus. Based on the content text of all accessible files obtained in step S31, and using the preset thesaurus, jieba segmentation is applied to the content text of each accessible file to obtain the segmentation results for all accessible file content texts. The segmentation results can be stored using data structures such as lists, dictionaries, or databases. The obtained segmentation results can be used for keyword generation, facilitating subsequent keyword generation.
[0101] Step S33: Associate the word segmentation results with the file identifiers of all accessible files to obtain multiple first keywords for all accessible files.
[0102] In one possible embodiment of this application, based on the file identifier of the accessible file obtained in step S22 and the word segmentation results of the content text of all accessible files obtained in step S32, key information is extracted from the word segmentation results using regular expressions or keyword matching algorithms. The keyword matching algorithm can be a forward maximum matching algorithm, a backward maximum matching algorithm, or similar algorithms. The key information of each accessible file is associated with its file identifier. These associations can be stored using storage structures such as dictionaries or key-value pairs. The word segmentation result with the highest frequency in the word segmentation results of the content text of each accessible file is taken as the first keyword of the accessible file, resulting in multiple first keywords for all accessible files. Multiple first keywords are stored using data structures such as dictionaries or lists. These multiple first keywords can be used to search for file content, facilitating subsequent file content retrieval.
[0103] It's possible that each accessible file may have multiple first keywords. After segmenting the content text of each accessible file, we obtain the segmentation results. We then use a statistical algorithm to iterate through the segmentation results of each accessible file, obtaining the most frequent segments, and selecting one or more of these most frequent segments as the first keyword for each accessible file.
[0104] Step S4: Obtain the second keyword in the search request, match the second keyword with multiple first keywords, and obtain the file content corresponding to the second keyword.
[0105] In one embodiment, a second keyword is obtained from a search request using command-line arguments, API requests, etc. Based on the second keyword, a string matching algorithm is used to find a first keyword that matches the second keyword among multiple first keywords. Based on the first keyword that matches the second keyword, the file content corresponding to the second keyword is obtained. This file content can be used for subsequent display, facilitating user viewing.
[0106] It is possible to match the second keyword with multiple first keywords. There can be one or more second keywords. For a single second keyword, it can match multiple first keywords and multiple corresponding file contents, providing more choices. However, the more second keywords there are, the fewer first keywords it can match, and the fewer corresponding file contents it can choose from.
[0107] like Figure 5 As shown, the process involves obtaining the second keyword from the search request, matching the second keyword with multiple first keywords, and obtaining the file content corresponding to the second keyword, including but not limited to the following steps:
[0108] Step S41: Obtain a preset file index, which includes the association between multiple first keywords and their corresponding file contents.
[0109] In one possible embodiment of this application, all accessible files in a folder can be traversed recursively. The `open` function is used to retrieve the file content from each accessible file, and the first key is retrieved from a data structure storing multiple first keys. Then, an association between the first key and the file content is established and stored in a data structure to obtain a preset file index. The obtained preset file index can be used to locate file content, facilitating subsequent file content retrieval.
[0110] Step S42: Obtain the second keyword from the search request.
[0111] In one possible embodiment of this application, a file content retrieval request is triggered by the user's input of a second keyword. Specifically, a keyword input event handler is set up on the local machine. When the user enters a keyword in the search bar provided by the operating system, this event handler generates a retrieval request. The keyword entered by the user is then added as a second keyword to the retrieval request, and the retrieval request is sent to the server. The server receives the retrieval request, parses it, and obtains the second keyword. The obtained second keyword can be used to match the first keyword, facilitating subsequent file content retrieval.
[0112] Step S43: Match the second keyword with multiple first keywords to obtain the first keyword that matches the second keyword.
[0113] In one possible embodiment of this application, based on the multiple first keywords obtained in step S33, a string matching algorithm or a fuzzy matching algorithm is used to match the second keyword obtained in step S42 with the multiple first keywords to obtain the first keyword that matches the second keyword. The first keyword that matches the second keyword can be used to find the corresponding file content, facilitating subsequent file content retrieval.
[0114] Step S44: Based on the first keyword that matches the second keyword, retrieve the corresponding file content from the file index to obtain the file content corresponding to the second keyword.
[0115] In one possible embodiment of this application, based on the first keyword that matches the second keyword obtained in step S43, the file content corresponding to the first keyword is obtained from the preset file index by traversing the preset file index, and the file content corresponding to the first keyword is found, and the file content corresponding to the second keyword is obtained.
[0116] In one embodiment, after obtaining the file content corresponding to the second keyword, such as Figure 6 As shown, the methods for retrieving file content also include, but are not limited to, the following steps:
[0117] Step S101: Deploy a web page on a server within the local area network and display the file content corresponding to the second keyword on the web page.
[0118] In one possible embodiment of this application, a web server is set up on a server within a local area network (LAN) using Apache, Nginx, or similar software. A web page is created on the web server, and the HTML code for the web page can be written using a text editor or program editor. An information sensing component is embedded in the server within the LAN. After sensing the file content corresponding to the second keyword obtained in step S44, the information sensing component is controlled to send a file display signal to the web server. The web server is controlled to receive the file display signal and use string formatting to insert the file content corresponding to the second keyword into the HTML code, thereby displaying the file content corresponding to the second keyword on the web page. After the file content corresponding to the second keyword is displayed on the web page, the second keyword can be easily highlighted within the file content.
[0119] Step S102: Based on the second keyword, highlight the second keyword corresponding to the file content on the Web page.
[0120] In one possible embodiment of this application, the file content corresponding to the second keyword is stored as a string, and then a string processing function or regular expression is used to traverse the file content corresponding to the second keyword to find the position of the second keyword in the file content corresponding to the second keyword, and then using ' The second keyword is wrapped by the tag. The highlight style of the second keyword is set by the CSS style. The web server inserts the file content with the highlighted second keyword into the corresponding position of the file content corresponding to the second keyword in the HTML code in step S101, replaces the original file content corresponding to the second keyword, and implements the operation of highlighting the file content corresponding to the second keyword on the web page. The obtained highlighted keyword can be used to quickly find the second keyword, and the user can quickly find the file content corresponding to the second keyword.
[0121] Possibly, the second keyword in the file content corresponding to the second keyword can also be highlighted directly on the web page. Specifically, a CSS style is added in the HTML code to set the highlight style of the second keyword in the file content corresponding to the second keyword, such as font color, font size, etc., and a traversal function is written using JavaScript. Then the CSS style and the traversal function are added to the tag corresponding to the web page. When the web page is loaded, the coding function traverses the file content corresponding to the second keyword in the web page, and the text containing the second keyword is highlighted according to the set highlight style.
[0122] In step S103, a download button is set in the web page, and the file content is downloaded by triggering the click operation of the user on the download button.
[0123] In a possible embodiment of the present application, in the HTML code of the web page, a tag is added, and the tag is used to set the highlight style of the second keyword in the file content corresponding to the second keyword. <button>The Web server receives the download request, and sends the file content corresponding to the second keyword to the Web server, and controls the Web server to download the file content corresponding to the second keyword as a file, thereby realizing the operation of downloading the file content corresponding to the second keyword.
[0124] As Figure 7 As shown, the embodiment of the present application provides a file content retrieval device, which calls the file scanning module 110 to first find the preset shared folder according to the path of the preset shared folder. The file scanning module 110 includes the permission detection module 111 and the first prompt module 112. After finding the preset shared folder, the permission detection module 111 is called to obtain the access permission of all files under the preset shared folder, and the files with the access permission are taken as accessible files. After obtaining the access permission of all files under the preset shared folder, the permission detection module 111 and the first prompt module 112 are connected. If it is found that some files have no access permission, the first prompt module 112 is called to generate and display the first prompt information, prompting the user that some files under the preset shared folder have no access permission and need to contact the administrator to obtain the access permission of the files. According to the obtained preset shared folder, all accessible files under the preset shared folder are obtained. The file scanning module 110 is connected with the information collection module 120. After obtaining all accessible files, the information collection module 120 is called to scan all accessible files under the preset shared folder, obtain the first scanning record, collect the file information of all accessible files, obtain the first file information, take the first file information as the target file information, and the target file information includes the file content and the file identifier. The information collection module 120 includes the comparison and analysis module 121 and the information updating module 122. After obtaining the first scanning record, based on the preset scanning time interval, the second updating time is reached. At the second updating time, the scanning program is used again to scan all accessible files under the preset shared folder, obtain the second scanning record, the second scanning record includes the second updating time, the comparison and analysis module 121 is called to compare and analyze the first scanning record and the second scanning record, and the analysis result is obtained. The comparison and analysis module 121 and the information updating module 122 are connected. After obtaining the analysis result, the information updating module 122 is called to update the first file information according to the analysis result, obtain the second file information, and take the second file information as the target file information. The information collection module 120 is connected with the keyword obtaining module 130. After obtaining the target file information of all accessible files, the keyword obtaining module is called to analyze the file content and the file identifier of the target file information of all accessible files, and a plurality of first keywords are obtained. The keyword obtaining module 130 is connected with the file content retrieval module 140. After obtaining the plurality of first keywords, the file content retrieval module 140 is called to obtain the second keyword in the retrieval request, match the second keyword with the plurality of first keywords, and obtain the file content corresponding to the second keyword.The file content retrieval module 140 comprises a file display and download module 141, after obtaining the file content corresponding to the second keyword, the file display and download module 141 is called, a Web page is deployed, the file content corresponding to the second keyword is displayed in the Web page, and a button for downloading the file content corresponding to the second keyword is set in the Web page. The above-mentioned file content retrieval method is applied to the file content retrieval device.
[0125] The application further discloses an electronic device. Figure 8 , Figure 8 is a structural schematic diagram of an electronic device disclosed by an embodiment of the application. The electronic device 800 can comprise at least one processor 801, at least one network interface 804, a user interface 803, a memory 805, and at least one communication bus 802.
[0126] The communication bus 802 is configured to realize the connection communication between the components. The user interface 803 can include a display, a camera, and optionally, a standard wired interface, a wireless interface. The network interface 804 can optionally include a standard wired interface, a wireless interface (such as a WI-FI interface). The processor 801 can include one or more processing cores. The processor 801 connects various parts within the server through various interfaces and lines, executes various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 805, and calling data stored in the memory 805. Optionally, the processor 801 can be implemented in at least one of a hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), programmable logic array (PLA). The processor 801 can integrate a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display; and the modem is used for processing wireless communication. It can be understood that the above-mentioned modem can also not be integrated into the processor 801, but can be realized by a separate chip. The memory 805 can include a random access memory (RAM) and a read-only memory (ROM). Optionally, the memory 805 includes a non-transitory computer-readable storage medium. The memory 805 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 805 can include a program storage area and a data storage area, wherein the program storage area can store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area can store data involved in the above-mentioned various method embodiments, etc. The memory 805 can also be at least one storage device located away from the above-mentioned processor 801. Referring to Figure 8 , the memory 805 as a computer storage medium can include an operating system, a network communication module, a user interface module, and an application program of a file content retrieval method.
[0127] In Figure 8 In the electronic device 800 shown, the user interface 803 can be used primarily to provide an interface for a user to input data, and the processor 801 can be used to invoke an application program stored in the memory 805 that retrieves a file content, which when executed by the one or more processors 801, causes the electronic device 800 to perform the method of one or more of the above-described embodiments.
[0128] This application is intended to cover any variations, uses, or adaptations of the disclosure and includes what is presently described and understood to be customary and within the scope of those skilled in the art, as set forth in the foregoing description and appended claims. The specification and examples are illustrative only and not restrictive of the scope and spirit of the disclosure, which is defined by the following claims.< / button>
Claims
1. A method for retrieving document content, characterized in that, The method, applied to servers within a local area network, includes: Get all accessible files in a preset shared folder. The preset shared folder stores local files and non-local files within the local area network. The accessible files refer to files in the preset shared folder that have access permissions. If a file in the shared folder does not have access permissions, obtain access permissions from the administrator or filter out files that do not have access permissions. Deploy the scanning program on the server within the local area network; Traverse the server directory to determine the path of the shared folder, query the preset shared folder based on the path, and use the scanning program to scan all the accessible files under the shared folder based on the preset scanning time interval to obtain the first scan record; Collect the file content and file identifier of the first scan record to obtain first file information, and use the first file information as target file information. The target file information includes file content and file identifier, wherein the file identifier is obtained by associating the file name with the file path. The first scan record includes the first update time; After collecting the file content and file identifier of the first scan record to obtain the first file information, the scanning program is used to scan all the accessible files in the shared folder based on a preset scanning time interval to obtain a second scan record. The second scan record includes a second update time, which is obtained after the first update time has passed through the preset scanning time interval. The first scan record and the second scan record are compared and analyzed to obtain the analysis results; Based on the analysis results, the first file information is updated to obtain the second file information, and the second file information is used as the target file information; The step of updating the first file information based on the analysis results to obtain the second file information includes: If the file identifier of the first scan record is different from the file identifier of the second scan record, the first file information is replaced with the second scan record, and the file content and file identifier of the second scan record are collected to obtain the second file information. If the second scan record has an additional file identifier compared to the first scan record, the newly added file identifier and the file content corresponding to the newly added file identifier are inserted into the first file information to obtain the second file information. If the second scan record has fewer file identifiers than the first scan record, the fewer file identifiers and the file content corresponding to the fewer file identifiers are deleted from the first file information to obtain the second file information; The file content and file identifier of all the accessible files are analyzed to obtain multiple first keywords for all the accessible files; Obtain the second keyword from the search request, match the second keyword with multiple first keywords, and obtain the file content corresponding to the second keyword.
2. The method as described in claim 1, characterized in that, The analysis of the file content and file identifier of all the accessible files yields multiple first keywords for all the accessible files, including: The contents of all the accessible files are read out in text form to obtain the text content of all the accessible files; Obtain a preset dictionary, and based on the preset dictionary, perform word segmentation on the content text of all the accessible files to obtain the word segmentation results of the content text of all the accessible files; The word segmentation results are associated with the file identifiers of all the accessible files to obtain multiple first keywords.
3. The method as described in claim 1, characterized in that, The step of obtaining the second keyword in the search request, matching the second keyword with multiple first keywords to obtain the file content corresponding to the second keyword includes: Obtain a preset file index, wherein the preset file index includes multiple associations between the first keyword and the corresponding file content; Retrieve the second keyword from the search request; The second keyword is matched with multiple first keywords to obtain the first keyword that matches the second keyword; Based on the first keyword that matches the second keyword, the corresponding file content is retrieved from the file index to obtain the file content corresponding to the second keyword.
4. The method as described in claim 1, characterized in that, After obtaining the second keyword in the search request, matching the second keyword with multiple first keywords to obtain the file content corresponding to the second keyword, the method further includes: Deploy a web page on a server within the local area network to display the file content corresponding to the second keyword on the web page; Based on the second keyword, the second keyword corresponding to the file content is highlighted on the web page; A download button is provided on the web page. When a user clicks the download button, the file content is downloaded.
5. A document content retrieval device, characterized in that, The device, used for servers within a local area network, includes: The file scanning module is used to obtain all accessible files in a preset shared folder. The preset shared folder stores local files and non-local files within the local area network. The accessible files refer to files in the preset shared folder that have access permissions. If a file in the shared folder does not have access permissions, the module obtains access permissions from the administrator or filters out files that do not have access permissions. An information collection module is used to deploy a scanning program on a server within the local area network; traverse the server directory, determine the path of a shared folder, query a preset shared folder based on the path, and scan all accessible files under the shared folder using the scanning program at a preset scanning time interval to obtain a first scan record; collect the file content and file identifier of the first scan record to obtain first file information, and use the first file information as target file information, wherein the target file information includes file content and file identifier, and the file identifier is obtained by associating the file name with the file path; the first scan record includes a first update time; after collecting the file content and file identifier of the first scan record to obtain the first file information, the scanning program scans all accessible files under the shared folder at a preset scanning time interval to obtain a second scan record, wherein the second scan record includes a second update time, which is the first update time after the preset scanning time interval. The process involves comparing and analyzing the first scan record and the second scan record to obtain analysis results; updating the first file information based on the analysis results to obtain second file information, and using the second file information as the target file information; wherein, updating the first file information based on the analysis results to obtain the second file information includes: when the file identifier of the first scan record is different from the file identifier of the second scan record, replacing the first file information with the second scan record, collecting the file content and file identifier of the second scan record to obtain the second file information; when the second scan record has an additional file identifier compared to the first scan record, inserting the additional file identifier and the file content corresponding to the additional file identifier into the first file information to obtain the second file information; when the second scan record has fewer file identifiers than the first scan record, deleting the fewer file identifiers and the file content corresponding to the fewer file identifiers from the first file information to obtain the second file information. The keyword acquisition module is used to analyze the file content and file identifier of all the accessible files to obtain multiple first keywords of all the accessible files; The file content retrieval module is used to obtain the second keyword in the retrieval request, match the second keyword with multiple first keywords, and obtain the file content corresponding to the second keyword.
6. An electronic device, characterized in that, The electronic device includes a processor, a memory, a user interface, and a network interface. The memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory to cause the electronic device to perform the method as described in any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed, perform the method as described in any one of claims 1-4.
Citation Information
Patent Citations
Method and device for preventing Trojan horse from damaging shared file, medium and electronic equipment
CN111581660A
File crawling and searching method and system
CN113934911A