Ejemplo n.º 1
0
        public PhoneticsWord?GetPhoneticsWord(string text) //todo multiple pronunciations
        {
            var splits = text.Split(
                '_',
                StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries
                );

            if (splits.Length == 1)
            {
                return(GetSinglePhoneticsWord(text));
            }

            var words = new List <PhoneticsWord>();

            foreach (var split in splits)
            {
                var word = GetSinglePhoneticsWord(split);

                if (word is null)
                {
                    return(null);
                }

                words.Add(word);
            }

            var newPhoneticsWord = new PhoneticsWord(
                text,
                0,
                true,
                words.SelectMany(x => x.Syllables).ToList()
                );

            return(newPhoneticsWord);
        }
Ejemplo n.º 2
0
        public IEnumerable <PhoneticsWord> GetPhoneticsWords(string text)
        {
            var splits = text.Split('_', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);

            if (splits.Length == 1)
            {
                return(Lookup[splits.Single()].Select(x => x.Value));
            }

            var words = new List <PhoneticsWord>();

            foreach (var split in splits)
            {
                var word = Lookup[split].Select(x => x.Value).FirstOrDefault(); //todo multiple pronunciations
                if (word == default)
                {
                    return(Enumerable.Empty <PhoneticsWord>());
                }

                words.Add(word);
            }

            var newPhoneticsWord = new PhoneticsWord(text, 0, words.SelectMany(x => x.Symbols).ToList());

            return(new[] { newPhoneticsWord });
        }