@@ -8,6 +8,7 @@ Stability : experimental
8
8
module Errors where
9
9
10
10
import Data.List
11
+ import Data.Maybe
11
12
import Data.Bifunctor
12
13
import RTree
13
14
import UDConcepts
@@ -125,14 +126,26 @@ simplifyErrorPattern = bimap simplifyUDPattern simplifyUDPattern
125
126
-- simplification of sequence patterns only works if there is only one
126
127
-- error, like in DaLAJ sentences
127
128
(SEQUENCE p1s,SEQUENCE p2s) -> (SEQUENCE p1s',SEQUENCE p2s')
128
- where (p1s',p2s') = unzip $ rmCommonPrePost $ p1s `zip` p2s
129
+ where (p1s',p2s') = simplifySeqs p1s p2s
129
130
(SEQUENCE_ p1s,SEQUENCE_ p2s) -> (SEQUENCE_ p1s',SEQUENCE_ p2s')
130
- where (p1s',p2s') = unzip $ rmCommonPrePost $ p1s `zip` p2s
131
+ where (p1s',p2s') = simplifySeqs p1s p2s
131
132
ep -> ep
132
133
where
133
134
filterSubpatterns p1s p2s = if length p1s == length p2s
134
135
then unzip $ filter (\ (p1,p2) -> p1 /= p2) (p1s `zip` p2s)
135
136
else (p1s,p2s)
137
+ simplifySeqs p1s p2s
138
+ -- word order error
139
+ | length p1s == length p2s = unzip $ rmCommonPrePost $ p1s `zip` p2s
140
+ -- missing token (assuming only one token is missing for now)
141
+ | length p1s < length p2s =
142
+ let i = fromJust $ elemIndex (head (p2s \\ p1s)) p2s
143
+ in (slice (i - 1 ) (i) p1s, slice (i - 1 ) (i + 1 ) p2s)
144
+ | length p1s > length p2s =
145
+ let i = fromJust $ elemIndex (head (p1s \\ p2s)) p1s
146
+ in (slice (i - 1 ) (i + 1 ) p1s, slice (i - 1 ) (i) p2s)
147
+ -- redundant token (assuming only one token is redundant for now)
148
+
136
149
137
150
-- | Shorthand to convert into a Universal morphosyntactic pattern and
138
151
-- simplify
0 commit comments