Пример #1
0
        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);
            }
        }
        /// <summary>
        /// Gets next training instance for models build over NomBank
        /// </summary>
        /// <returns>Next training instance</returns>
        public override ClassifiableEntity GetNextInstance()
        {
            // try to move to next node
            while (!_nodes.MoveNext())
            {
                NomBankEngine nomBankEngine = TreeBankEngine as NomBankEngine;

                // try to move to next NounInfo
                while (!MoveToNextValidNounInfo(ref _nounInfo))
                {
                    // try to move to next noun...if there are none we're done
                    if (!_nouns.MoveNext())
                    {
                        return(null);
                    }

                    // start before first NounInfo for current noun
                    _nounInfo = nomBankEngine.GetNounInfo(_nouns.Current).GetEnumerator();
                }

                // filter all nodes in the tree, keeping the ones that pass
                NomBankNode root = nomBankEngine.GetNomBankTree(_nounInfo.Current);
                _filteredNodes.Clear();  // reuse node collection for better memory usage
                foreach (NomBankNode n in root.AllNodes)
                {
                    if (Filter(n))
                    {
                        _filteredNodes.Add(n);
                    }
                }

                _nodes = _filteredNodes.GetEnumerator();
            }

            return(_nodes.Current);
        }