Mir-2002 commited on
Commit
de5560e
Β·
verified Β·
1 Parent(s): 4ed4f59

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +80 -2
README.md CHANGED
@@ -11,7 +11,7 @@ size_categories:
11
 
12
  # Overview
13
 
14
- This dataset contains 18,219 rows of code-docstring-ast data along with additional metadata. Data was gathered from various Python libraries and frameworks
15
  publicly available GitHub repos. Initial raw dataset count was 25,480 down to 18,219 after preprocessing.
16
 
17
  # Sources
@@ -63,4 +63,82 @@ An instance of the dataset is as follows:
63
  <line_number> : <The line number of the function, method, or class within the file>,
64
  <ast_sequence> : <The ast sequence of the raw source code. Scroll down for more info about this>
65
  }
66
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  # Overview
13
 
14
+ This dataset contains 18,219 rows of code-docstring-ast data along with additional metadata. Data was gathered from various Python libraries and frameworks and their
15
  publicly available GitHub repos. Initial raw dataset count was 25,480 down to 18,219 after preprocessing.
16
 
17
  # Sources
 
63
  <line_number> : <The line number of the function, method, or class within the file>,
64
  <ast_sequence> : <The ast sequence of the raw source code. Scroll down for more info about this>
65
  }
66
+ ```
67
+
68
+ # The AST Sequence
69
+
70
+ A function recursively converts the AST tree into a linear sequence. It uses depth markers (β”œ1>, β””2>, etc.) to show parent-child relationships. It also adds node identifiers by pairing
71
+ each node type with a meaningful identifier. Furthermore, pruning is also applied to irrelevant and shallow identifiers to denoise the dataset.
72
+
73
+ Here's an example of how the AST sequence is generated:
74
+
75
+ Example Code
76
+ ```
77
+ def calculate_area(radius):
78
+ """
79
+ Calculate the area of a circle.
80
+
81
+ Parameters:
82
+ radius (float): The radius of the circle
83
+
84
+ Returns:
85
+ float: The area of the circle
86
+ """
87
+ PI = 3.14159
88
+ area = PI * radius * radius
89
+ return area
90
+ ```
91
+
92
+ Resulting AST Sequence
93
+ ```
94
+ FunctionDef:calculate_area
95
+ β”œ1> args:[radius]
96
+ β”œ1> Assign:PI
97
+ β”‚ β””2> Constant:
98
+ β”œ1> Assign:area
99
+ β”‚ β””2> BinOp:
100
+ β”‚ β”œ3> BinOp:
101
+ β”‚ β”‚ β”œ4> Name:PI
102
+ β”‚ β”‚ β””4> Name:radius
103
+ β”‚ β””3> Name:radius
104
+ β””1> Return:
105
+ β””2> Name:area
106
+ ```
107
+
108
+ 1. The code is parsed via Python's `ast` module
109
+ 2. A method traverses this tree and linearizes the sequence
110
+ 3. Each node is then converted to a string with type-identifier keys
111
+ 4. Structural relationships are preserved using the depth markers
112
+ 5. Denoising of irrelevant and shallow nodes are applied
113
+
114
+ # Preprocessing
115
+
116
+ The following preprocessing steps were applied:
117
+
118
+ ## Text Cleaning
119
+
120
+ - Removed comments
121
+ - Filtering unusual/control characters
122
+ - Removed trailing whitespaces
123
+ - Converts all whitespace into a single spaces
124
+ - Removed tags from docstrings
125
+
126
+ ## AST Cleaning
127
+
128
+ - Removed noise using a custom blacklist
129
+ - Removed abnormally long nodes (>100)
130
+ - Stripped blank AST entries
131
+ - Ensured ASTs start with the proper root nodes (FunctionDef or ClassDef)
132
+
133
+ ## Language Filtering
134
+
135
+ - Removed non-English documentations
136
+ - Keeps an item if detection fails
137
+
138
+ ## Similarity Filtering
139
+
140
+ - Removed entries where similarity exceeds threshold (0.7)
141
+
142
+ # Split
143
+
144
+ - Dataset was split into a 70/15/15 ratio