Ejemplo n.º 1
0
 /// <summary>
 /// reset the verb dictionary according to the verb dictionary path
 /// </summary>
 /// <param name="newDicPath"></param>
 private static void ResetDicPath(string newDicPath)
 {
     if (newDicPath != verbDicPath)
     {
         verbDicPath = newDicPath;
         verbDic = new VerbList(verbDicPath);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// retrieves verb strings from dictioanary
        /// </summary>
        /// <param name="sentence"></param>
        /// <param name="verbDicPath"></param>
        /// <returns></returns>
        private static Dictionary<int, List<VerbInflection>> GetVerbParts(string[] sentence, string[] posSentence)
        {
            if (Conjlist.Count == 0)
                ConstructConjList ();
            var dic = new Dictionary<int, List<VerbInflection>>();
            if (verbDic == null)
            {
                verbDic = new VerbList(verbDicPath);
            }
            for (int i = 0; i < sentence.Length; i++)
            {
                if (posSentence[i] == "V" || posSentence[i] == "N" || posSentence[i] == "ADJ")
                {
                    bool add = false;

                    //     dic.Add(i, VerbList.VerbShapes.ContainsKey(sentence[i]) ? VerbList.VerbShapes[sentence[i]] : null);

                    if (posSentence[i] == "V")
                    {
                        dic.Add(i, VerbList.VerbShapes.ContainsKey(sentence[i]) ? VerbList.VerbShapes[sentence[i]] : null);
                        add = true;
                    }
                    else if (posSentence[i] == "N" || posSentence[i] == "ADJ")
                    {
                        if (VerbList.VerbShapes.ContainsKey(sentence[i]))
                        {
                            var data = VerbList.VerbShapes[sentence[i]];
                            foreach (var verbInflection in data)
                            {
                                if (verbInflection.TenseForm == TenseFormationType.PAYEH_MAFOOLI)
                                {
                                    add = true;
                                    dic.Add(i, data);
                                    break;
                                }
                            }

                        }
                        if (!add)
                        {
                            dic.Add(i, null);
                        }
                    }
                    if (dic[i] == null)
                    {
                        bool find = false;
                        if (sentence[i].StartsWith("می"))
                        {
                            string newSen = sentence[i].Remove(0, 2).Insert(0, "می‌");
                            if (VerbList.VerbShapes.ContainsKey(newSen))
                            {
                                sentence[i] = newSen;
                                find = true;
                                dic[i] = VerbList.VerbShapes[newSen];
                            }
                        }
                        else if (sentence[i].StartsWith("نمی"))
                        {
                            string newSen = sentence[i].Remove(0, 2).Insert(0, "نمی‌");
                            if (VerbList.VerbShapes.ContainsKey(newSen))
                            {
                                sentence[i] = newSen;
                                find = true;
                                dic[i] = VerbList.VerbShapes[newSen];
                            }
                        }
                        else if (sentence[i].Contains("ئی"))
                        {
                            string newSen = sentence[i].Replace("ئی", "یی");
                            if (VerbList.VerbShapes.ContainsKey(newSen))
                            {
                                sentence[i] = newSen;
                                find = true;
                                dic[i] = VerbList.VerbShapes[newSen];
                            }
                        }

                        if (!find)
                        {
                            if (!StaticDic.ContainsKey(sentence[i]))
                            {
                                StaticDic.Add(sentence[i], 1);
                            }
                            else
                            {
                                StaticDic[sentence[i]]++;
                            }
                        }
                    }
                }
                else
                {
                    dic.Add(i, null);

                }

            }
            return dic;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// retrieves verb strings from dictioanary
 /// </summary>
 /// <param name="sentence"></param>
 /// <param name="verbDicPath"></param>
 /// <returns></returns>
 private static Dictionary<int, List<VerbInflection>> GetVerbParts(string[] sentence)
 {
     if (Conjlist.Count == 0)
         ConstructConjList ();
     var dic = new Dictionary<int, List<VerbInflection>>();
     if (verbDic == null)
     {
         verbDic = new VerbList(verbDicPath);
     }
     for (int i = 0; i < sentence.Length; i++)
     {
         dic.Add(i, VerbList.VerbShapes.ContainsKey(sentence[i]) ? VerbList.VerbShapes[sentence[i]] : null);
     }
     return dic;
 }
Ejemplo n.º 4
0
        private static Dictionary<int, List<VerbInflection>> GetVerbParts(string[] sentence, string[] posSentence, string verbDicPath)
        {
            var dic = new Dictionary<int, List<VerbInflection>>();
            if (verbDic == null)
            {
                verbDic = new VerbList(verbDicPath);
            }
            for (int i = 0; i < sentence.Length; i++)
            {
                if (posSentence[i] == "V")
                {
                    dic.Add(i, VerbList.VerbShapes.ContainsKey(sentence[i]) ? VerbList.VerbShapes[sentence[i]] : null);
                    if (dic[i] == null)
                    {
                        bool find = false;
                        if (sentence[i].StartsWith("می"))
                        {
                            string newSen = sentence[i].Remove(0, 2).Insert(0, "می‌");
                            if (VerbList.VerbShapes.ContainsKey(newSen))
                            {
                                sentence[i] = newSen;
                                find = true;
                                dic[i] = VerbList.VerbShapes[newSen];
                            }
                        }
                        else if (sentence[i].StartsWith("نمی"))
                        {
                            string newSen = sentence[i].Remove(0, 2).Insert(0, "نمی‌");
                            if (VerbList.VerbShapes.ContainsKey(newSen))
                            {
                                sentence[i] = newSen;
                                find = true;
                                dic[i] = VerbList.VerbShapes[newSen];
                            }
                        }
                        else if (sentence[i].Contains("ئی"))
                        {
                            string newSen = sentence[i].Replace("ئی", "یی");
                            if (VerbList.VerbShapes.ContainsKey(newSen))
                            {
                                sentence[i] = newSen;
                                find = true;
                                dic[i] = VerbList.VerbShapes[newSen];
                            }
                        }

                        if (!find)
                        {
                            if (!StaticDic.ContainsKey(sentence[i]))
                            {
                                StaticDic.Add(sentence[i], 1);
                            }
                            else
                            {
                                StaticDic[sentence[i]]++;
                            }
                        }
                    }
                }
                else
                {
                    dic.Add(i, null);

                }
            }
            return dic;
        }