public PhraseEventArgs(IWordContainer phraseContainer)
    {
        //PhraseData = phraseContainer.PhraseData;
        PhraseContainer = phraseContainer;

        Phrase = new PhraseSequence();
        Phrase.Add(phraseContainer.Word); //PhraseData.GetPhraseSequence().PhraseElements[0]);
    }
Beispiel #2
0
 public static PhraseSequence GetComparableSubset(this PhraseSequence p)
 {
     var comparables = from elem in p.PhraseElements
                       where elem.Comparable
                       select elem;
     PhraseSequence phrase = new PhraseSequence();
     phrase.Translation = p.Translation;
     foreach (var e in comparables) {
         phrase.Add(e);
     }
     return phrase;
 }
Beispiel #3
0
 public static PhraseSequence Flatten(this IEnumerable<PhraseSequence> phrases)
 {
     var p = new PhraseSequence();
     foreach (var w in phrases) {
         p.Add(w);
     }
     return p;
 }
Beispiel #4
0
    public PhraseSequence InsertContext(ContextData context)
    {
        if (context == null) {
            return this;
        }

        var p = new PhraseSequence();
        p.Translation = Translation;
        foreach (var w in PhraseElements) {
            if (w.ElementType == PhraseSequenceElementType.ContextSlot) {
                var cd = context.Get(w.Text);
                if (cd != null) {
                    PhraseSequence replace = cd.Data;
                    foreach (var e in replace.PhraseElements) {
                        p.Add(e);
                    }
                    p.Translation = p.Translation.Replace("[" + w.Text + "]", HelperGetTranslation(replace));
                } else {
                    p.Add(w);
                }
            } else {
                p.Add(w);
            }
        }
        return p;
    }
 public PhraseEventArgs(PhraseSequenceElement word)
 {
     Phrase = new PhraseSequence();
     Phrase.Add(word);
 }