static CogFeatureSystem() { AnchorType = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "anchor"}; VowelType = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "vowel"}; ConsonantType = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "consonant"}; ToneLetterType = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "toneLetter"}; BoundaryType = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "boundary"}; SyllableType = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "syllable"}; StemType = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "stem"}; PrefixType = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "prefix"}; SuffixType = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "suffix"}; Type = new SymbolicFeature(Guid.NewGuid().ToString(), AnchorType, VowelType, ConsonantType, ToneLetterType, BoundaryType, SyllableType, StemType, PrefixType, SuffixType) {Description = "Type"}; Complex = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "complex"}; Simple = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "simple"}; SegmentType = new SymbolicFeature(Guid.NewGuid().ToString(), Complex, Simple) {Description = "SegmentType"}; OriginalStrRep = new StringFeature(Guid.NewGuid().ToString()) {Description = "OriginalStrRep"}; StrRep = new StringFeature(Guid.NewGuid().ToString()) {Description = "StrRep"}; First = new ComplexFeature(Guid.NewGuid().ToString()) {Description = "First"}; Onset = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "onset"}; Nucleus = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "nucleus"}; Coda = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "coda"}; SyllablePosition = new SymbolicFeature(Guid.NewGuid().ToString(), Onset, Nucleus, Coda) {Description = "SyllablePosition"}; Instance = new CogFeatureSystem(); }
private SymbolicFeatureValue(SymbolicFeatureValue sfv) : base(sfv) { _feature = sfv._feature; _first = sfv._first; _flags = sfv._flags; }
public static bool Normalize(Segmenter segmenter, string segment, out string normalizedSegment, out FeatureSymbol leftEnv, out FeatureSymbol rightEnv) { normalizedSegment = null; if (string.IsNullOrEmpty(segment) || segment.IsOneOf("#", "C", "V")) { leftEnv = null; rightEnv = null; return false; } string strRep = StripContext(segment, out leftEnv, out rightEnv); if (strRep.IsOneOf("-", "_")) { normalizedSegment = "-"; return true; } string normalized; if (segmenter.NormalizeSegmentString(strRep, out normalized)) { normalizedSegment = normalized; return true; } leftEnv = null; rightEnv = null; return false; }
public FeatureViewModel(SymbolicFeature feature, FeatureSymbol symbol) { _feature = feature; _values = new ReadOnlyCollection<FeatureValueViewModel>(feature.PossibleSymbols.Select(s => new FeatureValueViewModel(s)).ToArray()); if (symbol != null) _selectedValue = _values.Single(fv => fv.DomainSymbol == symbol); else if (_values.Count > 0) _selectedValue = _values[0]; }
public void Migrate(SegmentPool segmentPool, CogProject project) { if (project.FeatureSystem.ContainsFeature("airstream")) return; var pulmonic = new FeatureSymbol("pulmonic"); var ejective = new FeatureSymbol("ejective"); var implosive = new FeatureSymbol("implosive"); var click = new FeatureSymbol("click"); var airstream = new SymbolicFeature("airstream", pulmonic, ejective, implosive, click) {Description = "Airstream"}; project.FeatureSystem.Add(airstream); AddValue(project.Segmenter.Modifiers, "ʼ", ejective); AddValue(project.Segmenter.Consonants, "ɓ", implosive); AddValue(project.Segmenter.Consonants, "ɗ", implosive); AddValue(project.Segmenter.Consonants, "ʄ", implosive); AddValue(project.Segmenter.Consonants, "ɠ", implosive); AddValue(project.Segmenter.Consonants, "ʛ", implosive); FeatureSymbol affricate; if (project.FeatureSystem.TryGetSymbol("affricate", out affricate)) { project.Segmenter.Consonants.AddSymbolBasedOn("ʘ", "p", affricate, click); project.Segmenter.Consonants.AddSymbolBasedOn("ǀ", "θ", affricate, click); project.Segmenter.Consonants.AddSymbolBasedOn("ǁ", "ɬ", affricate, click); } project.Segmenter.Consonants.AddSymbolBasedOn("ǃ", "t", click); project.Segmenter.Consonants.AddSymbolBasedOn("ǂ", "c", click); foreach (Symbol symbol in project.Segmenter.Vowels.ToArray()) AddValue(project.Segmenter.Vowels, symbol, pulmonic); foreach (Symbol symbol in project.Segmenter.Consonants.Where(s => !s.FeatureStruct.ContainsFeature("airstream")).ToArray()) AddValue(project.Segmenter.Consonants, symbol, pulmonic); foreach (KeyValuePair<string, IWordAligner> aligner in project.WordAligners.Where(kvp => kvp.Value is Aline).ToArray()) { var aline = (Aline) aligner.Value; Dictionary<SymbolicFeature, int> featWeights = aline.FeatureWeights.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); featWeights[airstream] = 5; Dictionary<FeatureSymbol, int> valueMetrics = aline.ValueMetrics.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); valueMetrics[pulmonic] = 100; valueMetrics[ejective] = 66; valueMetrics[implosive] = 33; valueMetrics[click] = 0; project.WordAligners[aligner.Key] = new Aline(segmentPool, aline.RelevantVowelFeatures, aline.RelevantConsonantFeatures.Concat(airstream), featWeights, valueMetrics, aline.Settings); } }
public SymbolicFeatureValue(IEnumerable <FeatureSymbol> values) { FeatureSymbol[] symbols = values.ToArray(); if (symbols.Length == 0) { throw new ArgumentException("values cannot be empty", "values"); } _feature = symbols[0].Feature; _first = symbols[0]; Set(symbols); }
/// <summary> /// Gets the feature value associated with the specified ID. /// </summary> /// <param name="id">The ID.</param> /// <param name="symbol"> </param> /// <returns>The feature value.</returns> public bool TryGetSymbol(string id, out FeatureSymbol symbol) { foreach (SymbolicFeature sf in _features.OfType <SymbolicFeature>()) { if (sf.PossibleSymbols.TryGet(id, out symbol)) { return(true); } } symbol = null; return(false); }
public VarietySegmentViewModel(VarietyViewModel variety, Segment segment, FeatureSymbol position) : base(segment) { _variety = variety; FrequencyDistribution<Segment> freqDist; if (position == null) freqDist = variety.DomainVariety.SegmentFrequencyDistribution; else if (!variety.DomainVariety.SyllablePositionSegmentFrequencyDistributions.TryGetValue(position, out freqDist)) freqDist = null; if (freqDist != null) { _frequency = freqDist[segment]; _probability = (double) _frequency / freqDist.SampleOutcomeCount; } }
static HCFeatureSystem() { Anchor = new FeatureSymbol(Guid.NewGuid().ToString()) { Description = "anchor" }; Segment = new FeatureSymbol(Guid.NewGuid().ToString()) { Description = "segment" }; Boundary = new FeatureSymbol(Guid.NewGuid().ToString()) { Description = "boundary" }; Morph = new FeatureSymbol(Guid.NewGuid().ToString()) { Description = "morph" }; Type = new SymbolicFeature(Guid.NewGuid().ToString(), Anchor, Segment, Boundary, Morph) { Description = "Type" }; Dirty = new FeatureSymbol(Guid.NewGuid().ToString()) { Description = "Dirty" }; Clean = new FeatureSymbol(Guid.NewGuid().ToString()) { Description = "Clean" }; Modified = new SymbolicFeature(Guid.NewGuid().ToString(), Dirty, Clean) { Description = "Modified", DefaultValue = new SymbolicFeatureValue(Clean) }; Deleted = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "Deleted"}; NotDeleted = new FeatureSymbol(Guid.NewGuid().ToString()) {Description = "NotDeleted"}; Deletion = new SymbolicFeature(Guid.NewGuid().ToString(), Deleted, NotDeleted) { Description = "Deletion", DefaultValue = new SymbolicFeatureValue(NotDeleted) }; LeftSide = new FeatureSymbol(Guid.NewGuid().ToString()) { Description = "LeftSide" }; RightSide = new FeatureSymbol(Guid.NewGuid().ToString()) { Description = "RightSide" }; AnchorType = new SymbolicFeature(Guid.NewGuid().ToString(), LeftSide, RightSide) { Description = "AnchorType" }; StrRep = new StringFeature(Guid.NewGuid().ToString()) {Description = "StrRep"}; Allomorph = new StringFeature(Guid.NewGuid().ToString()) {Description = "Allomorph"}; Instance = new HCFeatureSystem(); LeftSideAnchor = FeatureStruct.New().Symbol(Anchor).Symbol(LeftSide).Value; RightSideAnchor = FeatureStruct.New().Symbol(Anchor).Symbol(RightSide).Value; }
private void SetFirst() { _first = _flags == 0 ? null : _feature.PossibleSymbols.First(Get); }
public SymbolicFeatureValue(FeatureSymbol value) { _feature = value.Feature; _first = value; Set(value.ToEnumerable()); }
public RelevantValueViewModel(FeatureSymbol symbol, int metric) { _symbol = symbol; _metric = metric; }
private bool Get(FeatureSymbol symbol) { return((_flags & (1UL << symbol.Index)) != 0); }
private void AssertShapeNodeEqual(ShapeNode actualNode, string expectedStrRep, FeatureSymbol expectedType) { Assert.That(actualNode.StrRep(), Is.EqualTo(expectedStrRep)); Assert.That(actualNode.Type(), Is.EqualTo(expectedType)); }
private static void AddValue(SymbolCollection symbols, string strRep, FeatureSymbol value) { Symbol symbol; if (symbols.TryGetValue(strRep, out symbol)) AddValue(symbols, symbol, value); }
public FeatureValueViewModel(FeatureSymbol symbol) { _symbol = symbol; }
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 bool ContainsSymbol(FeatureSymbol symbol) { return(ContainsSymbol(symbol.ID)); }
private static void AddValue(SymbolCollection symbols, Symbol symbol, FeatureSymbol value) { FeatureStruct fs = symbol.FeatureStruct.DeepClone(); fs.AddValue(value.Feature, value); fs.Freeze(); symbols.Remove(symbol); symbols.Add(symbol.StrRep, fs, symbol.Overwrite); }
private static string StripContext(string strRep, out FeatureSymbol leftEnv, out FeatureSymbol rightEnv) { leftEnv = GetEnvironment(strRep[0]); if (leftEnv != null) strRep = strRep.Remove(0, 1); rightEnv = GetEnvironment(strRep[strRep.Length - 1]); if (rightEnv != null) strRep = strRep.Remove(strRep.Length - 1, 1); return strRep; }
public Environment(FeatureSymbol leftEnv, FeatureSymbol rightEnv) { _leftEnv = leftEnv; _rightEnv = rightEnv; }