A PHP file classification method and device and a storage medium

By automatically classifying PHP files based on the similarity of their comments, strings, and code features, this solves the problem of antivirus engines being unable to recognize PHP files, thus improving the accuracy and efficiency of classification.

CN113704463BActive Publication Date: 2026-01-02TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110401336.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-14
Publication Date
2026-01-02
Estimated Expiration
2041-04-14

AI Technical Summary

Technical Problem

Existing antivirus engines cannot effectively identify whether PHP files are virus files, which requires manual analysis, which is time-consuming, labor-intensive, and costly. Furthermore, existing document classification methods have low accuracy for PHP files.

Method used

By extracting comments, strings, and code features from PHP files, the similarity between files is calculated, and feature correlation is used for automatic classification, reducing manual analysis and improving classification accuracy.

Benefits of technology

It enables automatic categorization of PHP files, reducing manual costs and improving the accuracy and efficiency of categorization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113704463B_ABST
    Figure CN113704463B_ABST
Patent Text Reader

Abstract

The application provides a PHP file classification method and device and a storage medium, which are applied to the technical field of computers and are used to improve the accuracy of PHP file classification. In the PHP file classification method, a file set to be classified is obtained, and the file set to be classified includes at least one PHP file to be classified; for each PHP file to be classified in the file set to be classified, a file similarity set corresponding to each PHP file to be classified is obtained respectively, each file similarity set includes: each file similarity determined based on the association degree of each feature between the corresponding PHP file to be classified and each reference PHP file; and each PHP file to be classified is classified based on the file similarity set corresponding to each PHP file to be classified. The PHP file to be processed is classified based on the features of the PHP file to be processed, and the accuracy of PHP file classification is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a PHP file classification method and device and storage medium. BACKGROUND

[0002] The PHP file which cannot be recognized by the antivirus engine is a PHP virus file or a suspected PHP virus file. At this time, the PHP file needs to be analyzed manually, and based on the analysis result, a specimen of whether the PHP file is a virus program or a suspected virus program is added in the virus library of the antivirus engine for subsequent detection of other files.

[0003] In the process of analyzing the PHP file by manual analysis, it is time-consuming and laborious to analyze and judge one by one, and the labor cost is relatively high. Therefore, a large number of PHP files can be classified; then, for at least one PHP file in the same category, the manual analysis method is used to determine whether it is a virus file or a suspected virus file, which can reduce the number of manual processing and save labor costs.

[0004] At present, only a method for classifying documents is proposed, but the focus of documents and PHP files is different, so the method for classifying documents cannot achieve good results for PHP files, and the accuracy is low. Therefore, how to improve the accuracy of PHP file classification is an urgent problem to be solved. SUMMARY

[0005] The present application provides a PHP file classification method, device and storage medium to improve the accuracy of PHP file classification.

[0006] In a first aspect, the present application provides a PHP file classification method, which comprises:

[0007] Obtain a set of files to be classified, the set of files to be classified including at least one PHP file to be classified;

[0008] For each PHP file to be classified in the set of files to be classified, obtain a respective file similarity set corresponding to each PHP file to be classified, each file similarity set including: each file similarity determined based on the respective feature correlation between the corresponding PHP file to be classified and each reference PHP file;

[0009] Based on the respective file similarity set corresponding to each PHP file to be classified, classify each PHP file to be classified.

[0010] In a second aspect, the present application provides a PHP file classification device, which comprises:

[0011] a first obtaining unit, configured to obtain a file set to be classified, the file set to be classified including at least one PHP file to be classified;

[0012] a second obtaining unit, configured to respectively obtain, for each PHP file to be classified in the file set to be classified, a file similarity set corresponding to the PHP file to be classified, each file similarity set including respective file similarities determined based on respective feature correlations between the PHP file to be classified and each reference PHP file;

[0013] a classifying unit, configured to perform classification processing on each PHP file to be classified based on the file similarity set corresponding to the PHP file to be classified.

[0014] In a possible implementation, the second obtaining unit is specifically configured to:

[0015] respectively perform the following operations for each PHP file to be classified:

[0016] for one PHP file to be classified in each PHP file to be classified, respectively obtain file similarities between the PHP file to be classified and each reference PHP file based on feature correlations between the PHP file to be classified and each reference PHP file, wherein the feature correlations are determined based on at least one of the annotation correlation information, the string correlation information, and the code correlation information;

[0017] obtain, based on the respective file similarities of each PHP file to be classified, the file similarity set corresponding to each PHP file to be classified.

[0018] In a possible implementation, the feature correlation between one PHP file to be classified and one reference PHP file in each reference PHP file is determined by the second obtaining unit in the following manner:

[0019] if one correlation information between the PHP file to be classified and the reference PHP file is obtained, the one correlation information is directly taken as the feature correlation;

[0020] if at least two correlation information between the PHP file to be classified and the reference PHP file are obtained, the feature correlation is determined based on a weighted processing result of the at least two correlation information.

[0021] In a possible implementation, before determining the feature correlation degree based on the weighted processing result of the at least two correlation degrees, the second obtaining unit is further configured to:

[0022] input the at least two correlation degrees into corresponding incentive functions respectively to adjust the accuracy, and obtain adjusted at least two correlation degrees.

[0023] In a possible implementation, the second obtaining unit is further configured to:

[0024] For each to-be-classified PHP file, the following operations are respectively performed:

[0025] If it is determined that there is at least one category group, for each to-be-classified PHP file, at least one file similarity set corresponding to the to-be-classified PHP file is obtained; the at least one file similarity set includes at least one of the following: a first file similarity set determined based on each first file similarity obtained by the to-be-classified PHP file and each other to-be-classified PHP file in the corresponding to-be-classified file set; at least one second file similarity set determined based on each second file similarity obtained by the to-be-classified PHP file and each target PHP file included in each category group in the at least one category group.

[0026] If it is determined that there is no at least one category group, for each to-be-classified PHP file, a file similarity set corresponding to the to-be-classified PHP file is obtained; the file similarity set is a first file similarity set determined based on each first file similarity obtained by the to-be-classified PHP file and each other to-be-classified PHP file in the corresponding to-be-classified file set.

[0027] In a possible implementation, the file similarity set includes the first file similarity set, and the classification unit is specifically configured to:

[0028] For each to-be-classified PHP file, the following operations are respectively performed:

[0029] For each to-be-classified PHP file, a first file similarity set corresponding to the to-be-classified PHP file is determined.

[0030] For each first file similarity in the first file similarity set, the following operations are respectively performed:

[0031] If it is determined that the first file similarity is greater than the first threshold, then the to-be-classified PHP file corresponding to the first file similarity and other to-be-classified PHP files are classified into the same category.

[0032] If it is determined that the first file similarity is not greater than the first threshold, then the to-be-classified PHP file corresponding to the first file similarity and other to-be-classified PHP files are classified into different categories.

[0033] In a possible implementation, the file similarity set includes at least one second file similarity set, and the classification unit is specifically configured to:

[0034] For each to-be-classified PHP file, the following operations are respectively performed:

[0035] For each to-be-classified PHP file, the following operations are respectively performed:

[0036] For each second file similarity set in the at least one second file similarity set, the following operations are respectively performed:

[0037] Selecting a preset number of second file similarities from a second file similarity set, and determining a decision similarity based on the selected second file similarities;

[0038] If it is determined that the decision similarity is greater than the second threshold, then the to-be-classified PHP file is classified into the category group corresponding to the second file similarity set;

[0039] If it is determined that the decision similarity is not greater than the second threshold, then the to-be-classified PHP file is not classified into the category group corresponding to the second file similarity set.

[0040] In a third aspect, an embodiment of the present application provides a PHP file classification device, including a memory and a processor, wherein the memory is configured to store computer instructions; and the processor is configured to execute the computer instructions to implement the PHP file classification method provided by the embodiment of the present application.

[0041] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores computer instructions, and the computer instructions are executed by a processor to implement the PHP file classification method provided by the embodiment of the present application.

