Example #1
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;
 }
Example #2
0
        public void Segment(Affix affix)
        {
            if (string.IsNullOrEmpty(affix.StrRep))
            {
                affix.Shape = _emptyShape;
                return;
            }

            var shape = new Shape(begin => new ShapeNode(FeatureStruct.New().Symbol(CogFeatureSystem.AnchorType).Feature(CogFeatureSystem.StrRep).EqualTo("#").Value));

            if (SegmentString(shape, affix.StrRep))
            {
                shape.Freeze();
                affix.Shape = shape;
            }
            else
            {
                affix.Shape = _emptyShape;
            }
        }
Example #3
0
 public AffixViewModel(Affix affix)
 {
     _affix = affix;
     _isValid = _affix.Shape.Count > 0;
     _affix.PropertyChanged += AffixPropertyChanged;
 }
Example #4
0
 private void NewAffix()
 {
     var vm = new EditAffixViewModel(_projectService.Project.Segmenter);
     if (_dialogService.ShowModalDialog(this, vm) == true)
     {
         var affix = new Affix(vm.StrRep, vm.Type == AffixViewModelType.Prefix ? AffixType.Prefix : AffixType.Suffix, vm.Category);
         _projectService.Project.Segmenter.Segment(affix);
         DomainVariety.Affixes.Add(affix);
         Messenger.Default.Send(new DomainModelChangedMessage(false));
         SelectedAffix = _affixes.Single(a => a.DomainAffix == affix);
     }
 }
Example #5
0
        public void Segment(Affix affix)
        {
            if (string.IsNullOrEmpty(affix.StrRep))
            {
                affix.Shape = _emptyShape;
                return;
            }

            var shape = new Shape(_spanFactory, begin => new ShapeNode(_spanFactory, FeatureStruct.New().Symbol(CogFeatureSystem.AnchorType).Feature(CogFeatureSystem.StrRep).EqualTo("#").Value));
            if (SegmentString(shape, affix.StrRep))
            {
                shape.Freeze();
                affix.Shape = shape;
            }
            else
            {
                affix.Shape = _emptyShape;
            }
        }