Skip to content

Commit

Permalink
feat: add lang pred in spellcheck insights (#1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 authored Dec 20, 2024
1 parent 9da49ad commit c921e8a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion robotoff/batch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from robotoff import settings
from robotoff.insights.importer import import_insights
from robotoff.models import db
from robotoff.prediction.langid import predict_lang
from robotoff.types import BatchJobType, Prediction, PredictionType, ServerType
from robotoff.utils import get_logger

Expand Down Expand Up @@ -49,10 +50,19 @@ def import_spellcheck_batch_predictions(batch_dir: str) -> None:
predictor_version = "llm-v1-" + datetime.datetime.now().strftime("%Y%m%d%H%M%S")

for _, row in df.iterrows():
lang_predictions = predict_lang(row["text"], k=1)
lang, lang_confidence = lang_predictions[0].lang, (
lang_predictions[0].confidence if lang_predictions else None
)
predictions.append(
Prediction(
type=PredictionType.ingredient_spellcheck,
data={"original": row["text"], "correction": row["correction"]},
data={
"original": row["text"],
"correction": row["correction"],
"lang": lang,
"lang_confidence": lang_confidence,
},
value_tag=row["lang"],
barcode=row["code"],
predictor_version=predictor_version,
Expand Down

0 comments on commit c921e8a

Please sign in to comment.