[0042] The present application has the following beneficial effects:

[0043] The embodiment of the present application provides a PHP file classification method and device and a storage medium, so as to improve the accuracy of PHP file classification. First, a to-be-classified file set is obtained, and the to-be-classified file set includes at least one to-be-classified PHP file; then, based on each to-be-classified PHP file in the to-be-classified file set, a file similarity set corresponding to each to-be-classified PHP file is obtained respectively, each file similarity set includes: each file similarity determined based on the feature correlation between the corresponding to-be-classified PHP file and each reference PHP file; and based on the file similarity set corresponding to each to-be-classified PHP file, each to-be-classified PHP file is classified. A method for classifying to-be-classified PHP files is provided, and in the method, the file similarity between the to-be-classified PHP file and the reference file is determined based on the feature correlation, the features of the PHP file are referred to for classifying the to-be-classified PHP file, and the accuracy of classification is improved.

[0044] Other features and advantages of the present application will be set forth in the following description, and in part will become apparent to those skilled in the art from the following description, or can be learned by practice of the present application. The objects and other advantages of the present application can be realized and achieved by the structure particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained from these drawings without creative labor.

[0046] Figure 1 An application scenario schematic diagram provided by the embodiment of the present application;

[0047] Figure 2 A PHP file classification method flowchart provided by the embodiment of the present application;

[0048] Figure 3 A method flowchart for determining a file similarity set provided by the embodiment of the present application;

[0049] Figure 4 A schematic diagram for determining a first file similarity set provided by the embodiment of the present application;

[0050] Figure 5 A schematic diagram for determining a second file similarity set provided by the embodiment of the present application;

[0051] Figure 6A PHP file provided for an embodiment of the present application;

[0052] Figure 7 A method flowchart for determining the file similarity between a to-be-classified PHP file and a reference PHP file provided for an embodiment of the present application;

[0053] Figure 8 A whole method flowchart for PHP file classification provided for an embodiment of the present application;

[0054] Figure 9 A structural diagram of a PHP file classification device provided for an embodiment of the present application;

[0055] Figure 10 A structural diagram of a computing device provided for an embodiment of the present application. DETAILED DESCRIPTION

[0056] In order to make the objectives, technical solutions and beneficial effects of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0057] The terms "first", "second", and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein.

[0058] Some terms in the embodiments of the present application are explained below to facilitate understanding by those skilled in the art.

[0059] 1. Hypertext Preprocessor (PHP): a scripting language executed on a server side, especially suitable for web development and can be embedded in Hypertext Markup Language (HTML). The PHP syntax utilizes C, Java and Perl, and the main goal of the language is to allow web developers to quickly write dynamic web pages. PHP scripts are mainly used in web server development, command line and desktop application programming. A PHP file is a script file that has been compiled in web server development, command line and desktop application programming.

[0060] 2. Antivirus Engine: This is a technical mechanism that determines whether a specific program's behavior is that of a virus (or something suspicious). The antivirus engine is the main part of antivirus software. It's the program that detects and discovers viruses. The virus database contains samples of discovered viruses. The virus database is used to compare all programs or files on the machine to see if they match. If they do, the program or file is confirmed to be a virus; otherwise, it may not be, because there are many undiscovered or newly created viruses.

[0061] 3. Jaccard Similarity: Also known as the Jaccard similarity coefficient, it is used to compare the similarity and differences between finite sample sets. Examples include similarity between sets, string similarity, object detection similarity, and document deduplication. Jaccard similarity is calculated as the ratio of the number of intersections to the number of unions. For example, given two sets A and B, the Jaccard similarity is defined as the ratio of the size of the intersection of A and B to the size of the size of the union of A and B. At this point, the higher the Jaccard similarity value, the higher the sample similarity. Conversely, the metric related to Jaccard similarity is called Jaccard distance, which describes the dissimilarity between sets; the higher the Jaccard distance, the lower the sample similarity.

[0062] 4. Levenshtein Similarity: Used to calculate the Levenshtein distance between two strings. The Levenshtein distance, also known as the edit distance, refers to the minimum number of edit operations required to transform one string into the other. Permitted edit operations include replacing one character with another, inserting a character, and deleting a character.

[0063] 5. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to realize the computing, storage, processing, and sharing of data.

[0064] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology and other technologies based on cloud computing business model application, which can form a resource pool and be used on demand. Cloud computing technology will become an important support. The background service of the technical network system needs a large amount of computing and storage resources, such as video websites, picture websites and more portals. With the high development and application of the Internet industry, every item may have its own identification mark in the future, and it needs to be transmitted to the background system for logical processing. Different levels of data will be processed separately, and various industry data will need strong system support, which can only be realized through cloud computing.

[0065] The design concept of the embodiment of the present application is briefly introduced as follows:

[0066] The embodiment of the present application provides a file classification method for a PHP file. In the related art, a method for automatically classifying documents is proposed. The document automatic classification method is mainly designed based on natural language processing technology (NLP) and machine learning (ML) in artificial intelligence technology. Specifically, the NLP method is used to convert text into a sequence, and then a machine learning related method is used for classification.

[0067] Artificial intelligence is to use digital computers or digital computer controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology of computer science, which tries to understand the essence of intelligence and produce a new intelligent machine that can react in a similar way to human intelligence.

[0068] Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology mainly includes computer vision technology, natural language processing technology, and machine learning / deep learning and other directions. With the research and progress of artificial intelligence technology, artificial intelligence has been researched and applied in many fields, such as common smart home, intelligent customer service, virtual assistant, smart speaker, intelligent marketing, unmanned vehicle, autonomous driving, robot, intelligent medical treatment, etc. It is believed that with the development of technology, artificial intelligence will be applied in more fields and play an increasingly important role.

[0069] Machine learning is a multi-disciplinary subject, involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, etc. It is a specialized study of how computers simulate or implement human learning behavior to acquire new knowledge or skills, reorganize existing knowledge structure, and continuously improve their performance. Compared with data mining, which finds mutual characteristics between large data, machine learning focuses more on algorithm design, enabling computers to automatically "learn" rules from data and use the rules to predict unknown data.

[0070] Machine learning is the core of artificial intelligence and the fundamental approach to making computers intelligent. Its applications are widespread in various fields of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, etc. Reinforcement learning (RL), also known as relearning, evaluation learning or enhancement learning, is one of the paradigms and methodologies of machine learning, which is used to describe and solve the problem of maximizing rewards or achieving specific goals through learning strategies in the interaction process between agents and the environment.

[0071] Using the document classification method cannot effectively classify PHP files because the focus of documents and PHP files is different, so the classification effect is not good when using the document classification method to classify PHP files.

[0072] In addition, in the process of classifying PHP files using the classification method based on NLP and machine learning, a word library corresponding to the PHP files and a machine learning model need to be constructed separately, which causes the classification method based on NLP and machine learning to have poor generality and consume many resources when classifying PHP files.

[0073] Therefore, the embodiments of the present application provide a PHP file classification method and device and a storage medium, which determine the file similarity between PHP files in combination with the characteristics of PHP files, and automatically classify similar PHP files into the same category according to the file similarity. This scheme is applicable to all PHP files, reduces the labor cost, and improves the accuracy of PHP file classification.

[0074] In the embodiment of the present application, a set of files to be classified is obtained, and the set of files to be classified includes at least one PHP file to be classified; for each PHP file to be classified in the set of files to be classified, a file similarity set corresponding to each PHP file to be classified is obtained respectively, each file similarity set includes: each file similarity determined based on the feature correlation between the corresponding PHP file to be classified and each reference PHP file; and each PHP file to be classified is classified based on the file similarity set corresponding to each PHP file to be classified.

[0075] In a possible implementation, the feature correlation is determined by the following method:

[0076] If one of the annotation correlation information, the string correlation information, and the code correlation information between one PHP file to be classified and one reference PHP file is obtained, the one correlation information is directly taken as the feature correlation;

[0077] If at least two of the annotation correlation information, the string correlation information, and the code correlation information between one PHP file to be classified and one reference PHP file are obtained, the feature correlation is determined based on the weighted processing result of the at least two correlation information.

[0078] In the embodiment of the present application, in the process of classifying the PHP files, the features unique to the PHP files are extracted in sequence, and the file similarity is calculated by combining multiple features, which improves the accuracy of the file similarity and further improves the accuracy of the PHP file classification.

[0079] After introducing the design idea of the embodiment of the present application, the application scenarios to which the technical solution of the embodiment of the present application can be applied will be briefly introduced, and it should be noted that the following application scenarios are only used to illustrate the embodiment of the present application but not to limit. In the specific implementation process, the technical solution provided by the embodiment of the present application can be flexibly applied according to actual needs.

[0080] Please refer to Figure 1 , Figure 1 An application scenario diagram is exemplarily provided, and the application scenario includes a terminal device 10 (such as but not limited to 10-1 or 10-2 shown in the diagram) and a server 11.

[0081] The terminal device 10 is an electronic device used by a user, and various reading software and websites with reading comment functions are installed and run in the terminal device 10. The terminal device 10 can be a personal computer, a mobile phone, a tablet computer, a notebook computer, an e-book reader, or other computer devices; and the terminal device 10 can also be a chat robot.

[0082] The server 11 can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms.

[0083] In a possible implementation, the terminal device 10 and the server 11 can communicate through a communication network, which is a wired network or a wireless network. Therefore, the terminal device 10 and the server 11 can be directly or indirectly connected through wired or wireless communication. For example, the terminal device 10 can also be indirectly connected to the server 11 through a wireless access point 12, or the terminal device 10 can be directly connected to the server 11 through the Internet, which is not limited in the present application.

[0084] In a possible implementation, the terminal device 10 downloads a program file from the server 11, and determines whether the downloaded program file is a virus program or a suspicious virus program through an antivirus engine in the terminal device. The specimens in the virus library of the antivirus engine need to be manually added.

[0085] When the terminal device 10 downloads at least one PHP file from the server 11, the antivirus engine in the terminal device 10 judges whether the downloaded PHP file is a virus program or a suspicious virus program. If the antivirus engine cannot identify the obtained at least one PHP file, the at least one PHP file needs to be analyzed by manual means, and the analysis result is added to the virus library of the antivirus engine as a specimen. If the obtained at least one PHP file is identified by manual means, it is time-consuming and laborious, and the labor cost is high. Therefore, the at least one PHP file is classified in advance, one or more in a category are analyzed, if it is determined that a PHP file in a category is a virus program or a suspected virus program, it is determined that all PHP files in the category are virus programs or suspected virus programs; or it is determined that the number of PHP files in a category that are virus programs or suspected virus programs reaches a preset value, it is determined that all PHP files in the category are virus programs or suspected virus programs. And add the PHP file that is a virus program or a suspected virus program to the virus library of the antivirus engine. Through the method of pre-classification and analysis of a category, the number of PHP files processed manually can be reduced, the manual time can be saved, and by analyzing a PHP file in a category, the purpose of quickly adding all PHP files in this category to the virus library can be achieved. At the same time, according to the analyzed PHP file, the newly added PHP file can be judged and quickly filtered out.

[0086] In a possible application scenario, the cloud storage technology can be used to save the PHP files to be classified in the embodiments of the present application. Cloud storage is a new concept extended and developed on the basis of cloud computing. A distributed cloud storage system (hereinafter referred to as a storage system) refers to a storage system that cooperatively works together to provide data storage and business access functions to the outside by means of functions such as cluster application, grid technology, and distributed storage file system, etc.

[0087] Based on the above application scenario, the PHP file classification method provided by the exemplary embodiments of the present application will be described in combination with the above-described application scenario according to the accompanying drawings. It should be noted that the above-described application scenario is only for the purpose of facilitating understanding of the spirit and principles of the present application, and the embodiments of the present application are not limited in this respect.

[0088] For reference Figure 2 , Figure 2 An exemplary PHP file classification method flowchart is provided in the embodiments of the present application, which includes the following steps:

[0089] Step S200, obtaining a to-be-classified file set, the to-be-classified file set including at least one to-be-classified PHP file.

[0090] The terminal device obtains at least one to-be-classified PHP file from the server to form the to-be-classified file set.

[0091] Step S201, for each to-be-classified PHP file in the to-be-classified file set, obtaining a file similarity set corresponding to each to-be-classified PHP file respectively, each file similarity set including: each file similarity determined based on the feature correlation between the corresponding to-be-classified PHP file and each reference PHP file.

[0092] In the embodiment of the present application, in order to reduce the workload of manual analysis, a design for pre-classifying the to-be-classified PHP files in the to-be-classified file set is provided, and a plurality of classified category groups are obtained, and then at least one PHP file in each category group is analyzed.

[0093] In the process of classifying each to-be-classified PHP file in the to-be-classified file set, each to-be-classified PHP file is classified based on the file similarity set corresponding to each to-be-classified PHP file.

[0094] Therefore, in the embodiment of the present application, the file similarity set corresponding to each to-be-classified PHP file needs to be obtained for each to-be-classified PHP file.

[0095] In a possible implementation, when obtaining the file similarity set corresponding to each to-be-classified PHP file in the to-be-classified file set, it is determined whether the local currently stores at least one classified category group.

[0096] If it is determined that there is at least one category group, it is determined that each to-be-classified PHP file corresponds to at least one file similarity set; the at least one file similarity set includes at least one of the following:

[0097] The first file similarity set is determined based on each first file similarity obtained by the to-be-classified PHP file and each other to-be-classified PHP file in the corresponding to-be-classified file set;

[0098] The at least one second file similarity set is determined based on each second file similarity corresponding to each category group obtained by the to-be-classified PHP file and each target PHP file included in each category group in the at least one category group.

[0099] If it is determined that there is no at least one category group currently, it is determined that each of the to-be-classified PHP files corresponds to a file similarity set respectively; wherein, one file similarity set is:

[0100] Based on the to-be-classified PHP file, each of the other to-be-classified PHP files in the corresponding to-be-classified file set, each of the first file similarities obtained, and the first file similarity set determined.

[0101] Next, taking one to-be-classified PHP file W in the to-be-classified set as an example, the determination of the file similarity set corresponding to the to-be-classified PHP file is described:

[0102] Please refer to Figure 3 , Figure 3 An example provides a flowchart of a method for determining a file similarity set in the embodiment of the application, including the following steps:

[0103] Step S300, obtaining a to-be-classified file set, the to-be-classified file set including at least one to-be-classified PHP file.

[0104] Step S301, selecting one to-be-classified PHP file W in the to-be-classified file set which needs to determine a file similarity set currently.

[0105] Randomly selecting one to-be-classified PHP file in the to-be-classified file set as the to-be-classified PHP file W which needs to determine a file similarity set currently.

[0106] Step S302, judging whether there is at least one category group locally currently, if there is at least one category group, executing step S303, otherwise executing step S305.

[0107] Step S303, determining that each reference PHP file includes two types of reference PHP files, which are respectively: each of the other to-be-classified PHP files in the to-be-classified file set except the to-be-classified PHP file W which needs to determine a file similarity set currently, and each of the target PHP files included in each of the at least one category group.

[0108] In a possible implementation, each of the reference PHP files can be embodied in the form of a set, if it is determined that there is at least one category group stored, it is determined that there are at least two reference PHP file sets, wherein, the at least two reference PHP file sets include:

[0109] A reference PHP file set composed of each other PHP file in the to-be-classified file set except the to-be-classified PHP file W for which the file similarity set needs to be determined currently; for example, the to-be-classified file set is {to-be-classified PHP file 1, to-be-classified PHP file 2, …, to-be-classified PHP file 10}, and the to-be-classified file set contains 10 to-be-classified PHP files; wherein the to-be-classified PHP file W is the to-be-classified PHP file 1, and the reference PHP file set is {to-be-classified PHP file 2, …, to-be-classified PHP file 10};

