예제 #1
0
 public SoundContext ToSoundContext(CogProject project, SegmentPool segmentPool)
 {
     IWordAligner aligner = project.WordAligners[ComponentIdentifiers.PrimaryWordAligner];
     SoundClass leftEnv = LeftEnvironment == null ? null : aligner.ContextualSoundClasses.First(sc => sc.Name == LeftEnvironment);
     SoundClass rightEnv = RightEnvironment == null ? null : aligner.ContextualSoundClasses.First(sc => sc.Name == RightEnvironment);
     return new SoundContext(leftEnv, new Ngram<Segment>(_target.Select(segmentPool.GetExisting)), rightEnv);
 }
 public CognateIdentifierOptionsViewModel(SegmentPool segmentPool, IProjectService projectService, EMSoundChangeInducerOptionsViewModel em,
     LexStatOptionsViewModel lexStat)
     : base("Cognacy", "Method", em, lexStat)
 {
     _segmentPool = segmentPool;
     _projectService = projectService;
 }
 public EMSoundChangeInducerOptionsViewModel(SegmentPool segmentPool, IProjectService projectService, BlairCognateIdentifierViewModel blairCognateIdentifier,
     ThresholdCognateIdentifierViewModel thresholdCognateIdentifier, DolgopolskyCognateIdentifierViewModel dolgopolskyCognateIdentifier, SCACognateIdentifierViewModel scaCognateIdentifier)
     : base("EM Sound Change Inducer", "Cognate Identifier Method", blairCognateIdentifier, thresholdCognateIdentifier, dolgopolskyCognateIdentifier, scaCognateIdentifier)
 {
     _segmentPool = segmentPool;
     _projectService = projectService;
 }
        public CognateIdentifierOptionsViewModel(SegmentPool segmentPool, IProjectService projectService, BlairCognateIdentifierViewModel blairCognateIdentifier,
			ThresholdCognateIdentifierViewModel thresholdCognateIdentifier, DolgopolskyCognateIdentifierViewModel dolgopolskyCognateIdentifier)
            : base("Likely cognate identification", "Comparison-Settings#likely-cognate-identification", "Method", blairCognateIdentifier, thresholdCognateIdentifier, dolgopolskyCognateIdentifier)
        {
            _segmentPool = segmentPool;
            _projectService = projectService;
        }
 public PoorMansAffixIdentifierViewModel(SpanFactory<ShapeNode> spanFactory, SegmentPool segmentPool, IProjectService projectService)
     : base("Automatic stemmer", "Input-Settings#automatic-stemmer")
 {
     _spanFactory = spanFactory;
     _segmentPool = segmentPool;
     _projectService = projectService;
 }
예제 #6
0
 public AnalysisService(SpanFactory<ShapeNode> spanFactory, SegmentPool segmentPool, IProjectService projectService, IDialogService dialogService, IBusyService busyService)
 {
     _spanFactory = spanFactory;
     _segmentPool = segmentPool;
     _projectService = projectService;
     _dialogService = dialogService;
     _busyService = busyService;
 }
예제 #7
0
 public AlineViewModel(SegmentPool segmentPool, IProjectService projectService, SoundClassesViewModel soundClasses)
     : base("Alignment", "Comparison-Settings#alignment")
 {
     _segmentPool = segmentPool;
     _projectService = projectService;
     _soundClasses = soundClasses;
     _soundClasses.PropertyChanged += ChildPropertyChanged;
 }
예제 #8
0
 public SCAAlignViewModel(SegmentPool segmentPool, IProjectService projectService, SoundClassesViewModel soundClasses)
     : base("SCA")
 {
     _segmentPool = segmentPool;
     _projectService = projectService;
     _soundClasses = soundClasses;
     _soundClasses.PropertyChanged += ChildPropertyChanged;
 }
 public SCACognateIdentifierViewModel(SegmentPool segmentPool, IProjectService projectService, SoundClassesViewModel soundClassesViewModel)
     : base("SCA")
 {
     _segmentPool = segmentPool;
     _projectService = projectService;
     _soundClasses = soundClassesViewModel;
     _soundClasses.PropertyChanged += ChildPropertyChanged;
 }
 public DolgopolskyCognateIdentifierViewModel(SegmentPool segmentPool, IProjectService projectService, SoundClassesViewModel soundClassesViewModel)
     : base("Dolgopolsky", "Dolgopolsky-Method-Settings")
 {
     _segmentPool = segmentPool;
     _projectService = projectService;
     _soundClasses = soundClassesViewModel;
     _soundClasses.PropertyChanged += ChildPropertyChanged;
 }
