Datasets:
File size: 6,589 Bytes
5e85025 b42773e 5e85025 b42773e c21c3a8 f359dde 5e85025 003c85f 5e85025 f359dde 5e85025 003c85f 5e85025 003c85f 5e85025 003c85f ae5f694 f359dde ae5f694 f359dde c6a5bd7 aa29aaf c6a5bd7 aa29aaf c6a5bd7 aa29aaf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
---
language:
- en
tags:
- software-engineering
- code-analysis
- refactoring
- AST
- lexical-features
- Python
- static-analysis
task_categories:
- feature-extraction
pretty_name: Python Function's code feature
size_categories:
- 1M<n<10M
license: cc-by-4.0
---
# π Python Function-Level AST and Lexical Features Dataset
## π Dataset Summary
This dataset integrates **function-level static analysis data** from Python repositories.
It merges three data sources:
1. **Lizard Cyclomatic Analysis**: provides complexity, NLOC, and basic function metadata.
2. **AST Extracted Features**: includes detailed abstract syntax tree information such as token counts, parameters, variable extraction, and function bodies.
3. **Lexical Features**: captures lexical and structural features of each function (e.g., class structure, modifiers, incoming/outgoing calls, and statement types) and presents it in natural language.
The resulting **Dataset** represents each Python function as a unified row combining complexity metrics, lexical information, and AST structure β enabling advanced research in:
- Code comprehension
- Automated refactoring
- Software quality analysis
- Function-level code search
- Maintainability prediction
- ML model training for software engineering tasks
---
## π§ Intended Uses
- Feature extraction for code comprehension and maintainability modeling.
- Supervised learning for:
- Maintainability prediction (regression / ordinal classification).
- Refactoring-need ranking (learning-to-rank).
- Benchmarking code-representation learning or graph-based refactoring tools.
- Downstream tasks such as clone detection, defect prediction, and code search.
---
## π Dataset Structure
Each row corresponds to **one Python function** identified across open-source repositories.
### Columns
| Column name | Description |
|------------------------------|---------------------------------------------------------------------------------------------------|
| `project_name` | Repository name |
| `class_name` | Class name containing the function (if applicable) |
| `class_modifiers` | Access modifiers of the class |
| `class_implements` | Interfaces implemented |
| `class_extends` | Class inheritance |
| `function_name` | Function name |
| `function_body` | Raw function body code |
| `cyclomatic_complexity` | Cyclomatic complexity measure |
| `NLOC` | Number of lines of code |
| `num_parameter` | Number of function parameters |
| `num_token` | Number of tokens |
| `num_variable` | Number of variables detected in function |
| `start_line` / `end_line` | Start and end line of the function in the file |
| `function_index` | Function index in AST parsing |
| `function_params` | Parameter names |
| `function_variable` | Variable names extracted |
| `function_return_type` | Return type (if inferred) |
| `function_body_line_type`| Mapping of statement types inside the function (e.g., Assign, If, Return) |
| `function_num_functions` | Number of functions declared inside |
| `function_num_lines` | Number of lines of function (lexical) |
| `outgoing_function_count` / `outgoing_function_names` | Number and names of functions called inside this function |
| `incoming_function_count` / `incoming_function_names` | Number and names of functions calling this function |
| `lexical_representation` | Present the code features as natural language. |
---
## βοΈ Data Sources
- Static analysis performed on public Python repositories cloned from [GitHub](https://github.com) that apply the following characteristics (python language projects, commits > 500, and contributors > 10).
- Function-level analysis uses:
- [`lizard`](https://pypi.org/project/lizard/) for cyclomatic complexity.
- Python AST (https://docs.python.org/3/library/ast.html) parsing for structural features.
- Lexical presentation driven by structural and 15 extract code features.
---
## π§ͺ Dataset Creation
### Collection
1. Clone open-source Python repositories.
2. Run Lizard static analysis to generate base metrics.
3. Parse source files to extract AST and 15 code features.
4. Convert code features to natural language using rule-based code.
5. Merge the three sources
---
## π‘ How to Load
```python
from datasets import load_dataset
data = load_dataset("rehaidib/PyFuncAST-Lex", split="train")
```
or manually:
```python
import pandas as pd
df = pd.read_parquet("PyFuncAST-Lex.parquet")
```
---
## Citation
If you use this dataset, please cite:
``` bibtex
@dataset{PyFuncAST-Lex,
title = {PyFuncAST-Lex: Python Function-Level AST and Lexical Features Dataset},
author = {Reem Al-Ehaidib},
year = {2025},
month = {11},
publisher = {Hugging Face Datasets},
version = {1.0},
url = {https://huggingface.co/datasets/rehaidib/pyfunc_code_features}
}
```
|