[0110] A reference PHP file set composed of each target PHP file in the same category group; for example, it is determined that there are 3 category groups, which are category group G1, category group G2, and category group G3. Wherein, the category group G1 is {target PHP file G1T1, target PHP file G1T2, …, target PHP file G1T6}, and the reference PHP file set is {target PHP file G1T1, target PHP file G1T2, …, target PHP file G1T6}; similarly, if the category group G2 is {target PHP file G2T1, target PHP file G2T2, …, target PHP file G2T5}, the reference PHP file set is {target PHP file G2T1, target PHP file G2T2, …, target PHP file G2T5}; and so on, when there are how many category groups, there are corresponding number of another reference PHP file set.

[0111] In step S304, based on the to-be-classified PHP file W, the first file similarity set determined based on each first file similarity obtained by the to-be-classified PHP file W and each other PHP file in the corresponding to-be-classified file set, and the at least one second file similarity set determined based on each second file similarity obtained by the to-be-classified PHP file W and each target PHP file in each category group in the at least one category group, at least one file similarity set corresponding to the to-be-classified PHP file W is obtained.

[0112] Case one: if it is determined that there is at least one category group currently in the local, each reference PHP file includes two types of reference PHP files, which are:

[0113] Each other PHP file in the to-be-classified file set except the to-be-classified PHP file W for which the file similarity set needs to be determined currently; and

[0114] Each target PHP file in the at least one category group.

[0115] At this time, each to-be-classified PHP file corresponds to at least one file similarity set.

[0116] Taking a PHP file W to be classified as an example, where the file similarity set needs to be determined, the file similarity set corresponding to the PHP file W to be classified must include at least one of the following:

[0117] 1. Based on the PHP file W to be classified and the similarity between each first file and each other PHP file to be classified in the corresponding set of files to be classified, the first file similarity set is determined.

[0118] For example, the set of files to be classified is {PHP file to be classified 1, PHP file to be classified 2, ..., PHP file to be classified 10}, which contains 10 PHP files to be classified.

[0119] For 10 PHP files to be classified, the first file similarity set of a PHP file W that needs to be classified needs to be determined. The first file similarity between W and the remaining 9 other PHP files to be classified is determined respectively. Based on the determined first file similarity, the first file similarity set is formed.

[0120] Please refer to Figure 4 , Figure 4 An exemplary schematic diagram of determining a first file similarity set is provided in an embodiment of this application. Let the PHP file W to be classified be PHP file 1, and the remaining 9 other PHP files to be classified be: PHP file 2...PHP file 10. Then, the first file similarity between PHP file 1 and PHP file 2...PHP file 10 is determined as: first file similarity 1-2, first file similarity 1-3...first file similarity 1-10; therefore, the first file similarity set is determined as {first file similarity 1-2, first file similarity 1-3...first file similarity 1-10}, where first file similarity 1-2 is the file similarity between PHP file 1 and PHP file 2, first file similarity 1-3 is the file similarity between PHP file 1 and PHP file 3, and so on, without further explanation.

[0121] Similarly, the first file similarity set corresponding to the PHP file 2 to be processed is {first file similarity 2-1, first file similarity 2-3...first file similarity 2-10};

[0122] The first file similarity set corresponding to the PHP file 3 to be processed is {first file similarity 3-1, first file similarity 3-2...first file similarity 3-10}, and so on.

[0123] 2. based on the to-be-classified PHP file W and each target PHP file contained in each of the at least one category group, obtaining each second file similarity corresponding to each of the at least one second file similarity set, wherein one second file similarity set corresponds to one category group;

[0124] For example, it is determined that there are currently three category groups, namely, category group G1, category group G2, and category group G3, and the to-be-classified PHP file W will correspond to three second file similarity sets, namely, second file similarity set W-G1, second file similarity set W-G2, and second file similarity set W-G3.

[0125] For example, the second file similarity set W-G1 corresponds to the category group G1.

[0126] In the embodiments of the present application, each second file similarity set includes each second file similarity between the to-be-classified PHP file W and each target PHP file GT in the corresponding category group G.

[0127] The following describes the determination of one second file similarity set corresponding to the to-be-classified PHP file W based on the second file similarity between the to-be-classified PHP file W and each target PHP file T contained in one category group:

[0128] For example, the second file similarity set W-G1 corresponds to the category group G1. Figure 5 Figure 5 An exemplary schematic diagram for determining a second file similarity set in the embodiments of the present application is provided, assuming that one category group is the category group G1, and the category group G1 is {target PHP file G1T1, target PHP file G1T2, …, target PHP file G1Tn}. It can be seen that the category group G1 contains n target PHP files.

[0129] At this time, the second file similarity between the to-be-classified PHP file W and each target PHP file G1T1, G1T2, …, G1Tn is determined respectively, and the determined second file similarities are second file similarity W-G1T1, second file similarity W-G1T2, …, and second file similarity W-G1Tn. Therefore, one second file similarity set W-G1 corresponding to the to-be-classified PHP file W is {second file similarity W-G1T1, second file similarity W-G1T2, …, second file similarity W-G1Tn}.

[0130] ​Step S305, determining each reference PHP file comprises a category of reference PHP files, which are each other PHP file in the set of to-be-classified files except the to-be-classified PHP file W for which the set of file similarities is currently being determined.

[0131] Step S306, obtaining each first file similarity between the to-be-classified PHP file W and each other to-be-classified file in the set of to-be-classified files, and determining a first set of file similarities based on the obtained first file similarities.

[0132] Case two: if it is determined that there is no at least one category group currently existing locally, each reference PHP file only comprises other to-be-classified PHP files in the set of to-be-classified files except the to-be-classified PHP file for which the set of file similarities is currently being determined;

[0133] Therefore, each to-be-classified PHP file corresponds to a set of file similarities, and the set of file similarities is a first set of file similarities determined based on each first file similarity obtained between a to-be-classified PHP file and each other to-be-classified file in the set of to-be-classified files, which will not be repeated here and can be specifically referred to the embodiments of case one.

[0134] Based on the above case one and case two, it can be known that, whether the reference PHP file is other to-be-classified PHP file in the set of to-be-classified files or target PHP file in the at least one category group, in the process of determining the set of file similarities corresponding to each to-be-classified PHP file, it is:

[0135] First, the file similarity between the to-be-classified PHP file and the reference PHP file is determined, and then the set of file similarities is composed based on the determined file similarity.

[0136] In the embodiments of the present application, the file similarity is determined based on the feature correlation degree, and in a possible implementation manner, the feature correlation degree is the file similarity. Therefore, how to determine the feature correlation degree in the embodiments of the present application will be mainly introduced below.

[0137] Taking the determination of the feature correlation degree between a to-be-classified PHP file W and a reference PHP file R as an example for description:

[0138] First, the same features are extracted from a to-be-classified PHP file W and a reference PHP file R respectively, and the to-be-classified PHP file W and the reference PHP file R are both PHP files, which contain features such as comments, strings and codes. Please refer to Figure 6 , Figure 6An example provides a schematic of a PHP file in the embodiment of the application, which can be known that the PHP file contains comment information, string information and code information.

[0139] Then, based on the extracted features of comment, string and code, at least one of the comment relevance information, the string relevance information and the code relevance information between the PHP file to be classified W and the reference PHP file R is obtained.

[0140] Finally, based on the obtained at least one relevance information, the feature relevance between the PHP file to be classified W and the reference PHP file R is determined.

[0141] In a possible implementation, if one of the comment relevance information, the string relevance information and the code relevance information between the PHP file to be classified W and the reference PHP file R is obtained, the one relevance information is directly taken as the feature relevance.

[0142] For example, if the comment relevance information is obtained, the comment relevance information is taken as the feature relevance; if the string relevance information is obtained, the string relevance information is taken as the feature relevance; and if the code relevance information is obtained, the code relevance information is taken as the feature relevance.

[0143] In a possible implementation, if at least two of the comment relevance information, the string relevance information and the code relevance information between the PHP file to be classified W and the reference PHP file R are obtained, the feature relevance is determined based on the weighted processing result of the at least two relevance information.

