Commit ·
16b46e9
verified ·
0
Parent(s):
Super-squash branch 'main' using huggingface_hub
Browse files- .gitattributes +55 -0
- README.md +160 -0
- calculate_code_readability.py +73 -0
- data/train-00000-of-00003-3debaf16ce325fe6.parquet +3 -0
- data/train-00001-of-00003-23f3f1e9b4b01385.parquet +3 -0
- data/train-00002-of-00003-1b6194e483487146.parquet +3 -0
- original/train-00000-of-00003-da7b7f628e7e10e5.parquet +3 -0
- original/train-00001-of-00003-8cf5de7cc9cd3e5f.parquet +3 -0
- original/train-00002-of-00003-ed372e1f9bb65acb.parquet +3 -0
.gitattributes
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.lz4 filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
# Audio files - uncompressed
|
| 38 |
+
*.pcm filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
*.sam filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
*.raw filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
# Audio files - compressed
|
| 42 |
+
*.aac filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
*.flac filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
# Image files - uncompressed
|
| 48 |
+
*.bmp filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
*.tiff filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
# Image files - compressed
|
| 53 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
*.webp filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
source_datasets: bigcode/the-stack-smol-xl
|
| 3 |
+
configs:
|
| 4 |
+
- config_name: default
|
| 5 |
+
data_files:
|
| 6 |
+
- split: train
|
| 7 |
+
path: data/train-*
|
| 8 |
+
- config_name: original
|
| 9 |
+
data_files:
|
| 10 |
+
- split: train
|
| 11 |
+
path: original/train-*
|
| 12 |
+
dataset_info:
|
| 13 |
+
- config_name: default
|
| 14 |
+
features:
|
| 15 |
+
- name: size
|
| 16 |
+
dtype: int64
|
| 17 |
+
- name: ext
|
| 18 |
+
dtype: string
|
| 19 |
+
- name: lang
|
| 20 |
+
dtype: string
|
| 21 |
+
- name: max_stars_repo_name
|
| 22 |
+
dtype: string
|
| 23 |
+
- name: max_stars_repo_licenses
|
| 24 |
+
sequence: string
|
| 25 |
+
- name: max_stars_count
|
| 26 |
+
dtype: float64
|
| 27 |
+
- name: max_issues_repo_name
|
| 28 |
+
dtype: string
|
| 29 |
+
- name: max_issues_repo_licenses
|
| 30 |
+
sequence: string
|
| 31 |
+
- name: max_issues_count
|
| 32 |
+
dtype: float64
|
| 33 |
+
- name: max_forks_repo_name
|
| 34 |
+
dtype: string
|
| 35 |
+
- name: max_forks_repo_licenses
|
| 36 |
+
sequence: string
|
| 37 |
+
- name: max_forks_count
|
| 38 |
+
dtype: float64
|
| 39 |
+
- name: text
|
| 40 |
+
dtype: string
|
| 41 |
+
- name: avg_line_length
|
| 42 |
+
dtype: float64
|
| 43 |
+
- name: max_line_length
|
| 44 |
+
dtype: int64
|
| 45 |
+
- name: alphanum_fraction
|
| 46 |
+
dtype: float64
|
| 47 |
+
- name: code_readability
|
| 48 |
+
dtype: float64
|
| 49 |
+
- name: token_len
|
| 50 |
+
dtype: int64
|
| 51 |
+
splits:
|
| 52 |
+
- name: train
|
| 53 |
+
num_bytes: 1138355923.3692224
|
| 54 |
+
num_examples: 205173
|
| 55 |
+
download_size: 394010253
|
| 56 |
+
dataset_size: 1138355923.3692224
|
| 57 |
+
- config_name: original
|
| 58 |
+
features:
|
| 59 |
+
- name: size
|
| 60 |
+
dtype: int64
|
| 61 |
+
- name: ext
|
| 62 |
+
dtype: string
|
| 63 |
+
- name: lang
|
| 64 |
+
dtype: string
|
| 65 |
+
- name: max_stars_repo_name
|
| 66 |
+
dtype: string
|
| 67 |
+
- name: max_stars_repo_licenses
|
| 68 |
+
sequence: string
|
| 69 |
+
- name: max_stars_count
|
| 70 |
+
dtype: float64
|
| 71 |
+
- name: max_issues_repo_name
|
| 72 |
+
dtype: string
|
| 73 |
+
- name: max_issues_repo_licenses
|
| 74 |
+
sequence: string
|
| 75 |
+
- name: max_issues_count
|
| 76 |
+
dtype: float64
|
| 77 |
+
- name: max_forks_repo_name
|
| 78 |
+
dtype: string
|
| 79 |
+
- name: max_forks_repo_licenses
|
| 80 |
+
sequence: string
|
| 81 |
+
- name: max_forks_count
|
| 82 |
+
dtype: float64
|
| 83 |
+
- name: text
|
| 84 |
+
dtype: string
|
| 85 |
+
- name: avg_line_length
|
| 86 |
+
dtype: float64
|
| 87 |
+
- name: max_line_length
|
| 88 |
+
dtype: int64
|
| 89 |
+
- name: alphanum_fraction
|
| 90 |
+
dtype: float64
|
| 91 |
+
- name: code_readability
|
| 92 |
+
dtype: float64
|
| 93 |
+
splits:
|
| 94 |
+
- name: train
|
| 95 |
+
num_bytes: 1210173023
|
| 96 |
+
num_examples: 218432
|
| 97 |
+
download_size: 401845994
|
| 98 |
+
dataset_size: 1210173023
|
| 99 |
+
license: odc-by
|
| 100 |
+
---
|
| 101 |
+
# Dataset Card for "the-stack-smol-xl-readable"
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
[Filtered](https://gist.github.com/pszemraj/60de22b09e9c91a16443519a1741e0c0) for 'readability' 0.8 and greater. ~560M llama2 tokens
|
| 105 |
+
|
| 106 |
+
columns:
|
| 107 |
+
|
| 108 |
+
```
|
| 109 |
+
{'train': ['size',
|
| 110 |
+
'ext',
|
| 111 |
+
'lang',
|
| 112 |
+
'max_stars_repo_name',
|
| 113 |
+
'max_stars_repo_licenses',
|
| 114 |
+
'max_stars_count',
|
| 115 |
+
'max_issues_repo_name',
|
| 116 |
+
'max_issues_repo_licenses',
|
| 117 |
+
'max_issues_count',
|
| 118 |
+
'max_forks_repo_name',
|
| 119 |
+
'max_forks_repo_licenses',
|
| 120 |
+
'max_forks_count',
|
| 121 |
+
'text',
|
| 122 |
+
'avg_line_length',
|
| 123 |
+
'max_line_length',
|
| 124 |
+
'alphanum_fraction',
|
| 125 |
+
'code_readability']}
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
## stats
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
### readability index
|
| 132 |
+
|
| 133 |
+
| | code_readability |
|
| 134 |
+
|:------|-------------------:|
|
| 135 |
+
| count | 218432 |
|
| 136 |
+
| mean | 0.840515 |
|
| 137 |
+
| std | 0.0288337 |
|
| 138 |
+
| min | 0.8 |
|
| 139 |
+
| 25% | 0.816354 |
|
| 140 |
+
| 50% | 0.836042 |
|
| 141 |
+
| 75% | 0.863379 |
|
| 142 |
+
| max | 0.987153 |
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
### tokens
|
| 147 |
+
|
| 148 |
+
llama2
|
| 149 |
+
|
| 150 |
+
```
|
| 151 |
+
token_len
|
| 152 |
+
count 205173.000000
|
| 153 |
+
mean 2654.322581
|
| 154 |
+
std 18141.069771
|
| 155 |
+
min 33.000000
|
| 156 |
+
25% 166.000000
|
| 157 |
+
50% 390.000000
|
| 158 |
+
75% 1078.000000
|
| 159 |
+
max 686163.000000
|
| 160 |
+
```
|
calculate_code_readability.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from itertools import chain
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def calculate_readability(code_string:str) -> float:
|
| 6 |
+
code = code_string.splitlines()
|
| 7 |
+
|
| 8 |
+
# Heuristic 1: Line length
|
| 9 |
+
max_line_length = 80
|
| 10 |
+
long_lines = sum(1 for line in code if len(line) > max_line_length)
|
| 11 |
+
long_line_ratio = long_lines / len(code)
|
| 12 |
+
|
| 13 |
+
# Heuristic 2: Identifier length
|
| 14 |
+
min_identifier_length = 2
|
| 15 |
+
max_identifier_length = 20
|
| 16 |
+
identifiers = re.findall(r"\b[a-zA-Z_][a-zA-Z0-9_]*\b", " ".join(code))
|
| 17 |
+
short_identifiers = sum(1 for id in identifiers if len(id) < min_identifier_length)
|
| 18 |
+
long_identifiers = sum(1 for id in identifiers if len(id) > max_identifier_length)
|
| 19 |
+
bad_identifier_ratio = (
|
| 20 |
+
(short_identifiers + long_identifiers) / len(identifiers) if identifiers else 0
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Heuristic 3: Comment density
|
| 24 |
+
target_comment_density = 0.15
|
| 25 |
+
comment_lines = sum(1 for line in code if re.search(r"//|/\*|\*/|#", line))
|
| 26 |
+
comment_density = abs(comment_lines / len(code) - target_comment_density)
|
| 27 |
+
|
| 28 |
+
# Heuristic 4: Cyclomatic Complexity (normalized by the number of functions)
|
| 29 |
+
control_structures = re.findall(
|
| 30 |
+
r"\b(if|else|for|while|switch|case|default|continue|break)\b",
|
| 31 |
+
" ".join(code),
|
| 32 |
+
re.I,
|
| 33 |
+
)
|
| 34 |
+
functions = re.findall(r"\b(def|function|func|sub)\b", " ".join(code), re.I)
|
| 35 |
+
cyclomatic_complexity = (len(control_structures) + 1) / (len(functions) + 1)
|
| 36 |
+
|
| 37 |
+
# Heuristic 5: Indentation consistency
|
| 38 |
+
indentation_levels = [
|
| 39 |
+
len(re.match(r"^[\s\t]*", line).group()) for line in code if line.strip() != ""
|
| 40 |
+
]
|
| 41 |
+
inconsistent_indentation = sum(
|
| 42 |
+
1
|
| 43 |
+
for i in range(1, len(indentation_levels))
|
| 44 |
+
if indentation_levels[i] - indentation_levels[i - 1] not in {0, 1, -1}
|
| 45 |
+
)
|
| 46 |
+
indentation_inconsistency_ratio = (
|
| 47 |
+
inconsistent_indentation / (len(indentation_levels) - 1)
|
| 48 |
+
if len(indentation_levels) > 1
|
| 49 |
+
else 0
|
| 50 |
+
)
|
| 51 |
+
# Normalize heuristic scores
|
| 52 |
+
normalized_scores = {
|
| 53 |
+
"long_line_ratio": 1 - min(long_line_ratio, 1),
|
| 54 |
+
"bad_identifier_ratio": 1 - min(bad_identifier_ratio, 1),
|
| 55 |
+
"comment_density_deviation": 1 - min(comment_density, 1),
|
| 56 |
+
"normalized_cyclomatic_complexity": 1 / (1 + cyclomatic_complexity),
|
| 57 |
+
"indentation_inconsistency_ratio": 1 - min(indentation_inconsistency_ratio, 1),
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
# Calculate the aggregate score as the average of the normalized scores
|
| 61 |
+
aggregate_score = sum(normalized_scores.values()) / len(normalized_scores)
|
| 62 |
+
|
| 63 |
+
return aggregate_score
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
# Example usage:
|
| 67 |
+
code_example = """def calculate_readability(code):
|
| 68 |
+
# This function calculates readability
|
| 69 |
+
avg_line_length = sum(len(line) for line in code) / len(code)
|
| 70 |
+
return avg_line_length"""
|
| 71 |
+
|
| 72 |
+
readability_score = calculate_readability(code_example)
|
| 73 |
+
print(readability_score)
|
data/train-00000-of-00003-3debaf16ce325fe6.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d2c2740eae6cdbcaacabac3dc5c8050a013dac848572f6cedf8b60698edd3c29
|
| 3 |
+
size 133220408
|
data/train-00001-of-00003-23f3f1e9b4b01385.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a53d5b71fbba00c0d3b5a8c537533c6e13166672a83315525ffc49377f36e1c0
|
| 3 |
+
size 130759686
|
data/train-00002-of-00003-1b6194e483487146.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:94842273ba9c59974ef5cfb3be816a1151be9c41c2957e034a9ae9007241e064
|
| 3 |
+
size 130030159
|
original/train-00000-of-00003-da7b7f628e7e10e5.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d5796bbd6861af21c727434fa3fce9623355ec3c1dc6947a626fd2407e6a53d5
|
| 3 |
+
size 135325874
|
original/train-00001-of-00003-8cf5de7cc9cd3e5f.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c10ec529e0dd1fa7955dec5e2129bbef02ca59cb92de4fda82169b93e730ddf9
|
| 3 |
+
size 134381590
|
original/train-00002-of-00003-ed372e1f9bb65acb.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ffd57e00700d7b00b617de9f83cccf5c4282330c6a005030ae5e198d78c2d97f
|
| 3 |
+
size 132138530
|