@@ -8,6 +8,9 @@ import org.ivdnt.galahad.evaluation.comparison.LayerComparison.Companion.truncat
88import org.ivdnt.galahad.evaluation.comparison.TermComparison
99import org.ivdnt.galahad.evaluation.frequency.TokenFrequency
1010
11+ // for compound lemma like "aan_pakken" instead of "aanpakken"
12+ val LEMMA_REGEX = Regex (" _" )
13+
1114interface 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
8584open 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
134133class 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
151150class 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
169168class UposByUposMetricsSettings : MetricsSettings {
0 commit comments