[0144] For example, if the comment relevance information and the string relevance information of the comment relevance information, the string relevance information and the code relevance information between the PHP file to be classified W and the reference PHP file R are obtained, the feature relevance between the PHP file to be classified W and the reference PHP file R is determined as: X1*comment relevance information+X2*string relevance information, wherein X1 and X2 are weights of the comment relevance information and the string relevance information respectively, and X1+X2=1.

[0145] If all the correlation information between the to-be-classified PHP file W and the reference PHP file R is obtained, the feature correlation between the to-be-classified PHP file W and the reference PHP file R is determined as: X1*annotation correlation information + X2*string correlation information + X3*code correlation information, where X1, X2, and X3 are weights of the annotation correlation information, the string correlation information, and the code correlation information respectively, and X1+X2+X3=1.

[0146] In a possible implementation, to ensure the accuracy of the file similarity, that is, to ensure the accuracy of the feature correlation, after at least two kinds of correlation information between a to-be-classified PHP file W and a reference PHP file R are obtained, the at least two kinds of correlation information are respectively input into corresponding activation functions for accuracy adjustment before the feature correlation is determined based on a weighted processing result of the at least two kinds of correlation information.

[0147] The following describes an example in which all the correlation information between a to-be-classified PHP file W and a reference PHP file R is obtained.

[0148] For details, refer to Figure 7 , Figure 7 An example provides a flowchart of a method for determining the file similarity between a to-be-classified PHP file and a reference PHP file in the embodiment of the application, including the following steps.

[0149] Step S700: annotation information is extracted from a to-be-classified PHP file W and a reference PHP file R, to obtain first annotation information of the to-be-classified PHP file W and second annotation information of the reference PHP file R.

[0150] The terminal device automatically scans the to-be-classified PHP file W and the reference PHP file R, and extracts the annotation information in the PHP file as the first feature by using the regular matching method. The annotation characters / / and / ** / in the PHP file are used for regular matching, including single-line and multi-line annotation information. The annotation information can provide a large amount of effective information, such as author information, time information, and explanation information of the code in the PHP file.

[0151] In a possible implementation, the extracted annotation information is stored in the form of an annotation list, and the to-be-classified PHP file W and the reference PHP file R each correspond to an annotation list, and each table element in the annotation list is a line of annotation information in the corresponding PHP file. For example, a plurality of lines of annotation information are extracted from the to-be-classified PHP file W, and each line of annotation information is a table element in the annotation list corresponding to the to-be-classified PHP file W.

[0152] In step S701, similarity matching is performed on the first annotation information and the second annotation information, to obtain annotation correlation information between the to-be-classified PHP file W and the reference PHP file R.

[0153] After the first annotation information and the second annotation information are determined, the Jaccard similarity is used to determine the annotation correlation information between the to-be-classified PHP file and the reference PHP file. That is, the number of same annotation information contained in the annotation list corresponding to the to-be-classified PHP file W and the annotation list corresponding to the reference PHP file is determined, and the total amount of annotation information in the two annotation lists is determined, and the ratio between the number of same annotation information and the total amount of annotation information is taken as the annotation correlation information.

[0154] That is, in the process of obtaining the annotation correlation information between the to-be-classified PHP file W and the reference PHP file R, that is, obtaining the ratio between the intersection and the union of the table elements contained in the annotation list of the to-be-classified PHP file W and the annotation list of the reference PHP file R.

[0155] In step S702, string information is extracted from the to-be-classified PHP file W and the reference PHP file R after the annotation information is extracted, to obtain first string information of the to-be-classified PHP file and second string information of the reference PHP file.

[0156] The terminal device extracts string information from the to-be-classified PHP file W and the reference PHP file R obtained after the annotation information is extracted, by using a regular matching method. The string is mainly matched by using “” and ‘’. The double quotation marks and the single quotation marks must appear in pairs. Because the PHP file contains a large amount of user-defined string information, the string information is key information for distinguishing the to-be-classified PHP file and the reference PHP file.

[0157] It should be noted that, in order to filter out incorrect matching places, neither the matched string information that is too long nor the matched string information that is too short is extracted.

[0158] In step S703, similarity matching is performed on the first string information and the second string information, to obtain string information correlation information between the to-be-classified PHP file W and the reference PHP file R.

[0159] In a possible implementation, based on the extracted string information, the Jaccard similarity is used to determine the string correlation information between the PHP file to be classified and the reference PHP file. For details, refer to the step of determining the annotation correlation information by using the Jaccard similarity, which is not described herein.

[0160] In step S704, the code information is extracted from the PHP file to be classified W and the reference PHP file R, respectively, after the annotation information and the string information are extracted, to obtain the first code information of the PHP file to be classified and the second code information of the reference PHP file.

[0161] After steps S700-S703, there is no annotation information and string information in the PHP file, and only variable names and code information are left.

[0162] In the process of extracting the code information from the PHP file to be classified W and the reference PHP file R, the terminal device mainly uses the dictionary matching method, that is, the code information of the PHP file to be classified and the code information of the reference PHP file are matched with the code information pre-constructed in the dictionary, respectively, to obtain the matching successful code information.

[0163] Specifically, the code information in the PHP file to be classified W is matched with the code information pre-constructed in the dictionary, and the matching successful code information is arranged according to the code order in the PHP file to generate a code sequence used to represent the code information. The reference PHP file uses the same way to determine the corresponding code sequence, which is not described herein.

[0164] In the embodiment of the present application, the code information pre-constructed in the dictionary matching method is determined by the following way:

[0165] First, a certain number of PHP files that have undergone annotation information extraction and string information extraction are obtained.

[0166] Then, the PHP files that have undergone annotation information extraction and string information extraction are subjected to word segmentation processing to obtain a code array. In a possible implementation, the PHP files are subjected to word segmentation processing by using a regular expression, and therefore, only words and characters that can appear in the PHP code are matched in the code array.

[0167] Finally, the frequency of the strings obtained in the code array is calculated, and the high-frequency PHP code with a frequency greater than a set threshold is extracted. For example, the threshold is set to 0.25, and at this time, the strings with a frequency higher than 0.25 are retained. In this process, the variable names are filtered out, and the remaining ones are basically PHP code information. The obtained PHP code information is stored in the dictionary for subsequent use when extracting the code information from the PHP file.

[0168] In step S705, similarity matching is performed on the first code information and the second code information to obtain code information correlation information between the PHP file to be classified and the reference PHP file.

[0169] For the code sequence used to represent the code information determined in step S704, since the code with a high frequency of occurrence in most PHP files is approximately the same, that is, the high-frequency words in most PHP files are approximately the same, and the code sequence has a sequence of codes, the Jaccard similarity cannot effectively distinguish the PHP files, and the Jaccard similarity is used to determine the code information correlation information between the PHP file to be classified and the reference PHP file, and the result of the determination has a great influence.

[0170] Therefore, in the embodiment of the present application, the Levenshtein similarity is used to determine the code information correlation information between the code sequence of the PHP file to be classified W and the code sequence of the reference PHP file R, that is, the Levenshtein distance is used as the code information correlation information. The Levenshtein similarity as a measure of the code information correlation information indicates that a certain code sequence needs to be transformed into another code sequence at least several times, and the fewer the number of transformations, the higher the correlation. The length of the code sequence can be limited to save the classification time.

[0171] In step S706, the comment correlation information, the string information correlation information, and the code information are respectively input into corresponding incentive functions for precision adjustment to obtain adjusted comment correlation information, string information correlation information, and code information.

[0172] The incentive function changes the linear growth of the correlation information. For example, the number of comments of the PHP file to be classified W and the reference PHP file R is fixed, and the corresponding comment correlation information is linearly related to the number of the same comment information in the PHP file to be classified W and the reference PHP file R. However, in fact, this is not the case. Since the comment information in the PHP file usually follows a certain format, there are many cases where the individual comment information of unrelated PHP files is consistent. If the comment information in the PHP file to be classified W and the reference PHP file R has multiple similarities, it is highly likely that they are PHP files of the same category. Therefore, it is known that the actual correlation information and the comment correlation information should not be a linear correspondence relationship. Therefore, the incentive function is added here to make the correlation information closer to the actual situation and prevent the correlation information from being too high to cause misjudgment.

