MCPcopy
hub / github.com/maziyarpanahi/openmed / create_prediction_result

Method create_prediction_result

tests/conftest.py:180–205  ·  view source on GitHub ↗

Create a PredictionResult for testing.

(
        text: str, entities: List[Dict], model_name: str = "test-model"
    )

Source from the content-addressed store, hash-verified

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

Callers 3

test_to_jsonMethod · 0.80
test_to_htmlMethod · 0.80
test_to_csv_rowsMethod · 0.80

Calls 3

EntityPredictionClass · 0.90
PredictionResultClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected