コード例 #1
0
        // Return the adjective's exception singular to plurial group
        public static string groupS2POf(string adjective, string gender, string number)
        {
            string res = "";

            // we transform the adjective to male singular if it is not
            if (number == "P")
            {
                adjective = plurialToSingular(adjective);
            }
            if (gender == "F")
            {
                adjective = femaleToMale(adjective);
            }
            // if the IA knows the adjective, we only have to make a research on the data base
            if (existe(adjective))
            {
                con.Open();
                res = new CMD("SELECT GroupS2P FROM Adjectifs WHERE Adjective = '" + adjective + "'", con).ExecuteScalar().ToString();
                con.Close();
            }
            // else, we had to estimate it
            else
            {
                int    length = adjective.Length;
                string ending = "";
                object resEnding;
                con.Open();
                for (int i = length; res == "" && i >= 1; i--)
                {
                    ending    = adjective.Substring(length - i);
                    resEnding = new CMD("SELECT GroupS2P FROM ExceptionsAdjectifsS2P WHERE Singular = '" + ending + "' ORDER BY GroupS2P ", con).ExecuteScalar();
                    if (resEnding != null)
                    {
                        res = resEnding.ToString();
                    }
                }
            }
            con.Close();
            if (res == "")
            {
                res = "10";
            }
            return(res);
        }
コード例 #2
0
        public static string femaleToMale(string adjective)
        {
            int    length    = adjective.Length;
            string resEnding = "";
            string ending    = "";
            object resReq;

            con.Open();
            for (int i = length; resEnding == "" && i >= 1; i--)
            {
                ending = adjective.Substring(length - i);
                resReq = new CMD("SELECT Male FROM ExceptionsAdjectifsM2F WHERE Female = '" + ending + "'", con).ExecuteScalar();
                // we collect the first result only
                if (resReq != null)
                {
                    resEnding = resReq.ToString();
                }
            }
            con.Close();
            return(adjective.Substring(0, length - ending.Length) + resEnding);
        }