1
0
forked from GitHub/gf-core

more automatic creation of files in CheckDict ; words for translation in DictionaryFre

This commit is contained in:
aarne
2014-04-10 07:06:57 +00:00
parent 37c473a559
commit 4b34c51e4c
2 changed files with 21 additions and 14 deletions

View File

@@ -1,20 +1,27 @@
import qualified Data.Map
import Data.List
createConcrete lang = do
bnc <- readFile "bnc-to-check.txt" >>= return . words -- list of BNC funs
dict <- readFile (gfFile "Dictionary" lang) >>= return . map words . lines -- current lang lexicon
let dictmap = Data.Map.fromList [(f,unwords ws) | "lin":f:"=":ws <- dict]
let bncdict = [(f,maybe "variants{} ;" id $ Data.Map.lookup f dictmap) | f <- bnc] -- current lang for BNC
writeFile (gfFile "todo/TopDict" lang) $ unlines [unwords ("lin":f:"=":[ws]) | (f,ws) <- bncdict] -- print inspectable file
bnc <- readFile "bnc-to-check.txt" >>= return . words -- list of BNC funs
dict <- readFile (gfFile "Dictionary" lang) >>= return . lines -- current lang lexicon
let header = getHeader dict
let dictmap = Data.Map.fromList [(f,unwords ws) | "lin":f:"=":ws <- map words dict]
let bncdict = [(f,maybe "variants{} ;" id $ Data.Map.lookup f dictmap) | f <- bnc] -- current lang for BNC
writeFile (gfFile "todo/tmp/Dictionary" lang) $
unlines $ header ++ [unwords ("lin":f:"=":[ws]) | (f,ws) <- bncdict] ++ ["}"] -- print inspectable file, to todo/tmp/
gfFile body lang = body ++ lang ++ ".gf"
mergeDict lang = do
old <- readFile (gfFile "Dictionary" lang) >>= return . map words . lines -- read old lexicon
new <- readFile "corrects.txt" >>= return . map words . lines -- read corrected and new words
let oldmap = Data.Map.fromList [(f,unwords ws) | "lin":f:"=":ws <- old]
let newlist = [(f,unwords (takeWhile (/= "--") ws)) | "lin":f:"=":ws <- new] -- drop comments from corrected words
let newmap = foldr (uncurry Data.Map.insert) oldmap newlist -- insert corrected words
writeFile "newdict.txt" $ unlines [unwords ("lin":f:"=":[ws]) | (f,ws) <- Data.Map.assocs newmap] -- print lin rules
old <- readFile (gfFile "Dictionary" lang) >>= return . lines -- read old lexicon
new <- readFile (gfFile "todo/Dictionary" lang) >>= return . lines -- read corrected and new words
let header = getHeader new
let oldmap = Data.Map.fromList [(f,unwords ws) | "lin":f:"=":ws <- map words old]
let newlist = [(f,unwords (takeWhile (/= "--") ws)) | "lin":f:"=":ws <- map words new] -- drop comments from corrected words
let newmap = foldr (uncurry Data.Map.insert) oldmap newlist -- insert corrected words
writeFile (gfFile "tmp/Dictionary" lang) $
unlines $ header ++ [unwords ("lin":f:"=":[ws]) | (f,ws) <- Data.Map.assocs newmap] ++ ["}"] -- print revised file to tmp/
-- get the part of Dict before the first lin rule
getHeader = takeWhile ((/= "lin") . take 3)

View File

@@ -18396,8 +18396,8 @@ lin transitive_A = mkA "transitif" ; -- tocheck
lin transitivity_N = mkN "transitivité" feminine ; -- tocheck
lin transitory_A = mkA "passager" ; -- tocheck
lin translatable_A = mkA "traduisible" ; -- tocheck
lin translate_V2 = mkV2 (mkV "translater") | mkV2 (mkV I.traduire_V2) ; -- tocheck
lin translation_N = mkN "translation" feminine | mkN "transmission" feminine | mkN "traduction" feminine ; -- tocheck
lin translate_V2 = mkV2 (mkV I.traduire_V2) ;
lin translation_N = mkN "traduction" feminine ;
lin translator_N = mkN "traducteur" masculine ; -- tocheck
lin transliterate_V2 = mkV2 (mkV "translittérer") ; -- tocheck
lin transliteration_N = mkN "transcription" feminine ; -- tocheck