[0173] It should be noted that step S706 can be set according to actual conditions, that is, the incentive function can be set or not set, and the expression of the incentive function can also be set according to actual conditions.

[0174] In step S707, the adjusted annotation correlation degree information, the string information correlation degree information and the code information are weighted, and the weighted result is taken as the feature correlation degree between the PHP file to be classified and the reference PHP file.

[0175] In step S708, the feature correlation degree between the PHP file to be classified and the reference PHP file is taken as the file similarity between the PHP file to be classified and the reference PHP file.

[0176] In step S202, each PHP file to be classified is classified based on the file similarity set corresponding to each PHP file to be classified.

[0177] In the embodiment of the application, the similarity set corresponding to each PHP file to be classified can contain only a first file similarity set, or can contain a first file similarity set and at least one second file similarity set. The processing manner is different when classifying the corresponding PHP file based on the first file similarity set and the at least one second file similarity set.

[0178] The following describes a PHP file W to be classified:

[0179] Case one: the file similarity set corresponding to the PHP file W to be classified contains a first file similarity set, and when the PHP file W to be classified is classified based on the file similarity set corresponding to the PHP file W to be classified:

[0180] First, for the PHP file W to be classified, the first file similarity set corresponding to the PHP file W to be classified is determined; for example, the first file similarity set is {first file similarity 1-2, first file similarity 1-3, …, first file similarity 1-10}.

[0181] Then, for each first file similarity in the first file similarity set, it is determined whether the other PHP files to be classified corresponding to the first file similarity are in the same category as the PHP file W to be classified.

[0182] In one possible implementation, if it is determined that the first file similarity is greater than a first threshold, the PHP file to be classified corresponding to the first file similarity and the other PHP files to be classified are classified into the same category.

[0183] Taking one of the first file similarities in the first file similarity set as an example, it is described that: assuming that one of the first file similarities is first file similarity 1-2, the first file similarity 1-2 is 98%, if the first threshold is 90%, it is determined that the first file similarity 1-2 is greater than the first threshold, and it is determined that the to-be-processed file 1 corresponding to the first file similarity and the other to-be-processed file 2 are classified into the same category.

[0184] In another possible implementation, if it is determined that the first file similarity is not greater than the first threshold, the to-be-classified PHP file corresponding to the first file similarity and the other to-be-classified PHP file are classified into different categories.

[0185] Taking one of the first file similarities in the first file similarity set as an example, it is described that: assuming that one of the first file similarities is first file similarity 1-3, the first file similarity 1-3 is 78%, if the first threshold is 90%, it is determined that the first file similarity 1-3 is not greater than the first threshold, and it is determined that the to-be-processed file 1 corresponding to the first file similarity and the other to-be-processed file 3 are classified into different categories.

[0186] Case two: the file similarity set corresponding to the to-be-classified PHP file W contains at least one second file similarity set, and when the to-be-classified PHP file W is classified based on the file similarity set corresponding to the to-be-classified PHP file W:

[0187] First, for the to-be-classified PHP file W, at least one second file similarity set corresponding to the to-be-classified PHP file W is determined, wherein one second file similarity set corresponds to one category group.

[0188] Then, based on each second file similarity set corresponding to the to-be-classified PHP file W, a corresponding determination similarity of each second file similarity set is determined; wherein each determination similarity is determined based on at least one second file similarity in the corresponding second file similarity set.

[0189] Specifically, for each second file similarity set corresponding to each second file similarity set of the to-be-classified PHP file W, a preset number of second file similarities are selected from the second file similarity set, and a determination similarity is determined based on the selected second file similarities.

[0190] Taking a second file similarity set W-G1 corresponding to the to-be-classified PHP file W as an example, the second file similarity set W-G1 is {second file similarity W-G1T1, second file similarity W-G1T2, …, second file similarity W-G1Tn}, and three second file similarities are selected from the second file similarity set W-G1, that is, the second file similarity W-G1T1, the second file similarity W-G1T2, and the second file similarity W-G1Tn. At this time, the similarity is determined as (second file similarity W-G1T1+second file similarity W-G1T2+second file similarity W-G1Tn) / 3.

[0191] Finally, based on the respective determined similarities, it is determined whether the to-be-classified PHP file W belongs to the category group corresponding to the respective determined similarities.

[0192] In a possible implementation, if it is determined that the determined similarity is greater than the second threshold value, the to-be-classified PHP file is divided into the category group corresponding to the second file similarity set.

[0193] For example, based on the determined similarity (second file similarity W-G1T1+second file similarity W-G1T2+second file similarity W-G1Tn) / 3, if the determined similarity is 91% and the second threshold value is 85%, it is determined that the determined similarity is greater than the second threshold value, and the to-be-classified PHP file is divided into the category group G1.

[0194] In another possible implementation, if it is determined that the determined similarity is not greater than the second threshold value, the to-be-classified PHP file is not divided into the category group corresponding to the second file similarity set.

[0195] For example, based on the determined similarity (second file similarity W-G1T1+second file similarity W-G1T2+second file similarity W-G1Tn) / 3, if the determined similarity is 78% and the second threshold value is 85%, it is determined that the determined similarity is not greater than the second threshold value, and the to-be-classified PHP file is not divided into the category group G1.

[0196] It should be noted that when the file similarity set corresponding to the to-be-classified PHP file W includes both the first file similarity set and at least one second file similarity set, the following operations can be performed: first, based on the first file similarity set, it is determined that other to-be-classified PHP files in the to-be-classified set belong to the same category as the to-be-classified PHP file W; then, it is determined in which category group the to-be-classified PHP file W belongs; and finally, the other to-be-classified PHP files in the same category and the to-be-classified PHP file W are divided into the category group.

[0197] For example, the to-be-classified PHP file W is classified into the category group G1. Figure 8 The to-be-classified PHP file W is classified into the category group G1.Figure 8 An exemplary overall method flowchart of PHP file classification in the embodiments of the present application is provided, including the following steps:

[0198] In step S800, a set of files to be classified is obtained, and the set of files to be classified includes at least one PHP file to be classified;

[0199] In step S801, a PHP file to be classified W is selected from the set of files to be classified, and the PHP file to be classified W needs to determine a set of file similarities at present;

[0200] In step S802, based on the remaining other PHP files to be classified in the set of files to be classified and the target PHP files in the currently stored category group, each reference PHP file corresponding to the PHP file to be classified W is determined;

[0201] In step S803, based on the PHP file to be classified W and each reference PHP file, at least one set of file similarities corresponding to the PHP file to be classified W is obtained;

[0202] In step S804, based on the at least one set of file similarities corresponding to the PHP file to be classified W, the PHP file to be classified W is classified.

[0203] Based on the same inventive concept, the embodiments of the present application also provide a PHP file classification device 900, please refer to Figure 9 , Figure 9 An exemplary PHP file classification device 900 in the embodiments of the present application is provided, and the device includes:

[0204] The first obtaining unit 901 is configured to obtain a set of files to be classified, and the set of files to be classified includes at least one PHP file to be classified;

[0205] The second obtaining unit 902 is configured to obtain, for each PHP file to be classified in the set of files to be classified, a set of file similarities corresponding to the PHP file to be classified respectively, and each set of file similarities includes: each file similarity determined based on the association degree of each feature between the corresponding PHP file to be classified and each reference PHP file;

[0206] The classification unit 903 is configured to classify each PHP file to be classified based on the set of file similarities corresponding to each PHP file to be classified.

[0207] In a possible implementation, the second obtaining unit 902 is specifically configured to:

[0208] For each PHP file to be classified, the following operations are performed respectively:

