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; }
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; } }
public AffixViewModel(Affix affix) { _affix = affix; _isValid = _affix.Shape.Count > 0; _affix.PropertyChanged += AffixPropertyChanged; }
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); } }
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; } }