예제 #11
0
 public SyllabifierViewModel(SegmentPool segmentPool, IProjectService projectService, IAnalysisService analysisService, SoundClassesViewModel sonorityClasses)
     : base("Syllabification", "Input-Settings#syllabification")
 {
     _segmentPool = segmentPool;
     _projectService = projectService;
     _analysisService = analysisService;
     _sonorityClasses = sonorityClasses;
     _sonorityClasses.PropertyChanged += ChildPropertyChanged;
     _sonorityClasses.DisplaySonority = true;
 }
예제 #12
0
        public void FindCommand()
        {
            DispatcherHelper.Initialize();
            var segmentPool = new SegmentPool();
            var projectService = Substitute.For<IProjectService>();
            var dialogService = Substitute.For<IDialogService>();
            var busyService = Substitute.For<IBusyService>();
            var analysisService = new AnalysisService(_spanFactory, segmentPool, projectService, dialogService, busyService);
            var exportService = Substitute.For<IExportService>();

            WordsViewModel.Factory wordsFactory = words => new WordsViewModel(busyService, words);
            WordViewModel.Factory wordFactory = word => new WordViewModel(busyService, analysisService, word);

            var segments = new SegmentsViewModel(projectService, dialogService, busyService, exportService, wordsFactory, wordFactory);

            CogProject project = TestHelpers.GetTestProject(_spanFactory, segmentPool);
            project.Meanings.AddRange(new[] {new Meaning("gloss1", "cat1"), new Meaning("gloss2", "cat2"), new Meaning("gloss3", "cat3")});
            project.Varieties.AddRange(new[] {new Variety("variety1"), new Variety("variety2")});
            project.Varieties[0].Words.AddRange(new[] {new Word("hɛ.loʊ", project.Meanings[0]), new Word("gʊd", project.Meanings[1]), new Word("bæd", project.Meanings[2])});
            project.Varieties[1].Words.AddRange(new[] {new Word("hɛlp", project.Meanings[0]), new Word("gu.gəl", project.Meanings[1]), new Word("gu.fi", project.Meanings[2])});
            projectService.Project.Returns(project);
            analysisService.SegmentAll();
            projectService.ProjectOpened += Raise.Event();

            WordsViewModel observedWords = segments.ObservedWords;
            observedWords.WordsView = new ListCollectionView(observedWords.Words);

            FindViewModel findViewModel = null;
            Action closeCallback = null;
            dialogService.ShowModelessDialog(segments, Arg.Do<FindViewModel>(vm => findViewModel = vm), Arg.Do<Action>(callback => closeCallback = callback));
            segments.FindCommand.Execute(null);
            Assert.That(findViewModel, Is.Not.Null);
            Assert.That(closeCallback, Is.Not.Null);

            // already open, shouldn't get opened twice
            dialogService.ClearReceivedCalls();
            segments.FindCommand.Execute(null);
            dialogService.DidNotReceive().ShowModelessDialog(segments, Arg.Any<FindViewModel>(), Arg.Any<Action>());

            // nothing selected, no match
            findViewModel.Field = FindField.Form;
            findViewModel.String = "nothing";
            findViewModel.FindNextCommand.Execute(null);
            Assert.That(observedWords.SelectedWords, Is.Empty);

            // nothing selected, matches
            segments.SelectedSegment = segments.Varieties[1].Segments[3];
            WordViewModel[] wordsViewArray = observedWords.WordsView.Cast<WordViewModel>().ToArray();
            findViewModel.String = "fi";
            findViewModel.FindNextCommand.Execute(null);
            Assert.That(observedWords.SelectedWords, Is.EquivalentTo(wordsViewArray[1].ToEnumerable()));
            findViewModel.FindNextCommand.Execute(null);
            Assert.That(observedWords.SelectedWords, Is.EquivalentTo(wordsViewArray[1].ToEnumerable()));
        }
