Exemplo n.º 1
0
        public void testRequiresAn()
        {
            Assert.IsTrue(DeterminerAgrHelper.requiresAn("elephant"));

            Assert.IsFalse(DeterminerAgrHelper.requiresAn("cow"));

            // Does not hand phonetics
            Assert.IsFalse(DeterminerAgrHelper.requiresAn("hour"));

            // But does have exceptions for some numerals
            Assert.IsFalse(DeterminerAgrHelper.requiresAn("one"));

            Assert.IsFalse(DeterminerAgrHelper.requiresAn("100"));
        }
Exemplo n.º 2
0
    /**
     * Check to see if a string ends with the indefinite article "a" and it agrees with {@code np}.
     * @param text
     * @param np
     * @return an altered version of {@code text} to use "an" if it agrees with {@code np}, the original string otherwise.
     */
    public static string checkEndsWithIndefiniteArticle(string text, string np)
    {
        var tokens = text.Split(' ');

        var lastToken = tokens[tokens.Length - 1];

        if (lastToken.equalsIgnoreCase("a") && DeterminerAgrHelper.requiresAn(np))
        {
            tokens[tokens.Length - 1] = "an";

            return(stringArrayToString(tokens));
        }

        return(text);
    }
Exemplo n.º 3
0
        /**
         * This method performs the morphology for determiners.
         *
         * @param determiner
         *            the <code>InflectedWordElement</code>.
         * @param realisation
         *            the current realisation of the determiner.
         */

        public static void doDeterminerMorphology(INLGElement determiner, string realisation)
        {
            if (realisation != null)
            {
                if (!(determiner.getRealisation().Equals("a")))
                {
                    if (determiner.isPlural())
                    {
                        // Use default inflection rules:
                        if ("that".Equals(determiner.getRealisation()))
                        {
                            determiner.setRealisation("those");
                        }
                        else if ("this".Equals(determiner.getRealisation()))
                        {
                            determiner.setRealisation("these");
                        }
                    }
                    else if (!determiner.isPlural())
                    {
                        // Use default push back to base form rules:
                        if ("those".Equals(determiner.getRealisation()))
                        {
                            determiner.setRealisation("that");
                        }
                        else if ("these".Equals(determiner.getRealisation()))
                        {
                            determiner.setRealisation("this");
                        }
                    }
                }

                // Special "a" determiner and perform a/an agreement:
                if (determiner.getRealisation().Equals("a"))
                {
                    if (determiner.isPlural())
                    {
                        determiner.setRealisation("some");
                    }
                    else if (DeterminerAgrHelper.requiresAn(realisation))
                    {
                        determiner.setRealisation("an");
                    }
                }
            }
        }