Copyright | See LICENSE file |
---|---|
License | BSD3 |
Maintainer | Brad Neimann |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Brassica.SoundChange
Description
The modules below provide Brassica’s support for sound changes. For further details on their syntax and processing, refer to the reference guide, and the documentation of individual modules.
In brief, a sound changes file passes through the following phases:
- First it is parsed to a
SoundChanges
CategorySpec
Directive
- Next it undergoes expansion to give a
SoundChanges
Expanded
GraphemeList
- Finally it can be applied to a
PWord
usingapplyChanges
or similar.
Words may also be extracted from a words file for application using
tokeniseWords
, and the file can be recreated using
detokeniseWords
or similar. (For an MDF file one can similarly
use tokeniseMDF
.)
For a simple example, the following sample applies a sound change file to a words file (without error-handling):
import Data.Maybe (mapMaybe) import System.Environment (getArgs) import Brassica.SoundChange main :: IO () main = do [changesFile, wordsFile] <- getArgs changes <- readFile changesFile words <- readFile wordsFile let Right changesParsed =parseSoundChanges
changes Right changesExpanded =expandSoundChanges
changesParsed Right wordsTokenised =withFirstCategoriesDecl
tokeniseWords
changesExpanded words wordsOutput = fmap (mapMaybegetOutput
.applyChanges
changesExpanded) $ wordsTokenised putStrLn $detokeniseWords
$ concatMap (splitMultipleResults
"/") wordsOutput
If writing sound changes in Haskell, it is suggested to skip
parsing and expansion and directly create a value of type
. Expansion is
of little use when SoundChanges
Expanded
(Bool
, [Grapheme
])Category
s and Autosegment
s can be assigned
names in the code itself.
Documentation
module Brassica.SoundChange.Types
module Brassica.SoundChange.Parse
module Brassica.SoundChange.Expand
module Brassica.SoundChange.Apply