예제 #13
0
        public void Migrate(SegmentPool segmentPool, CogProject project)
        {
            if (project.FeatureSystem.ContainsFeature("airstream"))
                return;

            var pulmonic = new FeatureSymbol("pulmonic");
            var ejective = new FeatureSymbol("ejective");
            var implosive = new FeatureSymbol("implosive");
            var click = new FeatureSymbol("click");
            var airstream = new SymbolicFeature("airstream",
                pulmonic,
                ejective,
                implosive,
                click) {Description = "Airstream"};
            project.FeatureSystem.Add(airstream);

            AddValue(project.Segmenter.Modifiers, "ʼ", ejective);

            AddValue(project.Segmenter.Consonants, "ɓ", implosive);
            AddValue(project.Segmenter.Consonants, "ɗ", implosive);
            AddValue(project.Segmenter.Consonants, "ʄ", implosive);
            AddValue(project.Segmenter.Consonants, "ɠ", implosive);
            AddValue(project.Segmenter.Consonants, "ʛ", implosive);

            FeatureSymbol affricate;
            if (project.FeatureSystem.TryGetSymbol("affricate", out affricate))
            {
                project.Segmenter.Consonants.AddSymbolBasedOn("ʘ", "p", affricate, click);
                project.Segmenter.Consonants.AddSymbolBasedOn("ǀ", "θ", affricate, click);
                project.Segmenter.Consonants.AddSymbolBasedOn("ǁ", "ɬ", affricate, click);
            }
            project.Segmenter.Consonants.AddSymbolBasedOn("ǃ", "t", click);
            project.Segmenter.Consonants.AddSymbolBasedOn("ǂ", "c", click);

            foreach (Symbol symbol in project.Segmenter.Vowels.ToArray())
                AddValue(project.Segmenter.Vowels, symbol, pulmonic);

            foreach (Symbol symbol in project.Segmenter.Consonants.Where(s => !s.FeatureStruct.ContainsFeature("airstream")).ToArray())
                AddValue(project.Segmenter.Consonants, symbol, pulmonic);

            foreach (KeyValuePair<string, IWordAligner> aligner in project.WordAligners.Where(kvp => kvp.Value is Aline).ToArray())
            {
                var aline = (Aline) aligner.Value;
                Dictionary<SymbolicFeature, int> featWeights = aline.FeatureWeights.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
                featWeights[airstream] = 5;
                Dictionary<FeatureSymbol, int> valueMetrics = aline.ValueMetrics.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
                valueMetrics[pulmonic] = 100;
                valueMetrics[ejective] = 66;
                valueMetrics[implosive] = 33;
                valueMetrics[click] = 0;
                project.WordAligners[aligner.Key] = new Aline(segmentPool, aline.RelevantVowelFeatures, aline.RelevantConsonantFeatures.Concat(airstream),
                    featWeights, valueMetrics, aline.Settings);
            }
        }
예제 #14
0
파일: ProjectService.cs 프로젝트: rmunn/cog
        public ProjectService(SpanFactory<ShapeNode> spanFactory, SegmentPool segmentPool, IDialogService dialogService, IBusyService busyService,
			ISettingsService settingsService, Lazy<IAnalysisService> analysisService)
        {
            _spanFactory = spanFactory;
            _segmentPool = segmentPool;
            _dialogService = dialogService;
            _busyService = busyService;
            _settingsService = settingsService;
            _analysisService = analysisService;

            Messenger.Default.Register<DomainModelChangedMessage>(this, HandleDomainModelChanged);
            Messenger.Default.Register<ComparisonPerformedMessage>(this, HandleComparisonPerformed);
        }
