Ejemplo n.º 1
0
        public IEnumerable <Syntagm> GetSyntagms()
        {
            var tokenList = tokenizer.GetTokens().ToList <Token>();

            for (int i = 0; i < tokenList.Count; i++)
            {
                switch (tokenList[i].Type)
                {
                case TokenType.Meta:
                    yield return(new Syntagm()
                    {
                        Text = tokenList[i].Value, Displayable = false
                    });

                    break;

                case TokenType.Space:
                    yield return(new Syntagm()
                    {
                        Text = tokenList[i].Value, Selectable = false
                    });

                    break;

                case TokenType.Word:
                    Syntagm syntagm = new Syntagm()
                    {
                        Text = tokenList[i].Value
                    };
                    int t;
                    for (t = i + 1; t < tokenList.Count && TagTokens.Contains(tokenList[t].Type); t++)
                    {
                        syntagm.AddTag(tokenList[t].Value);
                    }
                    i = t - 1;
                    yield return(syntagm);

                    break;

                case TokenType.Strong:
                case TokenType.Morpho:
                case TokenType.ReviewTag:
                    throw new Exception($"This tag type must follow a word ({tokenList[i].Type}/\"{tokenList[i].Value}\")");

                default:
                    throw new Exception($"Unhandled token type: {tokenList[i].Type}");
                }
            }
        }
Ejemplo n.º 2
0
 public SyntagmEventArgs(Syntagm s)
 {
     Syntagm = s;
 }