| 1 | #!/bin/sh |
| 2 | export LC_ALL=C |
| 3 | # convert morphological codes |
| 4 | sed -e 's/\t[[]\([^]]*LATIVE[^]]*\)\]+/\tip:\1\t/ |
| 5 | s/\t\([^[]\+\)[[]\([^]]*\(PREF\|LATIVE\)[^]]*\)\]+/\tip:\2\tpr:\1\t/ |
| 6 | s/\t\([^[\:]\+\)[[]/\tst:\1\t[/g |
| 7 | s/{+[[]\([^}]*\)\]}$/\tts:\1/ |
| 8 | s/\t\[\([^][]*\)\]/\tpo:\1\t/g |
| 9 | s/{[^{]*}//g |
| 10 | s/+[[]\([^[]\+\)\]/\tis:\1\t/g |
| 11 | s/\t\(ts:[^]]*\)\]+[[]/\t\1\tts:/ |
| 12 | s/\t\+/\t/g;s/\t*$//' | |
| 13 | sed 's/\t[^\t:]\+\t/\t/g;s/\t[^\t:]\+$//g |
| 14 | s/is:\([^_\t]*_\)\(ABLE\|ABSTRACT\|ACTION\|ATTRIBUTE\|DIMINUTIVE\|FACTITIVE\|FORMAL\|FREE\|FREQ\|FUTPART\|LESS\|LOCATIVE\|MEDIAL\|MODE\|MRS\|MULTIPLICATION\|MULTORD\|OCCUPATION\|ORDINAL\|PASSIVE\|PASTPART\|PRESPART\|PROCESS\/RESULT\|SORT\|SUPPLY\|TRANSITIVE\|UNABLE\)_/ds:\1\2_/g' | |
| 15 | sed 's/is:\(.*ds:\)/ds:\1/g;s/\tst:\t/\t/' >tmp/x.dic |
| 16 | |
| 17 | # create allomorph table |
| 18 | cat tmp/x.dic | grep -v '/[^ ]*w' | |
| 19 | sed -n '/\tst:/s/\t.[^tr]:[^\t]*//gp' | |
| 20 | sed 's/\tpr:\([^\t]*\)\tst:/\t\1/' | |
| 21 | sed 's/\/.*\t/\t/;s/\tst:/\t/' | |
| 22 | awk '{a[$2]=a[$2] "\tal:" $1} |
| 23 | END{for(i in a)print i"\t"a[i]}' >tmp/allomorf.txt |
| 24 | |
| 25 | # expand the dictionary with allomorph and pronounciation data |
| 26 | cat tmp/x.dic | LC_ALL=hu_HU.UTF-8 awk 'BEGIN{FS="[\t/ ]"} |
| 27 | FILENAME!="-"{a[$1]=a[$1] substr($0,index($0,"\t"));next} |
| 28 | # ph: field with simplified double consonants get extra |
| 29 | # ph: field, for example: "bitlisz" -> "Beatles" extended |
| 30 | # with ph:bitlis (without "z") for "bitlisszel" -> "Beatlesszel" |
| 31 | # exception: "->" in ph, eg. ph:klafá->klassza |
| 32 | a[$1] && a[$1]~/ph:[^ \t]*[szyae]\>/ && a[$1]!~/[-]>/ { |
| 33 | a[$1]=gensub(/(ph:[^ \t]*[ae]) /, "\\1* ", "g", a[$1]) |
| 34 | a[$1]=gensub(/(ph:[^ \t]*[ae])$/, "\\1*", "g", a[$1]) |
| 35 | a[$1]=gensub(/((ph:[^ \t]*s)z)\>/, "\\1\t\\2", "g", a[$1]) |
| 36 | a[$1]=gensub(/((ph:[^ \t]*[cz])s)\>/, "\\1\t\\2", "g", a[$1]) |
| 37 | a[$1]=gensub(/((ph:[^ \t]*[gnt])y)\>/, "\\1\t\\2", "g", a[$1]) |
| 38 | } |
| 39 | # concatenate with allomorphes |
| 40 | a[$1]{print $0 a[$1];next}{print$0}' tmp/allomorf.txt $1 - |
| 41 | |
| 42 | rm tmp/x.dic |