Пример #1
0
 public UnnaturalClass(string name, IEnumerable<string> segments, bool ignoreModifiers, Segmenter segmenter, int index = -1)
     : base(name)
 {
     _segmenter = segmenter;
     _segments = segments.ToList();
     _ignoreModifiers = ignoreModifiers;
     _normalizedSegments = new HashSet<string>();
     _index = index;
     foreach (string segment in _segments)
     {
         if (segment == "#" || segment == "-")
         {
             _normalizedSegments.Add(segment);
         }
         else if (segment.StartsWith("#"))
         {
             string normalized;
             if (Normalize(segment.Remove(0, 1), out normalized))
                 _normalizedSegments.Add("#" + normalized);
         }
         else if (segment.EndsWith("#"))
         {
             string normalized;
             if (Normalize(segment.Remove(segment.Length - 1, 1), out normalized))
                 _normalizedSegments.Add(normalized + "#");
         }
         else
         {
             string normalized;
             if (Normalize(segment, out normalized))
                 _normalizedSegments.Add(normalized);
         }
     }
 }
Пример #2
0
        public CogProject(SpanFactory<ShapeNode> spanFactory)
        {
            _segmenter = new Segmenter(spanFactory);
            _meanings = new KeyedBulkObservableList<string, Meaning>(meaning => meaning.Gloss);
            _meanings.CollectionChanged += MeaningsChanged;
            _varieties = new KeyedBulkObservableList<string, Variety>(variety => variety.Name);
            _varieties.CollectionChanged += VarietiesChanged;
            _varietyPairs = new VarietyPairCollection();

            _wordAligners = new ObservableDictionary<string, IWordAligner>();
            _cognateIdentifiers = new ObservableDictionary<string, ICognateIdentifier>();

            _projectProcessors = new ObservableDictionary<string, IProcessor<CogProject>>();
            _varietyProcessors = new ObservableDictionary<string, IProcessor<Variety>>();
            _varietyPairProcessors = new ObservableDictionary<string, IProcessor<VarietyPair>>();
        }
Пример #3
0
 public EditAffixViewModel(Segmenter segmenter, Affix affix)
 {
     _title = "Edit Affix";
     _segmenter = segmenter;
     _strRep = affix.StrRep;
     switch (affix.Type)
     {
         case AffixType.Prefix:
             _type = AffixViewModelType.Prefix;
             break;
         case AffixType.Suffix:
             _type = AffixViewModelType.Suffix;
             break;
     }
     _category = affix.Category;
 }
Пример #4
0
        public CogProject(SpanFactory<ShapeNode> spanFactory)
        {
            _segmenter = new Segmenter(spanFactory);
            _meanings = new MeaningCollection();
            _meanings.CollectionChanged += MeaningsChanged;
            _varieties = new VarietyCollection();
            _varieties.CollectionChanged += VarietiesChanged;
            _varietyPairs = new VarietyPairCollection();
            _cognacyDecisions = new CognacyDecisionCollection();

            _wordAligners = new ObservableDictionary<string, IWordAligner>();
            _cognateIdentifiers = new ObservableDictionary<string, ICognateIdentifier>();

            _projectProcessors = new ObservableDictionary<string, IProcessor<CogProject>>();
            _varietyProcessors = new ObservableDictionary<string, IProcessor<Variety>>();
            _varietyPairProcessors = new ObservableDictionary<string, IProcessor<VarietyPair>>();
        }
        public void StrRep_SetStrRep_VarietyIsValidUpdated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                var segmenter = new Segmenter(env.SpanFactory)
                {
                    Consonants = {"b", "t"},
                    Vowels = {"a"}
                };
                env.AnalysisService.Segment(Arg.Do<Variety>(variety => segmenter.Segment(variety.Words.First())));
                SetupProject(env);
                WordListsVarietyMeaningViewModel varietyMeaning = env.WordListsViewModel.Varieties[0].Meanings[0];

                varietyMeaning.StrRep = "cat";
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] {"cat"}));
                Assert.That(env.WordListsViewModel.Varieties[0].IsValid, Is.False);

                varietyMeaning.StrRep = "bat";
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] {"bat"}));
                Assert.That(env.WordListsViewModel.Varieties[0].IsValid, Is.True);
            }
        }
Пример #6
0
        public void Varieties_DomainModelChangedMessage_CheckForErrors()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                var project = new CogProject(env.SpanFactory);
                env.OpenProject(project);

                project.Meanings.Add(new Meaning("gloss1", "cat1"));
                var bat = new Word("bat", project.Meanings[0]);
                project.Varieties.Add(new Variety("variety1") {Words = {bat}});

                Assert.That(env.WordListsViewModel.Varieties[0].IsValid, Is.False);

                var segmenter = new Segmenter(env.SpanFactory)
                {
                    Consonants = {"b", "t"},
                    Vowels = {"a"}
                };
                segmenter.Segment(bat);

                Messenger.Default.Send(new DomainModelChangedMessage(true));
                Assert.That(env.WordListsViewModel.Varieties[0].IsValid, Is.True);
            }
        }
Пример #7
0
 public EditAffixViewModel(Segmenter segmenter)
 {
     _title = "New Affix";
     _segmenter = segmenter;
 }
 public AddUnnaturalClassSegmentViewModel(Segmenter segmenter)
 {
     _segmenter = segmenter;
 }