From e8032858f41d68f7ec05cadd0bd7a4eb49de05a6 Mon Sep 17 00:00:00 2001 From: aarne Date: Thu, 25 Jan 2007 17:49:39 +0000 Subject: [PATCH] produce a readable word list --- resource-1.0/thai/FileThai.hs | 17 +++++++++++++++++ resource-1.0/thai/Makefile | 3 +++ 2 files changed, 20 insertions(+) diff --git a/resource-1.0/thai/FileThai.hs b/resource-1.0/thai/FileThai.hs index 58936180c..13c94325f 100644 --- a/resource-1.0/thai/FileThai.hs +++ b/resource-1.0/thai/FileThai.hs @@ -14,6 +14,7 @@ module Main (main) where import GF.Text.Thai +import GF.Text.UTF8 import Data.List import System @@ -22,5 +23,21 @@ main = do xx <- getArgs case xx of "-p":f:[] -> thaiPronFile f Nothing + "-w":f:[] -> thaiWordList f f :[] -> thaiFile f Nothing _ -> putStrLn "usage: filethai (-p) File" + + +-- adapted to the format of StringsThai + +thaiWordList :: FilePath -> IO () +thaiWordList f = do + ss <- readFile f >>= return . lines + mapM_ mkLine ss + where + mkLine s = case words s of + o : "=" : s : ";" : "--" : es -> + putStrLn $ thai s ++ "\t" ++ pron s ++ "\t" ++ unwords es + _ -> return () + thai = encodeUTF8 . mkThaiWord . init . tail + pron = mkThaiPron . init . tail diff --git a/resource-1.0/thai/Makefile b/resource-1.0/thai/Makefile index 654dcdaff..54bd73510 100644 --- a/resource-1.0/thai/Makefile +++ b/resource-1.0/thai/Makefile @@ -2,3 +2,6 @@ strings: runghc -i../../../src FileThai.hs StringsThai.gf >StringsTha.gf pronstrings: runghc -i../../../src FileThai.hs -p StringsThai.gf >pronunciation/StringsTha.gf +wordlist: + runghc -i../../../src FileThai.hs -w StringsThai.gf +