[0209] For each of the to-be-classified PHP files, based on the feature correlation degree between the to-be-classified PHP file and each of the reference PHP files, a file similarity between the to-be-classified PHP file and each of the reference PHP files is obtained, wherein the feature correlation degree is determined based on at least one of the annotation correlation degree information, the string correlation degree information, and the code correlation degree information;

[0210] Based on the respective file similarities of each of the to-be-classified PHP files, a file similarity set corresponding to each of the to-be-classified PHP files is obtained.

[0211] In a possible implementation, the feature correlation degree between a to-be-classified PHP file and a reference PHP file is determined by the second obtaining unit 902 in the following manner:

[0212] If, for a to-be-classified PHP file, one of the annotation correlation degree information, the string correlation degree information, and the code correlation degree information between the to-be-classified PHP file and a reference PHP file is obtained, the one correlation degree information is directly taken as the feature correlation degree.

[0213] If, for a to-be-classified PHP file, at least two of the annotation correlation degree information, the string correlation degree information, and the code correlation degree information between the to-be-classified PHP file and a reference PHP file are obtained, the feature correlation degree is determined based on a weighted processing result of the at least two correlation degree information.

[0214] In a possible implementation, after the second obtaining unit 902 obtains, for a to-be-classified PHP file, at least two of the annotation correlation degree information, the string correlation degree information, and the code correlation degree information between the to-be-classified PHP file and a reference PHP file, and before the second obtaining unit 902 determines the feature correlation degree based on a weighted processing result of the at least two correlation degree information, the second obtaining unit 902 is further configured to:

[0215] The at least two correlation degree information is respectively input into a corresponding excitation function for accuracy adjustment to obtain adjusted at least two correlation degree information.

[0216] In a possible implementation, the second obtaining unit 902 is further configured to:

[0217] For each of the to-be-classified PHP files, the following operations are respectively performed:

[0218] If it is determined that there is at least one category group currently, for each of the to-be-classified PHP files, a file similarity set corresponding to the to-be-classified PHP file is obtained; wherein the at least one file similarity set includes at least one of the following: a first file similarity set determined based on each first file similarity obtained by the to-be-classified PHP file and each other to-be-classified PHP file in the corresponding to-be-classified file set; at least one second file similarity set determined based on each second file similarity corresponding to each category group obtained by the to-be-classified PHP file and each target PHP file included in each category group in the at least one category group;

[0219] If it is determined that there is no at least one category group currently, for each of the to-be-classified PHP files, a file similarity set corresponding to the to-be-classified PHP file is obtained; wherein the file similarity set is a first file similarity set determined based on each first file similarity obtained by the to-be-classified PHP file and each other to-be-classified PHP file in the corresponding to-be-classified file set.

[0220] In a possible implementation, the file similarity set includes the first file similarity set, and the classification unit 903 is specifically configured to:

[0221] For each of the to-be-classified PHP files, the following operations are respectively performed:

[0222] For each of the to-be-classified PHP files, a first file similarity set corresponding to the to-be-classified PHP file is determined;

[0223] For each of the first file similarities in the first file similarity set, the following operations are respectively performed:

[0224] If it is determined that a first file similarity is greater than a first threshold, a to-be-classified PHP file corresponding to the first file similarity and other to-be-classified PHP files are classified into a same category;

[0225] If it is determined that a first file similarity is not greater than a first threshold, a to-be-classified PHP file corresponding to the first file similarity and other to-be-classified PHP files are classified into different categories.

[0226] In a possible implementation, the file similarity set includes at least one second file similarity set, and the classification unit 903 is specifically configured to:

[0227] For each of the to-be-classified PHP files, the following operations are respectively performed:

[0228] For each of the to-be-classified PHP files, determine at least one second file similarity set corresponding to the to-be-classified PHP file, wherein one second file similarity set corresponds to one category group;

[0229] For each of the at least one second file similarity set, perform the following operations:

[0230] If the determined decision similarity is greater than the second threshold, the to-be-classified PHP file is classified into the category group corresponding to the second file similarity set.

[0231] If the determined decision similarity is not greater than the second threshold, the to-be-classified PHP file is not classified into the category group corresponding to the second file similarity set.

[0232] If the determined decision similarity is greater than the second threshold, the to-be-classified PHP file is classified into the category group corresponding to the second file similarity set.

[0233] If the determined decision similarity is not greater than the second threshold, the to-be-classified PHP file is not classified into the category group corresponding to the second file similarity set.

[0234] For the sake of description, each of the above sub-models is described as a unit (or a module) according to functions. Of course, the functions of each unit (or module) can be implemented in each or more software or hardware when the present application is implemented.

[0235] After introducing the PHP file classification method and device of the example embodiment of the present application, the PHP file classification computing device of another example embodiment of the present application is introduced.

[0236] Those skilled in the art can understand that each aspect of the present application can be implemented as a system, a method or a program product. Therefore, each aspect of the present application can be specifically implemented as a complete hardware embodiment, a complete software embodiment (including firmware, microcode, etc.), or an embodiment combining hardware and software, which can be collectively referred to as "circuitry", "module" or "system".

[0237] In one possible implementation, the PHP file classification computing device provided by the embodiments of the present application can at least include a processor and a memory. The memory stores program code, and when the program code is executed by the processor, the processor executes each step of the PHP file classification method in various example embodiments of the present application.

[0238] The PHP file classification computing device 1000 according to this embodiment of the present application will be described below with reference to Figure 10 The PHP file classification computing device 1000 according to this embodiment of the present application will be described below with reference to Figure 10The PHP file classification computing device 1000 is merely an example, and should not be taken as limiting the functionality or use of embodiments of the application.

[0239] As Figure 10 shown, the computing device 1000 can include a bus 1003 which is coupled to one or more of each of the following: a processor 1001; a memory 1002; a storage device 1007; and a presentation component 1008 such as a display device, speakers, a printing component, and so forth. As shown, the bus 1003 can be coupled to the following: the processor 1001; the memory 1002; the storage device 1007; and the presentation component 1008.

[0240] The bus 1003 represents one or more of any of several bus structures, including a memory bus or memory controller, a peripheral bus, a processor or local bus, and so forth using any of a variety of bus structures.

[0241] The memory 1002 can include read-only memory (ROM) 10023 in the form of flash-based or other nonvolatile memory. The memory 1002 can also include random access memory (RAM) 10021 in the form of synchronous dynamic RAM (SDRAM), static RAM (SRAM), twin-texture SRAM (TXT SRAM), or other types of RAM, including fast page mode RAM (FPM RAM), extended data output RAM (EDO RAM), extended data output dual transfer rate RAM (EDO DTR RAM), and so forth.

[0242] The memory 1002 can also include a program / utility 10025 having a set (at least one) of program modules 10024 such as an operating system, one or more application programs, other program modules, and program data, each or some combination thereof, which can include implementation of a network environment.

[0243] The computing device 1000 can also communicate with one or more external devices 1004 such as a keyboard, a pointing device, etc.; other devices such as are widely used in Figure 10 such as a router, a modem, and so on, via the network adapter 1006. As will be further illustrated below, the computing device 1000 can also include one or more input / output (I / O) interfaces 1005 coupled to the bus 1003 that can be used by the processor 1001 to communicate information and one or more storage devices 1007 (e.g., disk drives, optical drives, etc.) coupled to the bus 1003 for storing information and instructions for use by the processor 1001. Figure 10 It should be understood that although not shown, other hardware and / or software modules could be used in conjunction with the computing device 1000. Such

[0244] In some possible implementation, each aspect of the PHP file classification method provided by the present application can also be implemented in the form of a program product, which includes program codes for causing the computer device to perform the steps of the PHP file classification method according to various exemplary embodiments of the present application described above in the specification when the program product is run on the computer device.

[0245] The program product can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium may, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any suitable combination of the above. More specific examples (non-exhaustive list) of the readable storage medium include an electrical connection having one or more wires, a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0246] The program product of the short message sending control of the embodiment of the present application can adopt a portable compact disc read-only memory (CD-ROM) and include program codes, and can be run on a computing device.

