public string GetWordPron(string word)
        {
            var a = new SpanishWord(word);

            AnalyzeWordPron(a);
            return(a.Pron);
        }
Пример #2
0
 public void Parse(SpanishWord word)
 {
     number = 0; st = State.E; syl = new Syllable()
     {
         Number = number++
     }; cacheLast = null; this.word = word; word.SyllableList.AddLast(syl);
     for (var comb = word.CharCombList.First; comb != null; comb = comb.Next)
     {
         Read(comb);
     }
     ReadEndOfWord();
 }
Пример #3
0
 public PronounciationNotSet(SpanishWord word) : base(word.Content)
 {
 }
Пример #4
0
 public PronSetTwiceException(SpanishWord word) : base($"The pronunciation of word {word.Content} is set twice")
 {
 }
Пример #5
0
 public void Parse(SpanishWord word)
 {
     machine.Parse(word);
 }
 public void AnalyzeWordPron(SpanishWord word)
 {
     spanishLexer.CutCombs(word);
     spanishParser.Parse(word);
     spanishAnnouncer.Announce(word);
 }
        public virtual List <(int, int)> FindAllCombs(SpanishWord word)
        {
            var letterUsedFlags = 0;
            var w   = "^" + word.Content + '$';
            var ans = new List <(int, int)>();

            foreach (var ruleClout in LexerRules)
            {
                var cache = "";
                var state = ruleClout[cache];
                for (int i = 0; i < w.Length;)
                {
                    char c = w[i];
                    //Console.WriteLine($"state {(cache == "" ? "@Empty" : cache)} Reading {c}");
                    var output = state.FindNext(c);
startEmit:
                    var nextCache = output.State.Replace(ReplaceInputMacro, c);
                    if (output.EmitComb)
                    {
                        var startPos = i - output.Length - output.ProbeMove; // +1 -1 done here
                        var outLen   = output.Length;
                        if (startPos == -1)
                        {
                            startPos += 1;
                            outLen   -= 1;
                        }
                        else if (startPos + outLen == word.Content.Length + 1)
                        {
                            outLen -= 1;
                        }

                        var mask = BitMask.GetMask(startPos, outLen);
                        if ((mask & letterUsedFlags) != 0) // there is a conflict, go to default next
                        {
                            output = state.DefaultNext;
                            goto startEmit;
                        }
                        else
                        {
                            ans.Add((startPos, outLen));
                            letterUsedFlags |= mask;
                        }
                    }
                    cache = nextCache;
                    state = ruleClout[cache];
                    if (output.ProbeMove != 0)
                    {
                        i -= output.ProbeMove;
                    }
                    i++;
                }
            }
            ans.Sort((a, b) => a.Item1 - b.Item1);
#if DEBUG
            foreach (var ccc in ans)
            {
                Console.Write(ccc);
            }
            Console.WriteLine();
#endif
            return(ans);
        }