langident
custom_code
Simon Clematide commited on
Commit
3b1ef7b
·
1 Parent(s): 3b2c930

Replace newline characters in input text (as floret treats it as record separator) and update output keys for clarity

Browse files
Files changed (1) hide show
  1. langident.py +2 -2
langident.py CHANGED
@@ -14,7 +14,7 @@ class LangDetectionPipeline(Pipeline):
14
  return text
15
 
16
  def _forward(self, text, **kwargs):
17
- predictions, probabilities = self.model(text)
18
  return predictions, probabilities
19
 
20
  def postprocess(self, outputs, **kwargs):
@@ -25,5 +25,5 @@ class LangDetectionPipeline(Pipeline):
25
  ) # Convert to float for JSON serialization
26
 
27
  # Format as JSON-compatible dictionary
28
- model_output = {"label": label, "confidence": round(confidence * 100, 2)}
29
  return model_output
 
14
  return text
15
 
16
  def _forward(self, text, **kwargs):
17
+ predictions, probabilities = self.model(text.replace("\n", " "))
18
  return predictions, probabilities
19
 
20
  def postprocess(self, outputs, **kwargs):
 
25
  ) # Convert to float for JSON serialization
26
 
27
  # Format as JSON-compatible dictionary
28
+ model_output = {"language": label, "score": round(confidence * 100, 2)}
29
  return model_output