예제 #15
0
        public BlairCognateIdentifierViewModel(SegmentPool segmentPool, IProjectService projectService, SegmentMappingsViewModel ignoredMappings,
			SimilarSegmentMappingsViewModel.Factory similarSegmentMappingsFactory, SegmentMappingViewModel.Factory mappingFactory)
            : base("Blair")
        {
            _segmentPool = segmentPool;
            _projectService = projectService;
            _mappingFactory = mappingFactory;
            _ignoredMappings = ignoredMappings;
            _ignoredMappings.PropertyChanged += ChildPropertyChanged;
            _similarVowels = similarSegmentMappingsFactory(SoundType.Vowel);
            _similarVowels.PropertyChanged += ChildPropertyChanged;
            _similarConsonants = similarSegmentMappingsFactory(SoundType.Consonant);
            _similarConsonants.PropertyChanged += ChildPropertyChanged;
        }
예제 #16
0
        public void Segments()
        {
            var segmentPool = new SegmentPool();
            var busyService = Substitute.For<IBusyService>();
            var projectService = Substitute.For<IProjectService>();
            var dialogService = Substitute.For<IDialogService>();
            var analysisService = new AnalysisService(_spanFactory, segmentPool, projectService, dialogService, busyService);
            var project = TestHelpers.GetTestProject(_spanFactory, segmentPool);
            project.Meanings.Add(new Meaning("gloss1", "cat1"));
            project.Varieties.Add(new Variety("variety1"));
            var w = new Word("gugəl", project.Meanings[0]);
            project.Varieties[0].Words.Add(w);
            projectService.Project.Returns(project);

            var word = new WordViewModel(busyService, analysisService, w);

            Assert.That(word.Segments, Is.Empty);
            Assert.That(word.IsValid, Is.False);

            project.Segmenter.Segment(w);

            Assert.That(word.IsValid, Is.True);
            Assert.That(word.Segments.Select(s => s.StrRep), Is.EqualTo(new[] {"|", "g", "u", "g", "ə", "l", "|"}));

            word.Segments.Move(0, 2);

            Assert.That(word.Segments.Select(s => s.StrRep), Is.EqualTo(new[] {"g", "u", "|", "g", "ə", "l", "|"}));
            Annotation<ShapeNode> prefixAnn = w.Prefix;
            Assert.That(prefixAnn, Is.Not.Null);
            Assert.That(w.Shape.GetNodes(prefixAnn.Span).Select(n => n.OriginalStrRep()), Is.EqualTo(new[] {"g", "u"}));
            Assert.That(w.Shape.GetNodes(w.Stem.Span).Select(n => n.OriginalStrRep()), Is.EqualTo(new[] {"g", "ə", "l"}));
            Assert.That(w.Suffix, Is.Null);
            Assert.That(w.StemIndex, Is.EqualTo(2));
            Assert.That(w.StemLength, Is.EqualTo(3));

            WordSegmentViewModel seg = word.Segments[6];
            word.Segments.RemoveAt(6);
            word.Segments.Insert(5, seg);

            Assert.That(word.Segments.Select(s => s.StrRep), Is.EqualTo(new[] {"g", "u", "|", "g", "ə", "|", "l"}));
            prefixAnn = w.Prefix;
            Assert.That(prefixAnn, Is.Not.Null);
            Assert.That(w.Shape.GetNodes(prefixAnn.Span).Select(n => n.OriginalStrRep()), Is.EqualTo(new[] {"g", "u"}));
            Assert.That(w.Shape.GetNodes(w.Stem.Span).Select(n => n.OriginalStrRep()), Is.EqualTo(new[] {"g", "ə"}));
            Annotation<ShapeNode> suffixAnn = w.Suffix;
            Assert.That(suffixAnn, Is.Not.Null);
            Assert.That(w.Shape.GetNodes(suffixAnn.Span).Select(n => n.OriginalStrRep()), Is.EqualTo(new[] {"l"}));
            Assert.That(w.StemIndex, Is.EqualTo(2));
            Assert.That(w.StemLength, Is.EqualTo(2));
        }
