raghuram00 commited on
Commit
d054e60
Β·
1 Parent(s): 6b2967c

fix: added robust descriptive labels for dataset strings

Browse files
Files changed (1) hide show
  1. 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
- "constant": ("O(1)", "⚑ Constant Time", "Executes in the same time regardless of input size. Very fast!"),
12
- "linear": ("O(n)", "πŸ“ˆ Linear Time", "Execution time grows linearly with input size."),
13
- "logn": ("O(log n)", "πŸ” Logarithmic Time", "Very efficient! Common in binary search algorithms."),
14
- "nlogn": ("O(n log n)", "βš™οΈ Linearithmic Time", "Common in efficient sorting algorithms like merge sort."),
15
- "quadratic": ("O(n²)", "🐒 Quadratic Time", "Execution time grows quadratically. Common in nested loops."),
16
- "cubic": ("O(nΒ³)", "πŸ¦• Cubic Time", "Triple nested loops. Avoid for large inputs."),
17
- "np": ("O(2ⁿ)", "πŸ’€ Exponential Time", "NP-Hard complexity. Only feasible for very small inputs."),
 
 
 
 
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")