#!/bin/bash
#
#
# This program makes 
#     1. `Dictionary with prob' From CORPUS
#
# Part 1.
#
TOPDIR=.
echo 'Getting all the words from CORPUS'
awk -F+ ' { for(i = 1 ; i <= NF ; i++) print $i } ' $1 |sort|$TOPDIR/printhan |\
	awk -F/ ' { print $1 , $2 } ' | uniq -c | \
	awk ' { print $3 , $2 , $1 } ' | sort >trash.dict
awk ' BEGIN { tag = 0 } /pa/ {tag = 1} { if (tag ==0) print $0 > "notyeong" } { if (tag == 1) print $0 > "yeong" } ' trash.dict
echo 'DONE'
#$TOPDIR/freq < $1.tmp4 > $1.tmp5
#echo 'DONE....'
#
#
###echo 'Getting P(tag|word) from Frequencies of Word-Tag Pairs'
###wordambi < $1.tmp5 > $1.tmp6

#echo 'write (Tag , Word , Frequency)'
#awk ' { print $2 , $1 , $3 } ' $1.tmp5 > $1.tmp6
#sort < $1.tmp6 > $1.tmp7
#
#
#echo 'Splitting the Dictionary into Not-YeongEon and YeongEon'
#awk ' BEGIN { tag = 0 } /pa/ {tag = 1} { if (tag ==0) print $0 > "notyeong" } { if (tag == 1) print $0 > "yeong" } ' $1.tmp7
#echo 'DONE....'
#
#
#echo 'Putting the irr-code into YeongEon-Dictionary'
$TOPDIR/put_irr yeong $1.tmp8
#echo 'DONE....'
#/bin/rm $1.tmp7
#
#
#echo 'Merging the Not-YeongEon and YeongEon with irr-code'
cat $1.tmp8 >> notyeong
cat appenddict >> notyeong
echo 'DONE'
#/bin/rm yeong
#
# 
#/bin/mv notyeong $2 
#echo 'Now, The Dictionary with Probability is ' $2
#
#