예제 #17
0
        public VarietyPairViewModel(SegmentPool segmentPool, IProjectService projectService, WordPairsViewModel.Factory wordPairsFactory,
			WordPairViewModel.Factory wordPairFactory, VarietyPair varietyPair, bool areVarietiesInOrder)
            : base(varietyPair)
        {
            _segmentPool = segmentPool;
            _projectService = projectService;
            _varietyPair = varietyPair;
            _areVarietiesInOrder = areVarietiesInOrder;
            _wordPairsFactory = wordPairsFactory;
            _wordPairFactory = wordPairFactory;

            Messenger.Default.Register<ComparisonPerformedMessage>(this, HandleComparisonPerformed);

            UpdateVarietyPair();
        }
예제 #18
0
        public void Migrate(SegmentPool segmentPool, CogProject project)
        {
            AddToneNumber(project, "¹");
            AddToneNumber(project, "²");
            AddToneNumber(project, "³");
            AddToneNumber(project, "⁴");
            AddToneNumber(project, "⁵");

            FeatureSymbol alvPal;
            if (project.FeatureSystem.TryGetSymbol("alveolo-palatal", out alvPal))
            {
                project.Segmenter.Consonants.AddSymbolBasedOn("ȶ", "t", alvPal);
                project.Segmenter.Consonants.AddSymbolBasedOn("ȡ", "d", alvPal);
                project.Segmenter.Consonants.AddSymbolBasedOn("ȵ", "n", alvPal);
                project.Segmenter.Consonants.AddSymbolBasedOn("ȴ", "l", alvPal);
            }
        }
예제 #19
0
        public VarietyPairViewModel(SegmentPool segmentPool, IProjectService projectService, WordPairsViewModel.Factory wordPairsFactory, VarietyPair varietyPair, bool areVarietiesInOrder)
        {
            _segmentPool = segmentPool;
            _projectService = projectService;
            _varietyPair = varietyPair;
            _areVarietiesInOrder = areVarietiesInOrder;

            IWordAligner aligner = projectService.Project.WordAligners[ComponentIdentifiers.PrimaryWordAligner];
            _cognates = wordPairsFactory();
            foreach (WordPair wp in _varietyPair.WordPairs.Where(wp => wp.AreCognatePredicted))
                _cognates.WordPairs.Add(new WordPairViewModel(aligner, wp, _areVarietiesInOrder));
            _noncognates = wordPairsFactory();
            foreach (WordPair wp in _varietyPair.WordPairs.Where(wp => !wp.AreCognatePredicted))
                _noncognates.WordPairs.Add(new WordPairViewModel(aligner, wp, _areVarietiesInOrder));

            _soundChanges = new ReadOnlyList<SoundChangeViewModel>(_varietyPair.SoundChangeProbabilityDistribution.Conditions.SelectMany(lhs => _varietyPair.SoundChangeProbabilityDistribution[lhs].Samples,
                (lhs, segment) => new SoundChangeViewModel(lhs, segment, _varietyPair.SoundChangeProbabilityDistribution[lhs][segment], _varietyPair.SoundChangeFrequencyDistribution[lhs][segment])).ToList());
        }
예제 #20
0
        public static SoundContext ToSoundContext(this ShapeNode node, SegmentPool segmentPool, IEnumerable <SoundClass> soundClasses)
        {
            ShapeNode  prevNode = node.GetPrev(NodeFilter);
            SoundClass leftEnv;

            if (!soundClasses.TryGetMatchingSoundClass(segmentPool, prevNode, out leftEnv))
            {
                leftEnv = null;
            }
            ShapeNode  nextNode = node.GetNext(NodeFilter);
            SoundClass rightEnv;

            if (!soundClasses.TryGetMatchingSoundClass(segmentPool, nextNode, out rightEnv))
            {
                rightEnv = null;
            }
            return(new SoundContext(leftEnv, segmentPool.Get(node), rightEnv));
        }
