-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathTransformUD.hs
More file actions
24 lines (17 loc) · 852 Bytes
/
TransformUD.hs
File metadata and controls
24 lines (17 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module TransformUD where
import UDConcepts
-- build a string transformer from a transform function
transUD :: ([UDSentence] -> [UDSentence]) -> String -> String
transUD trans = prt . trans . parseUDText
-- transform functions on different levels
-- change sentences individually, as lists of words
transByUDWordLines :: ([UDWord] -> [UDWord]) -> ([UDSentence] -> [UDSentence])
transByUDWordLines tws = map (\uds -> uds{udWordLines = tws (udWordLines uds)})
-- change sentences individually, first analysing them to trees
transByUDTree :: (UDTree -> UDTree) -> ([UDSentence] -> [UDSentence])
transByUDTree tt = map apptt
where
apptt = udTree2sentence . tt . udSentence2tree
-- change words individually, e.g. their POS tag
transByUDWord :: (UDWord -> UDWord) -> ([UDSentence] -> [UDSentence])
transByUDWord tw = transByUDWordLines (map tw)