Documentation
¶
Index ¶
- Constants
- Variables
- func AllToLower(word []rune)
- func AllUpper(word string) bool
- func AnotherWordFollows(rs []rune, i, length, mode int) bool
- func CheckTonic(input []rune, startPos int, endPos int) (output []rune)
- func ConditionInput(input string) (output []rune)
- func ConvertDash(rs []rune, idx *int, len int) bool
- func ConvertSecondaryStress(rs []rune) bool
- func ConvertSilence(buf []rune, input []rune) (silence float64, output []rune)
- func DeleteEllipsis(rs []rune, idx *int, len int)
- func ExpandAbbreviation(input []rune, i, length int) (success bool, output []rune)
- func ExpandLetterMode(input []rune, cp *int, len int, status *int) (output []rune)
- func ExpandRawMode(buf []rune, j *int, length int, input []rune) (success bool, output []rune)
- func ExpandTagNumber(input []rune, j *int, length int) (success bool, output []rune)
- func GetState(buf []rune, i *int, mode, nextMode, curState, nextState, rawModeFlag *int, ...) (word []rune, output []rune, success bool)
- func HasPrimaryStress(rs []rune) bool
- func IllegalSlashCode(code string) bool
- func IllegalToken(token []rune) bool
- func InsertChunkMarker(input []rune, insertPos int, tgType []rune) (output []rune)
- func InsertRunes(input []rune, insert []rune, pos int) (output []rune)
- func InsertTag(input []rune, insertPt int, word []rune) (output []rune)
- func IsAcronym(word string) string
- func IsIsolated(rs []rune, i, len int) bool
- func IsMode(b byte) bool
- func IsPunctuation(r rune) bool
- func IsTelephoneNumber(rs []rune, i, len int) bool
- func MarkModes(input []rune) (success bool, output []rune)
- func NumberFollows(rs []rune, idx int, len int) bool
- func PartOfNumber(rs []rune, idx int, len int) bool
- func SetToneGroup(input []rune, tgPos int, word string) (success bool, output []rune)
- func ShiftSilence(buf []rune, i, length, mode int, input []rune) (shift bool, output []rune)
- func StripPunctuation(buf []rune) (output []rune)
- func WordFollows(rs []rune, i, length int) bool
- type NumParseMode
- type NumParser
- type TextParser
Constants ¶
const ( Normal = iota OverrideYears ForceSpell NumParseModeN )
const Abbreviation = 0
const And = "and"
const AreaCode = 4
const At = "at"
const Begin = 0
const ChunkBoundary = "/c"
const ClockMax = 2 // MAX # OF COLONS IN CLOCK TIMES
Todo: should this be an enum? (is in c++)
const CommasMax = 33 // MAX # OF COMMAS
const DefaultEndPunc = "."
const DefaultEscapeCharacter = 27
const Degenerate = 1
const Deleted = -11
const ElevenDigitCode = 3
const EmphasisMode = 2
const EmphasisModeBegin = -5
const EmphasisModeEnd = -6
const End = 1
const Equals = "equals"
const Expansion = 1
const FootBegin = "/_"
const FractionalDigitsMax = 100 // MAX # OF FRACTIONAL DIGITS
const HalfFlag = 2
const IntegerDigitsMax = 100 // MAX # OF INTEGER DIGITS
const IsGreaterThan = "is greater than"
const IsLessThan = "is less than"
const LastWord = "/l"
const LetterMode = 1
const LetterModeBegin = -3
const LetterModeEnd = -4
const LongMedialPause = "^ ^ ^"
const MaxFeetPerChunk = 100
const MaxPhonesPerChunk = 1500
const MedialPause = "^"
const Minus = "minus"
const ModeNestMax = 100
const NegativeMax = 3 // MAX # OF NEGATIVE SIGNS (-)
const No = 0 // GENERAL PURPOSE FLAGS
const NoNumerals = 0 // FLAGS RETURNED BY error_check()
const NonPhoneme = 0
const NonZero = 1
const NormalMode = -1
const Ok = 3
const OutputMax = 8192 // OUTPUT BUFFER SIZE IN CHARS
const Phoneme = 1
const Plus = "plus"
const Pronounciation = 1
const Punctuation = 1
const QuarterFlag = 3
const RawMode = 0
const RawModeBegin = -1
const RawModeEnd = -2
const SecondaryStress = "/\""
const SecondthFlag = 1 // FLAGS FOR special_flag
const SevenDigitCode = 1 // TELEPHONE FLAGS
const SilenceMax = 5.0
const SilenceMode = 4
const SilenceModeBegin = -9
const SilenceModeEnd = -10
const SilencePhone = "^"
const SilencePhoneLength = 0.1 // silence phone is 100ms
const StateBegin = 0
const StateEnd = 4
const StateFinalPunc = 3
const StateMedialPunc = 2
const StateSilence = 5
const StateTagging = 6
const StateUndefined = -1
const StateWord = 1
const SymbolLengthMax = 12
const TagBegin = "/t"
const TaggingMode = 3
const TaggingModeBegin = -7
const TaggingModeEnd = -8
const TenDigitCode = 2
const TgContinuation = "/3"
const TgExclamation = "/1"
const TgHalfPeriod = "/4"
const TgQuestion = "/2"
const TgStatement = "/0"
const TgUndefined = "/x"
const ToneGroupBoundary = "//"
const TonicBegin = "/*"
const TtsDictionary1 = 2
const TtsDictionary2 = 3
const TtsDictionary3 = 4
const TtsEmpty = 0
Dictionary Ordering Definitions
const TtsFalse = 0
const TtsLetterToSound = 5
const TtsNo = 0
const TtsNumberParser = 1
const TtsParserFailure = false
const TtsParserSuccess = true
const TtsTrue = 1
const TtsYes = 1
const UndefinedMode = -2
const UndefinedPosition = -1
const UtteranceBoundary = "#"
const Word = 0
const WordBegin = "/w"
const WordLengthMax = 1024
const Yes = 1
Variables ¶
var Acronyms [][]string
var Escape = rune(DefaultEscapeCharacter)
var Kit_SymbolType = kit.Enums.AddEnum(NumParseModeN, kit.NotBitFlag, nil)
var Triads = [][]string{
{"NULL_STRING", "THOUSAND", "MILLION", "BILLION", "TRILLION", "QUADRILLION", "QUINTILLION",
"SEXTILLION", "SEPTILLION", "OCTILLION", "NONILLION", "DECILLION", "UNDECILLION",
"DUODECILLION", "TREDECILLION", "QUATTUORDECILLION", "QUINDECILLION", "SEXDECILLION",
"SEPTENDECILLION", "OCTODECILLION", "NOVEMDECILLION", "VIGINTILLION"},
{"NULL_STRING", "THOUSANDTH", "MILLIONTH", "BILLIONTH", "TRILLIONTH", "QUADRILLIONTH",
"QUINTILLIONTH", "SEXTILLIONTH", "SEPTILLIONTH", "OCTILLIONTH", "NONILLIONTH",
"DECILLIONTH", "UNDECILLIONTH", "DUODECILLIONTH", "TREDECILLIONTH",
"QUATTUORDECILLIONTH", "QUINDECILLIONTH", "SEXDECILLIONTH", "SEPTENDECILLIONTH",
"OCTODECILLIONTH", "NOVEMDECILLIONTH", "VIGINTILLIONTH"},
{"NULL_STRING", "THOUSANDTHS", "MILLIONTHS", "BILLIONTHS", "TRILLIONTHS",
"QUADRILLIONTHS", "QUINTILLIONTHS", "SEXTILLIONTHS", "SEPTILLIONTHS", "OCTILLIONTHS",
"NONILLIONTHS", "DECILLIONTHS", "UNDECILLIONTHS", "DUODECILLIONTHS",
"TREDECILLIONTHS", "QUATTUORDECILLIONTHS", "QUINDECILLIONTHS", "SEXDECILLIONTHS",
"SEPTENDECILLIONTHS", "OCTODECILLIONTHS", "NOVEMDECILLIONTHS", "VIGINTILLIONTHS"}}
VARIABLES PERTAINING TO TRIADS AND TRIAD NAMES
Functions ¶
func AnotherWordFollows ¶
AnotherWordFollows returns 1 if another word follows in buffer, after position i. Else, 0 is returned
func CheckTonic ¶
CheckTonic Checks to see if a tonic marker is present in the stream between the start and end positions. If no tonic is present, then put one in at the last foot marker if it exists.
func ConditionInput ¶
ConditionInput converts all non-printable characters (except escape) character to blanks. Also connects words hyphenated over a newline.
func ConvertDash ¶
ConvertDash converts "--" to ", ", and "---" to ", ". Returns 1 if this is done, 0 otherwise.
func ConvertSecondaryStress ¶
ConvertSecondaryStress returns 1 if the pronunciation contains " (and ` for backwards compatibility)
func ConvertSilence ¶
ConvertSilence converts numeric quantity in "buffer" to appropriate number of silence phones, which are written onto the end of stream. Rounding is performed. Returns actual length of silence.
func DeleteEllipsis ¶
DeleteEllipsis deletes three dots in a row (disregarding whitespace). If four dots, then the last three are deleted.
func ExpandAbbreviation ¶
ExpandAbbreviation expands listed abbreviations. Two lists are used (see abbreviations.h): one list expands unconditionally, the other only if the abbreviation is followed by a number. The abbreviation p. is expanded to page. Single alphabetic characters have periods deleted, but no expansion is made. They are also capitalized. Returns 1 if expansion made (i.e. period is deleted),
func ExpandLetterMode ¶
ExpandLetterMode expands contents of letter mode string to word or words. A comma is added after each expansion, except the last letter when it is followed by punctuation. cp is current position
func ExpandRawMode ¶
Todo: What's up with passing token without ExpandRawMode writes raw mode contents to stream, checking phones and marker
func ExpandTagNumber ¶
ExpandTagNumber expand tag number in buffer at position j and write to stream. Perform error checking, returning error code if format of tag number is illegal.
func GetState ¶
func GetState(buf []rune, i *int, mode, nextMode, curState, nextState, rawModeFlag *int, input []rune) (word []rune, output []rune, success bool)
GetState determines the current state and next state in buffer. A word or punctuation is put into word. Raw mode contents are expanded and written to stream.
func HasPrimaryStress ¶
HasPrimaryStress returns 1 if the pronunciation contains ' (and ` for backwards compatibility)
func IllegalSlashCode ¶
IllegalSlashCode returns true if code is illegal
func IllegalToken ¶
IllegalToken returns 1 if token is not a valid DEGAS phone, otherwise 0.
func InsertChunkMarker ¶
/****************************************************************************** * * function: insert_chunk_marker * * purpose: Insert chunk markers and associated markers in the stream at the insert point. Use the tone group type passed in as an argument. * ******************************************************************************/
InsertChunkMarker inserts chunk markers and associated markers in the stream at the insert point. Use the tone group type passed in as an argument.
func IsAcronym ¶
IsAcronym returns a pointer to the pronunciation of a special acronym if it is defined in the list
func IsIsolated ¶
IsIsolated returns true if character at position i is isolated, i.e. is surrounded by space or mode marker.
func IsTelephoneNumber ¶
IsTelephoneNumber returns true if string at position i in buffer is of the form: (ddd)ddd-dddd where each d is a digit.
func MarkModes ¶
MarkModes parses input for modes, checking for errors, and marks output with mode start and end points. Tagging and silence mode arguments are checked.
func NumberFollows ¶
NumberFollows returns true if at least one digit follows the character at position i, to white space or mode marker.
func PartOfNumber ¶
PartOfNumber returns true if character at position i is part of a number (including mixtures with non-numeric characters)
func SetToneGroup ¶
SetToneGroup sets the tone group marker according to the punctuation passed in as "word". The marker is inserted in the
func ShiftSilence ¶
ShiftSilence looks past punctuation to see if some silence occurs before the next word (or raw mode contents), and shifts the silence to the current point on the stream. The the numeric quantity is converted to equivalent silence phones, and true is returned.
func StripPunctuation ¶
StripPunctuation deletes unnecessary punctuation, and converts some punctuation to another form.
func WordFollows ¶
WordFollows returns a true if a word or speakable symbol (letter mode) follows the position i in buffer. Raw, tagging, and silence mode contents are ignored. Returns false if any punctuation (except . as part of number) follows.
Types ¶
type NumParseMode ¶
type NumParseMode int
type NumParser ¶
type NumParser struct {
// contains filtered or unexported fields
}
func (*NumParser) DegenerateString ¶
DegenerateString returns a string which contains a character-by-character pronunciation
func (*NumParser) ErrorCheck ¶
func (np *NumParser) ErrorCheck(mode NumParseMode) int
***************************************************************************** * * function: error_check * * purpose: Checks the initiallly parsed word for format errors. * Returns NoNumerals if the word contains no digits, * Degenerate if the word contains errors, OK otherwise. * ***************************************************************************** ErrorCheck checks the initiallly parsed word for format errors. Returns "NoNumerals" if the word contains no digits. Returns "Degenerate" if the word contains errors, returns "OK" otherwise.
func (*NumParser) InitialParse ¶
func (np *NumParser) InitialParse()
InitialParse Finds positions of numbers, commas, and other symbols within the word.
func (*NumParser) NumberParser ¶
func (np *NumParser) NumberParser()
func (*NumParser) ParseNum ¶
func (np *NumParser) ParseNum(word string, mode NumParseMode) string
{
// SPECIAL PROCESSING OF WORD; EACH RETURNS IMMEDIATELY
// PROCESS CLOCK TIMES
if (clock_) {
// HOUR
if (leftZeroPad_) {
strcat(&output_[0], OH);
}
process_triad(&hour_[0], &output_[0], NO, NO, NO, NO, NO);
// MINUTE
if ((minute_[1] == '0') && (minute_[2] == '0')) {
if (military_) {
strcat(&output_[0], HUNDRED);
} else if (!seconds_) {
strcat(&output_[0], OCLOCK);
}
} else {
if ((minute_[1] == '0') && (minute_[2] != '0')) {
strcat(&output_[0], OH);
}
process_triad(&minute_[0], &output_[0], NO, NO, NO, NO, NO);
}
// SECOND
if (seconds_) {
strcat(&output_[0], AND);
if ((second_[1] == '0') && (second_[2] == '0')) {
strcat(&output_[0], ZERO);
} else {
process_triad(&second_[0], &output_[0], NO, NO, NO, NO, NO);
}
if ((second_[1] == '0') && (second_[2] == '1')) {
strcat(&output_[0], SECOND);
} else {
strcat(&output_[0], SECONDS);
}
}
return &output_[0];
}
// PROCESS TELEPHONE NUMBERS
if (telephone_ == SEVEN_DIGIT_CODE) {
for (int i = 0; i < 3; i++) {
process_digit(*(word_ + integerDigitsPos_[i]), &output_[0], NO, NO, NO);
}
strcat(&output_[0], PAUSE);
for (int i = 3; i < 7; i++) {
process_digit(*(word_ + integerDigitsPos_[i]), &output_[0], NO, NO, NO);
}
return &output_[0];
} else if (telephone_ == TenDigitCode) {
for (int i = 0; i < 3; i++) {
process_digit(*(word_ + integerDigitsPos_[i]), &output_[0], NO, NO, NO);
}
strcat(&output_[0], PAUSE);
for (int i = 3; i < 6; i++) {
process_digit(*(word_ + integerDigitsPos_[i]), &output_[0], NO, NO, NO);
}
strcat(&output_[0], PAUSE);
for (int i = 6; i < 10; i++) {
process_digit(*(word_ + integerDigitsPos_[i]), &output_[0], NO, NO, NO);
}
return &output_[0];
} else if (telephone_ == ElevenDigitCode) {
process_digit(word_[integerDigitsPos_[0]], &output_[0], NO, NO, NO);
if ((word_[integerDigitsPos_[1]] != '0') &&
(word_[integerDigitsPos_[2]] == '0') &&
(word_[integerDigitsPos_[3]] == '0')) {
process_digit(word_[integerDigitsPos_[1]], &output_[0], NO, NO, NO);
strcat(&output_[0], HUNDRED);
} else {
strcat(&output_[0], PAUSE);
for (int i = 1; i < 4; i++) {
process_digit(*(word_ + integerDigitsPos_[i]), &output_[0], NO, NO, NO);
}
}
strcat(&output_[0], PAUSE);
for (int i = 4; i < 7; i++) {
process_digit(*(word_ + integerDigitsPos_[i]), &output_[0], NO, NO, NO);
}
strcat(&output_[0], PAUSE);
for (int i = 7; i < 11; i++) {
process_digit(*(word_ + integerDigitsPos_[i]), &output_[0], NO, NO, NO);
}
return &output_[0];
} else if (telephone_ == AreaCode) {
strcat(&output_[0], AREA);
strcat(&output_[0], CODE);
for (int i = 0; i < 3; i++) {
process_digit(*(word_ + integerDigitsPos_[i]), &output_[0], NO, NO, NO);
}
strcat(&output_[0], PAUSE);
for (int i = 3; i < 6; i++) {
process_digit(*(word_ + integerDigitsPos_[i]), &output_[0], NO, NO, NO);
}
strcat(&output_[0], PAUSE);
for (int i = 6; i < 10; i++) {
process_digit(*(word_ + integerDigitsPos_[i]), &output_[0], NO, NO, NO);
}
return &output_[0];
}
// PROCESS ZERO DOLLARS AND ZERO CENTS
if (dollar_ && (!dollarNonzero_) && (!centsNonzero_)) {
strcat(&output_[0], ZERO);
strcat(&output_[0], DOLLARS);
return &output_[0];
}
// PROCESS FOR YEAR IF INTEGER IN RANGE 1000 TO 1999
if ((integerDigits_ == 4) && (wordLength_ == 4) &&
(word_[integerDigitsPos_[0]] == '1') && (mode != OVERRIDE_YEARS)) {
triad_[0] = '0';
triad_[1] = word_[integerDigitsPos_[0]];
triad_[2] = word_[integerDigitsPos_[1]];
process_triad(&triad_[0], &output_[0], NO, NO, NO, NO, NO);
if ((word_[integerDigitsPos_[2]] == '0') && (word_[integerDigitsPos_[3]] == '0')) {
strcat(&output_[0], HUNDRED);
} else if (word_[integerDigitsPos_[2]] == '0') {
strcat(&output_[0], OH);
process_digit(word_[integerDigitsPos_[3]], &output_[0], NO, NO, NO);
} else {
triad_[0] = '0';
triad_[1] = word_[integerDigitsPos_[2]];
triad_[2] = word_[integerDigitsPos_[3]];
process_triad(&triad_[0], &output_[0], NO, NO, NO, NO, NO);
}
return &output_[0];
}
// ORDINARY SEQUENTIAL PROCESSING
// APPEND POSITIVE OR NEGATIVE IF INDICATED
if (positive_) {
strcat(&output_[0], POSITIVE);
} else if (negative_) {
strcat(&output_[0], NEGATIVE);
}
// PROCESS SINGLE INTEGER DIGIT
if (integerDigits_ == 1) {
if ((word_[integerDigitsPos_[0]] == '0') && dollar_) {
;
} else {
process_digit(word_[integerDigitsPos_[0]], &output_[0], ordinal_, NO, NO);
}
ordinalPlural_ = (word_[integerDigitsPos_[0]] == '1') ? NO : YES;
} else if ((integerDigits_ >= 2) && (integerDigits_ <= (TRIADS_MAX * 3))) {
// PROCESS INTEGERS AS TRIADS, UP TO MAX LENGTH
int digit_index = 0, num_digits, triad_index, index, pause_flag = NO;
for (int i = 0; i < 3; i++) {
triad_[i] = '0';
}
index = (int) ((integerDigits_ - 1) / 3.0);
num_digits = integerDigits_ - (index * 3);
triad_index = 3 - num_digits;
for (int i = index; i >= 0; i--) {
while (num_digits--) {
triad_[triad_index++] = word_[integerDigitsPos_[digit_index++]];
}
if (process_triad(&triad_[0], &output_[0], pause_flag,
(ordinal_ && (ordinalTriad_ == i)),
rightZeroPad_, NO, NO) == NONZERO) {
if (ordinal_ && (ordinalTriad_ == i)) {
strcat(&output_[0], triad_name[1][i]);
} else {
strcat(&output_[0], triad_name[0][i]);
}
pause_flag = YES;
}
if ((i == 1) && (word_[integerDigitsPos_[digit_index]] == '0') &&
((word_[integerDigitsPos_[digit_index + 1]] != '0') ||
(word_[integerDigitsPos_[digit_index + 2]] != '0'))) {
strcat(&output_[0], AND);
pause_flag = NO;
}
triad_index = 0;
num_digits = 3;
}
} else if ((integerDigits_ > (TRIADS_MAX * 3)) && (!commas_) && (!ordinal_)) {
// PROCESS EXTREMELY LARGE NUMBERS AS STREAM OF SINGLE DIGITS
for (int i = 0; i < integerDigits_; i++) {
process_digit(*(word_ + integerDigitsPos_[i]), &output_[0], NO, NO, NO);
}
}
// APPEND DOLLAR OR DOLLARS IF NEEDED
if (dollar_ && dollarNonzero_) {
if (fractionalDigits_ && (fractionalDigits_ != 2)) {
;
} else if (dollarPlural_) {
strcat(&output_[0], DOLLARS);
} else if (!dollarPlural_) {
strcat(&output_[0], DOLLAR);
}
if (centsNonzero_ && (fractionalDigits_ == 2)) {
strcat(&output_[0], AND);
}
}
// APPEND POINT IF FRACTIONAL DIGITS, NO SLASH,
AND IF NOT .00 DOLLAR FORMAT
if (fractionalDigits_ && (!slash_) &&
((!dollar_) || (dollar_ && (fractionalDigits_ != 2)))) {
strcat(&output_[0], POINT);
for (int i = 0; i < fractionalDigits_; i++) {
process_digit(word_[fractionalDigitsPos_[i]], &output_[0], NO, NO, NO);
}
} else if (slash_) {
// PROCESS DENOMINATOR OF FRACTIONS
char ones_digit = '\0', tens_digit = '\0';
if (((integerDigits_ >= 3) && (fractionalDigits_ >= 3)) ||
(word_[integerDigitsPos_[integerDigits_ - 1]] == '0')) {
strcat(&output_[0], PAUSE);
}
ones_digit = word_[fractionalDigitsPos_[fractionalDigits_ - 1]];
if (fractionalDigits_ >= 2) {
tens_digit = word_[fractionalDigitsPos_[fractionalDigits_ - 2]];
}
ordinal_ = YES;
int special_flag = NO;
if ((ones_digit == '0' && tens_digit == '\0') ||
(ones_digit == '1' && tens_digit != '1')) {
strcat(&output_[0], OVER);
ordinal_ = ordinalPlural_ = NO;
} else if (ones_digit == '2') {
if (tens_digit == '\0') {
special_flag = HalfFlag;
} else if (tens_digit != '1') {
special_flag = SecondthFlag;
}
} else if (ones_digit == '4' && tens_digit == '\0') {
special_flag = QuarterFlag;
}
if (fractionalDigits_ == 1) {
process_digit(ones_digit, &output_[0], ordinal_, ordinalPlural_, special_flag);
} else if (fractionalDigits_ >= 2 && (fractionalDigits_ <= (TRIADS_MAX * 3))) {
int digit_index = 0, num_digits, triad_index, index, pause_flag = NO;
for (int i = 0; i < 3; i++) {
triad_[i] = '0';
}
index = (int) ((fractionalDigits_ - 1) / 3.0);
num_digits = fractionalDigits_ - (index * 3);
triad_index = 3 - num_digits;
for (int i = index; i >= 0; i--) {
while (num_digits--) {
triad_[triad_index++] = word_[fractionalDigitsPos_[digit_index++]];
}
if (process_triad(&triad_[0], &output_[0], pause_flag,
(ordinal_ && (fracOrdinalTriad_ == i)),
fracRightZeroPad_,
(ordinalPlural_ && (fracOrdinalTriad_ == i)),
(special_flag && (fracOrdinalTriad_ == i))) == NONZERO) {
if (ordinalPlural_ && (fracOrdinalTriad_ == i)) {
strcat(&output_[0], triad_name[2][i]);
} else if (ordinal_ && (fracOrdinalTriad_ == i)) {
strcat(&output_[0], triad_name[1][i]);
} else {
strcat(&output_[0], triad_name[0][i]);
}
pause_flag = YES;
}
if ((i == 1) &&
(word_[fractionalDigitsPos_[digit_index]] == '0') &&
((word_[fractionalDigitsPos_[digit_index + 1]] != '0') ||
(word_[fractionalDigitsPos_[digit_index + 2]] != '0'))) {
strcat(&output_[0], AND);
pause_flag = NO;
}
triad_index = 0;
num_digits = 3;
}
}
} else if (dollar_ && centsNonzero_ && (fractionalDigits_ == 2)) {
// APPEND CENTS
triad_[0] = '0';
triad_[1] = word_[fractionalDigitsPos_[0]];
triad_[2] = word_[fractionalDigitsPos_[1]];
if (process_triad(&triad_[0], &output_[0], NO, NO, NO, NO, NO) == NONZERO) {
if (centsPlural_) {
strcat(&output_[0], CENTS);
} else {
strcat(&output_[0], CENT);
}
}
}
// APPEND DOLLARS IF NOT $.00 FORMAT
if (dollar_ && fractionalDigits_ && (fractionalDigits_ != 2)) {
strcat(&output_[0], DOLLARS);
}
// APPEND PERCENT IF NECESSARY
if (percent_) {
strcat(&output_[0], PERCENT);
}
// RETURN OUTPUT TO CALLER
return &output_[0];
}
/****************************************************************************** * * function: number_parser * * purpose: Returns a pointer to a NULL terminated character string / which contains the pronunciation for the string pointed / at by the argument word_ptr. * ******************************************************************************/ const char* ParseNum returns the pronounciation
type TextParser ¶
type TextParser struct {
NumParser NumParser
Dictionaries []dictionary.DictionarySearch
// contains filtered or unexported fields
}
func NewTextParser ¶
func NewTextParser(configPath string, fns []string) *TextParser
NewTextParser create a new TextParser. fns (filenames) are to possible dictionaries. Could pass in different escape character in future
func (*TextParser) ExpandWord ¶
func (tp *TextParser) ExpandWord(word string, isTonic bool, input []rune) (output []rune)
TextParser writes pronunciation of word to stream. Deals with possessives if necessary. Also, deals with single characters, and upper case words (including special acronyms) if necessary. Add special marks if word is tonic
func (*TextParser) FinalConversion ¶
func (tp *TextParser) FinalConversion(input []rune) (success bool, output []rune)
FinalConversion converts contents of stream1 to stream2. Adds chunk, tone group, and associated markers expands words to pronunciations, and also expands other modes.
func (*TextParser) LookupWord ¶
func (tp *TextParser) LookupWord(word string) (pron string)
LookupWord returns the pronunciation of word, and sets dict to the dictionary in which it was found. Relies on the global dictionaryOrder. Todo: decide on struct/object members LookupWord
func (*TextParser) Parse ¶
func (tp *TextParser) Parse(rawtext string) string
ParseText takes plain english input, and produces phonetic suitable for further processing in the TTS system. If a parse error occurs, a value of 0 or above is returned. Usually this will point to the position of the error in the input buffer, but in later stages of the parse only a 0 is returned since positional information is lost. If no parser error, then TtsParserSuccess is returned.