-
Notifications
You must be signed in to change notification settings - Fork 26
/
segment.xfst
111 lines (105 loc) · 3.99 KB
/
segment.xfst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
! segment.xfst
!
! Released under the terms of the MIT License
! Copyright (c) 2011-2015 Çağrı Çöltekin <[email protected]>
!
! Permission is hereby granted, free of charge, to any person obtaining a
! copy of this software and associated documentation files (the "Software"),
! to deal in the Software without restriction, including without limitation
! the rights to use, copy, modify, merge, publish, distribute, sublicense,
! and/or sell copies of the Software, and to permit persons to whom the
! Software is furnished to do so, subject to the following conditions:
!
! The above copyright notice and this permission notice shall be included in
! all copies or substantial portions of the Software.
!
! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
! FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
! DEALINGS IN THE SOFTWARE.
!
!
! This script creates a segmenter.
!
! We first analyze the input, then use a modified generator
! that leaves the boundaries on the surface.
!
! The result is likely to be ambiguous. There are two types of
! ambiguities that this fst generates. Firs is due to multiple morphs
! that may be used for the same function.
! For example, this automaton will give `oku-r' and `oku-r-lar'
! for segmentation of `okur'. The second one is due to the fact that
! there are two ways to indicate third person plural verbal agreement
! either by a null morpheme (which is the case with `onlar kitap okur')
! or an over morpheme -lar. This can be fixed in the segmenter below
! as well. However, for these cases, filtering the output is easy
! anyway. One can check, whether the original string and the
! segmented string after removing the boundaries is the same or not.
!
! The other, more genuine segmentation ambiguity occurs when the
! string can be segmented in two different ways. For example `evleri'
! will both be segmented as `ev-leri' and `ev-ler-i'. Ambiguities
! that do not affect the segmentation aside, the first one has only
! the third person plural possessive morpheme, while the
! second one have two, one plural marker and one accusative case marker
! (or third person singular possessive marker).
!
! The consecutive boundaries that may happen because of the null
! morphemes are removed.
!
read lexc analyzer.cpp.lexc
eliminate flags
define Lexicon;
source morph-phon.cpp.xfst
define analyzeBasic AFilter
.o. Lexicon
.o. delStressMarks
.o. Abbr
.o. replaceApos
.o. NumberSpace
.o. NumericInsSilentP
.o. NumericSeparator
.o. CompNoun
.o. DeleteSI
.o. DeleteLAR
.o. InsertN
.o. DelS
.o. InsertS
.o. PronounExceptions
.o. InsertY
.o. iDeleteY
.o. NbeforePassive
.o. PassiveLN
.o. Causative
.o. Optative3
.o. SpaceBeforeMI
.o. NegAorist
.o. DeleteBuffer
.o. DeYeException
.o. YorException
.o. VowelHarmony
.o. VowelEpenthesis
.o. FSDevoicing
.o. VoicingAssimilation
.o. Redup
.o. DeleteSilentP
.o. KiKu
.o. DeleteCircumflex;
define analyze analyzeBasic .o. DeleteBoundary .o. Capitalize .o. Capitalize.i;
!
! This is the same analyzer. Except, it leaves the boundaries
! intact at the surface level
! TODO: this can be made more strict/unambigous.
!
define analyzeBM analyzeBasic
.o. %@RB|%@MB -> "-"
.o. "-" -> 0 // "-" _
.o. "-" -> 0 || _ .#.;
regex analyzeBM.i;
save stack segment-only.fst
clear stack
read regex analyzeBM.i .o. analyze;
save stack segment.fst