Copyright | (c) OleksandrZhabenko 2021 |
---|---|
License | MIT |
Maintainer | olexandr543@yahoo.com |
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
Extensions |
|
This is a computational scheme for generalized usage of the phonetic languages approach. It is intended to be exported qualified, so that the functions in every language implementation have the same names and signatures as these ones and the data type used here. It is may be not the most efficient implementation.
Synopsis
- class PhoneticElement a where
- readPEMaybe :: String -> Maybe a
- data PhoneticsRepresentationPL
- = PR {
- string :: String
- afterString :: String
- beforeString :: String
- | PRAfter {
- string :: String
- afterString :: String
- | PRBefore {
- string :: String
- beforeString :: String
- | PREmpty { }
- = PR {
- data PhoneticsRepresentationPLX
- type Generations = Int8
- type InterGenerationsString = String
- type WritingSystemPRPLX = [PhoneticsRepresentationPLX]
- type GWritingSystemPRPLX = [([PhoneticsRepresentationPLX], Generations)]
- type PhoneticRepresentationXInter = Either PhoneticsRepresentationPLX InterGenerationsString
- type IGWritingSystemPRPLX = [(PhoneticRepresentationXInter, Generations)]
- fromX2PRPL :: PhoneticsRepresentationPLX -> PhoneticsRepresentationPL
- fromPhoneticRX :: [PhoneticsRepresentationPLX] -> [PhoneticRepresentationXInter] -> [PhoneticsRepresentationPLX]
- isPRC :: PhoneticsRepresentationPLX -> Bool
- isPRAfterC :: PhoneticsRepresentationPLX -> Bool
- isPRBeforeC :: PhoneticsRepresentationPLX -> Bool
- isPREmptyC :: PhoneticsRepresentationPLX -> Bool
- stringToXSG :: GWritingSystemPRPLX -> Generations -> String -> IGWritingSystemPRPLX
- stringToXG :: GWritingSystemPRPLX -> String -> [PhoneticsRepresentationPLX]
- stringToXS :: WritingSystemPRPLX -> String -> [String]
- string2X :: WritingSystemPRPLX -> String -> [PhoneticsRepresentationPLX]
- rulesX :: PhoneticsRepresentationPLX -> Char
- fHelp4 :: (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> [a] -> ([a], [a], [a], [a])
- findSA :: PhoneticsRepresentationPL -> Array Int PhoneticsRepresentationPLX -> Maybe PhoneticsRepresentationPLX
- findSAI :: PhoneticRepresentationXInter -> (String, String) -> Array Int PhoneticsRepresentationPLX -> Maybe PhoneticsRepresentationPLX
- (~=) :: PhoneticsRepresentationPL -> PhoneticsRepresentationPLX -> Bool
- compareG :: PhoneticsRepresentationPL -> PhoneticsRepresentationPLX -> Ordering
Phonetics representation data type for the phonetic languages approach.
class PhoneticElement a where Source #
readPEMaybe :: String -> Maybe a Source #
Instances
data PhoneticsRepresentationPL Source #
The syllable after this is encoded with the representation with every Char
being some phonetic language phenomenon.
To see its usual written representation, use the defined showRepr
function (please, implement your own one).
PR | |
| |
PRAfter | |
| |
PRBefore | |
| |
PREmpty | |
Instances
data PhoneticsRepresentationPLX Source #
Extended variant of the PhoneticsRepresentationPL
data type where the information for the Char
is encoded into the
data itself. Is easier to implement the rules in the separate file by just specifying the proper and complete list of
PhoneticsRepresentationPLX
values. While the char
function can be used to group PhoneticRepresentationPLX
that represents some phenomenae, for the phonetic languages approach the string1
is used in the most cases.
PRC | |
| |
PRAfterC | |
PRBeforeC | |
PREmptyC | |
Instances
type Generations = Int8 Source #
Each generation represents a subset of rules for representation transformation. The PhoneticsRepresentationPLX
are groupped by the generations so that in every group with the same generation number (Int8
value, typically starting
from 1) the rules represented have no conflicts with each other (this guarantees that they can be applied simultaneously
without the danger of incorrect interference). Usage of Generations
is a design decision and is inspired by the
GHC RULES pragma and the GHC compilation multistage process.
type InterGenerationsString = String Source #
Each value represents temporary intermediate resulting String
data to be transformed further into the representation.
type WritingSystemPRPLX = [PhoneticsRepresentationPLX] Source #
If the list here is proper and complete, then it usually represents the whole writing system of the language. For proper usage, the list must be sorted in the ascending order.
type GWritingSystemPRPLX = [([PhoneticsRepresentationPLX], Generations)] Source #
The 'dynamic' representation of the general writing system that specifies what transformations are made simultaneously
during the conversion to the phonetic languages phonetics representation. During transformations those elements that have
greater Generations
are used earlier than others. The last ones are used those elements with the Generations
element
equal to 0 that must correspond to the PREmptyC
constructor-built records. For proper usage, the lists on the first
place of the tuples must be sorted in the ascending order.
type PhoneticRepresentationXInter = Either PhoneticsRepresentationPLX InterGenerationsString Source #
The intermediate representation of the phonetic languages data. Is used during conversions.
type IGWritingSystemPRPLX = [(PhoneticRepresentationXInter, Generations)] Source #
The 'dynamic' representation of the process of transformation for the general writing system during the conversion. Is not intended to be produced by hand, but automatically by programs.
fromPhoneticRX :: [PhoneticsRepresentationPLX] -> [PhoneticRepresentationXInter] -> [PhoneticsRepresentationPLX] Source #
Functions to work with the one.
Predicates
Convert to the PhoneticsRepresentationPLX
.
stringToXG :: GWritingSystemPRPLX -> String -> [PhoneticsRepresentationPLX] Source #
The full conversion function. Applies conversion into representation using the GWritingSystemPRPLX
provided.
stringToXS :: WritingSystemPRPLX -> String -> [String] Source #
string2X :: WritingSystemPRPLX -> String -> [PhoneticsRepresentationPLX] Source #
Uses the simplest variant of the GWritingSystemPRPLX
with just two generations where all the PREmptyC
elements in the
WritingSystemPRPLX
are used in the last order. Can be suitable for simple languages (e. g. Esperanto).
Apply conversion from PhoneticsRepresentationPLX
.
rulesX :: PhoneticsRepresentationPLX -> Char Source #
An analogue of the rulesPR
function for PhoneticsRepresentationPLX
.
Auxiliary functions
fHelp4 :: (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> [a] -> ([a], [a], [a], [a]) Source #
Splits the given list using 4 predicates into tuple of 4 lists of elements satisfying the predicates in the order being preserved.
findSA :: PhoneticsRepresentationPL -> Array Int PhoneticsRepresentationPLX -> Maybe PhoneticsRepresentationPLX Source #
findSAI :: PhoneticRepresentationXInter -> (String, String) -> Array Int PhoneticsRepresentationPLX -> Maybe PhoneticsRepresentationPLX Source #
Finds and element in the Array
that the corresponding PhoneticsRepresentationPLX
from the first argument is ~=
to the
it. The String
arguments inside the tuple pair are the beforeString
and the afterString
elements of it to be used in Right
case.
Some class extensions for Eq
and Ord
type classes
(~=) :: PhoneticsRepresentationPL -> PhoneticsRepresentationPLX -> Bool Source #
Partial equivalence that is used to find the appropriate PhoneticsRepresentationPL
for the class of
PhoneticsRepresentationPLX
values.
compareG :: PhoneticsRepresentationPL -> PhoneticsRepresentationPLX -> Ordering Source #
Partial equivalence that is used to find the appropriate PhoneticsRepresentationPL
for the class of
PhoneticsRepresentationPLX
values.