Ejemplo n.º 1
0
        private void AddWordsToSentence(Sentence sentence, string line)
        {
            if (sentence == null)
            {
                return;
            }

            var tokens = line.Split(new[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries);

            var newWord = ObjectCopier.Clone(wordPrototype);

            for (var i = 0; i < tokens.Length; i++)
            {
                var attribute = newWord.Attributes.FirstOrDefault(a => a.Position == i);
                if (attribute != null)
                {
                    attribute.Value = tokens[i];
                }
            }

            sentence.Words.Add(newWord);

            if (string.IsNullOrWhiteSpace(sentence.GetAttributeByName("id")))
            {
                sentence.SetAttributeByName("id", sentenceIdProvider++.ToString());
            }
        }