public static void ShowFormHocKy() { if (m_TermForm == null || m_TermForm.IsDisposed) { m_TermForm = new TermForm(); m_TermForm.MdiParent = MainForm.ActiveForm; m_TermForm.Show(); } else { m_TermForm.Activate(); } }
/// <summary> /// Creates an expression node and adds it to the give tree. /// </summary> /// <param name="root">Root node of expression tree.</param> /// <param name="term">Term for this node.</param> /// <param name="termForm">Indicates form of this term.</param> /// <param name="termExclude">Indicates if this is an excluded term.</param> /// <param name="conjunction">Conjunction used to join with other nodes.</param> /// <returns>The new root node.</returns> internal INode?AddNode(INode?root, string term, TermForm termForm, bool termExclude, ConjunctionType conjunction) { if (term.Length > 0 && !IsStopWord(term)) { INode node = new TerminalNode { Term = term, TermForm = termForm, Exclude = termExclude }; root = AddNode(root, node, conjunction); } return(root); }
/// <summary> /// Parses a query segment and converts it to an expression /// tree. /// </summary> /// <param name="query">Query segment to be converted.</param> /// <param name="defaultConjunction">Implicit conjunction type.</param> /// <returns>Root node of expression tree.</returns> internal INode?ParseNode(string?query, ConjunctionType defaultConjunction) { ConjunctionType conjunction = defaultConjunction; TermForm termForm = TermForm.Inflectional; bool termExclude = false; bool resetState = true; INode? root = null; INode? node; string term; ParsingHelper parser = new ParsingHelper(query); while (!parser.EndOfText) { if (resetState) { // Reset modifiers conjunction = defaultConjunction; termForm = TermForm.Inflectional; termExclude = false; resetState = false; } parser.SkipWhitespace(); if (parser.EndOfText) { break; } char ch = parser.Peek(); if (Punctuation.Contains(ch)) { switch (ch) { case '"': case '\'': termForm = TermForm.Literal; parser.MoveAhead(); term = parser.ParseWhile(c => c != ch); root = AddNode(root, term.Trim(), termForm, termExclude, conjunction); resetState = true; break; case '(': // Parse parentheses block term = ExtractBlock(parser, '(', ')'); node = ParseNode(term, defaultConjunction); root = AddNode(root, node, conjunction, true); resetState = true; break; case '<': // Parse angle brackets block term = ExtractBlock(parser, '<', '>'); node = ParseNode(term, ConjunctionType.Near); root = AddNode(root, node, conjunction); resetState = true; break; case '-': // Match when next term is not present termExclude = true; break; case '+': // Match next term exactly termForm = TermForm.Literal; break; case '~': // Match synonyms of next term termForm = TermForm.Thesaurus; break; default: break; } // Advance to next character parser.MoveAhead(); } else { // Parse this query term term = parser.ParseWhile(c => !Punctuation.Contains(c) && !char.IsWhiteSpace(c)); // Allow trailing wildcard if (parser.Peek() == '*') { term += parser.Peek(); parser.MoveAhead(); termForm = TermForm.Literal; } // Interpret term StringComparer comparer = StringComparer.OrdinalIgnoreCase; if (comparer.Compare(term, "AND") == 0) { conjunction = ConjunctionType.And; } else if (comparer.Compare(term, "OR") == 0) { conjunction = ConjunctionType.Or; } else if (comparer.Compare(term, "NEAR") == 0) { conjunction = ConjunctionType.Near; } else if (comparer.Compare(term, "NOT") == 0) { termExclude = true; } else { root = AddNode(root, term, termForm, termExclude, conjunction); resetState = true; } } } return(root); }
static int Main(string[] args) { if (args.Length == 1) { FileInfo f = new FileInfo(args[0]); if (f.Exists) { settingsFileName = f.Name; settings = CommBaseTermSettings.LoadFromXML(f.OpenRead()); if (settings == null) { MessageBox.Show("Bad settings file", "CommBase Terminal", MessageBoxButtons.OK); return 0; } } } else { settings = new CommBaseTermSettings(); } term = new BaseTerm(); frm = new MuFuDi(); Application.Run(frm); return 0; }