Create a PredictionResult for testing.
(
text: str, entities: List[Dict], model_name: str = "test-model"
)
| 178 | |
| 179 | @staticmethod |
| 180 | def create_prediction_result( |
| 181 | text: str, entities: List[Dict], model_name: str = "test-model" |
| 182 | ): |
| 183 | """Create a PredictionResult for testing.""" |
| 184 | from datetime import datetime |
| 185 | |
| 186 | from openmed.processing.outputs import EntityPrediction, PredictionResult |
| 187 | |
| 188 | entity_objects = [ |
| 189 | EntityPrediction( |
| 190 | text=e["word"], |
| 191 | label=e["entity"], |
| 192 | confidence=e["score"], |
| 193 | start=e.get("start"), |
| 194 | end=e.get("end"), |
| 195 | ) |
| 196 | for e in entities |
| 197 | ] |
| 198 | |
| 199 | return PredictionResult( |
| 200 | text=text, |
| 201 | entities=entity_objects, |
| 202 | model_name=model_name, |
| 203 | timestamp=datetime.now().isoformat(), |
| 204 | processing_time=0.123, |
| 205 | ) |
| 206 | |
| 207 | |
| 208 | # Make TestHelpers available as a fixture |
no test coverage detected