예제 #21
0
        public void Migrate(SegmentPool segmentPool, CogProject project)
        {
            // add prenasal superscript for n
            project.Segmenter.Consonants.AddSymbolBasedOn("ⁿ", "n");

            foreach (KeyValuePair<string, IProcessor<Variety>> kvp in project.VarietyProcessors.Where(kvp => kvp.Value is SspSyllabifier).ToArray())
            {
                var syllabifier = (SspSyllabifier) kvp.Value;
                SonorityClass[] scale = syllabifier.SonorityScale.OrderBy(sc => sc.Sonority).ThenBy(sc => sc.SoundClass.Name).ToArray();
                // if the user has changed the sonority scale preserve their changes and do not update
                if (HasSonorityScaleChanged(project, scale))
                    continue;

                // add prenasal sonority class
                var newScale = new List<SonorityClass> {new SonorityClass(1, new UnnaturalClass("Prenasal", new[] {"ᵐ", "ⁿ", "ᵑ"}, false, project.Segmenter))};
                foreach (SonorityClass sc in scale)
                {
                    SoundClass newClass;
                    switch (sc.SoundClass.Name)
                    {
                        case "Glide":
                            // correct the ignore modifiers flag on the "Glide" class
                            newClass = new UnnaturalClass("Glide", new[] {"j", "ɥ", "ɰ", "w"}, true, project.Segmenter);
                            break;
                        case "Open vowel":
                            // correct the height feature value on the "Open vowel" class
                            newClass = new NaturalClass("Open vowel", FeatureStruct.New(project.FeatureSystem).Symbol(CogFeatureSystem.VowelType).Symbol("syllabic+").Symbol("open").Value);
                            break;
                        default:
                            newClass = sc.SoundClass;
                            break;
                    }
                    // increment sonority for all existing classes
                    newScale.Add(new SonorityClass(sc.Sonority + 1, newClass));
                }
                project.VarietyProcessors[kvp.Key] = new SspSyllabifier(syllabifier.CombineVowels, syllabifier.CombineConsonants, syllabifier.VowelsSameSonorityTautosyllabic,
                    segmentPool, newScale);
            }
        }
예제 #22
0
 public void SetUp()
 {
     _featSys = new FeatureSystem
         {
             new SymbolicFeature("place",
                 new FeatureSymbol("bilabial"),
                 new FeatureSymbol("labiodental"),
                 new FeatureSymbol("dental"),
                 new FeatureSymbol("alveolar"),
                 new FeatureSymbol("retroflex"),
                 new FeatureSymbol("palato-alveolar"),
                 new FeatureSymbol("alveolo-palatal"),
                 new FeatureSymbol("palatal"),
                 new FeatureSymbol("velar"),
                 new FeatureSymbol("uvular"),
                 new FeatureSymbol("pharyngeal"),
                 new FeatureSymbol("epiglottal"),
                 new FeatureSymbol("glottal"))
         };
     _project = new CogProject(_spanFactory) {FeatureSystem = _featSys};
     _segmentPool = new SegmentPool();
 }
예제 #23
0
 public static SoundContext ToSoundContext(this ShapeNode node, SegmentPool segmentPool, IEnumerable<SoundClass> soundClasses)
 {
     ShapeNode prevNode = node.GetPrev(NodeFilter);
     SoundClass leftEnv;
     if (!soundClasses.TryGetMatchingSoundClass(segmentPool, prevNode, out leftEnv))
         leftEnv = null;
     ShapeNode nextNode = node.GetNext(NodeFilter);
     SoundClass rightEnv;
     if (!soundClasses.TryGetMatchingSoundClass(segmentPool, nextNode, out rightEnv))
         rightEnv = null;
     return new SoundContext(leftEnv, segmentPool.Get(node), rightEnv);
 }
