Skip to content

Commit d70cade

Browse files
committed
Metrics: apply _ regex to all lemma evaluations
1 parent fbf885f commit d70cade

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

server/src/main/kotlin/org/ivdnt/galahad/evaluation/metrics/MetricsSettings.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import org.ivdnt.galahad.evaluation.comparison.LayerComparison.Companion.truncat
88
import org.ivdnt.galahad.evaluation.comparison.TermComparison
99
import org.ivdnt.galahad.evaluation.frequency.TokenFrequency
1010

11+
// for compound lemma like "aan_pakken" instead of "aanpakken"
12+
val LEMMA_REGEX = Regex("_")
13+
1114
interface MetricsSettings {
1215
/** When are terms equal? */
1316
fun termsEqual(comp: TermComparison): Boolean
@@ -73,13 +76,9 @@ open class LemmaByLemmaMetricsSettings : MetricsSettings {
7376
override val nullTerm: String = "NO_LEMMA"
7477
override val requiredAnnotations: List<Annotation> = listOf(Annotation.LEMMA)
7578

76-
override fun termsEqual(comp: TermComparison): Boolean = comp.equalAnnotation(Annotation.LEMMA, lemmaRegex)
79+
override fun termsEqual(comp: TermComparison): Boolean = comp.equalAnnotation(Annotation.LEMMA, LEMMA_REGEX)
7780

7881
override fun groupBy(term: Term): String = term.lemma ?: nullTerm
79-
80-
companion object {
81-
val lemmaRegex = Regex("_")
82-
}
8382
}
8483

8584
open class DeprelByDeprel : MetricsSettings {
@@ -128,7 +127,7 @@ class LemmaByPosMetricsSettings : PosByPosMetricsSettings() {
128127
override val annotation: String = "Lemma"
129128
override val requiredAnnotations: List<Annotation> = listOf(Annotation.LEMMA, Annotation.POS)
130129

131-
override fun termsEqual(comp: TermComparison): Boolean = comp.equalAnnotation(Annotation.LEMMA)
130+
override fun termsEqual(comp: TermComparison): Boolean = comp.equalAnnotation(Annotation.LEMMA, LEMMA_REGEX)
132131
}
133132

134133
class PosByLemmaMetricsSettings : LemmaByLemmaMetricsSettings() {
@@ -145,7 +144,7 @@ class LemmaPosByPosMetricsSettings : PosByPosMetricsSettings() {
145144
override val requiredAnnotations: List<Annotation> = listOf(Annotation.LEMMA, Annotation.POS)
146145

147146
override fun termsEqual(comp: TermComparison): Boolean =
148-
comp.equalAnnotation(Annotation.POS) && comp.equalAnnotation(Annotation.LEMMA)
147+
comp.equalAnnotation(Annotation.POS) && comp.equalAnnotation(Annotation.LEMMA, LEMMA_REGEX)
149148
}
150149

151150
class DeprelHeadbyDeprelMetricsSettings : DeprelByDeprel() {
@@ -163,7 +162,7 @@ class LemmaPosByLemmaMetricsSettings : LemmaByLemmaMetricsSettings() {
163162
override val requiredAnnotations: List<Annotation> = listOf(Annotation.LEMMA, Annotation.POS)
164163

165164
override fun termsEqual(comp: TermComparison): Boolean =
166-
comp.equalAnnotation(Annotation.POS) && comp.equalAnnotation(Annotation.LEMMA)
165+
comp.equalAnnotation(Annotation.POS) && comp.equalAnnotation(Annotation.LEMMA, LEMMA_REGEX)
167166
}
168167

169168
class UposByUposMetricsSettings : MetricsSettings {

0 commit comments

Comments
 (0)