Kapittel 4

Dette kapitlet (kapittel 4 i Beesley/Karttunen Finite-State Morphology, cf. www.fsmbook.com, handlar om lexc, eit program laga for å optimalisere skrivinga av grammatikkar som består av leksika og suffiks

Formelt sett er lexc ein høgrerekursiv frasestrukturgrammatikk.

Disposisjon:


4.2 Enkle automatar
===================

Kompilere lexc-filer i lexc:
lexc -utf8
compile-source ex1-lex.txt


Kompilere lexc-filer i xfst:
xfst -utf8
read lexc < ex1-lex.txt



!ex1-lex.txt
LEXICON Root
dog # ;
cat # ;
bird # ;
%# # ;
2%0%%  # ;

!-----------


LEXICON Root
walk # ;
walks # ;
walked # ;
walking # ;
talk # ;
talks # ;
talked # ;
talking # ;
pack # ;
packs # ;
packed # ;
packing # ;

!-----------

LEXICON Root
walk V ;
talk V ;
pack V ;

LEXICON V
s    # ;
ed   # ;
ing  # ;
     # ; ! <- an empty-string entry

!----------


- Definer så mange leksika du vil (sme 1757, smj 868, sma 131)
- Eit leksikonoppslag kan ha kva leksikon som helst som kontinuasjonsklasse
- Kall leksikona kva du vil (men bruk fornuft!)
- Leksikonnamna blir ikkje del av automaten, dei er berre i lexc-fila
- Det er skilnad på store og små bokstavar, og du kan bruke æøåáčđŋšŧž LEXICON NYSTØ
- Leksikonoppslag kan vere tom, men dei SKAL ha kontinuasjonsleksika, og dei SKAL bli avslutta med semikolon
- Leksikonnamn sluttar IKKJE med semikolon
- ! innleier kommentarar. Bruk masse kommentarar
- Det første leksikonet må vere Root
- Nettverket slutar med #, som er finaltilstanden.

Problem med lexc: Berre segmental morfologi, ikkje så godt tilpassa
- avstandsdependensar (tysk gegangen)
- diskontinuerlegeg bøying (arabisk kitab)
- infiksering (litauisk) 
- reduplikasjon (tagalog)


!---------------------------- e2.txt
LEXICON Root
and   # ;
big   # ;
bird  N ;
blue  # ;
walk  V ;
cat   N ;
dog   N ;
old   # ;
or    # ;
pack  V ;
talk  V ;
walk  V ;
walk  N ;


LEXICON N
  # ;     ! an empty entry for single noun
s # ;     ! add ’s’ for plural nouns

LEXICON V
s   # ;   ! ’s’ suffix for 3rd-person sing. verbs
ed  # ;   ! ’ed’ suffix for past tense
ing # ;   ! ’ing’ for the present progressive
    # ;   ! an empty entry for bare verbs


!------------------------4.9 49.txt
LEXICON Root ! empty branches to the various
             ! LEXICONs that can start a word
Nouns ;
Verbs ;
Adjectives ;
Conjunctions ;
! add more classes here as needed

LEXICON Nouns
dog  N ;
cat  N ;
bird N ;

LEXICON N
  # ;
s # ;

LEXICON Verbs
walk V ;
talk V ;
pack V ;

LEXICON V
s   # ;
ed  # ;
ing # ;
    # ;

LEXICON Adjectives
old  # ;
big  # ;
blue # ;

LEXICON Conjunctions
and # ;
or  # ;


!--------------------4.10
LEXICON Root
kant V ; ! sing
dir V ;  ! say
vid V ;  ! see
LEXICON V
ad Vend ; ! aspect (an optional morpheme)
   Vend ;    ! empty form
LEXICON Vend
i # ;  ! infinitive
as # ; ! present
is # ; ! past
os # ; ! future
us # ; ! conditional
u # ;  ! subjunctive


!----------------4.11 (=4.10)
LEXICON Root
kant V ; ! sing
dir  V ; ! say
vid  V ; ! see

LEXICON V
     AD   ; ! empty entry--go to AD
     Vend ; ! empty entry--go to Vend

LEXICON AD
ad Vend ; ! aspect (an optional morpheme)

LEXICON Vend
i  # ; ! infinitive
as # ; ! present
is # ; ! past
os # ; ! future
us # ; ! conditional
u  # ; ! subjunctive



! empty branches to the various
! LEXICONs that can start a word

LEXICON Root 
Nouns ;
Verbs ;
Adjectives ;
Conjunctions ;
! add more classes here as needed

LEXICON Nouns
dog  N ;
cat  N ;
bird N ;

LEXICON N
  # ;
s # ;

LEXICON Verbs
walk V ;
talk V ;
pack V ;

LEXICON V
s   # ;
ed  # ;
ing # ;
    # ;

LEXICON Adjectives
old  # ;
big  # ;
blue # ;

LEXICON Conjunctions
and # ;
or  # ;


------esp1.lexc
LEXICON Root
NOUNP ;
ADJP ;

LEXICON NOUNP
ge NOUN ;
   NOUN ;
   
! Først tar vi substantiva
LEXICON NOUN
hund N ;
kat  N ;
bird N ;
elefant N ;
tigr N ;
best N ;
leon N ;

LEXICON N
 in N ;
 et N ;
 eg N ;
    OSUF ;
    ASUF ; 

LEXICON OSUF 
 o PL ;


! Så er det adjektiva
LEXICON ADJP
ne  ADJ ;
mal ADJ ;
    ADJ ;
    
LEXICON ADJ
bon	      ADER ;
long      ADER ;
alt	      ADER ;
grav      ADER ;
jung      ADER ;
ideal     ADER  "ideal"				  ; ! tja
luks      ADER  "luxurious"			  ;
blank     ADER  "white"				  ;
nigr      ADER  "black"				  ;
liber     ADER  "free"				  ;
evident   ADER  "obvious"			  ;
grandioz  ADER  "sublime/magnificent" ;
oportun   ADER  "convenient"		  ;


LEXICON ADER
et ASUF ;
eg ASUF ;
   ASUF ;
ec OSUF ;   
   
LEXICON ASUF
a PL ;

!Så litt felles morfologi til slutt
LEXICON PL
 j CASE ; 
   CASE ;
 
LEXICON CASE
 n # ; 
   # ;
 
 
 
 
 

Esperanto
=========

lexc
compile-source esp-nouns-lex.txt
save-source esp-nouns-lex.fst

xfst
load stack esp-nouns-lex.fst
up
up < testwords.txt




 
 

4.3 Å definere leksikalske transdusarar
=======================================


!---------------Latin

Multichar_Symbols 
+Verb +PresInd +Act
+1P +2P +3P +Sg +Pl


LEXICON Root
 AreVerbs ;

LEXICON AreVerbs
 canto:cant AreV ; ! to sing
 laudo:laud AreV ; ! to praise
 amo:am   AreV ; ! to love

LEXICON AreV
 o+Verb:0 AreConj ; ! N.B. two symbols,
                    ! o and +Verb on the
                    ! lexical side

LEXICON AreConj
  ArePresIndicAct ;
! ArePresIndicPass ; ! add later

LEXICON ArePresIndicAct
 +PresInd+Act:0 ArePresIndicEnds ;

LEXICON ArePresIndicEnds
 +1P+Sg:o  # ;
 +2P+Sg:as # ;
 +3P+Sg:at # ;

 +1P+Pl:amus # ;
 +2P+Pl:atis # ;
 +3P+Pl:ant  # ;


!---------------------


4.3.5 Esperanto substantiv, adjektiv og verb
!--------------------------------------etr.lexc
Multichar_Symbols

!Suffixes?
+Noun 
+Adj
+Verb
+Pl   ! for plural (j)
+Sg   ! for singular (i.e. not plural)
+Nom  ! ! nominative (-)
+Acc  ! for accusative (n)
+Aug  ! for augmentative (eg)
+Dim  ! for diminutive (et)
+Fem  ! for feminine (in)
+Past ! for past (is)
+Pres ! for present (as)
+Fut  ! for future (os)
+Subj ! for subjunctive (u)
+Inf  ! for infinitive (i)
+Cond ! for conditional (us)
+Cont ! for postverbal -ad
+Caus ! Causative
+Mid  ! Middle

!Prefixes
Op+   ! for opposite (mal)
Neg+  ! for negative (ne)
MF+   ! for male-female (ge)

!Derivasjonssuffiks
 +Nize
 +Nsuff
 +Asuff

! Slutt på dekl

! Root er starten

LEXICON Root
 NounPrefs ;
 AdjVerbPrefs ;


LEXICON NounPrefs
MF+:ge Nouns ;
       Nouns ;
   
! Først tar vi substantiva
LEXICON Nouns
 hund    FEM "dog"  ;
 kat     FEM "cat"  ;
 bird    FEM "bird"  ;
 elefant FEM "e"  ;
 tigr    FEM "t"  ;
 best    FEM "b"  ;
 leon    FEM "l"  ;
 infan FEM "child" ;
 urs FEM ;  
 dom N ;
 mond N ;
 tag N ;
 monat N ;
 jar N ;
 odor N ;
 urb N ;
 

LEXICON FEM
 +Noun+Fem:in N ;
   N ;
 
LEXICON N
 +Noun+Dim:et N ;
 +Noun+Aug:eg N ;
              OSUF ;
              ASUF ; 

LEXICON OSUF 
 +Nsuff:o PL ;


! Adj og V har same prefiks, faktiskt, nämligen, nämlich
LEXICON AdjVerbPrefs
 Neg+:ne  AV ; ! Dei går til AV som er Adj og V
 Op+:mal  AV ;
          AV ;
    
LEXICON AV ! Her splittar vi
 Adjectives ;
 Verbs ;
    
LEXICON Adjectives
 bon     	ADER ;
 long    	ADER ;
 alt     	ADER ;
 grav    	ADER ;
 jung    	ADER ;
 ideal   	ADER  "ideal"				  ; ! tja
 luks    	ADER  "luxurious"			  ;
 blank   	ADER  "white"				  ;
 nigr    	ADER  "black"				  ;
 liber   	ADER  "free"				  ;
 evident 	ADER  "obvious"			  ;
 grandioz	ADER  "sublime/magnificent" ;
 oportun 	ADER  "convenient"		  ;
 verd		ADER ;
 plat		ADER ;
 san 		ADER ;

LEXICON ADER
 +Adj+Dim:et ASUF ;
 +Adj+Aug:eg ASUF ;
 +Adj:       ASUF ;
 +Adj+Nize:ec     OSUF ;   
   
LEXICON ASUF
 +Asuff:a PL ;

!Så litt felles morfologi til slutt
LEXICON PL
 +Pl:j  CASE ; 
 +Sg:   CASE ;
 
LEXICON CASE
 +Acc:n # ; 
 +Nom:  # ;
   
   
! Verb
! ====
   
LEXICON Verbs
 kant V "sing" ; ! 
 dir  V "say" ; ! 
 vid  V "see" ; ! 
 don	 V "give" ; !
 est  V "be" ; !
 pens V "think" ; !
 dir  V "say" ; !
 fal  V "fall" ; !
 ir V ;
 ven V ;
 vetur V ;
 parol V ;
 far V ;
 raz V ;
 kant V ;


LEXICON V
 +Caus:ig ADsplit ;
 +Mid:iĝ  ADsplit ;
          ADsplit ;
          
          
LEXICON ADsplit
 +Verb:  AD   ; ! empty entry--go to AD
 +Verb:  Vend ; ! empty entry--go to Vend

LEXICON AD
 +Cont:ad Vend ; ! aspect (an optional morpheme)
 
LEXICON Vend
 +Inf:i  # ; ! infinitive
 +Pres:as # ; ! present
 +Past:is # ; ! past
 +Fut:os # ; ! future
 +Cond:us # ; ! conditional
 +Subj:u  # ; ! subjunctive
 
!------------------------------------------------------slutt


 

Bambona med lexc

Oppgåve til neste gong: Bambona med lexc.



4.4 lexc-grensesnittet
======================

Vi tar ikkje opp dette, når vi i staden brukar kommandoen
read lexc < fil.lexc
i xfst.


4.5 Nyttige lexc-strategiar
===========================

Prinsipp for leksikonskriving:

Eit leksikon må vere koherent
 Det er betre å oppretthalde distinksjonar på eit lågt nivå i lexc 
 enn å slå dei saman.
Poenget er at det skal vere eit koherent sett å peike TIL, 
det treng ikkje vere eit koherent sett å peike FRÅ.
 




4.6 Integrering og testing
==========================

4.7 Oppsummering
================