danasone commited on
Commit
a8294c6
1 Parent(s): 9a88164
Files changed (1) hide show
  1. ru_errant.py +15 -14
ru_errant.py CHANGED
@@ -88,21 +88,7 @@ def update_spacy_tokenizer(nlp):
88
  return nlp
89
 
90
 
91
- def annotate_errors(self, orig: str, cor: str, merging: str = "rules") -> list[Edit]:
92
- """
93
- Overrides `Annotator.annotate()` function to allow multiple errors per token.
94
- This is nesessary to parse combined errors, e.g.:
95
- ["werd", "Word"] >>> Errors: ["SPELL", "CASE"]
96
- The `classify()` method called inside is implemented in ruerrant_classifier.py
97
- (also overrides the original classifier).
98
- """
99
 
100
- alignment = self.annotator.align(orig, cor, False)
101
- edits = self.annotator.merge(alignment, merging)
102
- classified_edits = []
103
- for edit in edits:
104
- classified_edits.extend(self.annotator.classify(edit))
105
- return sorted(classified_edits, key=lambda x: (x[0], x[2]))
106
 
107
 
108
  @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
@@ -137,6 +123,21 @@ class RuErrant(evaluate.Metric):
137
  nlp=update_spacy_tokenizer(spacy.load("ru_core_news_lg")),
138
  merger=merger,
139
  classifier=classifier)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
  def _compute(self, sources, corrections, answers):
142
  """
 
88
  return nlp
89
 
90
 
 
 
 
 
 
 
 
 
91
 
 
 
 
 
 
 
92
 
93
 
94
  @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
 
123
  nlp=update_spacy_tokenizer(spacy.load("ru_core_news_lg")),
124
  merger=merger,
125
  classifier=classifier)
126
+ def annotate_errors(self, orig: str, cor: str, merging: str = "rules") -> list[Edit]:
127
+ """
128
+ Overrides `Annotator.annotate()` function to allow multiple errors per token.
129
+ This is nesessary to parse combined errors, e.g.:
130
+ ["werd", "Word"] >>> Errors: ["SPELL", "CASE"]
131
+ The `classify()` method called inside is implemented in ruerrant_classifier.py
132
+ (also overrides the original classifier).
133
+ """
134
+
135
+ alignment = self.annotator.align(orig, cor, False)
136
+ edits = self.annotator.merge(alignment, merging)
137
+ classified_edits = []
138
+ for edit in edits:
139
+ classified_edits.extend(self.annotator.classify(edit))
140
+ return sorted(classified_edits, key=lambda x: (x[0], x[2]))
141
 
142
  def _compute(self, sources, corrections, answers):
143
  """