Exemple #1
0
 public static unsafe InterpMorf[] ParseQuery(string query)
 {
     InterpMorf[] res = null;
     try
     {
         Cindalnet.SQLBot.Model.MorfeuszDllWrapper.CInterpMorf *items;
         int itemsCount;
         using (MorfeuszDllWrapper.ParseQuery(out items, out itemsCount, query))
         {
             res = new InterpMorf[itemsCount];
             for (int i = 0; i < itemsCount; i++)
             {
                 try
                 {
                     res[i].p      = items[i].p;
                     res[i].k      = items[i].k;
                     res[i].forma  = Marshal.PtrToStringAnsi(items[i].forma);
                     res[i].haslo  = Marshal.PtrToStringAnsi(items[i].haslo);
                     res[i].interp = Marshal.PtrToStringAnsi(items[i].interp);
                 }
                 catch (Exception)
                 { }
             }
         }
     }
     catch (Exception)
     {
     }
     return(res);
 }
Exemple #2
0
        private string MorfParse(string Query)
        {
            string res = "";

            Cindalnet.SQLBot.Model.MorfeuszDllWrapper.InterpMorf[] items = MorfeuszDllWrapper.ParseQuery(Query);
            int k = -1;

            foreach (var item in items)
            {   // Bierzemy pod uwagę pierwszą interpretację słowa
                if (k != item.k)
                {
                    if (res.Length > 0)
                    {
                        res += " ";
                    }
                    // Zamiana rzeczowników na ich formy podstawowe
                    if (item.interp.StartsWith("subst"))
                    {
                        res += item.haslo;
                    }
                    else
                    {
                        res += item.forma;
                    }
                    k = item.k;
                }
            }
            return(res);
        }