CN108319467A - A kind of annotation fill method - Google Patents

A kind of annotation fill method Download PDF

Info

Publication number
CN108319467A
CN108319467A CN201810005381.0A CN201810005381A CN108319467A CN 108319467 A CN108319467 A CN 108319467A CN 201810005381 A CN201810005381 A CN 201810005381A CN 108319467 A CN108319467 A CN 108319467A
Authority
CN
China
Prior art keywords
annotation
function
row
content
dictionary
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201810005381.0A
Other languages
Chinese (zh)
Other versions
CN108319467B (en
Inventor
汪刚
张文明
陈少杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201810005381.0A priority Critical patent/CN108319467B/en
Publication of CN108319467A publication Critical patent/CN108319467A/en
Application granted granted Critical
Publication of CN108319467B publication Critical patent/CN108319467B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/169Annotation, e.g. comment data or footnotes

Abstract

The present invention provides a kind of annotation fill method, including:S1, if containing the function not being annotated in the row content, extracts corresponding annotation, and the annotation is inserted between the row and previous row according to the function for arbitrary a line content in file destination from the annotation dictionary built in advance.A kind of annotation fill method provided by the invention by the function not being annotated in extraction document, and according to annotation dictionary population function, realizes the automatic filling of annotation, saves human cost and time cost, enhance the readability of code.

Description

A kind of annotation fill method
Technical field
The present invention relates to internet mobile terminal applicating developing technology field more particularly to a kind of annotation fill methods.
Background technology
With the fast development of mobile phone mobile terminal, mobile terminal apply played in daily life it is more and more important Effect.
In the development process of mobile terminal, many times need to add annotating for project.Addition annotation mainly has at 2 points Advantage quickly understands effect and the function of function, and then the modification of convenient code first, other developers is facilitated to read code And maintenance, second is that code development personnel itself is facilitated to deepen the understanding to function performance.
Annotation consists of two parts, and a part is annotation symbol, and a part is notes content.Wherein, the mould of annotation symbol Formula is generally fixed as all being double slashes.By taking the function in single file as an example, each function have the function statement and It realizes, addition is required for annotate in statement and realization:If the realization of function is added to annotation, and the statement of function does not add It is annotated, then annotation can be filled into statement automatically;If the statement of function is added to annotation, and the realization of function does not have The annotation of statement, then can be added in realization by addition annotation automatically.Conventional scheme is to paste to be operated using duplication, When including heap file and big flow function in engineering, manual operation is not only time-consuming and laborious, but also is susceptible to omission.
Invention content
The present invention is to solve problems of the prior art, provides a kind of annotation fill method.
On the one hand, the present invention proposes a kind of annotation fill method, including:S1, in arbitrary a line in file destination Hold, if containing the function that is not annotated in the row content, is extracted from the annotation dictionary built in advance according to the function pair The annotation answered, and the annotation is inserted between the row and previous row.
Preferably, the construction method of the annotation dictionary includes:S1, for arbitrary a line content of material file, if should Contain function in row content, and perhaps contain the corresponding annotation of the function in front two row content in previous row, then by the letter Number is corresponding with annotation to be stored in the annotation dictionary.
Preferably, further include:S0 obtains either objective file under the destination folder according to file destination clip directory The file destination is opened in path according to the path.
Preferably, the step S1 further comprises:S11, for arbitrary a line content in file destination, if in the row Contain function identification in appearance, then confirms in the row content and contain function;S12, if the row content is not contained with previous row content Annotation mark, then confirm that the function is not annotated;S13, is extracted according to the function from the annotation dictionary built in advance pair The annotation is inserted between the row and previous row by the annotation answered.
Preferably, the step s1 further comprises:S11, for arbitrary a line content in the material file, if should Contain function identification in row content, then confirms in the row content and contain function;S12, if in previous row perhaps in front two row content It is identified containing annotation, then confirms in the previous row and to contain the corresponding annotation of the function in perhaps front two row content;S13, will The function is corresponding with annotation to be stored in the annotation dictionary.
Preferably, the step S0 further comprises:File destination clip directory is inputted os.walk modules, application by S01 Destination folder described in for searching loops obtains the filename and catalogue of each file destination under the destination folder; S02 splices the filename and catalogue of any file destination, the path of the either objective file is obtained, according to the road Diameter opens the either objective file.
Preferably, the step S13 further comprises:Using the function as key, input in dictionary model, it will be from described The annotation is inserted by the corresponding value of the key returned in the annotation dictionary built in advance as the corresponding annotation of the function Between the row and previous row.
Preferably, the step s13 further comprises:The row content is extracted, the function identification in the row content is deleted, obtains Take the function in the row content;Extract perhaps front two row content in previous row, delete previous in perhaps in front two row content Annotation mark, obtains the corresponding annotation of the function;Using dictionary model using the function as key, corresponding annotation as value It is stored in the annotation dictionary.
On the other hand, the present invention proposes a kind of annotation filling device, including annotation filling module, for for file destination In arbitrary a line content, if containing the function that is not annotated in the row content, according to the function from the note built in advance It releases and extracts corresponding annotation in dictionary, and the annotation is inserted between the row and previous row.
In another aspect, the present invention proposes a kind of annotation pad device, including:At least one processor;And with the place At least one processor of device communication connection is managed, wherein:The memory, which is stored with, to be referred to by the program that the processor executes It enables, the processor calls described program instruction to be able to carry out foregoing method.
Another aspect, the present invention propose that a kind of non-transient computer readable storage medium, the non-transient computer are readable Storage medium stores computer instruction, and the computer instruction makes the computer execute foregoing method.
A kind of annotation fill method provided by the invention, by the function not being annotated in extraction document, and according to annotation Dictionary population function realizes the automatic filling of annotation, saves human cost and time cost, enhances the readable of code Property.
Description of the drawings
Fig. 1 is a kind of flow diagram of annotation fill method of the specific embodiment of the invention;
Fig. 2 is a kind of structural schematic diagram of annotation pad device of the specific embodiment of the invention.
Specific implementation mode
With reference to the accompanying drawings and examples, the specific implementation mode of the present invention is described in further detail.Implement below Example is not limited to the scope of the present invention for illustrating the present invention.
A kind of annotation fill method, including:S1, for arbitrary a line content in file destination, if containing in the row content There is the function not being annotated, then corresponding annotation is extracted from the annotation dictionary built in advance according to the function, and will be described Annotation is inserted between the row and previous row.
Specifically, it would be desirable to which the file for carrying out annotation filling is set as file destination, and the file destination includes several rows Content.
Arbitrary a line content in the file destination content is judged:If contain function in the row content, and The function for including in the row content is not annotated, then is extracted the function contained in the row content, and according to the letter Number extracts the corresponding annotation of the function in the annotation dictionary built in advance, and the corresponding annotation of the function is then inserted into this Before row content, i.e., between the row and previous row.
Wherein, the annotation dictionary is to store function and dictionary that function pair should annotate, in Python, dictionary It is a kind of data structure quoted by name or keyword, key can be number, character string, tuple, this structure class Type also referred to as maps.Dictionary type is unique built-in map type in Python.In the specific embodiment of the invention, the note It is key, the dictionary that annotation is value to release dictionary i.e. function.
It is corresponding with above-mentioned steps, if contained function in the row content, and the function has been annotated or the row Function is not contained in content, then jumps to other rows, and carrying out annotation to the function not being annotated contained in other row contents fills out It fills, until traversing the file destination, completes that all in the file destination corresponding annotation can be extracted in annotating dictionary Function mark.
In the specific embodiment of the invention, by the function not being annotated in extraction document, and according to annotation dictionary population letter Number, realizes the automatic filling of annotation, saves human cost and time cost, enhance the readability of code.
Based on above-mentioned specific embodiment, the construction method of a kind of annotation fill method, the annotation dictionary includes:S1 is right In arbitrary a line content of material file, if containing function in the row content, and perhaps contain in front two row content in previous row The corresponding annotation of the function is then stored in the function is corresponding with annotation in the annotation dictionary.
Specifically, it in carrying out annotation filling process to the function in file destination, needs according to the function from advance The corresponding annotation of the function is extracted in the annotation dictionary of structure.Wherein, the construction method of the annotation dictionary is as follows:
Set the file for building annotation dictionary to material file, the material file includes several row contents.
Arbitrary a line content in the material file is judged:If containing function in the row content, and the row Previous row content or front two row content in contain the corresponding annotation of the function, then respectively out of the row content and previous row Extraction function and corresponding annotation in appearance or front two row content, and the function and corresponding annotation are stored in annotation dictionary In.
It is corresponding with above-mentioned steps, if contain function in the row content, but the function is not annotated or the row In content do not contain function, then redirect other rows, it is corresponding to the function contained in other row contents and the function annotate into Row extraction, and be stored in the annotation dictionary, until traversing the material file, complete to all letters in the material file The structure of annotation dictionary is completed in the extraction and preservation of number and its annotation.
In the specific embodiment of the invention, by extracting function and its annotation in material file, annotation dictionary is constructed, is Realize that the automatic filling annotated in file destination provides realization condition.
Based on any of the above-described specific embodiment, a kind of annotation fill method further includes:S0, according to file destination clip directory The file destination is opened in the path for obtaining either objective file under the destination folder according to the path.
Specifically, when carrying out annotation filling to engineering project, All Files under a file is typically directed to and are carried out Annotation filling.Thus, before carrying out annotation filling to file destination, need to be corresponded to described in acquisition according to file destination clip directory The corresponding filename of each file destination under destination folder and catalogue, then by the corresponding file of each file destination Name and catalogue are spliced, and the path of each file destination is obtained.
Then, the either objective file is opened according to the path of any file destination, and reads any mesh Mark the content in file.In the specific embodiment of the invention, file destination is opened using open functions, but not limited to this.
In the specific embodiment of the invention, each file destination is obtained by destination folder, avoids the something lost of file destination Leakage.
Based on any of the above-described specific embodiment, Fig. 1 is a kind of flow of annotation fill method of the specific embodiment of the invention Schematic diagram, as shown in Figure 1, a kind of annotation fill method, the step S1 further comprises:S11, for appointing in file destination Meaning a line content confirms in the row content if containing function identification in the row content and contains function;S12, if the row content with Without containing annotation mark in previous row content, then confirm that the function is not annotated;S13 is built according to the function from advance Annotation dictionary in extract corresponding annotation, the annotation is inserted between the row and previous row.
Specifically, arbitrary a line content in the file destination is judged, is not noted if contained in the row content The function released then is filled the function and is annotated, further comprises:
First, for arbitrary a line content in the file destination, judge whether contain function identification table in the row content In any function identification.The function identification table includes several function identifications, and the function identification is for indicating current line Contain function in content, such as " def ", "+(" etc..
If containing any function identification in function identification table in the row content, confirms in the row content and contain letter Number judges the row content and whether contains annotation mark "/" in previous row content on this basis.
If perhaps previous row content includes the annotation mark in the row, then it is assumed that the function contained in the row content It has been annotated;If not including that the annotation identifies in the row content and previous row content, then it is assumed that contain in the row content Some functions are not annotated.
For the case where function and the function are not annotated is contained in arbitrary a line content, according to the letter in the row content Number extracts corresponding annotation from the annotation dictionary built in advance, and the annotation is inserted between the row and previous row.
In the specific embodiment of the invention, it is proposed that be real for the annotation fill method of single line function in file destination The automatic filling now annotated provides condition.
Based on any of the above-described specific embodiment, a kind of annotation fill method, the step s1 further comprises:S11, for Arbitrary a line content in the material file confirms in the row content if containing function identification in the row content and contains letter Number;If s12 confirms in the previous row containing annotation mark perhaps in front two row content in previous row in perhaps front two row Contain the corresponding annotation of the function in appearance;S13 is stored in the function is corresponding with annotation in the annotation dictionary.
Specifically, arbitrary a line content in the material file is judged, if in the row content containing function and There are corresponding annotations for the function, then by the function and its corresponding annotation deposit annotation dictionary, further comprise:
First, it is determined that in arbitrary a line content of the file destination, if including any function in function identification table Mark.The function identification table includes several function identifications, and the function identification is for indicating to contain letter in current line content Number, the function identification such as " def ", "+(" etc..
If confirming the row containing any function identification in mark table in arbitrary a line content in the file destination Contain function in content, on this basis, judge the row previous row content or front two row content in whether containing annotation mark Know "/".
If containing annotation mark in previous row perhaps in front two row content, then it is assumed that the function of the row is noted It releases;If in previous row perhaps in front two row content not including annotation mark, then it is assumed that the letter contained in the row content Number is not annotated.
For the case where function and the function have been annotated is contained in arbitrary a line content, the function and its right is extracted The annotation answered, and be stored in the function is corresponding with annotation in the annotation dictionary.
In the specific embodiment of the invention, by extracting function and its annotation in material file, annotation dictionary is constructed, is Realize that the automatic filling annotated in file destination provides realization condition.
Based on any of the above-described specific embodiment, a kind of annotation fill method, the step S0 further comprises:S01, by mesh Mark folder content input os.walk modules obtain the destination folder using destination folder described in for searching loops Under each file destination filename and catalogue;S02 splices the filename and catalogue of any file destination, obtains institute The either objective file is opened in the path for stating either objective file according to the path.
Specifically, os.walk is a file easy to use, directory traversal device in python, can help to research and develop people The efficient processing file of member, catalogue.In the specific embodiment of the invention, file destination clip directory is inputted into os.walk models, and answer The destination folder is traversed with for cycles, obtains the corresponding file of each file destination under the destination folder Name and catalogue.
For example, file destination clip directory is F:Aa, pass through os.walk obtain destination folder under file destination code It is as follows:
FileDir=" F:”+os.sep+“aa”
for root,dirs,files in os.walk(fileDir);
print(root)
print(dirs)
print(files)
Then, according to the corresponding filename of file destination and mesh under the destination folder of above-mentioned os.walk modules acquisition Record splices the filename and catalogue of any file destination, the path of the either objective file is obtained, according to the path Open the either objective file.
Based on any of the above-described specific embodiment, a kind of annotation fill method, the step S13 further comprises:It will be described Function is inputted as key in dictionary model, and the corresponding value of the key returned from the annotation dictionary built in advance is made For the corresponding annotation of the function, the annotation is inserted between the row and previous row.
Specifically, the dictionary in Python is a Container Type, in the specific embodiment of the invention for store from The function and corresponding annotation extracted in material file, when in order to carry out annotation filling to the function in file destination, Neng Goucong The corresponding annotation of the function is obtained in annotation dictionary.
Such as:
Dict={ ' hanshu1 ':' zhushi1 ', ' hanshu2 ':‘zhushi2’};
print“dict[‘hanshu1’]”;
As in above-mentioned codes, two groups of key-value pairs being stored in dictionary, the corresponding value of the key can be obtained by key.By function It is annotated in dictionary model as key input, the value of the corresponding key of annotation dictionary model output corresponds to the function Annotation.
Based on any of the above-described specific embodiment, a kind of annotation fill method, the step s13 further comprises:Extraction should Row content deletes the function identification in the row content, obtains the function in the row content;It extracts in previous row perhaps in front two row Hold, the annotation mark in the interior perhaps front two row content that deletes previous obtains the corresponding annotation of the function;Using dictionary model It is stored in the function as key, corresponding annotation in the annotation dictionary as value.
Specifically, for the case where function and the function have been annotated is contained in arbitrary a line content, first, extraction should Row content deletes function identification and additional character in the row content, obtains the function in the row content.For example, deleting the row In def or " " etc..
Then, the annotation mark in the be expert at content of the corresponding annotation of the function, such as " // ", " */" are deleted, is obtained The corresponding annotation of the function.
Finally, it regard the function extracted in above-mentioned steps as value as key, corresponding annotation, by dictionary model, preserves In annotating dictionary.
Based on any of the above-described method specific embodiment, a kind of annotation filling device, including annotation filling module;The annotation It fills module to be used for for arbitrary a line content in file destination, if containing the function not being annotated, root in the row content Extract corresponding annotation from the annotation dictionary built in advance according to the function, and by the annotation be inserted into the row and previous row it Between.
Specifically, it would be desirable to which the file for carrying out annotation filling is set as file destination, and the file destination includes several rows Content.
Annotation filling module judges arbitrary a line content in the file destination content:If in the row content Containing function, and the function for including in the row content is not annotated, then is extracted the function contained in the row content, and The corresponding annotation of the function is extracted in the annotation dictionary built in advance according to the function, it is then that the function is corresponding Annotation is inserted into before the row content, i.e., between the row and previous row.
Wherein, the annotation dictionary is to store function and dictionary that function pair should annotate, in Python, dictionary It is a kind of data structure quoted by name or keyword, key can be number, character string, tuple, this structure class Type also referred to as maps.Dictionary type is unique built-in map type in Python.In the specific embodiment of the invention, the note It is key, the dictionary that annotation is value to release dictionary i.e. function.
Corresponding with aforesaid operations, if annotation filling module judges to contain function in the row content, and the function is Through be annotated or the row content in do not contain function, then jump to other rows, be not annotated to what is contained in other row contents Function carry out annotation filling, until traverse the file destination, complete to it is all in the file destination can be in annotation word The mark of the function of corresponding annotation is extracted in allusion quotation.
In the specific embodiment of the invention, by the function not being annotated in extraction document, and according to annotation dictionary population letter Number, realizes the automatic filling of annotation, saves human cost and time cost, enhance the readability of code.
Based on any of the above-described specific embodiment, the construction method of a kind of annotation filling device, the annotation dictionary includes: S1, for arbitrary a line content of material file, if contain function in the row content, and in previous row perhaps in front two row content Containing the corresponding annotation of the function, then it is stored in the function is corresponding with annotation in the annotation dictionary.
Specifically, it in carrying out annotation filling process to the function in file destination, needs according to the function from advance The corresponding annotation of the function is extracted in the annotation dictionary of structure.Wherein, the construction method of the annotation dictionary is as follows:
Set the file for building annotation dictionary to material file, the material file includes several row contents.
Arbitrary a line content in the material file is judged:If containing function in the row content, and the row Previous row content or front two row content in contain the corresponding annotation of the function, then respectively out of the row content and previous row Extraction function and corresponding annotation in appearance or front two row content, and the function and corresponding annotation are stored in annotation dictionary In.
It is corresponding with above-mentioned steps, if contain function in the row content, but the function is not annotated or the row In content do not contain function, then redirect other rows, it is corresponding to the function contained in other row contents and the function annotate into Row extraction, and be stored in the annotation dictionary, until traversing the material file, complete to all letters in the material file The structure of annotation dictionary is completed in the extraction and preservation of number and its annotation.
In the specific embodiment of the invention, by extracting function and its annotation in material file, annotation dictionary is constructed, is Realize that the automatic filling annotated in file destination provides realization condition.
Based on any of the above-described specific embodiment, a kind of annotation filling device further includes file destination acquisition module, the mesh Mark file acquisition module is used to obtain the path of either objective file under the destination folder, root according to file destination clip directory The file destination is opened according to the path.
Specifically, when carrying out annotation filling to engineering project, All Files under a file is typically directed to and are carried out Annotation filling.Thus, before carrying out annotation filling to file destination, need file destination acquisition module according to destination folder Catalogue corresponds to the corresponding filename of each file destination and catalogue obtained under the destination folder, then by each mesh The corresponding filename of mark file and catalogue are spliced, and the path of each file destination is obtained.
Then, file destination acquisition module opens the either objective file according to the path of any file destination, And read the content in the either objective file.In the specific embodiment of the invention, file destination is opened using open functions, but It is without being limited thereto.
In the specific embodiment of the invention, each file destination is obtained by destination folder, avoids the something lost of file destination Leakage.
Based on any of the above-described specific embodiment, a kind of annotation filling device, the annotation filling module further comprises letter Number acquisition submodule, annotation inquiry submodule and annotation filling submodule;Wherein, the function acquisition submodule, for for Arbitrary a line content in file destination confirms in the row content if containing function identification in the row content and contains function;Institute Annotation inquiry submodule is stated, if confirming that the function is not noted without containing annotation mark in the row content and previous row content It releases;The annotation fills submodule, will for extracting corresponding annotation from the annotation dictionary built in advance according to the function The annotation is inserted between the row and previous row.
Specifically, arbitrary a line content in the file destination is judged, is not noted if contained in the row content The function released then is filled the function and is annotated, further comprises:
First, function acquisition submodule is for arbitrary a line content in the file destination, judge in the row content whether Contain any function identification in function identification table.The function identification table includes several function identifications, the function identification For indicating to contain function in current line content, such as " def ", "+(" etc..
If containing any function identification in function identification table in the row content, confirms in the row content and contain letter Number, on this basis, annotation inquiry submodule judge the row content and whether contain annotation mark "/" in previous row content.
If perhaps previous row content includes the annotation mark in the row, then it is assumed that the function contained in the row content It has been annotated;If not including that the annotation identifies in the row content and previous row content, then it is assumed that contain in the row content Some functions are not annotated.
For containing the case where function and the function are not annotated in arbitrary a line content, annotation filling submodule according to Function in the row content extracts corresponding annotation from the annotation dictionary built in advance, and the annotation is inserted into the row with before Between a line.
In the specific embodiment of the invention, it is proposed that be real for the annotation fill method of single line function in file destination The automatic filling now annotated provides condition.
Based on any of the above-described specific embodiment, a kind of annotation filling device, the step s1 further comprises:S11, for Arbitrary a line content in the material file confirms in the row content if containing function identification in the row content and contains letter Number;If s12 confirms in the previous row containing annotation mark perhaps in front two row content in previous row in perhaps front two row Contain the corresponding annotation of the function in appearance;S13 is stored in the function is corresponding with annotation in the annotation dictionary.
Specifically, arbitrary a line content in the material file is judged, if in the row content containing function and There are corresponding annotations for the function, then by the function and its corresponding annotation deposit annotation dictionary, further comprise:
First, it is determined that in arbitrary a line content of the file destination, if including any function in function identification table Mark.The function identification table includes several function identifications, and the function identification is for indicating to contain letter in current line content Number, the function identification such as " def ", "+(" etc..
If confirming the row containing any function identification in mark table in arbitrary a line content in the file destination Contain function in content, on this basis, judge the row previous row content or front two row content in whether containing annotation mark Know "/".
If containing annotation mark in previous row perhaps in front two row content, then it is assumed that the function of the row is noted It releases;If in previous row perhaps in front two row content not including annotation mark, then it is assumed that the letter contained in the row content Number is not annotated.
For the case where function and the function have been annotated is contained in arbitrary a line content, the function and its right is extracted The annotation answered, and be stored in the function is corresponding with annotation in the annotation dictionary.
In the specific embodiment of the invention, by extracting function and its annotation in material file, annotation dictionary is constructed, is Realize that the automatic filling annotated in file destination provides realization condition.
Based on any of the above-described specific embodiment, a kind of annotation filling device, the file destination acquisition module further wraps Include file traversal submodule and path acquisition submodule;Wherein, the file traverses submodule, is used for destination folder Catalogue input os.walk modules obtain each under the destination folder using destination folder described in for searching loops The filename and catalogue of file destination;The path acquisition submodule, for splice any file destination filename and Catalogue obtains the path of the either objective file, and the either objective file is opened according to the path.
Specifically, os.walk is a file easy to use, directory traversal device in python, can help to research and develop people The efficient processing file of member, catalogue.In the specific embodiment of the invention, file traversal submodule inputs file destination clip directory Os.walk models, and application for cycles traverse the destination folder, obtain each mesh under the destination folder Mark the corresponding filename of file and catalogue.
For example, file destination clip directory is F:Aa, pass through os.walk obtain destination folder under file destination code It is as follows:
FileDir=" F:”+os.sep+“aa”
for root,dirs,files in os.walk(fileDir);
print(root)
print(dirs)
print(files)
Then, the file destination pair under the destination folder that path acquisition submodule is obtained according to above-mentioned os.walk modules The filename and catalogue answered splice the filename and catalogue of any file destination, obtain the road of the either objective file Diameter opens the either objective file according to the path.
Based on any of the above-described specific embodiment, a kind of annotation filling device, the annotation filling submodule is further used for: It using the function as key, inputs in dictionary model, the key returned from the annotation dictionary built in advance is corresponded to Value as the corresponding annotation of the function, the annotation is inserted between the row and previous row.
Specifically, the dictionary in Python is a Container Type, in the specific embodiment of the invention for store from The function and corresponding annotation extracted in material file, when in order to carry out annotation filling to the function in file destination, Neng Goucong The corresponding annotation of the function is obtained in annotation dictionary.
Such as:
Dict={ ' hanshu1 ':' zhushi1 ', ' hanshu2 ':‘zhushi2’};
print“dict[‘hanshu1’]”;
As in above-mentioned codes, two groups of key-value pairs being stored in dictionary, the corresponding value of the key can be obtained by key.By function It is annotated in dictionary model as key input, the value of the corresponding key of annotation dictionary model output corresponds to the function Annotation.
Based on any of the above-described specific embodiment, a kind of annotation filling device, the step s13 further comprises:Extraction should Row content deletes the function identification in the row content, obtains the function in the row content;It extracts in previous row perhaps in front two row Hold, the annotation mark in the interior perhaps front two row content that deletes previous obtains the corresponding annotation of the function;Using dictionary model It is stored in the function as key, corresponding annotation in the annotation dictionary as value.
Specifically, for the case where function and the function have been annotated is contained in arbitrary a line content, first, extraction should Row content deletes function identification and additional character in the row content, obtains the function in the row content.For example, deleting the row In def or " " etc..
Then, the annotation mark in the be expert at content of the corresponding annotation of the function, such as " // ", " */" are deleted, is obtained The corresponding annotation of the function.
Finally, it regard the function extracted in above-mentioned steps as value as key, corresponding annotation, by dictionary model, preserves In annotating dictionary.
Fig. 2 is a kind of structural schematic diagram of annotation pad device of the specific embodiment of the invention, as shown in Fig. 2, the equipment Including:At least one processor 201;And at least one processor 202 communicated to connect with the processor 201, wherein:Institute It states memory 202 and is stored with the program instruction that can be executed by the processor 201, the processor 201 calls described program to refer to The method that order is able to carry out the annotation filling that the various embodiments described above are provided, such as including:For any one in file destination Row content, if being carried from the annotation dictionary built in advance according to the function containing the function not being annotated in the row content Corresponding annotation is taken, and the annotation is inserted between the row and previous row.
The embodiment of the present invention also provides a kind of non-transient computer readable storage medium, the non-transient computer readable storage Medium storing computer instructs, which makes computer execute the annotation fill method that corresponding embodiment is provided, example Such as include:For arbitrary a line content in file destination, if containing the function not being annotated in the row content, according to Function extracts corresponding annotation from the annotation dictionary built in advance, and the annotation is inserted between the row and previous row.
One of ordinary skill in the art will appreciate that:Realize that all or part of step of above method embodiment can pass through The relevant hardware of program instruction is completed, and program above-mentioned can be stored in a computer read/write memory medium, the program When being executed, step including the steps of the foregoing method embodiments is executed;And storage medium above-mentioned includes:ROM, RAM, magnetic disc or light The various media that can store program code such as disk.
Finally, the present processes are only preferable embodiment, are not intended to limit the scope of the present invention.It is all Within the spirit and principles in the present invention, any modification, equivalent replacement, improvement and so on should be included in the protection of the present invention Within the scope of.

Claims (10)

1. a kind of annotation fill method, which is characterized in that including:
S1, for arbitrary a line content in file destination, if containing the function not being annotated in the row content, according to Function extracts corresponding annotation from the annotation dictionary built in advance, and the annotation is inserted between the row and previous row.
2. according to the method described in claim 1, it is characterized in that, the construction method of the annotation dictionary includes:
S1, for arbitrary a line content of material file, if contain function in the row content, and in previous row perhaps in front two row Contain the corresponding annotation of the function in appearance, is then stored in the function is corresponding with annotation in the annotation dictionary.
3. according to the method described in claim 1, it is characterized in that, further including:
S0 obtains the path of either objective file under the destination folder according to file destination clip directory, according to the path Open the file destination.
4. according to the method described in claim 1, it is characterized in that, the step S1 further comprises:
S11, if containing function identification in the row content, confirms the row content for arbitrary a line content in file destination In contain function;
S12 confirms that the function is not annotated if the row content is identified with previous row content without containing annotation;
S13 extracts corresponding annotation according to the function from the annotation dictionary built in advance, by the annotation be inserted into the row with Between previous row.
5. according to the method described in claim 2, it is characterized in that, the step s1 further comprises:
S11 confirms the row for arbitrary a line content in the material file if containing function identification in the row content Contain function in content;
If s12 confirms in the previous row containing annotation mark perhaps in front two row content in previous row in perhaps front two row Contain the corresponding annotation of the function in appearance;
S13 is stored in the function is corresponding with annotation in the annotation dictionary.
6. according to the method described in claim 3, it is characterized in that, the step S0 further comprises:
File destination clip directory is inputted os.walk modules by S01, using destination folder described in for searching loops, obtains institute State the filename and catalogue of each file destination under destination folder;
S02 splices the filename and catalogue of any file destination, the path of the either objective file is obtained, according to institute It states path and opens the either objective file.
7. according to the method described in claim 4, it is characterized in that, the step S13 further comprises:
It using the function as key, inputs in dictionary model, the key that will be returned from the annotation dictionary built in advance The annotation is inserted between the row and previous row by corresponding value as the corresponding annotation of the function.
8. according to the method described in claim 5, it is characterized in that, the step s13 further comprises:
The row content is extracted, the function identification in the row content is deleted, obtains the function in the row content;
Extract perhaps front two row content in previous row, delete previous in annotation mark perhaps in front two row content, obtain institute State the corresponding annotation of function;
It is stored in the function as key, corresponding annotation in the annotation dictionary as value using dictionary model.
9. a kind of annotation filling device, which is characterized in that including:
Annotation filling module, for for arbitrary a line content in file destination, if containing not being annotated in the row content Function then extracts corresponding annotation according to the function from the annotation dictionary built in advance, and the annotation is inserted into the row Between previous row.
10. a kind of annotation pad device, which is characterized in that including:
At least one processor;And at least one processor being connect with the processor communication, wherein:The memory is deposited The program instruction that can be executed by the processor is contained, the processor calls described program instruction to be able to carry out such as claim 1 to 8 any method.
CN201810005381.0A 2018-01-03 2018-01-03 Comment filling method Active CN108319467B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810005381.0A CN108319467B (en) 2018-01-03 2018-01-03 Comment filling method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810005381.0A CN108319467B (en) 2018-01-03 2018-01-03 Comment filling method

Publications (2)

Publication Number Publication Date
CN108319467A true CN108319467A (en) 2018-07-24
CN108319467B CN108319467B (en) 2022-01-04

Family

ID=62894566

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810005381.0A Active CN108319467B (en) 2018-01-03 2018-01-03 Comment filling method

Country Status (1)

Country Link
CN (1) CN108319467B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112836477A (en) * 2021-01-15 2021-05-25 亿企赢网络科技有限公司 Code annotation document generation method and device, electronic equipment and storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1114068A (en) * 1994-06-17 1995-12-27 国际商业机器公司 System for annotating software windows
US20100057800A1 (en) * 2006-11-20 2010-03-04 Funnelback Pty Ltd Annotation index system and method
CN101689190A (en) * 2007-07-10 2010-03-31 国际商业机器公司 A method, system and computer program for intelligent text annotation
CN102222004A (en) * 2011-07-01 2011-10-19 福建富士通信息软件有限公司 Method for transforming switch special language into C language
US20150089474A1 (en) * 2013-09-25 2015-03-26 Shashank Mohan Jain Runtime generation and injection of java annotations
US20160170748A1 (en) * 2014-12-11 2016-06-16 Jie Zhang Generic annotation seeker
WO2016117607A1 (en) * 2015-01-23 2016-07-28 国立研究開発法人情報通信研究機構 Annotation assistance device and computer program therefor
CN106681708A (en) * 2016-11-16 2017-05-17 中国科学院软件研究所 Automatic source code annotation generation method based on data mining
CN107341014A (en) * 2017-06-27 2017-11-10 乐视致新电子科技(天津)有限公司 Electronic equipment, the generation method of technical documentation and device

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1114068A (en) * 1994-06-17 1995-12-27 国际商业机器公司 System for annotating software windows
US20100057800A1 (en) * 2006-11-20 2010-03-04 Funnelback Pty Ltd Annotation index system and method
CN101689190A (en) * 2007-07-10 2010-03-31 国际商业机器公司 A method, system and computer program for intelligent text annotation
CN102222004A (en) * 2011-07-01 2011-10-19 福建富士通信息软件有限公司 Method for transforming switch special language into C language
US20150089474A1 (en) * 2013-09-25 2015-03-26 Shashank Mohan Jain Runtime generation and injection of java annotations
US20160170748A1 (en) * 2014-12-11 2016-06-16 Jie Zhang Generic annotation seeker
WO2016117607A1 (en) * 2015-01-23 2016-07-28 国立研究開発法人情報通信研究機構 Annotation assistance device and computer program therefor
CN106681708A (en) * 2016-11-16 2017-05-17 中国科学院软件研究所 Automatic source code annotation generation method based on data mining
CN107341014A (en) * 2017-06-27 2017-11-10 乐视致新电子科技(天津)有限公司 Electronic equipment, the generation method of technical documentation and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
ANDREW KUCHLING: "如何打造全能战士——Python的字典类", 《程序员》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112836477A (en) * 2021-01-15 2021-05-25 亿企赢网络科技有限公司 Code annotation document generation method and device, electronic equipment and storage medium
CN112836477B (en) * 2021-01-15 2024-02-09 亿企赢网络科技有限公司 Method and device for generating code annotation document, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN108319467B (en) 2022-01-04

Similar Documents

Publication Publication Date Title
US5355472A (en) System for substituting tags for non-editable data sets in hypertext documents and updating web files containing links between data sets corresponding to changes made to the tags
US5551028A (en) Design data management system and associated method
CN105144088B (en) Metadata is associated with and with source code based on its application and service
Sanderson et al. Automatic data organization, storage, and analysis of camera trap pictures
US5623661A (en) System for and method of providing delta-versioning of the contents of PCTE file objects
US9292483B2 (en) Intelligent text annotation
CN107958057A (en) A kind of code generating method and device for being used for Data Migration in heterogeneous database
CN107844301A (en) A kind of Android application channel closes bag method and device
US11074133B2 (en) Method, electronic device and computer readable medium of file management
US7483906B2 (en) Method and system for renaming consecutive keys in a B-tree
CN101533346B (en) Source file comparing unit and method thereof
CN110263187A (en) Draw this recognition methods, device, storage medium and computer equipment
CN108509199A (en) Automatically generate the method, apparatus, equipment and storage medium of Chinese annotation
CN110262784A (en) A kind of cloud notes implementation method and device
Butler Mining Java class identifier naming conventions
CN107346317A (en) A kind of data query method and apparatus
CN108319467A (en) A kind of annotation fill method
CN107291832A (en) A kind of date storage method based on list storage structure
CN106445564B (en) There is the mixing quoting method and system of different programming language projects for same platform
CN109992585A (en) Data lead-in method for office management system
CN109426515A (en) The generation method and device of upgrade package
US8407196B1 (en) Object-oriented database for file system emulator
CN109426496A (en) Method, storage medium, electronic equipment and the system of program log write-in file
CN111339042A (en) Data operation processing method and system and scheduling server
CN110704372B (en) Data recovery method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant