void add_word(Element_Word word, Element_Base choice) { foreach (Element_Base item in choice.children) { if (word.text == item.word_text) { choice.children.Remove(item); } } choice.add(word); List <Element_Base> vocabulary = new List <Element_Base>(); vocabulary.AddRange(choice.children); vocabulary.Sort(delegate(Element_Base first, Element_Base second) { return(first.word_text.CompareTo(second.word_text)); }); choice.children.Clear(); foreach (Element_Base item in vocabulary) { choice.children.Add(item); } }
public Element_Word find_word(string text) { object item = vocabulary.get(text); if (item != null) { if (item.GetType() == typeof(Element_Word)) { return(item as Element_Word); } else { List <Element_Word> list = item as List <Element_Word>; return(list[0]); } } foreach (Familiar_Document reference in referenced_documents) { Element_Word word = reference.find_word(text); if (word != null) { return(word); } } return(null); }
public Token(string new_text, Element_Word new_word) { generated = true; source = new_word; text = new_text; properties = new Singular_Indexer(this); }
public string check_word_for_property(Token word, string key) { if (word == null) { return(null); } if (word.source.GetType() == typeof(Element_Item)) { Element_Item item = word.source as Element_Item; if (!item.properties.ContainsKey(key)) { return(check_word_for_property(word.parent, key)); } return(item.properties[key]); } else { Element_Word item = word.source as Element_Word; if (!item.properties.ContainsKey(key)) { if (parent.generated) { return(check_source_for_property(item.parent, key)); } else { return(check_word_for_property(word.parent, key)); } } return(item.properties[key]); } }
public string check_source_for_property(Element_Base word, string key) { if (word == null) { return(null); } if (word.GetType() == typeof(Element_Item)) { Element_Item item = word as Element_Item; if (!item.properties.ContainsKey(key)) { return(check_source_for_property(word.parent, key)); } return(item.properties[key]); } else if (word.GetType() == typeof(Element_Word)) { Element_Word item = word as Element_Word; if (!item.properties.ContainsKey(key)) { return(check_source_for_property(word.parent, key)); } return(item.properties[key]); } else { return(check_source_for_property(word.parent, key)); } }
public Element_Base create_child(XmlElement element) { Element_Base result = null; switch (element.Name.ToLower()) { case "rule": { result = new Element_Item(); document.all_rules.Add((Element_Item)result); break; } case "ruleref": case "reference": result = new Element_Reference(); break; case "tag": result = new Element_Tag(); break; case "item": result = new Element_Item(); if (result.name != "") { document.all_rules.Add((Element_Item)result); } break; case "one-of": case "choice": result = new Element_Choice(); break; case "dictation": result = new Element_Dictation(); break; case "word": result = new Element_Word(); break; //case "filter": // if (Familiar_Word.Filter.filters.has_key(element.InnerText)) // filters.Add(Familiar_Word.Filter.filters[element.InnerText]); // return null; default: return(null); } add(result); result.initialize(element); return(result); }
public void add_word(Element_Word word, string rule_name) { Element_Base rule = get_rule(rule_name); if (rule == null) { return; } add_word(word, rule.children[0]); }
public bool contains_key(string key) { if (additions.ContainsKey(key)) { return(true); } if (parent.source.GetType() == typeof(Element_Item)) { Element_Item item = parent.source as Element_Item; return(item.properties.ContainsKey(key)); } else { Element_Word item = parent.source as Element_Word; return(item.properties.ContainsKey(key)); } }
//private void create_final_word() //{ // text = ""; // if (value != null) // text = value; // if (text != null) // { // initialize(text); // } //} public void initialize(string input_text) { id = input_text; Match match = Regex.Match(input_text, @"::([^.]+).(\d+)(?:\.(\d+))?"); if (match.Success) { Familiar_Document item_document = Familiar_Document.find_document(match.Groups[1].Value); source = item_document.items[int.Parse(match.Groups[2].Value)]; if (source.GetType() != typeof(Element_Word)) { text = source.text; return; } Element_Word item = source as Element_Word; text = item.display; if (match.Groups[3].Value != "") { text = item.get_suffix(item.suffixes[int.Parse(match.Groups[3].Value)]); } } else { // var source = MetaHub.Core.Meta_Object.parse_absolute_path(input_text); // if (source != null) // { // text = input_text; //// Feedback.print(text + "\r\n", Feedback.Status.info); // } // else // text = input_text; } }