예제 #24
0
        public static bool TryGetMatchingSoundClass(this IEnumerable <SoundClass> soundClasses, SegmentPool segmentPool, ShapeNode node, out SoundClass soundClass)
        {
            Annotation <ShapeNode> stemAnn = ((Shape)node.List).Annotations.First(ann => ann.Type() == CogFeatureSystem.StemType);
            ShapeNode left = null;

            if (stemAnn.Range.Contains(node) || node.Annotation.CompareTo(stemAnn) > 0)
            {
                ShapeNode leftNode = node.GetPrev(NodeFilter);
                if (leftNode != null)
                {
                    left = stemAnn.Range.Contains(leftNode) ? leftNode : node.List.Begin;
                }
            }

            Ngram <Segment> target = stemAnn.Range.Contains(node) ? segmentPool.Get(node) : Segment.Anchor;

            ShapeNode right = null;

            if (stemAnn.Range.Contains(node) || node.Annotation.CompareTo(stemAnn) < 0)
            {
                ShapeNode rightNode = node.GetNext(NodeFilter);
                if (rightNode != null)
                {
                    right = stemAnn.Range.Contains(rightNode) ? rightNode : node.List.End;
                }
            }

            soundClass = soundClasses.FirstOrDefault(sc => sc.Matches(left, target, right));
            return(soundClass != null);
        }
예제 #25
0
파일: TestHelpers.cs 프로젝트: rmunn/cog
 public static CogProject GetTestProject(SpanFactory<ShapeNode> spanFactory, SegmentPool segmentPool)
 {
     Stream stream = Assembly.GetAssembly(typeof(TestHelpers)).GetManifestResourceStream("SIL.Cog.TestUtils.TestProject.cogx");
     return ConfigManager.Load(spanFactory, segmentPool, stream);
 }
예제 #26
0
        public static bool TryGetMatchingSoundClass(this IEnumerable <SoundClass> soundClasses, SegmentPool segmentPool, Alignment <Word, ShapeNode> alignment, int seq, int col, out SoundClass soundClass)
        {
            ShapeNode       leftNode  = alignment.GetLeftNode(seq, col);
            Ngram <Segment> target    = alignment[seq, col].ToNgram(segmentPool);
            ShapeNode       rightNode = alignment.GetRightNode(seq, col);

            soundClass = soundClasses.FirstOrDefault(sc => sc.Matches(leftNode, target, rightNode));
            return(soundClass != null);
        }
예제 #27
0
        public static SoundContext ToSoundContext(this Alignment <Word, ShapeNode> alignment, SegmentPool segmentPool, int seq, int col, IEnumerable <SoundClass> soundClasses)
        {
            ShapeNode  leftNode = alignment.GetLeftNode(seq, col);
            SoundClass leftEnv;

            if (leftNode == null || !soundClasses.TryGetMatchingSoundClass(segmentPool, leftNode, out leftEnv))
            {
                leftEnv = null;
            }
            Ngram <Segment> target    = alignment[seq, col].ToNgram(segmentPool);
            ShapeNode       rightNode = alignment.GetRightNode(seq, col);
            SoundClass      rightEnv;

            if (rightNode == null || !soundClasses.TryGetMatchingSoundClass(segmentPool, rightNode, out rightEnv))
            {
                rightEnv = null;
            }
            return(new SoundContext(leftEnv, target, rightEnv));
        }
예제 #28
0
            public TestEnvironment()
            {
                DispatcherHelper.Initialize();
                _segmentPool = new SegmentPool();
                _projectService = Substitute.For<IProjectService>();
                _dialogService = Substitute.For<IDialogService>();
                var busyService = Substitute.For<IBusyService>();
                var exportService = Substitute.For<IExportService>();
                _analysisService = new AnalysisService(_spanFactory, _segmentPool, _projectService, _dialogService, busyService);

                WordPairsViewModel.Factory wordPairsFactory = () => new WordPairsViewModel(busyService);
                VarietyPairViewModel.Factory varietyPairFactory = (vp, order) => new VarietyPairViewModel(_segmentPool, _projectService, wordPairsFactory, vp, order);

                _varietyPairs = new VarietyPairsViewModel(_projectService, busyService, _dialogService, exportService, _analysisService, varietyPairFactory);

                _project = TestHelpers.GetTestProject(_spanFactory, _segmentPool);
                _projectService.Project.Returns(_project);
            }
예제 #29
0
 public static Ngram <Segment> ToNgram(this IEnumerable <ShapeNode> nodes, SegmentPool segmentPool)
 {
     return(new Ngram <Segment>(nodes.Select(segmentPool.Get)));
 }
