示例#1
0
        /// <summary>
        /// Converts argument indexes for the current NomBank tree to their PropBank version
        /// </summary>
        /// <param name="argumentIndexes">Argument indexes to convert</param>
        public void ConvertArgumentIndexesToPropBank(Set <int> argumentIndexes)
        {
            // get current role set
            RoleSet roleSet = RoleSet;

            // check each index
            Set <int> indexesToAdd    = null;
            Set <int> indexesToRemove = null;
            Role      role;

            foreach (int index in argumentIndexes)
            {
                if (roleSet.TryGet(index, out role) && role.Source != -1)
                {
                    // add the source index
                    if (indexesToAdd == null)
                    {
                        indexesToAdd = new Set <int>(false);  // might have duplicates
                    }
                    indexesToAdd.Add(role.Source);

                    // remove the current index
                    if (indexesToRemove == null)
                    {
                        indexesToRemove = new Set <int>();
                    }

                    indexesToRemove.Add(index);
                }
            }

            // remove converted indexes first
            if (indexesToRemove != null)
            {
                foreach (int indexToRemove in indexesToRemove)
                {
                    argumentIndexes.Remove(indexToRemove);
                }
            }

            // add verb-sourced indexes
            if (indexesToAdd != null)
            {
                foreach (int indexToAdd in indexesToAdd)
                {
                    if (!argumentIndexes.Contains(indexToAdd))
                    {
                        argumentIndexes.Add(indexToAdd);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Tests the current node
        /// </summary>
        /// <param name="nomBankEngine">NomBankEngine to use in testing</param>
        public void Test(NomBankEngine nomBankEngine)
        {
            // check predicate node
            if (IsPredicate && !nomBankEngine.TokenIsMarkable(MrgFile, SentenceNumber, TokenNumber))
            {
                throw new Exception("Invalid markable token entry");
            }

            // check support verbs
            if (IsSupportVerb && !nomBankEngine.TokenIsSupportVerb(MrgFile, SentenceNumber, TokenNumber))
            {
                throw new Exception("Support verb mismatch");
            }

            // check morphological variant
            if (IsRoot && !nomBankEngine.ContainsMorphologicalVariantOf(Information.Noun))
            {
                throw new Exception("Noun does not exist in section");
            }

            // test children nodes
            IEnumerator <TreeBankNode> childEnum = Children;

            while (childEnum.MoveNext())
            {
                (childEnum.Current as NomBankNode).Test(nomBankEngine);
            }

            RoleSet roleSet = (Root as NomBankNode).RoleSet;

            foreach (Role role in roleSet)
            {
                if (roleSet.Get(role.Number).Description != role.Description)
                {
                    throw new Exception();
                }
            }
        }
示例#3
0
 /// <summary>
 /// Adds a role set to this frame
 /// </summary>
 /// <param name="roleSet">Role set to add</param>
 public void AddRoleSet(RoleSet roleSet)
 {
     _idRoleSet.Add(roleSet.ID, roleSet);
 }