private void testAllNounsBtn_Click(object sender, EventArgs e) { ClearItemList(); // get all noun information Thread t = new Thread(new ThreadStart(delegate() { SetNomBankGroupEnabled(false); // error logging string errorFile = "error_log.txt"; if (File.Exists(errorFile)) { File.Delete(errorFile); } int numErrors = 0; // get all nouns foreach (string noun in _nomBankEngine.AllNouns) { // get noun info for each noun int entries = 0; foreach (NounInfo ni in _nomBankEngine.GetNounInfo(noun)) { try { // test tree NomBankNode predTree = _nomBankEngine.GetNomBankTree(ni); predTree.Test(_nomBankEngine); } catch (Exception ex) { // write error information StreamWriter errorLog = new StreamWriter(errorFile, true); errorLog.WriteLine("Error at " + ni.File + ", " + ni.SentenceNumber + ", " + ni.LeafNumber + ". Label information: " + ni.LabeledNodeLocations + ". Exception: " + ex + "\n"); errorLog.Close(); ++numErrors; } ++entries; } AddStringToList("Found " + entries + " attestations for all senses of \"" + noun + "\""); } if (numErrors > 0) { MessageBox.Show(numErrors + " errors were encountered. Check error log at \"" + errorFile + "\" for details"); } else { MessageBox.Show("No errors were found."); } SetNomBankGroupEnabled(true); })); t.Start(); }
private void getNounAttBtn_Click(object sender, EventArgs e) { ClearItemList(); if (!_nomBankEngine.Contains(nounCombo.Text)) { MessageBox.Show("NomBank does not contain \"" + nounCombo.Text + "\""); return; } // get attestations for each noun List <NomBankNode.BracketedOutputOptions> options = new List <NomBankNode.BracketedOutputOptions>(); options.Add(NomBankNode.BracketedOutputOptions.IgnoreBracketProbabilities); if (includeNounSense.Checked) { options.Add(NomBankNode.BracketedOutputOptions.IncludePredicateFrame); } NomBankNode.BracketedOutputOptions[] optionsArray = options.ToArray(); foreach (NounInfo ni in _nomBankEngine.GetNounInfo(nounCombo.Text)) { NomBankNode tree = _nomBankEngine.GetNomBankTree(ni); if (tree == null) { continue; } string text = tree.FullLocation + ": " + tree.GetBracketedText(optionsArray); AddStringToList(text); } }
private void getNodesByFeatureBtn_Click(object sender, EventArgs e) { ClearItemList(); if (!_nomBankEngine.Contains(nounCombo.Text)) { MessageBox.Show("NomBank does not contain \"" + nounCombo.Text + "\""); return; } // get attestations for each noun List <NomBankNode.BracketedOutputOptions> options = new List <NomBankNode.BracketedOutputOptions>(); options.Add(NomBankNode.BracketedOutputOptions.IgnoreBracketProbabilities); if (includeNounSense.Checked) { options.Add(NomBankNode.BracketedOutputOptions.IncludePredicateFrame); } NomBankNode.BracketedOutputOptions[] optionsArray = options.ToArray(); // get all nodes with given feature foreach (NounInfo ni in _nomBankEngine.GetNounInfo(nounCombo.Text)) { NomBankNode tree = _nomBankEngine.GetNomBankTree(ni); if (tree == null) { continue; } foreach (NomBankNode n in tree.GetDescendants((NomBankNodeLabel.NodeFeature)nodeFeatureCombo.SelectedItem)) { if (n.SurfaceText != "") { AddStringToList(n.GetBracketedText(optionsArray)); } } } }