[0247] The readable signal medium can include a data signal carried in a baseband or as a carrier wave in a propagated data signal, in which the readable program codes are carried. Such a propagated data signal can take on many forms, including but not limited to electro-magnetic signal, optical signal, or any suitable combination of the above. The readable signal medium can also be any readable medium that can send, propagate or transfer program codes for use by or in connection with an instruction execution system, apparatus or device.

[0248] The program codes contained on the readable medium can be transmitted by any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.

[0249] The program codes for performing the operations of the present application can be written in any combination of one or more programming languages, including an object-oriented programming language such as Java, C++, etc., and a conventional procedural programming language such as "C" language or similar programming languages.

[0250] It should be noted that, although several units or sub-units of the apparatus are mentioned in the foregoing detailed description, such division is merely exemplary and not mandatory. Indeed, according to an embodiment of the application, the features and functionalities of two or more units described above can be embodied in each unit. Conversely, the features and functionalities of each unit described above can be further divided into units embodied by several units.

[0251] Moreover, although the operations of the method(s) herein can be described in a particular, sequential order, this order is not meant to be a limitation and is not intended to imply that

[0252] Obviously, many modifications and changes can be made to the application without departing from the spirit and scope of the application. It is understood that the application is not to be limited to the particular examples described herein, but that the application should be construed in accordance with the appended claims and their equivalents.

Claims

1. A method for classifying PHP files using a hypertext preprocessor, characterized in that, The method comprises: The terminal device obtains at least one to-be-classified PHP file from the server to form a to-be-classified file set; For each to-be-classified PHP file in the to-be-classified file set, a respective file similarity set corresponding to each to-be-classified PHP file is obtained, each file similarity set comprising: each file similarity determined based on the respective feature correlation between the to-be-classified PHP file and each reference PHP file; Determine whether there is at least one classified category group currently stored in the local, wherein the classified category group is obtained by pre-classifying the to-be-classified PHP files in the to-be-classified set; If it is determined that there is at least one category group currently, a first file similarity set of a to-be-classified PHP file is obtained based on the respective feature correlation between the to-be-classified PHP file and each other to-be-classified PHP file in the to-be-classified file set; and each second file similarity corresponding to each category group is determined based on the to-be-classified PHP file and each target PHP file contained in the at least one category group, to determine at least one second file similarity set; If it is determined that there is no at least one category group currently, a first file similarity set of the to-be-classified PHP file is obtained based on the respective feature correlation between the to-be-classified PHP file and each other to-be-classified PHP file in the to-be-classified file set; Classify the to-be-classified PHP files based on the respective file similarity set corresponding to each to-be-classified PHP file; The method comprises the following steps: Extract the annotation information from the to-be-classified PHP file and the reference PHP file respectively, and obtain the annotation correlation information between the first annotation information of the to-be-classified PHP file and the second annotation information of the reference PHP file; Extract the string information from the to-be-classified PHP file and the reference PHP file after extracting the annotation information respectively, and obtain the string correlation information between the first string information of the to-be-classified PHP file and the second string information of the reference PHP file; Extract the code information from the to-be-classified PHP file and the reference PHP file after extracting the annotation information and the string information respectively, and obtain the code information correlation information between the first code information of the to-be-classified PHP file and the second code information of the reference PHP file; Input the annotation correlation information, the string information correlation information, and the code information into the corresponding incentive function respectively for accuracy adjustment to obtain the adjusted annotation correlation information, the string information correlation information, and the code information; Weight the adjusted annotation correlation information, the string information correlation information, and the code information, and take the weighted processing result as the feature correlation between the to-be-classified PHP file and the reference PHP file.

2. The method of claim 1, wherein, The file similarity set includes a first file similarity set, and the classification processing of each PHP file to be classified is performed based on the file similarity set corresponding to the PHP file to be classified, and includes: For each PHP file to be classified, the following operations are performed: For one PHP file to be classified in the PHP files to be classified, a first file similarity set corresponding to the PHP file to be classified is determined; For each first file similarity in the first file similarity set, the following operations are performed: If it is determined that a first file similarity is greater than a first threshold, the PHP file to be classified and other PHP files to be classified corresponding to the first file similarity are classified into the same category; If it is determined that a first file similarity is not greater than a first threshold, the PHP file to be classified and other PHP files to be classified corresponding to the first file similarity are classified into different categories.

3. The method of claim 1, wherein, The file similarity set includes at least one second file similarity set, and the classification processing of each PHP file to be classified is performed based on the file similarity set corresponding to the PHP file to be classified, and includes: For each PHP file to be classified, the following operations are performed: For one PHP file to be classified in the PHP files to be classified, at least one second file similarity set corresponding to the PHP file to be classified is determined, wherein one second file similarity set corresponds to one category group; For each second file similarity set in the at least one second file similarity set, the following operations are performed: Select a preset number of second file similarities from one second file similarity set, and determine a judgment similarity based on the selected second file similarities; If it is determined that the judgment similarity is greater than a second threshold, the PHP file to be classified is classified into the category group corresponding to the one second file similarity set; If it is determined that the judgment similarity is not greater than a second threshold, the PHP file to be classified is not classified into the category group corresponding to the one second file similarity set.

4. A PHP file classifying apparatus characterized by comprising: The device includes: A first obtaining unit configured to obtain at least one PHP file to be classified from a server by a terminal device to form a set of files to be classified; A second obtaining unit configured to obtain, for each PHP file to be classified in the set of files to be classified, a file similarity set corresponding to the PHP file to be classified, wherein each file similarity set includes: each file similarity determined based on each feature correlation between the corresponding PHP file to be classified and each reference PHP file; Determine whether at least one classified category group is stored in the local current, wherein the classified category group is obtained by pre-classifying the PHP files to be classified in the set of files to be classified; If it is determined that there is at least one category group currently, a first file similarity set of the one PHP file to be classified is obtained based on the relevance of each feature between the one PHP file to be classified and each other PHP file to be classified in the corresponding set of files to be classified; and each second file similarity corresponding to each category group is determined based on the PHP file to be classified and each target PHP file included in the at least one category group, and at least one second file similarity set is determined; If it is determined that there is no at least one category group currently, a first file similarity set of the PHP file to be classified is obtained based on the relevance of each feature between the PHP file to be classified and each other PHP file to be classified in the corresponding set of files to be classified; The classification unit is configured to classify each of the PHP files to be classified based on the file similarity set corresponding to each of the PHP files to be classified; The second obtaining unit is configured to: extract annotation information from the PHP file to be classified and the reference PHP file respectively, and obtain annotation relevance information between first annotation information of the PHP file to be classified and second annotation information of the reference PHP file; extract string information from the PHP file to be classified and the reference PHP file after the annotation information is extracted respectively, and obtain string relevance information between first string information of the PHP file to be classified and second string information of the reference PHP file; extract code information from the PHP file to be classified and the reference PHP file after the annotation information and the string information are extracted respectively, and obtain code information relevance information between first code information of the PHP file to be classified and second code information of the reference PHP file; perform similarity matching on the first code information and the second code information to obtain code information relevance information between the PHP file to be classified and the reference PHP file; input the annotation relevance information, the string relevance information, and the code information into corresponding incentive functions respectively for accuracy adjustment to obtain adjusted annotation relevance information, string relevance information, and code information; perform weighting processing on the adjusted annotation relevance information, the string relevance information, and the code information, and take a result of the weighting processing as the feature relevance between the PHP file to be classified and the reference PHP file.

5. A PHP file classifying apparatus characterized by comprising: The device comprises a memory and a processor, wherein the memory is configured to store computer instructions, and the processor is configured to execute the computer instructions to implement the method according to any one of claims 1-3.

6. A computer-readable storage medium, characterized in that, A computer readable storage medium stores computer instructions, and the computer instructions are executed by a processor to implement the method according to any one of claims 1-3.

Citation Information

Patent Citations

  • Picture classification method, device, storage medium and electronic equipment

    CN108121816A