Spaces:
Sleeping
Sleeping
Commit Β·
d054e60
1
Parent(s): 6b2967c
fix: added robust descriptive labels for dataset strings
Browse files- backend/main.py +12 -8
backend/main.py
CHANGED
|
@@ -6,15 +6,19 @@ from fastapi.staticfiles import StaticFiles
|
|
| 6 |
from pydantic import BaseModel
|
| 7 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 8 |
|
| 9 |
-
# Complexity descriptions
|
| 10 |
DESCRIPTIONS = {
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
| 15 |
-
"
|
| 16 |
-
"
|
| 17 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
|
| 20 |
app = FastAPI(title="Code Complexity Predictor API")
|
|
|
|
| 6 |
from pydantic import BaseModel
|
| 7 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 8 |
|
| 9 |
+
# Complexity descriptions (robust mapping for codeparrot labels)
|
| 10 |
DESCRIPTIONS = {
|
| 11 |
+
"O(1)": ("O(1)", "β‘ Constant Time", "Executes in the same time regardless of input size. Very fast!"),
|
| 12 |
+
"O(N)": ("O(N)", "π Linear Time", "Execution time grows linearly with input size."),
|
| 13 |
+
"O(log N)": ("O(log N)", "π Logarithmic Time", "Very efficient! Common in binary search algorithms."),
|
| 14 |
+
"O(N log N)": ("O(N log N)", "βοΈ Linearithmic Time", "Common in efficient sorting algorithms like merge sort."),
|
| 15 |
+
"O(N^2)": ("O(NΒ²)", "π’ Quadratic Time", "Execution time grows quadratically. Common in nested loops."),
|
| 16 |
+
"O(N^3)": ("O(NΒ³)", "π¦ Cubic Time", "Triple nested loops. Avoid for large inputs."),
|
| 17 |
+
"O(2^N)": ("O(2βΏ)", "π Exponential Time", "NP-Hard complexity. Only feasible for very small inputs."),
|
| 18 |
+
"O(NP)": ("O(NP)", "π NP-Complete", "Infeasible for large inputs without approximation."),
|
| 19 |
+
"constant": ("O(1)", "β‘ Constant Time", "Executes in the same time regardless of input size. Very fast!"),
|
| 20 |
+
"linear": ("O(N)", "π Linear Time", "Execution time grows linearly with input size."),
|
| 21 |
+
"quadratic": ("O(NΒ²)", "π’ Quadratic Time", "Execution time grows quadratically. Common in nested loops."),
|
| 22 |
}
|
| 23 |
|
| 24 |
app = FastAPI(title="Code Complexity Predictor API")
|