예제 #30
0
 public SoundCorrespondence ToSoundCorrespondence(SegmentPool segmentPool, Dictionary<WordPairSurrogate, WordPair> wordPairs)
 {
     var corr = new SoundCorrespondence(segmentPool.GetExisting(Segment1), segmentPool.GetExisting(Segment2)) {Frequency = Frequency};
     corr.WordPairs.AddRange(_wordPairs.Select(wps => wordPairs[wps]));
     return corr;
 }
예제 #31
0
 public static SoundContext ToSoundContext(this Alignment<Word, ShapeNode> alignment, SegmentPool segmentPool, int seq, int col, IEnumerable<SoundClass> soundClasses)
 {
     ShapeNode leftNode = alignment.GetLeftNode(seq, col);
     SoundClass leftEnv;
     if (leftNode == null || !soundClasses.TryGetMatchingSoundClass(segmentPool, leftNode, out leftEnv))
         leftEnv = null;
     Ngram<Segment> target = alignment[seq, col].ToNgram(segmentPool);
     ShapeNode rightNode = alignment.GetRightNode(seq, col);
     SoundClass rightEnv;
     if (rightNode == null || !soundClasses.TryGetMatchingSoundClass(segmentPool, rightNode, out rightEnv))
         rightEnv = null;
     return new SoundContext(leftEnv, target, rightEnv);
 }
예제 #32
0
 public void SetUp()
 {
     _segmentPool = new SegmentPool();
     _project = ConfigManager.Load(_spanFactory, _segmentPool, "Services\\ProjectMigrations\\ProjectMigration4Tests.cogx");
 }
예제 #33
0
 public LexStatOptionsViewModel(SegmentPool segmentPool, IProjectService projectService, DolgopolskyCognateIdentifierViewModel dolgopolskyCognateIdentifier, SCACognateIdentifierViewModel scaCognateIdentifier)
     : base("LexStat", "Sound Class", dolgopolskyCognateIdentifier, scaCognateIdentifier)
 {
     _segmentPool = segmentPool;
     _projectService = projectService;
 }
예제 #34
0
 public static bool TryGetMatchingSoundClass(this IEnumerable<SoundClass> soundClasses, SegmentPool segmentPool, Alignment<Word, ShapeNode> alignment, int seq, int col, out SoundClass soundClass)
 {
     ShapeNode leftNode = alignment.GetLeftNode(seq, col);
     Ngram<Segment> target = alignment[seq, col].ToNgram(segmentPool);
     ShapeNode rightNode = alignment.GetRightNode(seq, col);
     soundClass = soundClasses.FirstOrDefault(sc => sc.Matches(leftNode, target, rightNode));
     return soundClass != null;
 }
예제 #35
0
        public static bool TryGetMatchingSoundClass(this IEnumerable<SoundClass> soundClasses, SegmentPool segmentPool, ShapeNode node, out SoundClass soundClass)
        {
            Annotation<ShapeNode> stemAnn = ((Shape) node.List).Annotations.First(ann => ann.Type() == CogFeatureSystem.StemType);
            ShapeNode left = null;
            if (stemAnn.Span.Contains(node) || node.Annotation.CompareTo(stemAnn) > 0)
            {
                ShapeNode leftNode = node.GetPrev(NodeFilter);
                if (leftNode != null)
                    left = stemAnn.Span.Contains(leftNode) ? leftNode : node.List.Begin;
            }

            Ngram<Segment> target = stemAnn.Span.Contains(node) ? segmentPool.Get(node) : Segment.Anchor;

            ShapeNode right = null;
            if (stemAnn.Span.Contains(node) || node.Annotation.CompareTo(stemAnn) < 0)
            {
                ShapeNode rightNode = node.GetNext(NodeFilter);
                if (rightNode != null)
                    right = stemAnn.Span.Contains(rightNode) ? rightNode : node.List.End;
            }

            soundClass = soundClasses.FirstOrDefault(sc => sc.Matches(left, target, right));
            return soundClass != null;
        }