public override PatternNode<ComplexConcParagraphData, ShapeNode> GeneratePattern(FeatureSystem featSys) { var fs = new FeatureStruct(); var typeFeat = featSys.GetFeature<SymbolicFeature>("type"); fs.AddValue(typeFeat, typeFeat.PossibleSymbols["word"]); AddStringValue(featSys, fs, Form, "form"); AddStringValue(featSys, fs, Gloss, "gloss"); if (Category != null) { var catFeat = featSys.GetFeature<SymbolicFeature>("cat"); IEnumerable<FeatureSymbol> symbols = Category.ReallyReallyAllPossibilities.Concat(Category).Select(pos => catFeat.PossibleSymbols[pos.Hvo.ToString(CultureInfo.InvariantCulture)]); if (NegateCategory) symbols = catFeat.PossibleSymbols.Except(symbols); fs.AddValue(catFeat, symbols); } if (m_inflFeatures.Count > 0) { var inflFeat = featSys.GetFeature<ComplexFeature>("infl"); fs.AddValue(inflFeat, GetFeatureStruct(featSys, m_inflFeatures)); } var wordBdryFS = FeatureStruct.New(featSys).Symbol("bdry").Symbol("wordBdry").Value; var group = new Group<ComplexConcParagraphData, ShapeNode>(); group.Children.Add(new Quantifier<ComplexConcParagraphData, ShapeNode>(0, 1, new Constraint<ComplexConcParagraphData, ShapeNode>(wordBdryFS)) {IsGreedy = false}); group.Children.Add(new Constraint<ComplexConcParagraphData, ShapeNode>(fs)); group.Children.Add(new Quantifier<ComplexConcParagraphData, ShapeNode>(0, 1, new Constraint<ComplexConcParagraphData, ShapeNode>(wordBdryFS)) {IsGreedy = false}); return AddQuantifier(group); }
public void Determinize() { var featSys = new FeatureSystem { new StringFeature("A"), new StringFeature("B"), new StringFeature("C"), new StringFeature("D"), new StringFeature("E"), new StringFeature("F") }; var nfst = new Fst <AnnotatedStringData, int>(_operations); nfst.StartState = nfst.CreateState(); State <AnnotatedStringData, int> s1 = nfst.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("C").EqualTo("true").Value, nfst.CreateState()); State <AnnotatedStringData, int> sa = s1.Arcs.Add(FeatureStruct.New(featSys).Feature("D").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("E").EqualTo("true").Value, nfst.CreateAcceptingState()); State <AnnotatedStringData, int> s2 = nfst.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("B").EqualTo("true").Value, nfst.CreateState()); State <AnnotatedStringData, int> s3 = s2.Arcs.Add(FeatureStruct.New(featSys).Value, FeatureStruct.New(featSys).Value, nfst.CreateState()); s3.Arcs.Add(FeatureStruct.New(featSys).Feature("B").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("B").EqualTo("true").Value, sa); Fst <AnnotatedStringData, int> dfst; Assert.That(nfst.TryDeterminize(out dfst), Is.True); }
public void Compose() { var featSys = new FeatureSystem { new StringFeature("value") }; var fst1 = new Fst <AnnotatedStringData, int>(_operations); fst1.StartState = fst1.CreateState(); State <AnnotatedStringData, int> s1 = fst1.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("value").EqualTo("a").Value, FeatureStruct.New(featSys).Feature("value").EqualTo("x").Value, fst1.CreateAcceptingState()); s1.Arcs.Add(FeatureStruct.New(featSys).Feature("value").EqualTo("b").Value, FeatureStruct.New(featSys).Feature("value").EqualTo("y").Value, s1); var fst2 = new Fst <AnnotatedStringData, int>(_operations); fst2.StartState = fst2.CreateAcceptingState(); fst2.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("value").EqualTo("x").Value, null, fst2.StartState); fst2.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("value").EqualTo("y").Value, FeatureStruct.New(featSys).Feature("value").EqualTo("z").Value, fst2.StartState); Fst <AnnotatedStringData, int> composedFsa = fst1.Compose(fst2); var writer = new StringWriter(); composedFsa.ToGraphViz(writer); Assert.That(writer.ToString().Replace("\r\n", "\n"), Is.EqualTo(@"digraph G { 0 [shape=""diamond"", color=""green""]; 0 -> 1 [label=""[value:\""a\""],1:ε""]; 1 [shape=""circle"", color=""red"", peripheries=""2""]; 1 -> 1 [label=""[value:\""b\""],1:([value:\""z\""],∪)""]; } ".Replace("\r\n", "\n"))); }
public void Compose() { var featSys = new FeatureSystem { new StringFeature("value") }; var fst1 = new Fst <StringData, int>(_operations); fst1.StartState = fst1.CreateState(); State <StringData, int> s1 = fst1.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("value").EqualTo("a").Value, FeatureStruct.New(featSys).Feature("value").EqualTo("x").Value, fst1.CreateAcceptingState()); s1.Arcs.Add(FeatureStruct.New(featSys).Feature("value").EqualTo("b").Value, FeatureStruct.New(featSys).Feature("value").EqualTo("y").Value, s1); var fst2 = new Fst <StringData, int>(_operations); fst2.StartState = fst2.CreateAcceptingState(); fst2.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("value").EqualTo("x").Value, null, fst2.StartState); fst2.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("value").EqualTo("y").Value, FeatureStruct.New(featSys).Feature("value").EqualTo("z").Value, fst2.StartState); Fst <StringData, int> composedFsa = fst1.Compose(fst2); var writer = new System.IO.StreamWriter(string.Format("c:\\ltor-composed-nfst.dot")); composedFsa.ToGraphViz(writer); writer.Close(); }
public void IsDeterminizable() { var featSys = new FeatureSystem { new StringFeature("A"), new StringFeature("B"), new StringFeature("C"), new StringFeature("D"), new StringFeature("E"), new StringFeature("F") }; var fst = new Fst <AnnotatedStringData, int>(_operations); fst.StartState = fst.CreateState(); State <AnnotatedStringData, int> s1 = fst.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("E").EqualTo("true").Value, fst.CreateState()); State <AnnotatedStringData, int> s2 = fst.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("F").EqualTo("true").Value, fst.CreateState()); State <AnnotatedStringData, int> s3 = s1.Arcs.Add(FeatureStruct.New(featSys).Feature("B").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("D").EqualTo("true").Value, fst.CreateState()); s2.Arcs.Add(FeatureStruct.New(featSys).Feature("C").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("D").EqualTo("true").Value, s3); State <AnnotatedStringData, int> s4 = s3.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, fst.CreateAcceptingState()); Assert.That(fst.IsDeterminizable, Is.True); s4.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, s4); Assert.That(fst.IsDeterminizable, Is.False); }
public void IsDeterminizable() { var featSys = new FeatureSystem { new StringFeature("A"), new StringFeature("B"), new StringFeature("C"), new StringFeature("D"), new StringFeature("E"), new StringFeature("F") }; var fst = new Fst <StringData, int>(_operations); fst.StartState = fst.CreateState(); State <StringData, int> s1 = fst.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("E").EqualTo("true").Value, fst.CreateState()); State <StringData, int> s2 = fst.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("F").EqualTo("true").Value, fst.CreateState()); State <StringData, int> s3 = s1.Arcs.Add(FeatureStruct.New(featSys).Feature("B").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("D").EqualTo("true").Value, fst.CreateState()); s2.Arcs.Add(FeatureStruct.New(featSys).Feature("C").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("D").EqualTo("true").Value, s3); State <StringData, int> s4 = s3.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, fst.CreateAcceptingState()); Assert.That(fst.IsDeterminizable, Is.True); s4.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, s4); var writer = new System.IO.StreamWriter(string.Format("c:\\ltor-nfst.dot")); fst.ToGraphViz(writer); writer.Close(); Assert.That(fst.IsDeterminizable, Is.False); }
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(); }
private static FeatureStruct GetFeatureStruct(FeatureSystem featSys, IMoMorphSynAnalysis msa) { IFsFeatStruc fs = null; var stemMsa = msa as IMoStemMsa; if (stemMsa != null) { fs = stemMsa.MsFeaturesOA; } else { var inflMsa = msa as IMoInflAffMsa; if (inflMsa != null) { fs = inflMsa.InflFeatsOA; } else { var dervMsa = msa as IMoDerivAffMsa; if (dervMsa != null) { fs = dervMsa.ToMsFeaturesOA; } } } if (fs != null && !fs.IsEmpty) { return(GetFeatureStruct(featSys, fs)); } return(null); }
private static FeatureStruct GetFeatureStruct(FeatureSystem featSys, IFsFeatStruc fs) { var featStruct = new FeatureStruct(); foreach (IFsFeatureSpecification featSpec in fs.FeatureSpecsOC) { var complexVal = featSpec as IFsComplexValue; if (complexVal != null) { var cfs = complexVal.ValueOA as IFsFeatStruc; if (complexVal.FeatureRA != null && cfs != null && !cfs.IsEmpty) { featStruct.AddValue(featSys.GetFeature(complexVal.FeatureRA.Hvo.ToString(CultureInfo.InvariantCulture)), GetFeatureStruct(featSys, cfs)); } } else { var closedVal = featSpec as IFsClosedValue; if (closedVal != null && closedVal.FeatureRA != null) { var symFeat = featSys.GetFeature <SymbolicFeature>(closedVal.FeatureRA.Hvo.ToString(CultureInfo.InvariantCulture)); FeatureSymbol symbol; if (symFeat.PossibleSymbols.TryGetValue(closedVal.ValueRA.Hvo.ToString(CultureInfo.InvariantCulture), out symbol)) { featStruct.AddValue(symFeat, symbol); } } } } return(featStruct); }
internal FeatureStructBuilder(FeatureSystem featSys, FeatureStruct fs, IDictionary<int, FeatureValue> ids, bool mutable) { _featSys = featSys; _fs = fs; _ids = ids; _mutable = mutable; }
protected void LoadSettings(Segmenter segmenter, FeatureSystem featSys, XElement elem, WordPairAlignerSettings settings) { var modeStr = (string)elem.Element(ConfigManager.Cog + "Mode"); if (modeStr != null) { switch (modeStr) { case "local": settings.Mode = AlignmentMode.Local; break; case "global": settings.Mode = AlignmentMode.Global; break; case "semi-global": settings.Mode = AlignmentMode.SemiGlobal; break; case "half-local": settings.Mode = AlignmentMode.HalfLocal; break; } } settings.ExpansionCompressionEnabled = (bool?)elem.Element(ConfigManager.Cog + "ExpansionCompressionEnabled") ?? false; XElement soundClassesElem = elem.Element(ConfigManager.Cog + "ContextualSoundClasses"); if (soundClassesElem != null && soundClassesElem.HasElements) { settings.ContextualSoundClasses = ConfigManager.LoadSoundClasses(segmenter, featSys, soundClassesElem); } }
public void Compile() { m_featSys = new FeatureSystem { new SymbolicFeature("type", new FeatureSymbol("bdry", "Boundary"), new FeatureSymbol("word", "Word"), new FeatureSymbol("morph", "Morph"), new FeatureSymbol("ttag", "Text Tag")) {Description = "Type"}, new SymbolicFeature("anchorType", new FeatureSymbol("paraBdry", "Paragraph"), new FeatureSymbol("segBdry", "Segment"), new FeatureSymbol("wordBdry", "Word")) }; foreach (IWritingSystem ws in m_cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems) { m_featSys.Add(new StringFeature(string.Format("entry-{0}", ws.Handle)) {Description = string.Format("Entry-{0}", ws.Abbreviation)}); m_featSys.Add(new StringFeature(string.Format("form-{0}", ws.Handle)) {Description = string.Format("Form-{0}", ws.Abbreviation)}); } foreach (IWritingSystem ws in m_cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems) m_featSys.Add(new StringFeature(string.Format("gloss-{0}", ws.Handle)) {Description = string.Format("Gloss-{0}", ws.Abbreviation)}); m_featSys.Add(new SymbolicFeature("cat", m_cache.ServiceLocator.GetInstance<IPartOfSpeechRepository>().AllInstances() .Select(pos => new FeatureSymbol(pos.Hvo.ToString(CultureInfo.InvariantCulture), pos.Abbreviation.BestAnalysisAlternative.Text))) { Description = "Category" }); m_featSys.Add(new SymbolicFeature("tag", m_cache.LangProject.TextMarkupTagsOA.PossibilitiesOS .SelectMany(poss => poss.SubPossibilitiesOS, (category, tag) => new FeatureSymbol(tag.Hvo.ToString(CultureInfo.InvariantCulture), tag.Abbreviation.BestAnalysisAlternative.Text))) { Description = "Tag" }); m_featSys.Add(new ComplexFeature("infl") {Description = "Infl", DefaultValue = FeatureStruct.New().Value}); foreach (IFsFeatDefn feature in m_cache.LangProject.MsFeatureSystemOA.FeaturesOC) { var complexFeat = feature as IFsComplexFeature; if (complexFeat != null) { m_featSys.Add(new ComplexFeature(complexFeat.Hvo.ToString(CultureInfo.InvariantCulture)) {Description = complexFeat.Abbreviation.BestAnalysisAlternative.Text, DefaultValue = FeatureStruct.New().Value}); } else { var closedFeat = (IFsClosedFeature) feature; m_featSys.Add(new SymbolicFeature(closedFeat.Hvo.ToString(CultureInfo.InvariantCulture), closedFeat.ValuesOC.Select(sym => new FeatureSymbol(sym.Hvo.ToString(CultureInfo.InvariantCulture), sym.Abbreviation.BestAnalysisAlternative.Text)) .Concat(new FeatureSymbol(closedFeat.Hvo.ToString(CultureInfo.InvariantCulture) + "_us", "unspecified"))) { Description = closedFeat.Abbreviation.BestAnalysisAlternative.Text, DefaultSymbolID = closedFeat.Hvo.ToString(CultureInfo.InvariantCulture) + "_us" }); } } var pattern = new Pattern<ComplexConcParagraphData, ShapeNode>(); pattern.Children.Add(m_root.GeneratePattern(m_featSys)); m_matcher = new Matcher<ComplexConcParagraphData, ShapeNode>(m_spanFactory, pattern, new MatcherSettings<ShapeNode> {UseDefaults = true}); }
public void Compose() { var featSys = new FeatureSystem { new StringFeature("value") }; var fst1 = new Fst<AnnotatedStringData, int>(_operations); fst1.StartState = fst1.CreateState(); State<AnnotatedStringData, int> s1 = fst1.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("value").EqualTo("a").Value, FeatureStruct.New(featSys).Feature("value").EqualTo("x").Value, fst1.CreateAcceptingState()); s1.Arcs.Add(FeatureStruct.New(featSys).Feature("value").EqualTo("b").Value, FeatureStruct.New(featSys).Feature("value").EqualTo("y").Value, s1); var fst2 = new Fst<AnnotatedStringData, int>(_operations); fst2.StartState = fst2.CreateAcceptingState(); fst2.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("value").EqualTo("x").Value, null, fst2.StartState); fst2.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("value").EqualTo("y").Value, FeatureStruct.New(featSys).Feature("value").EqualTo("z").Value, fst2.StartState); Fst<AnnotatedStringData, int> composedFsa = fst1.Compose(fst2); var writer = new StringWriter(); composedFsa.ToGraphViz(writer); Assert.That(writer.ToString().Replace("\r\n", "\n"), Is.EqualTo(@"digraph G { 0 [shape=""diamond"", color=""green""]; 0 -> 1 [label=""[value:\""a\""],1:ε""]; 1 [shape=""circle"", color=""red"", peripheries=""2""]; 1 -> 1 [label=""[value:\""b\""],1:([value:\""z\""],∪)""]; } ".Replace("\r\n", "\n"))); }
internal FeatureStructBuilder(FeatureSystem featSys, FeatureStruct fs, IDictionary <int, FeatureValue> ids, bool mutable) { _featSys = featSys; _fs = fs; _ids = ids; _mutable = mutable; }
protected void AddStringValue(FeatureSystem featSys, FeatureStruct fs, ITsString tss, string id) { if (tss != null) { var feat = featSys.GetFeature <StringFeature>(string.Format("{0}-{1}", id, tss.get_WritingSystemAt(0).ToString(CultureInfo.InvariantCulture))); fs.AddValue(feat, tss.Text); } }
public EditNaturalClassViewModel(FeatureSystem featSys, IEnumerable<SoundClass> soundClasses) : base("New Feature-based Class", soundClasses) { _availableFeatures = new BindableList<FeatureViewModel>(featSys.OfType<SymbolicFeature>().Select(f => new FeatureViewModel(f))); _activeFeatures = new BindableList<FeatureViewModel>(); _addCommand = new RelayCommand(AddFeature, CanAddFeature); _removeCommand = new RelayCommand(RemoveFeature, CanRemoveFeature); }
private static void ParseSymbols(FeatureSystem featSys, XElement elem, ICollection <Symbol> symbols) { foreach (XElement symbolElem in elem.Elements(Cog + "Symbol")) { FeatureStruct fs = LoadFeatureStruct(featSys, symbolElem); var strRep = (string)symbolElem.Attribute("strRep"); symbols.Add(new Symbol(strRep, fs, ((string)symbolElem.Attribute("overwrite")) != "false")); } }
public EditNaturalClassViewModel(FeatureSystem featSys, IEnumerable <SoundClass> soundClasses) : base("New Feature-based Class", soundClasses) { _availableFeatures = new BindableList <FeatureViewModel>(featSys.OfType <SymbolicFeature>().Select(f => new FeatureViewModel(f))); _activeFeatures = new BindableList <FeatureViewModel>(); _addCommand = new RelayCommand(AddFeature, CanAddFeature); _removeCommand = new RelayCommand(RemoveFeature, CanRemoveFeature); }
private void AddSegDef(CharacterDefinitionTable table, FeatureSystem phoneticFeatSys, string strRep, params string[] symbols) { var fs = new FeatureStruct(); foreach (string symbolID in symbols) { FeatureSymbol symbol = phoneticFeatSys.GetSymbol(symbolID); fs.AddValue(symbol.Feature, new SymbolicFeatureValue(symbol)); } table.AddSegment(strRep, fs); }
private static FeatureStruct LoadFeatureStruct(FeatureSystem featSys, XElement elem) { var fs = new FeatureStruct(); foreach (XElement featureValueElem in elem.Elements(Cog + "FeatureValue")) { var feature = (SymbolicFeature)featSys.GetFeature((string)featureValueElem.Attribute("feature")); fs.AddValue(feature, ((string)featureValueElem.Attribute("value")).Split(' ').Select(featSys.GetSymbol)); } return(fs); }
public override PatternNode<ComplexConcParagraphData, ShapeNode> GeneratePattern(FeatureSystem featSys) { var fs = new FeatureStruct(); var typeFeat = featSys.GetFeature<SymbolicFeature>("type"); fs.AddValue(typeFeat, typeFeat.PossibleSymbols["ttag"]); if (Tag != null) { var tagFeat = featSys.GetFeature<SymbolicFeature>("tag"); fs.AddValue(tagFeat, tagFeat.PossibleSymbols[Tag.Hvo.ToString(CultureInfo.InvariantCulture)]); } return AddQuantifier(new Constraint<ComplexConcParagraphData, ShapeNode>(fs)); }
/// <summary> /// Initializes a new instance of the <see cref="Language"/> class. /// </summary> public Language() { _strata = new ObservableCollection <Stratum>(); _strata.CollectionChanged += StrataChanged; PhonologicalFeatureSystem = new FeatureSystem(); SyntacticFeatureSystem = new SyntacticFeatureSystem(); _naturalClasses = new List <NaturalClass>(); _stemNames = new List <StemName>(); _mprFeatures = new List <MprFeature>(); _mprFeatureGroups = new List <MprFeatureGroup>(); _tables = new List <CharacterDefinitionTable>(); _families = new List <LexFamily>(); _prules = new List <IPhonologicalRule>(); _morphemeCoOccurRules = new List <MorphemeCoOccurrenceRule>(); _allomorphCoOccurRules = new List <AllomorphCoOccurrenceRule>(); }
public void SetUp() { _featSys = new FeatureSystem { new SymbolicFeature("manner", new FeatureSymbol("stop"), new FeatureSymbol("affricate"), new FeatureSymbol("fricative"), new FeatureSymbol("approximant")) }; _project = new CogProject(_spanFactory) { FeatureSystem = _featSys }; _segmentPool = new SegmentPool(); }
public EditNaturalClassViewModel(FeatureSystem featSys, IEnumerable<SoundClass> soundClasses, NaturalClass naturalClass) : base("Edit Feature-based Class", soundClasses, naturalClass) { _type = naturalClass.Type == CogFeatureSystem.ConsonantType ? SoundType.Consonant : SoundType.Vowel; _availableFeatures = new BindableList<FeatureViewModel>(); _activeFeatures = new BindableList<FeatureViewModel>(); foreach (SymbolicFeature feature in featSys.OfType<SymbolicFeature>()) { SymbolicFeatureValue sfv; if (naturalClass.FeatureStruct.TryGetValue(feature, out sfv)) _activeFeatures.Add(new FeatureViewModel(feature, (FeatureSymbol) sfv)); else _availableFeatures.Add(new FeatureViewModel(feature)); } _addCommand = new RelayCommand(AddFeature, CanAddFeature); _removeCommand = new RelayCommand(RemoveFeature, CanRemoveFeature); }
internal static SoundClass LoadSoundClass(Segmenter segmenter, FeatureSystem featSys, XElement elem) { var name = (string)elem.Attribute("name"); if (elem.Name == Cog + "NaturalClass") { FeatureStruct fs = LoadFeatureStruct(featSys, elem); fs.AddValue(CogFeatureSystem.Type, ((string)elem.Attribute("type")) == "vowel" ? CogFeatureSystem.VowelType : CogFeatureSystem.ConsonantType); return(new NaturalClass(name, fs)); } if (elem.Name == Cog + "UnnaturalClass") { IEnumerable <string> segments = elem.Elements(Cog + "Segment").Select(segElem => (string)segElem); var ignoreModifiers = (bool?)elem.Attribute("ignoreModifiers") ?? false; return(new UnnaturalClass(name, segments, ignoreModifiers, segmenter)); } return(null); }
public override PatternNode<ComplexConcParagraphData, ShapeNode> GeneratePattern(FeatureSystem featSys) { var group = new Group<ComplexConcParagraphData, ShapeNode>(); Alternation<ComplexConcParagraphData, ShapeNode> alternation = null; bool inAlternation = false; foreach (ComplexConcPatternNode child in Children) { if (child is ComplexConcOrNode) { if (alternation == null) { alternation = new Alternation<ComplexConcParagraphData, ShapeNode>(); alternation.Children.Add(group.Children.Last); } inAlternation = true; } else { if (!inAlternation && alternation != null) { group.Children.Add(alternation); alternation = null; } PatternNode<ComplexConcParagraphData, ShapeNode> newNode = child.GeneratePattern(featSys); if (inAlternation) { alternation.Children.Add(newNode); inAlternation = false; } else { group.Children.Add(newNode); } } } if (alternation != null) group.Children.Add(alternation.Children.Count == 1 ? alternation.Children.First : alternation); return AddQuantifier(group); }
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(); }
public EditNaturalClassViewModel(FeatureSystem featSys, IEnumerable <SoundClass> soundClasses, NaturalClass naturalClass) : base("Edit Feature-based Class", soundClasses, naturalClass) { _type = naturalClass.Type == CogFeatureSystem.ConsonantType ? SoundType.Consonant : SoundType.Vowel; _availableFeatures = new BindableList <FeatureViewModel>(); _activeFeatures = new BindableList <FeatureViewModel>(); foreach (SymbolicFeature feature in featSys.OfType <SymbolicFeature>()) { SymbolicFeatureValue sfv; if (naturalClass.FeatureStruct.TryGetValue(feature, out sfv)) { _activeFeatures.Add(new FeatureViewModel(feature, (FeatureSymbol)sfv)); } else { _availableFeatures.Add(new FeatureViewModel(feature)); } } _addCommand = new RelayCommand(AddFeature, CanAddFeature); _removeCommand = new RelayCommand(RemoveFeature, CanRemoveFeature); }
protected FeatureStruct GetFeatureStruct(FeatureSystem featSys, IDictionary <IFsFeatDefn, object> values) { var fs = new FeatureStruct(); foreach (KeyValuePair <IFsFeatDefn, object> kvp in values) { if (kvp.Key is IFsComplexFeature) { var childValues = (IDictionary <IFsFeatDefn, object>)kvp.Value; fs.AddValue(featSys.GetFeature(kvp.Key.Hvo.ToString(CultureInfo.InvariantCulture)), GetFeatureStruct(featSys, childValues)); } else if (kvp.Key is IFsClosedFeature) { var value = (ClosedFeatureValue)kvp.Value; var symFeat = featSys.GetFeature <SymbolicFeature>(kvp.Key.Hvo.ToString(CultureInfo.InvariantCulture)); FeatureSymbol symbol = symFeat.PossibleSymbols[value.Symbol.Hvo.ToString(CultureInfo.InvariantCulture)]; fs.AddValue(symFeat, value.Negate ? new SymbolicFeatureValue(symFeat.PossibleSymbols.Except(symbol.ToEnumerable())) : new SymbolicFeatureValue(symbol)); } } return(fs); }
public ComplexConcParagraphData(SpanFactory <ShapeNode> spanFactory, FeatureSystem featSys, IStTxtPara para) { m_para = para; m_shape = new Shape(spanFactory, begin => new ShapeNode(spanFactory, FeatureStruct.New(featSys).Symbol("bdry").Symbol("paraBdry").Value)); if (!GenerateShape(spanFactory, featSys)) { // if there are any analyses that are out-of-sync with the baseline, we force a parse // and try again, somehow this can happen even though we have already parsed all // paragraphs that is out-of-date NonUndoableUnitOfWorkHelper.DoSomehow(m_para.Cache.ActionHandlerAccessor, () => { using (var pp = new ParagraphParser(m_para.Cache)) { pp.ForceParse(m_para); } }); m_shape.Clear(); if (!GenerateShape(spanFactory, featSys)) { throw new InvalidOperationException("A paragraph cannot be parsed properly."); } } }
public void Determinize() { var featSys = new FeatureSystem { new StringFeature("A"), new StringFeature("B"), new StringFeature("C"), new StringFeature("D"), new StringFeature("E"), new StringFeature("F") }; var nfst = new Fst <StringData, int>(_operations); nfst.StartState = nfst.CreateState(); State <StringData, int> s1 = nfst.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("C").EqualTo("true").Value, nfst.CreateState()); State <StringData, int> sa = s1.Arcs.Add(FeatureStruct.New(featSys).Feature("D").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("E").EqualTo("true").Value, nfst.CreateAcceptingState()); State <StringData, int> s2 = nfst.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("B").EqualTo("true").Value, nfst.CreateState()); State <StringData, int> s3 = s2.Arcs.Add(FeatureStruct.New(featSys).Value, FeatureStruct.New(featSys).Value, nfst.CreateState()); s3.Arcs.Add(FeatureStruct.New(featSys).Feature("B").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("B").EqualTo("true").Value, sa); var writer = new System.IO.StreamWriter(string.Format("c:\\ltor-nfst.dot")); nfst.ToGraphViz(writer); writer.Close(); Fst <StringData, int> dfst; Assert.That(nfst.TryDeterminize(out dfst), Is.True); writer = new System.IO.StreamWriter(string.Format("c:\\ltor-dfst.dot")); dfst.ToGraphViz(writer); writer.Close(); }
public override PatternNode<ComplexConcParagraphData, ShapeNode> GeneratePattern(FeatureSystem featSys) { var fs = new FeatureStruct(); var typeFeat = featSys.GetFeature<SymbolicFeature>("type"); fs.AddValue(typeFeat, typeFeat.PossibleSymbols["morph"]); AddStringValue(featSys, fs, Form, "form"); AddStringValue(featSys, fs, Gloss, "gloss"); AddStringValue(featSys, fs, Entry, "entry"); if (Category != null) { var catFeat = featSys.GetFeature<SymbolicFeature>("cat"); IEnumerable<FeatureSymbol> symbols = Category.ReallyReallyAllPossibilities.Concat(Category).Select(pos => catFeat.PossibleSymbols[pos.Hvo.ToString(CultureInfo.InvariantCulture)]); if (NegateCategory) symbols = catFeat.PossibleSymbols.Except(symbols); fs.AddValue(catFeat, symbols); } if (m_inflFeatures.Count > 0) { var inflFeat = featSys.GetFeature<ComplexFeature>("infl"); fs.AddValue(inflFeat, GetFeatureStruct(featSys, m_inflFeatures)); } return AddQuantifier(new Constraint<ComplexConcParagraphData, ShapeNode>(fs)); }
public void Determinize() { var featSys = new FeatureSystem { new StringFeature("A"), new StringFeature("B"), new StringFeature("C"), new StringFeature("D"), new StringFeature("E"), new StringFeature("F") }; var nfst = new Fst<AnnotatedStringData, int>(_operations); nfst.StartState = nfst.CreateState(); State<AnnotatedStringData, int> s1 = nfst.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("C").EqualTo("true").Value, nfst.CreateState()); State<AnnotatedStringData, int> sa = s1.Arcs.Add(FeatureStruct.New(featSys).Feature("D").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("E").EqualTo("true").Value, nfst.CreateAcceptingState()); State<AnnotatedStringData, int> s2 = nfst.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("B").EqualTo("true").Value, nfst.CreateState()); State<AnnotatedStringData, int> s3 = s2.Arcs.Add(FeatureStruct.New(featSys).Value, FeatureStruct.New(featSys).Value, nfst.CreateState()); s3.Arcs.Add(FeatureStruct.New(featSys).Feature("B").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("B").EqualTo("true").Value, sa); Fst<AnnotatedStringData, int> dfst; Assert.That(nfst.TryDeterminize(out dfst), Is.True); }
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("palatal"), new FeatureSymbol("velar"), new FeatureSymbol("uvular"), new FeatureSymbol("pharyngeal"), new FeatureSymbol("glottal")), new SymbolicFeature("manner", new FeatureSymbol("stop"), new FeatureSymbol("affricate"), new FeatureSymbol("fricative"), new FeatureSymbol("approximant"), new FeatureSymbol("trill"), new FeatureSymbol("flap"), new FeatureSymbol("close-vowel"), new FeatureSymbol("mid-vowel"), new FeatureSymbol("open-vowel")), new SymbolicFeature("voice", new FeatureSymbol("voice+"), new FeatureSymbol("voice-")), new SymbolicFeature("height", new FeatureSymbol("close"), new FeatureSymbol("near-close"), new FeatureSymbol("close-mid"), new FeatureSymbol("mid"), new FeatureSymbol("open-mid"), new FeatureSymbol("near-open"), new FeatureSymbol("open")), new SymbolicFeature("backness", new FeatureSymbol("front"), new FeatureSymbol("near-front"), new FeatureSymbol("central"), new FeatureSymbol("near-back"), new FeatureSymbol("back")), new SymbolicFeature("round", new FeatureSymbol("round+"), new FeatureSymbol("round-")) }; _segmentPool = new SegmentPool(); _segmenter = new Segmenter(_spanFactory) { Consonants = { {"c", FeatureStruct.New(_featSys).Symbol("palatal").Symbol("stop").Symbol("voice-").Value}, {"b", FeatureStruct.New(_featSys).Symbol("bilabial").Symbol("stop").Symbol("voice+").Value}, {"r", FeatureStruct.New(_featSys).Symbol("alveolar").Symbol("trill").Symbol("voice+").Value} }, Vowels = { {"a", FeatureStruct.New(_featSys).Symbol("open").Symbol("front").Symbol("round-").Symbol("open-vowel").Symbol("voice+").Value} }, Boundaries = {"-"}, Modifiers = {"\u0303", "\u0308"}, Joiners = {"\u0361"} }; var syllabifier = new SimpleSyllabifier(false, false); var meaning = new Meaning("test", null); var v1 = new Variety("variety1"); _word1 = new Word("car", meaning); _segmenter.Segment(_word1); v1.Words.Add(_word1); syllabifier.Process(v1); var v2 = new Variety("variety2"); _word2 = new Word("bar", meaning); _segmenter.Segment(_word2); v2.Words.Add(_word2); syllabifier.Process(v2); var vp = new VarietyPair(v1, v2); vp.SoundChangeFrequencyDistribution = new ConditionalFrequencyDistribution<SoundContext, Ngram<Segment>>(); vp.SoundChangeFrequencyDistribution[_word1.Shape.First.ToSoundContext(_segmentPool, Enumerable.Empty<SoundClass>())].Increment(_segmentPool.Get(_word2.Shape.First)); vp.SoundChangeProbabilityDistribution = new ConditionalProbabilityDistribution<SoundContext, Ngram<Segment>>(vp.SoundChangeFrequencyDistribution, (sc, fd) => new MaxLikelihoodProbabilityDistribution<Ngram<Segment>>(fd)); v1.VarietyPairs.VarietyPairAdded(vp); v2.VarietyPairs.VarietyPairAdded(vp); }
private bool GenerateShape(SpanFactory <ShapeNode> spanFactory, FeatureSystem featSys) { m_shape.Add(FeatureStruct.New(featSys).Symbol("bdry").Symbol("wordBdry").Value); var typeFeat = featSys.GetFeature <SymbolicFeature>("type"); var catFeat = featSys.GetFeature <SymbolicFeature>("cat"); var inflFeat = featSys.GetFeature <ComplexFeature>("infl"); var segments = new Dictionary <ISegment, List <Annotation <ShapeNode> > >(); foreach (ISegment segment in m_para.SegmentsOS) { var annotations = new List <Annotation <ShapeNode> >(); foreach (Tuple <IAnalysis, int, int> analysis in segment.GetAnalysesAndOffsets()) { // check if analyses are out-of-sync with the baseline ITsString baselineStr = m_para.Contents.GetSubstring(analysis.Item2, analysis.Item3); ITsString formStr = analysis.Item1.GetForm(baselineStr.get_WritingSystemAt(0)); if (!baselineStr.Text.Equals(formStr.Text, StringComparison.InvariantCultureIgnoreCase)) { return(false); } var wordform = analysis.Item1 as IWfiWordform; if (wordform != null) { var wordFS = new FeatureStruct(); wordFS.AddValue(typeFeat, typeFeat.PossibleSymbols["word"]); foreach (int ws in wordform.Form.AvailableWritingSystemIds) { StringFeature strFeat; if (featSys.TryGetFeature(string.Format("form-{0}", ws), out strFeat)) { wordFS.AddValue(strFeat, wordform.Form.get_String(ws).Text); } } ShapeNode node = m_shape.Add(wordFS); node.Annotation.Data = analysis; annotations.Add(node.Annotation); } else { if (analysis.Item1 is IPunctuationForm) { annotations.Add(null); continue; } FeatureStruct wordInflFS = null; IWfiAnalysis wanalysis = analysis.Item1.Analysis; ShapeNode analysisStart = null; foreach (IWfiMorphBundle mb in wanalysis.MorphBundlesOS) { var morphFS = new FeatureStruct(); morphFS.AddValue(typeFeat, typeFeat.PossibleSymbols["morph"]); foreach (int ws in mb.Form.AvailableWritingSystemIds.Union(mb.MorphRA == null ? Enumerable.Empty <int>() : mb.MorphRA.Form.AvailableWritingSystemIds)) { StringFeature strFeat; if (!featSys.TryGetFeature(string.Format("form-{0}", ws), out strFeat)) { continue; } IEnumerable <string> forms = Enumerable.Empty <string>(); ITsString mbForm = mb.Form.StringOrNull(ws); if (mbForm != null) { forms = forms.Concat(mbForm.Text); } if (mb.MorphRA != null) { ITsString morphForm = mb.MorphRA.Form.StringOrNull(ws); if (morphForm != null) { forms = forms.Concat(morphForm.Text); } } morphFS.AddValue(strFeat, forms.Distinct()); } if (mb.SenseRA != null) { foreach (int ws in mb.SenseRA.Gloss.AvailableWritingSystemIds) { StringFeature strFeat; if (featSys.TryGetFeature(string.Format("gloss-{0}", ws), out strFeat)) { morphFS.AddValue(strFeat, mb.SenseRA.Gloss.get_String(ws).Text); } } } if (mb.MorphRA != null) { var entry = (ILexEntry)mb.MorphRA.Owner; foreach (int ws in entry.LexemeFormOA.Form.AvailableWritingSystemIds) { StringFeature strFeat; if (featSys.TryGetFeature(string.Format("entry-{0}", ws), out strFeat)) { morphFS.AddValue(strFeat, entry.LexemeFormOA.Form.get_String(ws).Text); } } } if (mb.MsaRA != null && mb.MsaRA.ComponentsRS != null) { FeatureSymbol[] catSymbols = GetHvoOfMsaPartOfSpeech(mb.MsaRA).Select(hvo => catFeat.PossibleSymbols[hvo.ToString(CultureInfo.InvariantCulture)]).ToArray(); if (catSymbols.Length > 0) { morphFS.AddValue(catFeat, catSymbols); } var inflFS = GetFeatureStruct(featSys, mb.MsaRA); if (inflFS != null) { morphFS.AddValue(inflFeat, inflFS); if (wordInflFS == null) { wordInflFS = inflFS.DeepClone(); } else { wordInflFS.Union(inflFS); } } } ShapeNode node = m_shape.Add(morphFS); if (analysisStart == null) { analysisStart = node; } } var wordFS = new FeatureStruct(); wordFS.AddValue(typeFeat, typeFeat.PossibleSymbols["word"]); if (wanalysis.CategoryRA != null) { wordFS.AddValue(catFeat, catFeat.PossibleSymbols[wanalysis.CategoryRA.Hvo.ToString(CultureInfo.InvariantCulture)]); } if (wordInflFS != null && !wordInflFS.IsEmpty) { wordFS.AddValue(inflFeat, wordInflFS); } wordform = wanalysis.Wordform; foreach (int ws in wordform.Form.AvailableWritingSystemIds) { StringFeature strFeat; if (featSys.TryGetFeature(string.Format("form-{0}", ws), out strFeat)) { wordFS.AddValue(strFeat, wordform.Form.get_String(ws).Text); } } var gloss = analysis.Item1 as IWfiGloss; if (gloss != null) { foreach (int ws in gloss.Form.AvailableWritingSystemIds) { StringFeature strFeat; if (featSys.TryGetFeature(string.Format("gloss-{0}", ws), out strFeat)) { wordFS.AddValue(strFeat, gloss.Form.get_String(ws).Text); } } } Annotation <ShapeNode> ann; if (analysisStart != null) { ann = m_shape.Annotations.Add(analysisStart, m_shape.Last, wordFS); m_shape.Add(FeatureStruct.New(featSys).Symbol("bdry").Symbol("wordBdry").Value); } else { ShapeNode node = m_shape.Add(wordFS); ann = node.Annotation; } ann.Data = analysis; annotations.Add(ann); } } segments[segment] = annotations; m_shape.Add(FeatureStruct.New(featSys).Symbol("bdry").Symbol("segBdry").Value); } foreach (ITextTag tag in m_para.OwnerOfClass <IStText>().TagsOC) { // skip invalid tags // TODO: should these tags be cleaned up somewhere? if (tag.BeginAnalysisIndex >= tag.BeginSegmentRA.AnalysesRS.Count || tag.EndAnalysisIndex >= tag.EndSegmentRA.AnalysesRS.Count || tag.BeginAnalysisIndex > tag.EndAnalysisIndex) { continue; } List <Annotation <ShapeNode> > beginSegment, endSegment; if (!segments.TryGetValue(tag.BeginSegmentRA, out beginSegment) || !segments.TryGetValue(tag.EndSegmentRA, out endSegment)) { continue; } Annotation <ShapeNode> beginAnnotation = beginSegment[tag.BeginAnalysisIndex]; Annotation <ShapeNode> endAnnotation = endSegment[tag.EndAnalysisIndex]; ICmPossibility tagType = tag.TagRA; if (tagType == null || beginAnnotation == null || endAnnotation == null) { continue; // guard against LT-14549 crash } Annotation <ShapeNode> tagAnn = new Annotation <ShapeNode>(spanFactory.Create(beginAnnotation.Span.Start, endAnnotation.Span.End), FeatureStruct.New(featSys).Symbol("ttag").Symbol(tagType.Hvo.ToString(CultureInfo.InvariantCulture)).Value) { Data = tag }; m_shape.Annotations.Add(tagAnn, false); } return(true); }
protected FeatureStruct GetFeatureStruct(FeatureSystem featSys, IDictionary<IFsFeatDefn, object> values) { var fs = new FeatureStruct(); foreach (KeyValuePair<IFsFeatDefn, object> kvp in values) { if (kvp.Key is IFsComplexFeature) { var childValues = (IDictionary<IFsFeatDefn, object>) kvp.Value; fs.AddValue(featSys.GetFeature(kvp.Key.Hvo.ToString(CultureInfo.InvariantCulture)), GetFeatureStruct(featSys, childValues)); } else if (kvp.Key is IFsClosedFeature) { var value = (ClosedFeatureValue) kvp.Value; var symFeat = featSys.GetFeature<SymbolicFeature>(kvp.Key.Hvo.ToString(CultureInfo.InvariantCulture)); FeatureSymbol symbol = symFeat.PossibleSymbols[value.Symbol.Hvo.ToString(CultureInfo.InvariantCulture)]; fs.AddValue(symFeat, value.Negate ? new SymbolicFeatureValue(symFeat.PossibleSymbols.Except(symbol.ToEnumerable())) : new SymbolicFeatureValue(symbol)); } } return fs; }
public abstract PatternNode<ComplexConcParagraphData, ShapeNode> GeneratePattern(FeatureSystem featSys);
public virtual void FixtureSetUp() { SpanFactory = new IntegerSpanFactory(); PhoneticFeatSys = new FeatureSystem { new SymbolicFeature("son", new FeatureSymbol("son+", "+"), new FeatureSymbol("son-", "-"), new FeatureSymbol("son?", "?")) { DefaultSymbolID = "son?" }, new SymbolicFeature("syl", new FeatureSymbol("syl+", "+"), new FeatureSymbol("syl-", "-"), new FeatureSymbol("syl?", "?")) { DefaultSymbolID = "syl?" }, new SymbolicFeature("cons", new FeatureSymbol("cons+", "+"), new FeatureSymbol("cons-", "-"), new FeatureSymbol("cons?", "?")) { DefaultSymbolID = "cons?" }, new SymbolicFeature("high", new FeatureSymbol("high+", "+"), new FeatureSymbol("high-", "-"), new FeatureSymbol("high?", "?")) { DefaultSymbolID = "high?" }, new SymbolicFeature("back", new FeatureSymbol("back+", "+"), new FeatureSymbol("back-", "-"), new FeatureSymbol("back?", "?")) { DefaultSymbolID = "back?" }, new SymbolicFeature("front", new FeatureSymbol("front+", "+"), new FeatureSymbol("front-", "-"), new FeatureSymbol("front?", "?")) { DefaultSymbolID = "front?" }, new SymbolicFeature("low", new FeatureSymbol("low+", "+"), new FeatureSymbol("low-", "-"), new FeatureSymbol("low?", "?")) { DefaultSymbolID = "low?" }, new SymbolicFeature("rnd", new FeatureSymbol("rnd+", "+"), new FeatureSymbol("rnd-", "-"), new FeatureSymbol("rnd?", "?")) { DefaultSymbolID = "rnd?" }, new SymbolicFeature("ant", new FeatureSymbol("ant+", "+"), new FeatureSymbol("ant-", "-"), new FeatureSymbol("ant?", "?")) { DefaultSymbolID = "ant?" }, new SymbolicFeature("cor", new FeatureSymbol("cor+", "+"), new FeatureSymbol("cor-", "-"), new FeatureSymbol("cor?", "?")) { DefaultSymbolID = "cor?" }, new SymbolicFeature("voice", new FeatureSymbol("voice+", "+"), new FeatureSymbol("voice-", "-"), new FeatureSymbol("voice?", "?")) { DefaultSymbolID = "voice?" }, new SymbolicFeature("cont", new FeatureSymbol("cont+", "+"), new FeatureSymbol("cont-", "-"), new FeatureSymbol("cont?", "?")) { DefaultSymbolID = "cont?" }, new SymbolicFeature("nas", new FeatureSymbol("nas+", "+"), new FeatureSymbol("nas-", "-"), new FeatureSymbol("nas?", "?")) { DefaultSymbolID = "nas?" }, new SymbolicFeature("str", new FeatureSymbol("str+", "+"), new FeatureSymbol("str-", "-"), new FeatureSymbol("str?", "?")) { DefaultSymbolID = "str?" }, new StringFeature("strRep") }; WordFeatSys = new FeatureSystem { new SymbolicFeature("POS", new FeatureSymbol("noun"), new FeatureSymbol("verb"), new FeatureSymbol("adj"), new FeatureSymbol("adv"), new FeatureSymbol("det")) }; Word = new FeatureSymbol("Word"); NP = new FeatureSymbol("NP"); VP = new FeatureSymbol("VP"); Seg = new FeatureSymbol("Seg"); Bdry = new FeatureSymbol("Bdry"); Allo = new FeatureSymbol("Allo"); Type = new SymbolicFeature("Type", Word, NP, VP, Seg, Bdry, Allo); TypeFeatSys = new FeatureSystem { Type }; Characters = new Dictionary <char, FeatureStruct> { { 'b', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor-") .Symbol("voice+") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value }, { 'd', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor+") .Symbol("voice+") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value }, { 'g', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high+") .Symbol("ant-") .Symbol("cor-") .Symbol("voice+") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value }, { 'p', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor-") .Symbol("voice-") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value }, { 't', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor+") .Symbol("voice-") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value }, { 'q', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high+") .Symbol("ant-") .Symbol("cor-") .Symbol("voice-") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value }, { 'c', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high+") .Symbol("ant-") .Symbol("cor-") .Symbol("voice-") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value }, { 'k', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high+") .Symbol("ant-") .Symbol("cor-") .Symbol("voice-") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value }, { 'x', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high+") .Symbol("ant-") .Symbol("cor-") .Symbol("voice-") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value }, { 'j', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high+") .Symbol("ant-") .Symbol("cor+") .Symbol("voice+") .Symbol("cont-") .Symbol("nas-") .Symbol("str+").Value }, { 's', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor+") .Symbol("voice-") .Symbol("cont+") .Symbol("nas-") .Symbol("str+").Value }, { 'z', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor+") .Symbol("voice+") .Symbol("cont+") .Symbol("nas-") .Symbol("str+").Value }, { 'f', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor-") .Symbol("voice-") .Symbol("cont+") .Symbol("nas-") .Symbol("str+").Value }, { 'v', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor-") .Symbol("voice+") .Symbol("cont+") .Symbol("nas-") .Symbol("str+").Value }, { 'w', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons-") .Symbol("high+") .Symbol("back+") .Symbol("front-") .Symbol("low-") .Symbol("rnd+") .Symbol("ant-") .Symbol("cor-").Value }, { 'y', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons-") .Symbol("high+") .Symbol("back-") .Symbol("front+") .Symbol("low-") .Symbol("rnd-") .Symbol("ant-") .Symbol("cor-").Value }, { 'h', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons-") .Symbol("high-") .Symbol("back-") .Symbol("front-") .Symbol("low+") .Symbol("ant-") .Symbol("cor-") .Symbol("voice-") .Symbol("cont+") .Symbol("nas-") .Symbol("str-").Value }, { 'r', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("back-") .Symbol("front-") .Symbol("low-") .Symbol("ant-") .Symbol("cor+") .Symbol("voice+") .Symbol("cont+") .Symbol("nas-") .Symbol("str-").Value }, { 'l', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("back-") .Symbol("front-") .Symbol("low-") .Symbol("ant+") .Symbol("cor+") .Symbol("voice+") .Symbol("cont+") .Symbol("nas-") .Symbol("str-").Value }, { 'm', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("low-") .Symbol("ant+") .Symbol("cor-") .Symbol("voice+") .Symbol("cont-") .Symbol("nas+") .Symbol("str-").Value }, { 'n', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("low-") .Symbol("ant+") .Symbol("cor+") .Symbol("voice+") .Symbol("cont-") .Symbol("nas+") .Symbol("str-").Value }, { 'N', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("low-") .Symbol("ant+") .Symbol("cor?") .Symbol("voice+") .Symbol("cont-") .Symbol("nas+") .Symbol("str-").Value }, { 'a', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl+") .Symbol("cons-") .Symbol("high-") .Symbol("back-") .Symbol("front+") .Symbol("low+") .Symbol("rnd-").Value }, { 'e', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl+") .Symbol("cons-") .Symbol("high-") .Symbol("back-") .Symbol("front+") .Symbol("low-") .Symbol("rnd-").Value }, { 'i', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl+") .Symbol("cons-") .Symbol("high+") .Symbol("back-") .Symbol("front+") .Symbol("low-") .Symbol("rnd-").Value }, { 'o', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl+") .Symbol("cons-") .Symbol("high-") .Symbol("back+") .Symbol("front-") .Symbol("low+") .Symbol("rnd-").Value }, { 'u', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl+") .Symbol("cons-") .Symbol("high+") .Symbol("back+") .Symbol("front-") .Symbol("low-") .Symbol("rnd+").Value }, { '+', FeatureStruct.New(PhoneticFeatSys) .Symbol(Bdry) .Feature("strRep").EqualTo("+").Value }, { ',', FeatureStruct.New(PhoneticFeatSys) .Symbol(Bdry) .Feature("strRep").EqualTo(",").Value }, { ' ', FeatureStruct.New(PhoneticFeatSys) .Symbol(Bdry) .Feature("strRep").EqualTo(" ").Value }, { '.', FeatureStruct.New(PhoneticFeatSys) .Symbol(Bdry) .Feature("strRep").EqualTo(".").Value } }; }
public FeatureStructBuilder(FeatureSystem featSys, FeatureStruct fs) : this(featSys, fs, false) { }
public FeatureStructBuilder(FeatureSystem featSys, FeatureStruct fs, bool mutable) : this(featSys, fs, new Dictionary<int, FeatureValue>(), mutable) { }
public void FixtureSetUp() { SpanFactory = new ShapeSpanFactory(); TraceManager = new TraceManager(); var phonologicalFeatSys = new FeatureSystem { new SymbolicFeature("voc", new FeatureSymbol("voc+", "+"), new FeatureSymbol("voc-", "-")), new SymbolicFeature("cons", new FeatureSymbol("cons+", "+"), new FeatureSymbol("cons-", "-")), new SymbolicFeature("high", new FeatureSymbol("high+", "+"), new FeatureSymbol("high-", "-")), new SymbolicFeature("low", new FeatureSymbol("low+", "+"), new FeatureSymbol("low-", "-")), new SymbolicFeature("back", new FeatureSymbol("back+", "+"), new FeatureSymbol("back-", "-")), new SymbolicFeature("round", new FeatureSymbol("round+", "+"), new FeatureSymbol("round-", "-")), new SymbolicFeature("vd", new FeatureSymbol("vd+", "+"), new FeatureSymbol("vd-", "-")), new SymbolicFeature("asp", new FeatureSymbol("asp+", "+"), new FeatureSymbol("asp-", "-")), new SymbolicFeature("del_rel", new FeatureSymbol("del_rel+", "+"), new FeatureSymbol("del_rel-", "-")), new SymbolicFeature("ATR", new FeatureSymbol("ATR+", "+"), new FeatureSymbol("ATR-", "-")), new SymbolicFeature("strident", new FeatureSymbol("strident+", "+"), new FeatureSymbol("strident-", "-")), new SymbolicFeature("cont", new FeatureSymbol("cont+", "+"), new FeatureSymbol("cont-", "-")), new SymbolicFeature("nasal", new FeatureSymbol("nasal+", "+"), new FeatureSymbol("nasal-", "-")), new SymbolicFeature("poa", new FeatureSymbol("bilabial"), new FeatureSymbol("labiodental"), new FeatureSymbol("alveolar"), new FeatureSymbol("velar")) }; phonologicalFeatSys.Freeze(); var syntacticFeatSys = new SyntacticFeatureSystem { new SymbolicFeature("foo", new FeatureSymbol("foo+", "+"), new FeatureSymbol("foo-", "-")), new SymbolicFeature("baz", new FeatureSymbol("baz+", "+"), new FeatureSymbol("baz-", "-")), new SymbolicFeature("num", new FeatureSymbol("sg"), new FeatureSymbol("pl")), new SymbolicFeature("pers", new FeatureSymbol("1"), new FeatureSymbol("2"), new FeatureSymbol("3"), new FeatureSymbol("4")), new SymbolicFeature("tense", new FeatureSymbol("past"), new FeatureSymbol("pres")), new SymbolicFeature("evidential", new FeatureSymbol("witnessed")), new SymbolicFeature("aspect", new FeatureSymbol("perf"), new FeatureSymbol("impf")), new SymbolicFeature("mood", new FeatureSymbol("active"), new FeatureSymbol("passive")), new SymbolicFeature("fum", new FeatureSymbol("fum+", "+"), new FeatureSymbol("fum-", "-")), new SymbolicFeature("bar", new FeatureSymbol("bar+", "+"), new FeatureSymbol("bar-", "-")) }; syntacticFeatSys.AddPartsOfSpeech(new FeatureSymbol("N", "Noun"), new FeatureSymbol("V", "Verb"), new FeatureSymbol("TV", "Transitive Verb"), new FeatureSymbol("IV", "Intransitive Verb"), new FeatureSymbol("A", "Adjective")); Head = syntacticFeatSys.AddHeadFeature(); Foot = syntacticFeatSys.AddFootFeature(); syntacticFeatSys.Freeze(); Table1 = new CharacterDefinitionTable(SpanFactory) { Name = "table1" }; AddSegDef(Table1, phonologicalFeatSys, "a", "cons-", "voc+", "high-", "low+", "back+", "round-", "vd+"); AddSegDef(Table1, phonologicalFeatSys, "i", "cons-", "voc+", "high+", "low-", "back-", "round-", "vd+"); AddSegDef(Table1, phonologicalFeatSys, "u", "cons-", "voc+", "high+", "low-", "back+", "round+", "vd+"); AddSegDef(Table1, phonologicalFeatSys, "o", "cons-", "voc+", "high-", "low-", "back+", "round+", "vd+"); AddSegDef(Table1, phonologicalFeatSys, "y", "cons-", "voc+", "high+", "low-", "back-", "round+", "vd+"); AddSegDef(Table1, phonologicalFeatSys, "ɯ", "cons-", "voc+", "high+", "low-", "back+", "round-", "vd+"); AddSegDef(Table1, phonologicalFeatSys, "p", "cons+", "voc-", "bilabial", "vd-", "asp-", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "t", "cons+", "voc-", "alveolar", "vd-", "asp-", "del_rel-", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "k", "cons+", "voc-", "velar", "vd-", "asp-", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "ts", "cons+", "voc-", "alveolar", "vd-", "asp-", "del_rel+", "strident+", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "pʰ", "cons+", "voc-", "bilabial", "vd-", "asp+", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "tʰ", "cons+", "voc-", "alveolar", "vd-", "asp+", "del_rel-", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "kʰ", "cons+", "voc-", "velar", "vd-", "asp+", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "tsʰ", "cons+", "voc-", "alveolar", "vd-", "asp+", "del_rel+", "strident+", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "b", "cons+", "voc-", "bilabial", "vd+", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "d", "cons+", "voc-", "alveolar", "vd+", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "g", "cons+", "voc-", "velar", "vd+", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "m", "cons+", "voc-", "bilabial", "vd+", "cont-", "nasal+"); AddSegDef(Table1, phonologicalFeatSys, "n", "cons+", "voc-", "alveolar", "vd+", "strident-", "cont-", "nasal+"); AddSegDef(Table1, phonologicalFeatSys, "ŋ", "cons+", "voc-", "velar", "vd+", "cont-", "nasal+"); AddSegDef(Table1, phonologicalFeatSys, "s", "cons+", "voc-", "alveolar", "vd-", "asp-", "del_rel-", "strident+", "cont+"); AddSegDef(Table1, phonologicalFeatSys, "z", "cons+", "voc-", "alveolar", "vd+", "asp-", "del_rel-", "strident+", "cont+"); AddSegDef(Table1, phonologicalFeatSys, "f", "cons+", "voc-", "labiodental", "vd-", "asp-", "strident+", "cont+"); AddSegDef(Table1, phonologicalFeatSys, "v", "cons+", "voc-", "labiodental", "vd+", "asp-", "strident+", "cont+"); Table2 = new CharacterDefinitionTable(SpanFactory) { Name = "table2" }; AddSegDef(Table2, phonologicalFeatSys, "a", "cons-", "voc+", "high-", "low+", "back+", "round-", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "i", "cons-", "voc+", "high+", "low-", "back-", "round-", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "u", "cons-", "voc+", "high+", "low-", "back+", "round+", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "y", "cons-", "voc+", "high+", "low-", "back-", "round+", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "o", "cons-", "voc+", "high-", "low-", "back+", "round+", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "p", "cons+", "voc-", "bilabial", "vd-"); AddSegDef(Table2, phonologicalFeatSys, "t", "cons+", "voc-", "alveolar", "vd-", "del_rel-", "strident-"); AddSegDef(Table2, phonologicalFeatSys, "k", "cons+", "voc-", "velar", "vd-"); AddSegDef(Table2, phonologicalFeatSys, "ts", "cons+", "voc-", "alveolar", "vd-", "del_rel+", "strident+"); AddSegDef(Table2, phonologicalFeatSys, "b", "cons+", "voc-", "bilabial", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "d", "cons+", "voc-", "alveolar", "vd+", "strident-"); AddSegDef(Table2, phonologicalFeatSys, "g", "cons+", "voc-", "velar", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "m", "cons+", "voc-", "bilabial", "vd+", "cont-", "nasal+"); AddSegDef(Table2, phonologicalFeatSys, "n", "cons+", "voc-", "alveolar", "vd+", "cont-", "nasal+"); AddSegDef(Table2, phonologicalFeatSys, "ŋ", "cons+", "voc-", "velar", "vd+", "cont-", "nasal+"); AddSegDef(Table2, phonologicalFeatSys, "s", "cons+", "voc-", "alveolar", "vd-", "asp-", "del_rel-", "strident+", "cont+"); AddSegDef(Table2, phonologicalFeatSys, "z", "cons+", "voc-", "alveolar", "vd+", "asp-", "del_rel-", "strident+", "cont+"); AddSegDef(Table2, phonologicalFeatSys, "f", "cons+", "voc-", "labiodental", "vd-", "asp-", "strident+", "cont+"); AddSegDef(Table2, phonologicalFeatSys, "v", "cons+", "voc-", "labiodental", "vd+", "asp-", "strident+", "cont+"); AddBdryDef(Table2, "+"); AddBdryDef(Table2, "#"); AddBdryDef(Table2, "!"); AddBdryDef(Table2, "."); AddBdryDef(Table2, "$"); Table3 = new CharacterDefinitionTable(SpanFactory) { Name = "table3" }; AddSegDef(Table3, phonologicalFeatSys, "a", "cons-", "voc+", "high-", "low+", "back+", "round-", "vd+", "ATR+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "a̘", "cons-", "voc+", "high-", "low+", "back+", "round-", "vd+", "ATR-", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "i", "cons-", "voc+", "high+", "low-", "back-", "round-", "vd+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "u", "cons-", "voc+", "high+", "low-", "back+", "round+", "vd+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "y", "cons-", "voc+", "high+", "low-", "back-", "round+", "vd+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "ɯ", "cons-", "voc+", "high+", "low-", "back+", "round-", "vd+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "o", "cons-", "voc+", "high-", "low-", "back+", "round+", "vd+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "p", "cons+", "voc-", "bilabial", "vd-", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "t", "cons+", "voc-", "alveolar", "vd-", "del_rel-", "strident-", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "k", "cons+", "voc-", "velar", "vd-", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "ts", "cons+", "voc-", "alveolar", "vd-", "del_rel+", "strident+", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "b", "cons+", "voc-", "bilabial", "vd+", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "d", "cons+", "voc-", "alveolar", "vd+", "strident-", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "g", "cons+", "voc-", "velar", "vd+", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "m", "cons+", "voc-", "bilabial", "vd+", "cont-", "nasal+"); AddSegDef(Table3, phonologicalFeatSys, "n", "cons+", "voc-", "alveolar", "vd+", "strident-", "cont-", "nasal+"); AddSegDef(Table3, phonologicalFeatSys, "ŋ", "cons+", "voc-", "velar", "vd+", "cont-", "nasal+"); AddSegDef(Table3, phonologicalFeatSys, "s", "cons+", "voc-", "alveolar", "vd-", "asp-", "del_rel-", "strident+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "z", "cons+", "voc-", "alveolar", "vd+", "asp-", "del_rel-", "strident+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "f", "cons+", "voc-", "labiodental", "vd-", "asp-", "strident+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "v", "cons+", "voc-", "labiodental", "vd+", "asp-", "strident+", "cont+"); AddBdryDef(Table3, "+"); AddBdryDef(Table3, "#"); AddBdryDef(Table3, "!"); AddBdryDef(Table3, "."); Latinate = new MprFeature { Name = "latinate" }; Germanic = new MprFeature { Name = "germanic" }; Morphophonemic = new Stratum(Table3) { Name = "Morphophonemic", MorphologicalRuleOrder = MorphologicalRuleOrder.Unordered }; Allophonic = new Stratum(Table1) { Name = "Allophonic", MorphologicalRuleOrder = MorphologicalRuleOrder.Unordered }; Surface = new Stratum(Table1) { Name = "Surface", MorphologicalRuleOrder = MorphologicalRuleOrder.Unordered }; Entries = new Dictionary<string, LexEntry>(); var fs = FeatureStruct.New(syntacticFeatSys) .Symbol("N") .Feature(Head).EqualTo(head => head .Symbol("foo+").Symbol("baz-")) .Feature(Foot).EqualTo(foot => foot .Symbol("fum-").Symbol("bar+")).Value; AddEntry("1", fs, Allophonic, "pʰit"); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("N") .Feature(Head).EqualTo(head => head .Symbol("foo+").Symbol("baz-")) .Feature(Foot).EqualTo(foot => foot .Symbol("fum-").Symbol("bar+")).Value; AddEntry("2", fs, Allophonic, "pit"); AddEntry("5", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "pʰut"); AddEntry("6", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "kʰat"); AddEntry("7", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "kʰut"); AddEntry("8", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "dat"); AddEntry("9", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Allophonic, "dat"); AddEntry("10", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "ga̘p"); AddEntry("11", FeatureStruct.New(syntacticFeatSys).Symbol("A").Value, Morphophonemic, "gab"); AddEntry("12", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "ga+b"); AddEntry("13", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bubabu"); AddEntry("14", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bubabi"); AddEntry("15", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bɯbabu"); AddEntry("16", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bibabi"); AddEntry("17", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bubi"); AddEntry("18", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bibu"); AddEntry("19", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "b+ubu"); AddEntry("20", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bubababi"); AddEntry("21", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bibababu"); AddEntry("22", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bubabababi"); AddEntry("23", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bibabababu"); AddEntry("24", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bubui"); AddEntry("25", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "buibu"); AddEntry("26", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "buibui"); AddEntry("27", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "buiibuii"); AddEntry("28", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "buitibuiti"); AddEntry("29", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "iibubu"); AddEntry("30", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "bu+ib"); AddEntry("31", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "buib"); AddEntry("32", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "sag"); AddEntry("33", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "sas"); AddEntry("34", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "saz"); AddEntry("35", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "sat"); AddEntry("36", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "sasibo"); AddEntry("37", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "sasibut"); AddEntry("38", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "sasibud"); AddEntry("39", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "ab+ba"); AddEntry("40", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "abba"); AddEntry("41", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Allophonic, "pip"); AddEntry("42", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "bubibi"); AddEntry("43", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "bubibu"); AddEntry("44", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "gigigi"); AddEntry("45", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "nbinding"); AddEntry("46", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bupu"); AddEntry("47", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "tag"); AddEntry("48", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "pag"); AddEntry("49", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "ktb"); AddEntry("50", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "suupu"); AddEntry("51", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "miu"); AddEntry("52", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "pu"); AddEntry("53", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "mi"); AddEntry("54", FeatureStruct.New().Value, Morphophonemic, "pi"); AddEntry("55", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "mim+ɯɯ"); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("num").EqualTo("pl")).Value; AddEntry("Perc0", fs, Morphophonemic, "ssag"); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("1") .Feature("num").EqualTo("pl")).Value; AddEntry("Perc1", fs, Morphophonemic, "ssag"); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("3") .Feature("num").EqualTo("pl")).Value; AddEntry("Perc2", fs, Morphophonemic, "ssag"); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("2", "3") .Feature("num").EqualTo("pl")).Value; AddEntry("Perc3", fs, Morphophonemic, "ssag"); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("1", "3") .Feature("num").EqualTo("pl")).Value; AddEntry("Perc4", fs, Morphophonemic, "ssag"); var seeFamily = new LexFamily { Name = "SEE" }; seeFamily.Entries.Add(AddEntry("bl1", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "si")); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("tense").EqualTo("past")).Value; seeFamily.Entries.Add(AddEntry("bl2", fs, Morphophonemic, "sau")); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("tense").EqualTo("pres")).Value; seeFamily.Entries.Add(AddEntry("bl3", fs, Morphophonemic, "sis")); LexEntry entry = AddEntry("pos1", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "ba"); entry.MprFeatures.Add(Latinate); entry = AddEntry("pos2", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "ba"); entry.MprFeatures.Add(Germanic); var vowel = FeatureStruct.New(phonologicalFeatSys).Symbol(HCFeatureSystem.Segment).Symbol("voc+").Value; entry = AddEntry("free", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "tap", "taz", "tas"); entry.Allomorphs[0].Environments.Add(new AllomorphEnvironment(SpanFactory, ConstraintType.Require, null, Pattern<Word, ShapeNode>.New().Annotation(vowel).Value)); entry = AddEntry("disj", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "baz", "bat", "bad", "bas"); var unroundedVowel = FeatureStruct.New(phonologicalFeatSys).Symbol(HCFeatureSystem.Segment).Symbol("voc+").Symbol("round-").Value; entry.Allomorphs[0].Environments.Add(new AllomorphEnvironment(SpanFactory, ConstraintType.Require, null, Pattern<Word, ShapeNode>.New().Annotation(unroundedVowel).Value)); entry.Allomorphs[1].Environments.Add(new AllomorphEnvironment(SpanFactory, ConstraintType.Require, null, Pattern<Word, ShapeNode>.New().Annotation(vowel).Value)); entry.Allomorphs[2].Environments.Add(new AllomorphEnvironment(SpanFactory, ConstraintType.Require, null, Pattern<Word, ShapeNode>.New().Annotation(vowel).Value)); entry = AddEntry("stemname", FeatureStruct.New(syntacticFeatSys).Symbol("V").Feature(Head).EqualTo(head => head.Feature("tense").EqualTo("pres")).Value, Morphophonemic, "san", "sad", "sap"); entry.Allomorphs[1].StemName = new StemName( FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("1")).Value, FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("2")).Value) {Name = "sn1"}; entry.Allomorphs[2].StemName = new StemName( FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("1")).Value, FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("3")).Value) {Name = "sn2"}; AddEntry("synfs", FeatureStruct.New(syntacticFeatSys).Symbol("V").Feature(Head).EqualTo(head => head.Feature("tense").EqualTo("pres")).Value, Morphophonemic, "bag"); entry = AddEntry("bound", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "dag"); entry.PrimaryAllomorph.IsBound = true; Language = new Language { Name = "Test", PhonologicalFeatureSystem = phonologicalFeatSys, SyntacticFeatureSystem = syntacticFeatSys, Strata = { Morphophonemic, Allophonic, Surface } }; }
public abstract PatternNode <ComplexConcParagraphData, ShapeNode> GeneratePattern(FeatureSystem featSys);
public override PatternNode<ComplexConcParagraphData, ShapeNode> GeneratePattern(FeatureSystem featSys) { throw new System.NotImplementedException(); }
public void Compile() { m_featSys = new FeatureSystem { new SymbolicFeature("type", new FeatureSymbol("bdry", "Boundary"), new FeatureSymbol("word", "Word"), new FeatureSymbol("morph", "Morph"), new FeatureSymbol("ttag", "Text Tag")) { Description = "Type" }, new SymbolicFeature("anchorType", new FeatureSymbol("paraBdry", "Paragraph"), new FeatureSymbol("segBdry", "Segment"), new FeatureSymbol("wordBdry", "Word")) }; foreach (CoreWritingSystemDefinition ws in m_cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems) { m_featSys.Add(new StringFeature(string.Format("entry-{0}", ws.Handle)) { Description = string.Format("Entry-{0}", ws.Abbreviation) }); m_featSys.Add(new StringFeature(string.Format("form-{0}", ws.Handle)) { Description = string.Format("Form-{0}", ws.Abbreviation) }); } foreach (CoreWritingSystemDefinition ws in m_cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems) { m_featSys.Add(new StringFeature(string.Format("gloss-{0}", ws.Handle)) { Description = string.Format("Gloss-{0}", ws.Abbreviation) }); } m_featSys.Add(new SymbolicFeature("cat", m_cache.ServiceLocator.GetInstance <IPartOfSpeechRepository>().AllInstances() .Select(pos => new FeatureSymbol(pos.Hvo.ToString(CultureInfo.InvariantCulture), pos.Abbreviation.BestAnalysisAlternative.Text))) { Description = "Category" }); m_featSys.Add(new SymbolicFeature("tag", m_cache.LangProject.TextMarkupTagsOA.PossibilitiesOS .SelectMany(poss => poss.SubPossibilitiesOS, (category, tag) => new FeatureSymbol(tag.Hvo.ToString(CultureInfo.InvariantCulture), tag.Abbreviation.BestAnalysisAlternative.Text))) { Description = "Tag" }); m_featSys.Add(new ComplexFeature("infl") { Description = "Infl", DefaultValue = FeatureStruct.New().Value }); foreach (IFsFeatDefn feature in m_cache.LangProject.MsFeatureSystemOA.FeaturesOC) { var complexFeat = feature as IFsComplexFeature; if (complexFeat != null) { m_featSys.Add(new ComplexFeature(complexFeat.Hvo.ToString(CultureInfo.InvariantCulture)) { Description = complexFeat.Abbreviation.BestAnalysisAlternative.Text, DefaultValue = FeatureStruct.New().Value }); } else { var closedFeat = (IFsClosedFeature)feature; m_featSys.Add(new SymbolicFeature(closedFeat.Hvo.ToString(CultureInfo.InvariantCulture), closedFeat.ValuesOC.Select(sym => new FeatureSymbol(sym.Hvo.ToString(CultureInfo.InvariantCulture), sym.Abbreviation.BestAnalysisAlternative.Text)) .Concat(new FeatureSymbol(closedFeat.Hvo.ToString(CultureInfo.InvariantCulture) + "_us", "unspecified"))) { Description = closedFeat.Abbreviation.BestAnalysisAlternative.Text, DefaultSymbolID = closedFeat.Hvo.ToString(CultureInfo.InvariantCulture) + "_us" }); } } var pattern = new Pattern <ComplexConcParagraphData, ShapeNode>(); pattern.Children.Add(m_root.GeneratePattern(m_featSys)); m_matcher = new Matcher <ComplexConcParagraphData, ShapeNode>(m_spanFactory, pattern, new MatcherSettings <ShapeNode> { UseDefaults = true }); }
public void IsDeterminizable() { var featSys = new FeatureSystem { new StringFeature("A"), new StringFeature("B"), new StringFeature("C"), new StringFeature("D"), new StringFeature("E"), new StringFeature("F") }; var fst = new Fst<AnnotatedStringData, int>(_operations); fst.StartState = fst.CreateState(); State<AnnotatedStringData, int> s1 = fst.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("E").EqualTo("true").Value, fst.CreateState()); State<AnnotatedStringData, int> s2 = fst.StartState.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("F").EqualTo("true").Value, fst.CreateState()); State<AnnotatedStringData, int> s3 = s1.Arcs.Add(FeatureStruct.New(featSys).Feature("B").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("D").EqualTo("true").Value, fst.CreateState()); s2.Arcs.Add(FeatureStruct.New(featSys).Feature("C").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("D").EqualTo("true").Value, s3); State<AnnotatedStringData, int> s4 = s3.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, fst.CreateAcceptingState()); Assert.That(fst.IsDeterminizable, Is.True); s4.Arcs.Add(FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, FeatureStruct.New(featSys).Feature("A").EqualTo("true").Value, s4); Assert.That(fst.IsDeterminizable, Is.False); }
public override PatternNode<ComplexConcParagraphData, ShapeNode> GeneratePattern(FeatureSystem featSys) { return new Constraint<ComplexConcParagraphData, ShapeNode>(FeatureStruct.New(featSys).Symbol("bdry").Symbol("wordBdry").Value); }
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("palatal"), new FeatureSymbol("velar"), new FeatureSymbol("uvular"), new FeatureSymbol("pharyngeal"), new FeatureSymbol("glottal")), new SymbolicFeature("manner", new FeatureSymbol("stop"), new FeatureSymbol("affricate"), new FeatureSymbol("fricative"), new FeatureSymbol("approximant"), new FeatureSymbol("trill"), new FeatureSymbol("flap"), new FeatureSymbol("close-vowel"), new FeatureSymbol("mid-vowel"), new FeatureSymbol("open-vowel")), new SymbolicFeature("voice", new FeatureSymbol("voice+"), new FeatureSymbol("voice-")), new SymbolicFeature("height", new FeatureSymbol("close"), new FeatureSymbol("near-close"), new FeatureSymbol("close-mid"), new FeatureSymbol("mid"), new FeatureSymbol("open-mid"), new FeatureSymbol("near-open"), new FeatureSymbol("open")), new SymbolicFeature("backness", new FeatureSymbol("front"), new FeatureSymbol("near-front"), new FeatureSymbol("central"), new FeatureSymbol("near-back"), new FeatureSymbol("back")), new SymbolicFeature("round", new FeatureSymbol("round+"), new FeatureSymbol("round-")) }; _segmentPool = new SegmentPool(); _segmenter = new Segmenter(_spanFactory) { Consonants = { { "c", FeatureStruct.New(_featSys).Symbol("palatal").Symbol("stop").Symbol("voice-").Value }, { "b", FeatureStruct.New(_featSys).Symbol("bilabial").Symbol("stop").Symbol("voice+").Value }, { "r", FeatureStruct.New(_featSys).Symbol("alveolar").Symbol("trill").Symbol("voice+").Value } }, Vowels = { { "a", FeatureStruct.New(_featSys).Symbol("open").Symbol("front").Symbol("round-").Symbol("open-vowel").Symbol("voice+").Value } }, Boundaries = { "-" }, Modifiers = { "\u0303", "\u0308" }, Joiners = { "\u0361" } }; var syllabifier = new SimpleSyllabifier(false, false); var meaning = new Meaning("test", null); var v1 = new Variety("variety1"); _word1 = new Word("car", meaning); _segmenter.Segment(_word1); v1.Words.Add(_word1); syllabifier.Process(v1); var v2 = new Variety("variety2"); _word2 = new Word("bar", meaning); _segmenter.Segment(_word2); v2.Words.Add(_word2); syllabifier.Process(v2); var vp = new VarietyPair(v1, v2); vp.CognateSoundCorrespondenceFrequencyDistribution = new ConditionalFrequencyDistribution <SoundContext, Ngram <Segment> >(); vp.CognateSoundCorrespondenceFrequencyDistribution[_word1.Shape.First.ToSoundContext(_segmentPool, Enumerable.Empty <SoundClass>())].Increment(_segmentPool.Get(_word2.Shape.First)); vp.CognateSoundCorrespondenceProbabilityDistribution = new ConditionalProbabilityDistribution <SoundContext, Ngram <Segment> >(vp.CognateSoundCorrespondenceFrequencyDistribution, (sc, fd) => new MaxLikelihoodProbabilityDistribution <Ngram <Segment> >(fd)); v1.VarietyPairs.VarietyPairAdded(vp); v2.VarietyPairs.VarietyPairAdded(vp); }
public void FixtureSetUp() { SpanFactory = new ShapeSpanFactory(); TraceManager = new TraceManager(); var phonologicalFeatSys = new FeatureSystem { new SymbolicFeature("voc", new FeatureSymbol("voc+", "+"), new FeatureSymbol("voc-", "-")), new SymbolicFeature("cons", new FeatureSymbol("cons+", "+"), new FeatureSymbol("cons-", "-")), new SymbolicFeature("high", new FeatureSymbol("high+", "+"), new FeatureSymbol("high-", "-")), new SymbolicFeature("low", new FeatureSymbol("low+", "+"), new FeatureSymbol("low-", "-")), new SymbolicFeature("back", new FeatureSymbol("back+", "+"), new FeatureSymbol("back-", "-")), new SymbolicFeature("round", new FeatureSymbol("round+", "+"), new FeatureSymbol("round-", "-")), new SymbolicFeature("vd", new FeatureSymbol("vd+", "+"), new FeatureSymbol("vd-", "-")), new SymbolicFeature("asp", new FeatureSymbol("asp+", "+"), new FeatureSymbol("asp-", "-")), new SymbolicFeature("del_rel", new FeatureSymbol("del_rel+", "+"), new FeatureSymbol("del_rel-", "-")), new SymbolicFeature("ATR", new FeatureSymbol("ATR+", "+"), new FeatureSymbol("ATR-", "-")), new SymbolicFeature("strident", new FeatureSymbol("strident+", "+"), new FeatureSymbol("strident-", "-")), new SymbolicFeature("cont", new FeatureSymbol("cont+", "+"), new FeatureSymbol("cont-", "-")), new SymbolicFeature("nasal", new FeatureSymbol("nasal+", "+"), new FeatureSymbol("nasal-", "-")), new SymbolicFeature("poa", new FeatureSymbol("bilabial"), new FeatureSymbol("labiodental"), new FeatureSymbol("alveolar"), new FeatureSymbol("velar")) }; phonologicalFeatSys.Freeze(); var syntacticFeatSys = new SyntacticFeatureSystem { new SymbolicFeature("foo", new FeatureSymbol("foo+", "+"), new FeatureSymbol("foo-", "-")), new SymbolicFeature("baz", new FeatureSymbol("baz+", "+"), new FeatureSymbol("baz-", "-")), new SymbolicFeature("num", new FeatureSymbol("sg"), new FeatureSymbol("pl")), new SymbolicFeature("pers", new FeatureSymbol("1"), new FeatureSymbol("2"), new FeatureSymbol("3"), new FeatureSymbol("4")), new SymbolicFeature("tense", new FeatureSymbol("past"), new FeatureSymbol("pres")), new SymbolicFeature("evidential", new FeatureSymbol("witnessed")), new SymbolicFeature("aspect", new FeatureSymbol("perf"), new FeatureSymbol("impf")), new SymbolicFeature("mood", new FeatureSymbol("active"), new FeatureSymbol("passive")), new SymbolicFeature("fum", new FeatureSymbol("fum+", "+"), new FeatureSymbol("fum-", "-")), new SymbolicFeature("bar", new FeatureSymbol("bar+", "+"), new FeatureSymbol("bar-", "-")) }; syntacticFeatSys.AddPartsOfSpeech(new FeatureSymbol("N", "Noun"), new FeatureSymbol("V", "Verb"), new FeatureSymbol("TV", "Transitive Verb"), new FeatureSymbol("IV", "Intransitive Verb"), new FeatureSymbol("A", "Adjective")); Head = syntacticFeatSys.AddHeadFeature(); Foot = syntacticFeatSys.AddFootFeature(); syntacticFeatSys.Freeze(); Table1 = new CharacterDefinitionTable(SpanFactory) { Name = "table1" }; AddSegDef(Table1, phonologicalFeatSys, "a", "cons-", "voc+", "high-", "low+", "back+", "round-", "vd+"); AddSegDef(Table1, phonologicalFeatSys, "i", "cons-", "voc+", "high+", "low-", "back-", "round-", "vd+"); AddSegDef(Table1, phonologicalFeatSys, "u", "cons-", "voc+", "high+", "low-", "back+", "round+", "vd+"); AddSegDef(Table1, phonologicalFeatSys, "o", "cons-", "voc+", "high-", "low-", "back+", "round+", "vd+"); AddSegDef(Table1, phonologicalFeatSys, "y", "cons-", "voc+", "high+", "low-", "back-", "round+", "vd+"); AddSegDef(Table1, phonologicalFeatSys, "ɯ", "cons-", "voc+", "high+", "low-", "back+", "round-", "vd+"); AddSegDef(Table1, phonologicalFeatSys, "p", "cons+", "voc-", "bilabial", "vd-", "asp-", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "t", "cons+", "voc-", "alveolar", "vd-", "asp-", "del_rel-", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "k", "cons+", "voc-", "velar", "vd-", "asp-", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "ts", "cons+", "voc-", "alveolar", "vd-", "asp-", "del_rel+", "strident+", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "pʰ", "cons+", "voc-", "bilabial", "vd-", "asp+", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "tʰ", "cons+", "voc-", "alveolar", "vd-", "asp+", "del_rel-", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "kʰ", "cons+", "voc-", "velar", "vd-", "asp+", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "tsʰ", "cons+", "voc-", "alveolar", "vd-", "asp+", "del_rel+", "strident+", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "b", "cons+", "voc-", "bilabial", "vd+", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "d", "cons+", "voc-", "alveolar", "vd+", "strident-", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "g", "cons+", "voc-", "velar", "vd+", "cont-", "nasal-"); AddSegDef(Table1, phonologicalFeatSys, "m", "cons+", "voc-", "bilabial", "vd+", "cont-", "nasal+"); AddSegDef(Table1, phonologicalFeatSys, "n", "cons+", "voc-", "alveolar", "vd+", "strident-", "cont-", "nasal+"); AddSegDef(Table1, phonologicalFeatSys, "ŋ", "cons+", "voc-", "velar", "vd+", "cont-", "nasal+"); AddSegDef(Table1, phonologicalFeatSys, "s", "cons+", "voc-", "alveolar", "vd-", "asp-", "del_rel-", "strident+", "cont+"); AddSegDef(Table1, phonologicalFeatSys, "z", "cons+", "voc-", "alveolar", "vd+", "asp-", "del_rel-", "strident+", "cont+"); AddSegDef(Table1, phonologicalFeatSys, "f", "cons+", "voc-", "labiodental", "vd-", "asp-", "strident+", "cont+"); AddSegDef(Table1, phonologicalFeatSys, "v", "cons+", "voc-", "labiodental", "vd+", "asp-", "strident+", "cont+"); Table2 = new CharacterDefinitionTable(SpanFactory) { Name = "table2" }; AddSegDef(Table2, phonologicalFeatSys, "a", "cons-", "voc+", "high-", "low+", "back+", "round-", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "i", "cons-", "voc+", "high+", "low-", "back-", "round-", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "u", "cons-", "voc+", "high+", "low-", "back+", "round+", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "y", "cons-", "voc+", "high+", "low-", "back-", "round+", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "o", "cons-", "voc+", "high-", "low-", "back+", "round+", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "p", "cons+", "voc-", "bilabial", "vd-"); AddSegDef(Table2, phonologicalFeatSys, "t", "cons+", "voc-", "alveolar", "vd-", "del_rel-", "strident-"); AddSegDef(Table2, phonologicalFeatSys, "k", "cons+", "voc-", "velar", "vd-"); AddSegDef(Table2, phonologicalFeatSys, "ts", "cons+", "voc-", "alveolar", "vd-", "del_rel+", "strident+"); AddSegDef(Table2, phonologicalFeatSys, "b", "cons+", "voc-", "bilabial", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "d", "cons+", "voc-", "alveolar", "vd+", "strident-"); AddSegDef(Table2, phonologicalFeatSys, "g", "cons+", "voc-", "velar", "vd+"); AddSegDef(Table2, phonologicalFeatSys, "m", "cons+", "voc-", "bilabial", "vd+", "cont-", "nasal+"); AddSegDef(Table2, phonologicalFeatSys, "n", "cons+", "voc-", "alveolar", "vd+", "cont-", "nasal+"); AddSegDef(Table2, phonologicalFeatSys, "ŋ", "cons+", "voc-", "velar", "vd+", "cont-", "nasal+"); AddSegDef(Table2, phonologicalFeatSys, "s", "cons+", "voc-", "alveolar", "vd-", "asp-", "del_rel-", "strident+", "cont+"); AddSegDef(Table2, phonologicalFeatSys, "z", "cons+", "voc-", "alveolar", "vd+", "asp-", "del_rel-", "strident+", "cont+"); AddSegDef(Table2, phonologicalFeatSys, "f", "cons+", "voc-", "labiodental", "vd-", "asp-", "strident+", "cont+"); AddSegDef(Table2, phonologicalFeatSys, "v", "cons+", "voc-", "labiodental", "vd+", "asp-", "strident+", "cont+"); AddBdryDef(Table2, "+"); AddBdryDef(Table2, "#"); AddBdryDef(Table2, "!"); AddBdryDef(Table2, "."); AddBdryDef(Table2, "$"); Table3 = new CharacterDefinitionTable(SpanFactory) { Name = "table3" }; AddSegDef(Table3, phonologicalFeatSys, "a", "cons-", "voc+", "high-", "low+", "back+", "round-", "vd+", "ATR+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "a̘", "cons-", "voc+", "high-", "low+", "back+", "round-", "vd+", "ATR-", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "i", "cons-", "voc+", "high+", "low-", "back-", "round-", "vd+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "u", "cons-", "voc+", "high+", "low-", "back+", "round+", "vd+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "y", "cons-", "voc+", "high+", "low-", "back-", "round+", "vd+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "ɯ", "cons-", "voc+", "high+", "low-", "back+", "round-", "vd+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "o", "cons-", "voc+", "high-", "low-", "back+", "round+", "vd+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "p", "cons+", "voc-", "bilabial", "vd-", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "t", "cons+", "voc-", "alveolar", "vd-", "del_rel-", "strident-", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "k", "cons+", "voc-", "velar", "vd-", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "ts", "cons+", "voc-", "alveolar", "vd-", "del_rel+", "strident+", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "b", "cons+", "voc-", "bilabial", "vd+", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "d", "cons+", "voc-", "alveolar", "vd+", "strident-", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "g", "cons+", "voc-", "velar", "vd+", "cont-", "nasal-"); AddSegDef(Table3, phonologicalFeatSys, "m", "cons+", "voc-", "bilabial", "vd+", "cont-", "nasal+"); AddSegDef(Table3, phonologicalFeatSys, "n", "cons+", "voc-", "alveolar", "vd+", "strident-", "cont-", "nasal+"); AddSegDef(Table3, phonologicalFeatSys, "ŋ", "cons+", "voc-", "velar", "vd+", "cont-", "nasal+"); AddSegDef(Table3, phonologicalFeatSys, "s", "cons+", "voc-", "alveolar", "vd-", "asp-", "del_rel-", "strident+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "z", "cons+", "voc-", "alveolar", "vd+", "asp-", "del_rel-", "strident+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "f", "cons+", "voc-", "labiodental", "vd-", "asp-", "strident+", "cont+"); AddSegDef(Table3, phonologicalFeatSys, "v", "cons+", "voc-", "labiodental", "vd+", "asp-", "strident+", "cont+"); AddBdryDef(Table3, "+"); AddBdryDef(Table3, "#"); AddBdryDef(Table3, "!"); AddBdryDef(Table3, "."); Latinate = new MprFeature { Name = "latinate" }; Germanic = new MprFeature { Name = "germanic" }; Morphophonemic = new Stratum(Table3) { Name = "Morphophonemic", MorphologicalRuleOrder = MorphologicalRuleOrder.Unordered }; Allophonic = new Stratum(Table1) { Name = "Allophonic", MorphologicalRuleOrder = MorphologicalRuleOrder.Unordered }; Surface = new Stratum(Table1) { Name = "Surface", MorphologicalRuleOrder = MorphologicalRuleOrder.Unordered }; Entries = new Dictionary <string, LexEntry>(); var fs = FeatureStruct.New(syntacticFeatSys) .Symbol("N") .Feature(Head).EqualTo(head => head .Symbol("foo+").Symbol("baz-")) .Feature(Foot).EqualTo(foot => foot .Symbol("fum-").Symbol("bar+")).Value; AddEntry("1", fs, Allophonic, "pʰit"); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("N") .Feature(Head).EqualTo(head => head .Symbol("foo+").Symbol("baz-")) .Feature(Foot).EqualTo(foot => foot .Symbol("fum-").Symbol("bar+")).Value; AddEntry("2", fs, Allophonic, "pit"); AddEntry("5", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "pʰut"); AddEntry("6", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "kʰat"); AddEntry("7", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "kʰut"); AddEntry("8", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "dat"); AddEntry("9", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Allophonic, "dat"); AddEntry("10", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "ga̘p"); AddEntry("11", FeatureStruct.New(syntacticFeatSys).Symbol("A").Value, Morphophonemic, "gab"); AddEntry("12", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "ga+b"); AddEntry("13", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bubabu"); AddEntry("14", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bubabi"); AddEntry("15", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bɯbabu"); AddEntry("16", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bibabi"); AddEntry("17", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bubi"); AddEntry("18", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bibu"); AddEntry("19", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "b+ubu"); AddEntry("20", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bubababi"); AddEntry("21", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bibababu"); AddEntry("22", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bubabababi"); AddEntry("23", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bibabababu"); AddEntry("24", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bubui"); AddEntry("25", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "buibu"); AddEntry("26", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "buibui"); AddEntry("27", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "buiibuii"); AddEntry("28", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "buitibuiti"); AddEntry("29", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "iibubu"); AddEntry("30", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "bu+ib"); AddEntry("31", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "buib"); AddEntry("32", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "sag"); AddEntry("33", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "sas"); AddEntry("34", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "saz"); AddEntry("35", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "sat"); AddEntry("36", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "sasibo"); AddEntry("37", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "sasibut"); AddEntry("38", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "sasibud"); AddEntry("39", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "ab+ba"); AddEntry("40", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "abba"); AddEntry("41", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Allophonic, "pip"); AddEntry("42", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "bubibi"); AddEntry("43", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "bubibu"); AddEntry("44", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "gigigi"); AddEntry("45", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "nbinding"); AddEntry("46", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "bupu"); AddEntry("47", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "tag"); AddEntry("48", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "pag"); AddEntry("49", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "ktb"); AddEntry("50", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Allophonic, "suupu"); AddEntry("51", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "miu"); AddEntry("52", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "pu"); AddEntry("53", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "mi"); AddEntry("54", FeatureStruct.New().Value, Morphophonemic, "pi"); AddEntry("55", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "mim+ɯɯ"); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("num").EqualTo("pl")).Value; AddEntry("Perc0", fs, Morphophonemic, "ssag"); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("1") .Feature("num").EqualTo("pl")).Value; AddEntry("Perc1", fs, Morphophonemic, "ssag"); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("3") .Feature("num").EqualTo("pl")).Value; AddEntry("Perc2", fs, Morphophonemic, "ssag"); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("2", "3") .Feature("num").EqualTo("pl")).Value; AddEntry("Perc3", fs, Morphophonemic, "ssag"); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("1", "3") .Feature("num").EqualTo("pl")).Value; AddEntry("Perc4", fs, Morphophonemic, "ssag"); var seeFamily = new LexFamily { Name = "SEE" }; seeFamily.Entries.Add(AddEntry("bl1", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "si")); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("tense").EqualTo("past")).Value; seeFamily.Entries.Add(AddEntry("bl2", fs, Morphophonemic, "sau")); fs = FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("tense").EqualTo("pres")).Value; seeFamily.Entries.Add(AddEntry("bl3", fs, Morphophonemic, "sis")); LexEntry entry = AddEntry("pos1", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "ba"); entry.MprFeatures.Add(Latinate); entry = AddEntry("pos2", FeatureStruct.New(syntacticFeatSys).Symbol("N").Value, Morphophonemic, "ba"); entry.MprFeatures.Add(Germanic); var vowel = FeatureStruct.New(phonologicalFeatSys).Symbol(HCFeatureSystem.Segment).Symbol("voc+").Value; entry = AddEntry("free", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "tap", "taz", "tas"); entry.Allomorphs[0].Environments.Add(new AllomorphEnvironment(SpanFactory, ConstraintType.Require, null, Pattern <Word, ShapeNode> .New().Annotation(vowel).Value)); entry = AddEntry("disj", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "baz", "bat", "bad", "bas"); var unroundedVowel = FeatureStruct.New(phonologicalFeatSys).Symbol(HCFeatureSystem.Segment).Symbol("voc+").Symbol("round-").Value; entry.Allomorphs[0].Environments.Add(new AllomorphEnvironment(SpanFactory, ConstraintType.Require, null, Pattern <Word, ShapeNode> .New().Annotation(unroundedVowel).Value)); entry.Allomorphs[1].Environments.Add(new AllomorphEnvironment(SpanFactory, ConstraintType.Require, null, Pattern <Word, ShapeNode> .New().Annotation(vowel).Value)); entry.Allomorphs[2].Environments.Add(new AllomorphEnvironment(SpanFactory, ConstraintType.Require, null, Pattern <Word, ShapeNode> .New().Annotation(vowel).Value)); entry = AddEntry("stemname", FeatureStruct.New(syntacticFeatSys).Symbol("V").Feature(Head).EqualTo(head => head.Feature("tense").EqualTo("pres")).Value, Morphophonemic, "san", "sad", "sap"); entry.Allomorphs[1].StemName = new StemName( FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("1")).Value, FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("2")).Value) { Name = "sn1" }; entry.Allomorphs[2].StemName = new StemName( FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("1")).Value, FeatureStruct.New(syntacticFeatSys) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("3")).Value) { Name = "sn2" }; AddEntry("synfs", FeatureStruct.New(syntacticFeatSys).Symbol("V").Feature(Head).EqualTo(head => head.Feature("tense").EqualTo("pres")).Value, Morphophonemic, "bag"); entry = AddEntry("bound", FeatureStruct.New(syntacticFeatSys).Symbol("V").Value, Morphophonemic, "dag"); entry.PrimaryAllomorph.IsBound = true; Language = new Language { Name = "Test", PhonologicalFeatureSystem = phonologicalFeatSys, SyntacticFeatureSystem = syntacticFeatSys, Strata = { Morphophonemic, Allophonic, Surface } }; }
public FeatureStructBuilder(FeatureSystem featSys, bool mutable) : this(featSys, new FeatureStruct(), mutable) { }
public override PatternNode <ComplexConcParagraphData, ShapeNode> GeneratePattern(FeatureSystem featSys) { var group = new Group <ComplexConcParagraphData, ShapeNode>(); Alternation <ComplexConcParagraphData, ShapeNode> alternation = null; bool inAlternation = false; foreach (ComplexConcPatternNode child in Children) { if (child is ComplexConcOrNode) { if (alternation == null) { alternation = new Alternation <ComplexConcParagraphData, ShapeNode>(); alternation.Children.Add(group.Children.Last); } inAlternation = true; } else { if (!inAlternation && alternation != null) { group.Children.Add(alternation); alternation = null; } PatternNode <ComplexConcParagraphData, ShapeNode> newNode = child.GeneratePattern(featSys); if (inAlternation) { alternation.Children.Add(newNode); inAlternation = false; } else { group.Children.Add(newNode); } } } if (alternation != null) { group.Children.Add(alternation.Children.Count == 1 ? alternation.Children.First : alternation); } return(AddQuantifier(group)); }
protected void AddStringValue(FeatureSystem featSys, FeatureStruct fs, ITsString tss, string id) { if (tss != null) { var feat = featSys.GetFeature<StringFeature>(string.Format("{0}-{1}", id, tss.get_WritingSystemAt(0).ToString(CultureInfo.InvariantCulture))); fs.AddValue(feat, tss.Text); } }
public void SetUp() { _featSys = new FeatureSystem { new SymbolicFeature("manner", new FeatureSymbol("stop"), new FeatureSymbol("affricate"), new FeatureSymbol("fricative"), new FeatureSymbol("approximant")) }; _project = new CogProject(_spanFactory) {FeatureSystem = _featSys}; _segmentPool = new SegmentPool(); }
public virtual void FixtureSetUp() { SpanFactory = new IntegerSpanFactory(); PhoneticFeatSys = new FeatureSystem { new SymbolicFeature("son", new FeatureSymbol("son+", "+"), new FeatureSymbol("son-", "-"), new FeatureSymbol("son?", "?")) {DefaultSymbolID = "son?"}, new SymbolicFeature("syl", new FeatureSymbol("syl+", "+"), new FeatureSymbol("syl-", "-"), new FeatureSymbol("syl?", "?")) {DefaultSymbolID = "syl?"}, new SymbolicFeature("cons", new FeatureSymbol("cons+", "+"), new FeatureSymbol("cons-", "-"), new FeatureSymbol("cons?", "?")) {DefaultSymbolID = "cons?"}, new SymbolicFeature("high", new FeatureSymbol("high+", "+"), new FeatureSymbol("high-", "-"), new FeatureSymbol("high?", "?")) {DefaultSymbolID = "high?"}, new SymbolicFeature("back", new FeatureSymbol("back+", "+"), new FeatureSymbol("back-", "-"), new FeatureSymbol("back?", "?")) {DefaultSymbolID = "back?"}, new SymbolicFeature("front", new FeatureSymbol("front+", "+"), new FeatureSymbol("front-", "-"), new FeatureSymbol("front?", "?")) {DefaultSymbolID = "front?"}, new SymbolicFeature("low", new FeatureSymbol("low+", "+"), new FeatureSymbol("low-", "-"), new FeatureSymbol("low?", "?")) {DefaultSymbolID = "low?"}, new SymbolicFeature("rnd", new FeatureSymbol("rnd+", "+"), new FeatureSymbol("rnd-", "-"), new FeatureSymbol("rnd?", "?")) {DefaultSymbolID = "rnd?"}, new SymbolicFeature("ant", new FeatureSymbol("ant+", "+"), new FeatureSymbol("ant-", "-"), new FeatureSymbol("ant?", "?")) {DefaultSymbolID = "ant?"}, new SymbolicFeature("cor", new FeatureSymbol("cor+", "+"), new FeatureSymbol("cor-", "-"), new FeatureSymbol("cor?", "?")) {DefaultSymbolID = "cor?"}, new SymbolicFeature("voice", new FeatureSymbol("voice+", "+"), new FeatureSymbol("voice-", "-"), new FeatureSymbol("voice?", "?")) {DefaultSymbolID = "voice?"}, new SymbolicFeature("cont", new FeatureSymbol("cont+", "+"), new FeatureSymbol("cont-", "-"), new FeatureSymbol("cont?", "?")) {DefaultSymbolID = "cont?"}, new SymbolicFeature("nas", new FeatureSymbol("nas+", "+"), new FeatureSymbol("nas-", "-"), new FeatureSymbol("nas?", "?")) {DefaultSymbolID = "nas?"}, new SymbolicFeature("str", new FeatureSymbol("str+", "+"), new FeatureSymbol("str-", "-"), new FeatureSymbol("str?", "?")) {DefaultSymbolID = "str?"}, new StringFeature("strRep") }; WordFeatSys = new FeatureSystem { new SymbolicFeature("POS", new FeatureSymbol("noun"), new FeatureSymbol("verb"), new FeatureSymbol("adj"), new FeatureSymbol("adv"), new FeatureSymbol("det")) }; Word = new FeatureSymbol("Word"); NP = new FeatureSymbol("NP"); VP = new FeatureSymbol("VP"); Seg = new FeatureSymbol("Seg"); Bdry = new FeatureSymbol("Bdry"); Allo = new FeatureSymbol("Allo"); Type = new SymbolicFeature("Type", Word, NP, VP, Seg, Bdry, Allo); TypeFeatSys = new FeatureSystem {Type}; Characters = new Dictionary<char, FeatureStruct> { {'b', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor-") .Symbol("voice+") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value}, {'d', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor+") .Symbol("voice+") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value}, {'g', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high+") .Symbol("ant-") .Symbol("cor-") .Symbol("voice+") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value}, {'p', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor-") .Symbol("voice-") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value}, {'t', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor+") .Symbol("voice-") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value}, {'q', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high+") .Symbol("ant-") .Symbol("cor-") .Symbol("voice-") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value}, {'c', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high+") .Symbol("ant-") .Symbol("cor-") .Symbol("voice-") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value}, {'k', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high+") .Symbol("ant-") .Symbol("cor-") .Symbol("voice-") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value}, {'x', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high+") .Symbol("ant-") .Symbol("cor-") .Symbol("voice-") .Symbol("cont-") .Symbol("nas-") .Symbol("str-").Value}, {'j', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high+") .Symbol("ant-") .Symbol("cor+") .Symbol("voice+") .Symbol("cont-") .Symbol("nas-") .Symbol("str+").Value}, {'s', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor+") .Symbol("voice-") .Symbol("cont+") .Symbol("nas-") .Symbol("str+").Value}, {'z', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor+") .Symbol("voice+") .Symbol("cont+") .Symbol("nas-") .Symbol("str+").Value}, {'f', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor-") .Symbol("voice-") .Symbol("cont+") .Symbol("nas-") .Symbol("str+").Value}, {'v', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son-") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("ant+") .Symbol("cor-") .Symbol("voice+") .Symbol("cont+") .Symbol("nas-") .Symbol("str+").Value}, {'w', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons-") .Symbol("high+") .Symbol("back+") .Symbol("front-") .Symbol("low-") .Symbol("rnd+") .Symbol("ant-") .Symbol("cor-").Value}, {'y', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons-") .Symbol("high+") .Symbol("back-") .Symbol("front+") .Symbol("low-") .Symbol("rnd-") .Symbol("ant-") .Symbol("cor-").Value}, {'h', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons-") .Symbol("high-") .Symbol("back-") .Symbol("front-") .Symbol("low+") .Symbol("ant-") .Symbol("cor-") .Symbol("voice-") .Symbol("cont+") .Symbol("nas-") .Symbol("str-").Value}, {'r', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("back-") .Symbol("front-") .Symbol("low-") .Symbol("ant-") .Symbol("cor+") .Symbol("voice+") .Symbol("cont+") .Symbol("nas-") .Symbol("str-").Value}, {'l', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("back-") .Symbol("front-") .Symbol("low-") .Symbol("ant+") .Symbol("cor+") .Symbol("voice+") .Symbol("cont+") .Symbol("nas-") .Symbol("str-").Value}, {'m', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("low-") .Symbol("ant+") .Symbol("cor-") .Symbol("voice+") .Symbol("cont-") .Symbol("nas+") .Symbol("str-").Value}, {'n', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("low-") .Symbol("ant+") .Symbol("cor+") .Symbol("voice+") .Symbol("cont-") .Symbol("nas+") .Symbol("str-").Value}, {'N', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl-") .Symbol("cons+") .Symbol("high-") .Symbol("low-") .Symbol("ant+") .Symbol("cor?") .Symbol("voice+") .Symbol("cont-") .Symbol("nas+") .Symbol("str-").Value}, {'a', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl+") .Symbol("cons-") .Symbol("high-") .Symbol("back-") .Symbol("front+") .Symbol("low+") .Symbol("rnd-").Value}, {'e', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl+") .Symbol("cons-") .Symbol("high-") .Symbol("back-") .Symbol("front+") .Symbol("low-") .Symbol("rnd-").Value}, {'i', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl+") .Symbol("cons-") .Symbol("high+") .Symbol("back-") .Symbol("front+") .Symbol("low-") .Symbol("rnd-").Value}, {'o', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl+") .Symbol("cons-") .Symbol("high-") .Symbol("back+") .Symbol("front-") .Symbol("low+") .Symbol("rnd-").Value}, {'u', FeatureStruct.New(PhoneticFeatSys) .Symbol(Seg) .Symbol("son+") .Symbol("syl+") .Symbol("cons-") .Symbol("high+") .Symbol("back+") .Symbol("front-") .Symbol("low-") .Symbol("rnd+").Value}, {'+', FeatureStruct.New(PhoneticFeatSys) .Symbol(Bdry) .Feature("strRep").EqualTo("+").Value}, {',', FeatureStruct.New(PhoneticFeatSys) .Symbol(Bdry) .Feature("strRep").EqualTo(",").Value}, {' ', FeatureStruct.New(PhoneticFeatSys) .Symbol(Bdry) .Feature("strRep").EqualTo(" ").Value}, {'.', FeatureStruct.New(PhoneticFeatSys) .Symbol(Bdry) .Feature("strRep").EqualTo(".").Value} }; }
public override PatternNode <ComplexConcParagraphData, ShapeNode> GeneratePattern(FeatureSystem featSys) { var fs = new FeatureStruct(); var typeFeat = featSys.GetFeature <SymbolicFeature>("type"); fs.AddValue(typeFeat, typeFeat.PossibleSymbols["word"]); AddStringValue(featSys, fs, Form, "form"); AddStringValue(featSys, fs, Gloss, "gloss"); if (Category != null) { var catFeat = featSys.GetFeature <SymbolicFeature>("cat"); IEnumerable <FeatureSymbol> symbols = Category.ReallyReallyAllPossibilities.Concat(Category).Select(pos => catFeat.PossibleSymbols[pos.Hvo.ToString(CultureInfo.InvariantCulture)]); if (NegateCategory) { symbols = catFeat.PossibleSymbols.Except(symbols); } fs.AddValue(catFeat, symbols); } if (m_inflFeatures.Count > 0) { var inflFeat = featSys.GetFeature <ComplexFeature>("infl"); fs.AddValue(inflFeat, GetFeatureStruct(featSys, m_inflFeatures)); } var wordBdryFS = FeatureStruct.New(featSys).Symbol("bdry").Symbol("wordBdry").Value; var group = new Group <ComplexConcParagraphData, ShapeNode>(); group.Children.Add(new Quantifier <ComplexConcParagraphData, ShapeNode>(0, 1, new Constraint <ComplexConcParagraphData, ShapeNode>(wordBdryFS)) { IsGreedy = false }); group.Children.Add(new Constraint <ComplexConcParagraphData, ShapeNode>(fs)); group.Children.Add(new Quantifier <ComplexConcParagraphData, ShapeNode>(0, 1, new Constraint <ComplexConcParagraphData, ShapeNode>(wordBdryFS)) { IsGreedy = false }); return(AddQuantifier(group)); }
public FeatureStructBuilder(FeatureSystem featSys) : this(featSys, new FeatureStruct()) { }