Ejemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="verbs">Verbs to get predicates trees for (null for all)</param>
 /// <param name="propBankEngine">PropBank engine to draw training predicate trees from</param>
 /// <param name="instanceFilter">Instance filter to apply</param>
 /// <param name="sections">TreeBank sections to draw instances from</param>
 public PropBankPredicateTreeInstanceProvider(Set <string> verbs,
                                              PropBankEngine propBankEngine,
                                              InstanceFilterDelegate instanceFilter,
                                              Set <int> sections)
     : base(propBankEngine, instanceFilter, sections)
 {
     Verbs = verbs;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets next training instance for models build over PropBank
        /// </summary>
        /// <returns>Next training instance</returns>
        public override ClassifiableEntity GetNextInstance()
        {
            // try to move to next node
            while (!_nodeEnum.MoveNext())
            {
                PropBankEngine propBankEngine = TreeBankEngine as PropBankEngine;

                // try to move to next VerbInfo
                while (!MoveToNextValidVerbInfo(ref _verbInfoEnum))
                {
                    // try to move to next verb...if there are none we're done
                    if (!_verbEnum.MoveNext())
                    {
                        return(null);
                    }

                    // start before first VerbInfo for current verb
                    _verbInfoEnum = propBankEngine.GetVerbInfo(_verbEnum.Current).GetEnumerator();
                }

                // filter all nodes in the tree, keeping the good ones
                PropBankNode        root          = propBankEngine.GetPropBankTree(_verbInfoEnum.Current);
                List <PropBankNode> filteredNodes = new List <PropBankNode>();
                foreach (PropBankNode n in root.AllNodes)
                {
                    if (Filter(n))
                    {
                        filteredNodes.Add(n);
                    }
                }

                _nodeEnum = filteredNodes.GetEnumerator();
            }

            return(_nodeEnum.Current);
        }