private void AddSuffix(SuffixDictionaryLine entry, Dictionary<string, Suffix> suffixesById, MorphemeSurfaceDictionary<Suffix> suffixes) { string id = entry.Id; string lex = entry.Lex; MorphemeType morphemeType; if (!Enum.TryParse(entry.Type, out morphemeType)) { morphemeType = MorphemeType.O; Console.WriteLine("Invalid Morpheme Type: " + entry.Type); } string[] flags = entry.Flags.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); string[] rulesToken = entry.Rules.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); Debug.Assert(entry.Surfaces != null, "entry.Surfaces != null"); var surfaces = new List<string>(entry.Surfaces.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries)); List<OrthographyRule> rules = _orthography.GetRules(rulesToken); var suffix = new Suffix(id, lex, morphemeType, LabelSet.ConvertLabelNamesToIndexes(flags), rules); suffixesById.Add(id, suffix); foreach (string surface in surfaces) { suffixes.Add(surface, suffix); } }
private void AddSuffix(SuffixDictionaryLine entry, Dictionary <string, Suffix> suffixesById, MorphemeSurfaceDictionary <Suffix> suffixes) { string id = entry.Id; string lex = entry.Lex; MorphemeType morphemeType; if (!Enum.TryParse(entry.Type, out morphemeType)) { morphemeType = MorphemeType.O; Console.WriteLine("Invalid Morpheme Type: " + entry.Type); } string[] flags = entry.Flags.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] rulesToken = entry.Rules.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); Debug.Assert(entry.Surfaces != null, "entry.Surfaces != null"); var surfaces = new List <string>(entry.Surfaces.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)); List <OrthographyRule> rules = _orthography.GetRules(rulesToken); var suffix = new Suffix(id, lex, morphemeType, LabelSet.ConvertLabelNamesToIndexes(flags), rules); suffixesById.Add(id, suffix); foreach (string surface in surfaces) { suffixes.Add(surface, suffix); } }
private void AddSuffix(SuffixDictionaryLine entry, Dictionary <string, Suffix> suffixesById, MorphemeSurfaceDictionary <Suffix> suffixes) { string id = entry.Id; string lex = entry.Lex; MorphemeType morphemeType; if (!Enum.TryParse(entry.Type, out morphemeType)) { morphemeType = MorphemeType.O; Trace.TraceEvent(TraceEventType.Error, 0, $"Invalid Morpheme Type: {entry.Type}"); } string[] labels = entry.Labels.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] rulesToken = entry.Rules.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); Debug.Assert(entry.Surfaces != null, "entry.Surfaces != null"); var surfaces = new List <string>(entry.Surfaces.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)); List <OrthographyRule> rules = _orthography.GetRules(rulesToken); var suffix = new Suffix(id, lex, new ImmutableSortedSet <string>(surfaces), morphemeType, new ImmutableHashSet <string>(labels), rules); if (suffixesById.ContainsKey(id)) { Trace.TraceEvent(TraceEventType.Warning, 0, $"Duplicate suffix: {id}"); } else { suffixesById.Add(id, suffix); } foreach (string surface in surfaces) { suffixes.Add(surface.Replace('_', ' '), suffix); } }
private void AddSuffix(SuffixDictionaryLine entry, Dictionary<string, Suffix> suffixesById, MorphemeSurfaceDictionary<Suffix> suffixes) { string id = entry.Id; string lex = entry.Lex; MorphemeType morphemeType; if (!Enum.TryParse(entry.Type, out morphemeType)) { morphemeType = MorphemeType.O; Trace.TraceEvent(TraceEventType.Error, 0, $"Invalid Morpheme Type: {entry.Type}"); } string[] labels = entry.Labels.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); string[] rulesToken = entry.Rules.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); Debug.Assert(entry.Surfaces != null, "entry.Surfaces != null"); var surfaces = new List<string>(entry.Surfaces.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries)); List<OrthographyRule> rules = _orthography.GetRules(rulesToken); var suffix = new Suffix(id, lex, new ImmutableSortedSet<string>(surfaces), morphemeType, new ImmutableHashSet<string>(labels), rules); if (suffixesById.ContainsKey(id)) { Trace.TraceEvent(TraceEventType.Warning, 0, $"Duplicate suffix: {id}"); } else { suffixesById.Add(id, suffix); } foreach (string surface in surfaces) { suffixes.Add(surface.Replace('_', ' '), suffix); } }