Skip to content

Commit 4364427

Browse files
committed
feat: integrated correction into evaluation
1 parent 621e19b commit 4364427

6 files changed

Lines changed: 290 additions & 355 deletions

File tree

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,44 @@
11
# FSA Correction Module
22

3-
Compares student FSAs against expected FSAs, leveraging the validation module for detailed feedback.
3+
Compares student FSAs against expected FSAs, returns `Result` with `FSAFeedback`.
44

55
## Exports
66

77
```python
88
from evaluation_function.correction import (
9-
analyze_fsa_correction, # Main pipeline
9+
analyze_fsa_correction, # Main pipeline -> Result
1010
check_minimality, # Check if FSA is minimal
11-
CorrectionResult, # Result model
1211
)
1312
```
1413

1514
## Pipeline
1615

1716
```
18-
┌─────────────────────────────────────────────────────────────────┐
19-
│ analyze_fsa_correction() │
20-
│ (student_fsa, expected_fsa) │
21-
├─────────────────────────────────────────────────────────────────┤
22-
│ Step 1: Structural Validation │
23-
│ └── is_valid_fsa() → List[ValidationError] │
24-
├─────────────────────────────────────────────────────────────────┤
25-
│ Step 2: Minimality Check (optional) │
26-
│ └── check_minimality() → bool │
27-
├─────────────────────────────────────────────────────────────────┤
28-
│ Step 3: Structural Analysis │
29-
│ └── get_structured_info_of_fsa() → StructuralInfo │
30-
├─────────────────────────────────────────────────────────────────┤
31-
│ Step 4: Language Equivalence │
32-
│ └── fsas_accept_same_language() → are_isomorphic() │
33-
│ Provides detailed feedback with ElementHighlight │
34-
├─────────────────────────────────────────────────────────────────┤
35-
│ OUTPUT: CorrectionResult │
36-
│ ├── is_equivalent: bool │
37-
│ ├── is_isomorphic: bool │
38-
│ ├── is_minimal: Optional[bool] │
39-
│ ├── validation_errors: List[ValidationError] │
40-
│ ├── equivalence_errors: List[ValidationError] │
41-
│ └── structural_info: StructuralInfo │
42-
│ │
43-
│ Methods: │
44-
│ ├── .model_dump() → dict │
45-
│ ├── .to_fsa_feedback() → FSAFeedback │
46-
│ └── .get_language_comparison() → LanguageComparison │
47-
└─────────────────────────────────────────────────────────────────┘
17+
analyze_fsa_correction(student_fsa, expected_fsa, require_minimal=False) -> Result
18+
├── 1. Validate student FSA (is_valid_fsa)
19+
├── 2. Check minimality (if required)
20+
├── 3. Structural analysis (get_structured_info_of_fsa)
21+
└── 4. Language equivalence (fsas_accept_same_language -> are_isomorphic)
22+
└── All "why" feedback comes from here
4823
```
4924

50-
## Usage
25+
## Result
5126

5227
```python
53-
from evaluation_function.correction import analyze_fsa_correction, check_minimality
54-
55-
# Compare two FSAs
56-
result = analyze_fsa_correction(student_fsa, expected_fsa, check_minimality=True)
57-
58-
# Check result
59-
result.is_equivalent # bool
60-
result.equivalence_errors # List[ValidationError] with ElementHighlight
28+
Result(
29+
is_correct: bool, # True if FSAs accept same language
30+
feedback: str, # Human-readable summary
31+
fsa_feedback: FSAFeedback # Structured feedback for UI
32+
)
33+
```
6134

62-
# For UI
63-
result.to_fsa_feedback() # FSAFeedback schema
35+
## Usage
6436

65-
# As dict
66-
result.model_dump() # dict
37+
```python
38+
from evaluation_function.correction import analyze_fsa_correction
6739

68-
# Check minimality only
69-
check_minimality(fsa) # bool
40+
result = analyze_fsa_correction(student_fsa, expected_fsa)
41+
result.is_correct # bool
42+
result.feedback # "Correct!" or "Languages differ: ..."
43+
result.fsa_feedback.errors # List[ValidationError] with ElementHighlight
7044
```

evaluation_function/correction/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@
33
Compares student FSAs against expected FSAs.
44
55
Exports:
6-
- analyze_fsa_correction: Main pipeline (FSA vs FSA -> CorrectionResult)
6+
- analyze_fsa_correction: Main pipeline (FSA vs FSA -> Result)
77
- check_minimality: Check if FSA is minimal
8-
- CorrectionResult: Result model with .to_fsa_feedback(), .model_dump()
98
"""
109

1110
from .correction import (
1211
analyze_fsa_correction,
1312
check_minimality,
14-
CorrectionResult,
1513
)
1614

1715
__all__ = [
1816
"analyze_fsa_correction",
1917
"check_minimality",
20-
"CorrectionResult",
2118
]

0 commit comments

Comments
 (0)