コード例 #1
0
        public BaseStructure Clone()
        {
            var newStruct = new BaseStructure();

            newStruct.HasBandMotammemi          = HasBandMotammemi;
            newStruct.HasBandMotemmemiAgreement = HasBandMotemmemiAgreement;
            newStruct.HasBandMotemmemiEltezami  = HasBandMotemmemiEltezami;
            newStruct.HasEzafehObject           = HasEzafehObject;
            newStruct.HasMoq    = HasMoq;
            newStruct.HasMosnad = HasMosnad;
            newStruct.HasObject = HasObject;
            newStruct.HasPrepositionalObject1 = HasPrepositionalObject1;
            newStruct.HasPrepositionalObject2 = HasPrepositionalObject2;
            newStruct.HasRa           = HasRa;
            newStruct.HasSecondObject = HasSecondObject;
            newStruct.HasSubject      = HasSubject;
            newStruct.HasTammeez      = HasTammeez;
            newStruct.PrepositionalObjectPreposition1 = PrepositionalObjectPreposition1;
            newStruct.PrepositionalObjectPreposition2 = PrepositionalObjectPreposition2;
            newStruct.MoqType = MoqType;
            return(newStruct);
        }
コード例 #2
0
        public static void RefreshVerbList(string verbpath, string valencePath)
        {
            BaseStrucDic = new Dictionary<string, List<BaseStructure>>();
            var verbValDic = new Dictionary<string, VerbPlusValency>();
            var reader = new StreamReader(verbpath);
            var newVerbReader = new StreamReader(valencePath);
            string sentence;
            var mainCatList = new List<List<string>>();
            while ((sentence = reader.ReadLine()) != null)
            {
                sentence = StringUtil.RefineAndFilterPersianWord(sentence);
                mainCatList.Add(sentence.Trim().Split("\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList());
            }
            while ((sentence = newVerbReader.ReadLine()) != null)
            {
                sentence = StringUtil.RefineAndFilterPersianWord(sentence);
                var split = sentence.Split("\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                string bonMazi = split[0];
                string bonMozare = split[1];
                string prefix = split[2];
                string nonVerbalElement = split[3];
                string preposition = split[4];

                foreach (List<string> list in mainCatList)
                {
                    if (bonMazi == list[2] && bonMozare == list[3] && prefix == list[5] && nonVerbalElement == list[4] && preposition == list[6])
                    {
                        string verbStr = prefix + "#" + bonMazi + "#" + bonMozare + "#" + nonVerbalElement + "#" + preposition;
                        if (prefix == "-")
                            verbStr = bonMazi + "#" + bonMozare + "#" + nonVerbalElement + "#" + preposition;
                        var newVerbPlusVal = new VerbPlusValency(verbStr, new List<ValencyFrame>());
                        if (!verbValDic.ContainsKey(verbStr))
                            verbValDic.Add(verbStr, newVerbPlusVal);

                        verbValDic[verbStr].AddNewFrame(GetValencyFrame(split[5]));

                        if (bonMazi == "کرد" && nonVerbalElement != "-")
                        {
                            string newVerbStr = prefix + "\t" + "\tنمود\tنما\t" +
                                         nonVerbalElement + "\t" + preposition;
                            if (prefix == "-")
                                newVerbStr = "\t" + "\tنمود\tنما\t" + nonVerbalElement + "\t" + preposition;
                            var newerVerbPlusVal = new VerbPlusValency(newVerbStr, new List<ValencyFrame>());
                            if (!verbValDic.ContainsKey(newVerbStr))
                                verbValDic.Add(newVerbStr, newerVerbPlusVal);
                            verbValDic[newVerbStr].AddNewFrame(GetValencyFrame(split[5]));
                        }

                    }
                }
            }
            int maxTedad = 0;
            foreach (var verbPlusValency in verbValDic)
            {
                int counter = 0;
                int sumTedad = 0;
                foreach (ValencyFrame valencyFrame in verbPlusValency.Value.ValencyFrameList)
                {
                    int tedad = 1;
                    foreach (ValencySlot valencySlot in valencyFrame.ValencyList)
                    {
                        int localTedad = 1;
                        if (valencySlot.ValencyType is Mafool)
                        {
                            var maf = (Mafool)valencySlot.ValencyType;
                            if (maf.RaState == "را+/-")
                                localTedad *= 2;
                        }
                        if (valencySlot.ValencyType is MafoolHarfeEzafeh)
                        {
                            var mafh = (MafoolHarfeEzafeh)valencySlot.ValencyType;
                            localTedad *= mafh.PrepositionList.Count;
                        }
                        if (valencySlot.ValencyType is MotammemQeidi)
                        {
                            var motammemQeidi = (MotammemQeidi)valencySlot.ValencyType;
                            localTedad *= motammemQeidi.AdverbialCase.Count;
                        }
                        if (valencySlot.ValencyType is BandMotammemi)
                        {
                            var band = (BandMotammemi)valencySlot.ValencyType;
                            if (band.Agreement == "مطابقت+/-")
                                localTedad *= 2;
                            if (band.Eltezami == "التزامی+/-")
                                localTedad *= 2;
                        }
                        if (valencySlot.Obligatory == false)
                            localTedad++;
                        tedad *= localTedad;
                    }
                    verbValDic[verbPlusValency.Key].ValencyFrameList[counter].NumOfDifferentFrames = tedad;
                    counter++;
                    sumTedad += tedad;
                }
                verbValDic[verbPlusValency.Key].NumOfBaseStructures = sumTedad;
                if (sumTedad > maxTedad)
                    maxTedad = sumTedad;
            }
            foreach (var verbPlusValency in verbValDic)
            {
                int sumTedad = verbValDic[verbPlusValency.Key].NumOfBaseStructures;
                var structures = new BaseStructure[sumTedad];
                for (int i = 0; i < sumTedad; i++)
                {
                    structures[i] = new BaseStructure();
                }

            }
            var dic = new Dictionary<string, List<string>>();
            var basicBaseStructure = new BaseStructure();
            foreach (var verbPlusValency in verbValDic)
            {
                if (!BaseStrucDic.ContainsKey(verbPlusValency.Key))
                    BaseStrucDic.Add(verbPlusValency.Key, new List<BaseStructure>());
                var baseStructureList = new List<BaseStructure>();
                baseStructureList.Add(basicBaseStructure.Clone());

                foreach (ValencyFrame valencyFrame in verbPlusValency.Value.ValencyFrameList)
                {
                    foreach (ValencySlot valencySlot in valencyFrame.ValencyList)
                    {
                        var newTempList = new List<BaseStructure>();
                        if (!valencySlot.Obligatory)
                        {
                            newTempList.AddRange(baseStructureList.Select(baseStructure => baseStructure.Clone()));
                        }
                        if (valencySlot.ValencyType is Fael)
                        {

                            foreach (BaseStructure baseStructure in baseStructureList)
                            {
                                var newBaseStruct1 = baseStructure.Clone();
                                newBaseStruct1.HasSubject = true;
                                newTempList.Add(newBaseStruct1);
                            }
                        }
                        else if (valencySlot.ValencyType is MafoolNeshanehEzafi)
                        {
                            foreach (BaseStructure baseStructure in baseStructureList)
                            {
                                var newBaseStruct1 = baseStructure.Clone();
                                newBaseStruct1.HasEzafehObject = true;
                                newTempList.Add(newBaseStruct1);
                            }
                        }
                        else if (valencySlot.ValencyType is MafoolDovvom)
                        {
                            foreach (BaseStructure baseStructure in baseStructureList)
                            {
                                var newBaseStruct1 = baseStructure.Clone();
                                newBaseStruct1.HasSecondObject = true;
                                newTempList.Add(newBaseStruct1);
                            }
                        }
                        else if (valencySlot.ValencyType is Mosnad)
                        {
                            foreach (BaseStructure baseStructure in baseStructureList)
                            {
                                var newBaseStruct1 = baseStructure.Clone();
                                newBaseStruct1.HasMosnad = true;
                                newTempList.Add(newBaseStruct1);
                            }
                        }
                        else if (valencySlot.ValencyType is Tameez)
                        {
                            foreach (BaseStructure baseStructure in baseStructureList)
                            {
                                var newBaseStruct1 = baseStructure.Clone();
                                newBaseStruct1.HasTammeez = true;
                                newTempList.Add(newBaseStruct1);
                            }
                        }
                        else if (valencySlot.ValencyType is Mafool)
                        {
                            var maf = (Mafool)valencySlot.ValencyType;
                            if (maf.RaState == "را+/-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var newBaseStruct1 = baseStructure.Clone();
                                    newBaseStruct1.HasObject = true;
                                    newBaseStruct1.HasRa = true;
                                    var newBaseStruct2 = baseStructure.Clone();
                                    newBaseStruct2.HasObject = true;
                                    newBaseStruct2.HasRa = false;
                                    newTempList.Add(newBaseStruct1);
                                    newTempList.Add(newBaseStruct2);
                                }
                            }
                            else if (maf.RaState == "را+")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var newBaseStruct1 = baseStructure.Clone();
                                    newBaseStruct1.HasObject = true;
                                    newBaseStruct1.HasRa = true;
                                    newTempList.Add(newBaseStruct1);
                                }
                            }
                            else
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var newBaseStruct2 = baseStructure.Clone();
                                    newBaseStruct2.HasObject = true;
                                    newBaseStruct2.HasRa = false;
                                    newTempList.Add(newBaseStruct2);
                                }
                            }
                        }

                        else if (valencySlot.ValencyType is MafoolHarfeEzafeh)
                        {
                            var mafh = (MafoolHarfeEzafeh)valencySlot.ValencyType;
                            foreach (string preposition in mafh.PrepositionList)
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var newBaseStruct = baseStructure.Clone();
                                    if (newBaseStruct.HasPrepositionalObject1)
                                    {
                                        newBaseStruct.HasPrepositionalObject2 = true;
                                        newBaseStruct.PrepositionalObjectPreposition2 = preposition;
                                    }
                                    else
                                    {
                                        newBaseStruct.HasPrepositionalObject1 = true;
                                        newBaseStruct.PrepositionalObjectPreposition1 = preposition;
                                    }
                                    newTempList.Add(newBaseStruct);
                                }
                            }
                        }

                        else if (valencySlot.ValencyType is MotammemQeidi)
                        {
                            var motammemQeidi = (MotammemQeidi)valencySlot.ValencyType;
                            foreach (string advCase in motammemQeidi.AdverbialCase)
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var newBaseStruct = baseStructure.Clone();
                                    newBaseStruct.HasMoq = true;
                                    newBaseStruct.MoqType = advCase;
                                    newTempList.Add(newBaseStruct);
                                }
                            }
                        }

                        else if (valencySlot.ValencyType is BandMotammemi)
                        {
                            var band = (BandMotammemi)valencySlot.ValencyType;
                            if (band.Agreement == "مطابقت+/-" && band.Eltezami == "التزامی+/-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi = true;
                                    baseStruct1.HasBandMotemmemiAgreement = true;
                                    baseStruct1.HasBandMotemmemiEltezami = true;
                                    newTempList.Add(baseStruct1);
                                    var baseStruct2 = baseStruct1.Clone();
                                    baseStruct2.HasBandMotemmemiAgreement = false;
                                    newTempList.Add(baseStruct2);
                                    var baseStruct3 = baseStruct1.Clone();
                                    baseStruct3.HasBandMotemmemiEltezami = false;
                                    newTempList.Add(baseStruct3);
                                    var baseStruct4 = baseStruct1.Clone();
                                    baseStruct4.HasBandMotemmemiEltezami = false;
                                    baseStruct4.HasBandMotemmemiAgreement = false;
                                    newTempList.Add(baseStruct4);
                                }
                            }
                            else if (band.Agreement == "مطابقت+/-" && band.Eltezami == "التزامی+")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi = true;
                                    baseStruct1.HasBandMotemmemiAgreement = true;
                                    baseStruct1.HasBandMotemmemiEltezami = true;
                                    newTempList.Add(baseStruct1);
                                    var baseStruct2 = baseStruct1.Clone();
                                    baseStruct2.HasBandMotemmemiAgreement = false;
                                    newTempList.Add(baseStruct2);
                                }
                            }
                            else if (band.Agreement == "مطابقت+/-" && band.Eltezami == "التزامی-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi = true;
                                    baseStruct1.HasBandMotemmemiAgreement = true;
                                    baseStruct1.HasBandMotemmemiEltezami = false;
                                    newTempList.Add(baseStruct1);
                                    var baseStruct2 = baseStruct1.Clone();
                                    baseStruct2.HasBandMotemmemiAgreement = false;
                                    newTempList.Add(baseStruct2);
                                }
                            }
                            else if (band.Agreement == "مطابقت+" && band.Eltezami == "التزامی+/-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi = true;
                                    baseStruct1.HasBandMotemmemiAgreement = true;
                                    baseStruct1.HasBandMotemmemiEltezami = true;
                                    newTempList.Add(baseStruct1);
                                    var baseStruct3 = baseStruct1.Clone();
                                    baseStruct3.HasBandMotemmemiEltezami = false;
                                    newTempList.Add(baseStruct3);
                                }
                            }
                            else if (band.Agreement == "مطابقت+" && band.Eltezami == "التزامی+")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi = true;
                                    baseStruct1.HasBandMotemmemiAgreement = true;
                                    baseStruct1.HasBandMotemmemiEltezami = true;
                                    newTempList.Add(baseStruct1);
                                }
                            }
                            else if (band.Agreement == "مطابقت+" && band.Eltezami == "التزامی-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi = true;
                                    baseStruct1.HasBandMotemmemiAgreement = true;
                                    baseStruct1.HasBandMotemmemiEltezami = false;
                                    newTempList.Add(baseStruct1);
                                }
                            }
                            else if (band.Agreement == "مطابقت-" && band.Eltezami == "التزامی+/-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi = true;
                                    baseStruct1.HasBandMotemmemiAgreement = false;
                                    baseStruct1.HasBandMotemmemiEltezami = true;
                                    newTempList.Add(baseStruct1);
                                    var baseStruct3 = baseStruct1.Clone();
                                    baseStruct3.HasBandMotemmemiEltezami = false;
                                    newTempList.Add(baseStruct3);
                                }
                            }
                            else if (band.Agreement == "مطابقت-" && band.Eltezami == "التزامی+")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi = true;
                                    baseStruct1.HasBandMotemmemiAgreement = false;
                                    baseStruct1.HasBandMotemmemiEltezami = true;
                                    newTempList.Add(baseStruct1);
                                }
                            }
                            else if (band.Agreement == "مطابقت-" && band.Eltezami == "التزامی-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct4 = baseStructure.Clone();
                                    baseStruct4.HasBandMotemmemiEltezami = false;
                                    baseStruct4.HasBandMotemmemiAgreement = false;
                                    newTempList.Add(baseStruct4);
                                }
                            }
                        }
                        if (newTempList.Count > 0)
                            baseStructureList = newTempList;
                    }
                }
                foreach (BaseStructure baseStructure in baseStructureList)
                {
                    if (!BaseStrucDic[verbPlusValency.Key].Contains(baseStructure))
                        BaseStrucDic[verbPlusValency.Key].Add(baseStructure);
                }
            }
        }
コード例 #3
0
        public static void RefreshVerbList(string verbpath, string valencePath)
        {
            BaseStrucDic = new Dictionary <string, List <BaseStructure> >();
            var    verbValDic    = new Dictionary <string, VerbPlusValency>();
            var    reader        = new StreamReader(verbpath);
            var    newVerbReader = new StreamReader(valencePath);
            string sentence;
            var    mainCatList = new List <List <string> >();

            while ((sentence = reader.ReadLine()) != null)
            {
                sentence = StringUtil.RefineAndFilterPersianWord(sentence);
                mainCatList.Add(sentence.Trim().Split("\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList());
            }
            while ((sentence = newVerbReader.ReadLine()) != null)
            {
                sentence = StringUtil.RefineAndFilterPersianWord(sentence);
                var    split            = sentence.Split("\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                string bonMazi          = split[0];
                string bonMozare        = split[1];
                string prefix           = split[2];
                string nonVerbalElement = split[3];
                string preposition      = split[4];

                foreach (List <string> list in mainCatList)
                {
                    if (bonMazi == list[2] && bonMozare == list[3] && prefix == list[5] && nonVerbalElement == list[4] && preposition == list[6])
                    {
                        string verbStr = prefix + "#" + bonMazi + "#" + bonMozare + "#" + nonVerbalElement + "#" + preposition;
                        if (prefix == "-")
                        {
                            verbStr = bonMazi + "#" + bonMozare + "#" + nonVerbalElement + "#" + preposition;
                        }
                        var newVerbPlusVal = new VerbPlusValency(verbStr, new List <ValencyFrame>());
                        if (!verbValDic.ContainsKey(verbStr))
                        {
                            verbValDic.Add(verbStr, newVerbPlusVal);
                        }

                        verbValDic[verbStr].AddNewFrame(GetValencyFrame(split[5]));

                        if (bonMazi == "کرد" && nonVerbalElement != "-")
                        {
                            string newVerbStr = prefix + "\t" + "\tنمود\tنما\t" +
                                                nonVerbalElement + "\t" + preposition;
                            if (prefix == "-")
                            {
                                newVerbStr = "\t" + "\tنمود\tنما\t" + nonVerbalElement + "\t" + preposition;
                            }
                            var newerVerbPlusVal = new VerbPlusValency(newVerbStr, new List <ValencyFrame>());
                            if (!verbValDic.ContainsKey(newVerbStr))
                            {
                                verbValDic.Add(newVerbStr, newerVerbPlusVal);
                            }
                            verbValDic[newVerbStr].AddNewFrame(GetValencyFrame(split[5]));
                        }
                    }
                }
            }
            int maxTedad = 0;

            foreach (var verbPlusValency in verbValDic)
            {
                int counter  = 0;
                int sumTedad = 0;
                foreach (ValencyFrame valencyFrame in verbPlusValency.Value.ValencyFrameList)
                {
                    int tedad = 1;
                    foreach (ValencySlot valencySlot in valencyFrame.ValencyList)
                    {
                        int localTedad = 1;
                        if (valencySlot.ValencyType is Mafool)
                        {
                            var maf = (Mafool)valencySlot.ValencyType;
                            if (maf.RaState == "را+/-")
                            {
                                localTedad *= 2;
                            }
                        }
                        if (valencySlot.ValencyType is MafoolHarfeEzafeh)
                        {
                            var mafh = (MafoolHarfeEzafeh)valencySlot.ValencyType;
                            localTedad *= mafh.PrepositionList.Count;
                        }
                        if (valencySlot.ValencyType is MotammemQeidi)
                        {
                            var motammemQeidi = (MotammemQeidi)valencySlot.ValencyType;
                            localTedad *= motammemQeidi.AdverbialCase.Count;
                        }
                        if (valencySlot.ValencyType is BandMotammemi)
                        {
                            var band = (BandMotammemi)valencySlot.ValencyType;
                            if (band.Agreement == "مطابقت+/-")
                            {
                                localTedad *= 2;
                            }
                            if (band.Eltezami == "التزامی+/-")
                            {
                                localTedad *= 2;
                            }
                        }
                        if (valencySlot.Obligatory == false)
                        {
                            localTedad++;
                        }
                        tedad *= localTedad;
                    }
                    verbValDic[verbPlusValency.Key].ValencyFrameList[counter].NumOfDifferentFrames = tedad;
                    counter++;
                    sumTedad += tedad;
                }
                verbValDic[verbPlusValency.Key].NumOfBaseStructures = sumTedad;
                if (sumTedad > maxTedad)
                {
                    maxTedad = sumTedad;
                }
            }
            foreach (var verbPlusValency in verbValDic)
            {
                int sumTedad   = verbValDic[verbPlusValency.Key].NumOfBaseStructures;
                var structures = new BaseStructure[sumTedad];
                for (int i = 0; i < sumTedad; i++)
                {
                    structures[i] = new BaseStructure();
                }
            }
            var dic = new Dictionary <string, List <string> >();
            var basicBaseStructure = new BaseStructure();

            foreach (var verbPlusValency in verbValDic)
            {
                if (!BaseStrucDic.ContainsKey(verbPlusValency.Key))
                {
                    BaseStrucDic.Add(verbPlusValency.Key, new List <BaseStructure>());
                }
                var baseStructureList = new List <BaseStructure>();
                baseStructureList.Add(basicBaseStructure.Clone());

                foreach (ValencyFrame valencyFrame in verbPlusValency.Value.ValencyFrameList)
                {
                    foreach (ValencySlot valencySlot in valencyFrame.ValencyList)
                    {
                        var newTempList = new List <BaseStructure>();
                        if (!valencySlot.Obligatory)
                        {
                            newTempList.AddRange(baseStructureList.Select(baseStructure => baseStructure.Clone()));
                        }
                        if (valencySlot.ValencyType is Fael)
                        {
                            foreach (BaseStructure baseStructure in baseStructureList)
                            {
                                var newBaseStruct1 = baseStructure.Clone();
                                newBaseStruct1.HasSubject = true;
                                newTempList.Add(newBaseStruct1);
                            }
                        }
                        else if (valencySlot.ValencyType is MafoolNeshanehEzafi)
                        {
                            foreach (BaseStructure baseStructure in baseStructureList)
                            {
                                var newBaseStruct1 = baseStructure.Clone();
                                newBaseStruct1.HasEzafehObject = true;
                                newTempList.Add(newBaseStruct1);
                            }
                        }
                        else if (valencySlot.ValencyType is MafoolDovvom)
                        {
                            foreach (BaseStructure baseStructure in baseStructureList)
                            {
                                var newBaseStruct1 = baseStructure.Clone();
                                newBaseStruct1.HasSecondObject = true;
                                newTempList.Add(newBaseStruct1);
                            }
                        }
                        else if (valencySlot.ValencyType is Mosnad)
                        {
                            foreach (BaseStructure baseStructure in baseStructureList)
                            {
                                var newBaseStruct1 = baseStructure.Clone();
                                newBaseStruct1.HasMosnad = true;
                                newTempList.Add(newBaseStruct1);
                            }
                        }
                        else if (valencySlot.ValencyType is Tameez)
                        {
                            foreach (BaseStructure baseStructure in baseStructureList)
                            {
                                var newBaseStruct1 = baseStructure.Clone();
                                newBaseStruct1.HasTammeez = true;
                                newTempList.Add(newBaseStruct1);
                            }
                        }
                        else if (valencySlot.ValencyType is Mafool)
                        {
                            var maf = (Mafool)valencySlot.ValencyType;
                            if (maf.RaState == "را+/-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var newBaseStruct1 = baseStructure.Clone();
                                    newBaseStruct1.HasObject = true;
                                    newBaseStruct1.HasRa     = true;
                                    var newBaseStruct2 = baseStructure.Clone();
                                    newBaseStruct2.HasObject = true;
                                    newBaseStruct2.HasRa     = false;
                                    newTempList.Add(newBaseStruct1);
                                    newTempList.Add(newBaseStruct2);
                                }
                            }
                            else if (maf.RaState == "را+")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var newBaseStruct1 = baseStructure.Clone();
                                    newBaseStruct1.HasObject = true;
                                    newBaseStruct1.HasRa     = true;
                                    newTempList.Add(newBaseStruct1);
                                }
                            }
                            else
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var newBaseStruct2 = baseStructure.Clone();
                                    newBaseStruct2.HasObject = true;
                                    newBaseStruct2.HasRa     = false;
                                    newTempList.Add(newBaseStruct2);
                                }
                            }
                        }

                        else if (valencySlot.ValencyType is MafoolHarfeEzafeh)
                        {
                            var mafh = (MafoolHarfeEzafeh)valencySlot.ValencyType;
                            foreach (string preposition in mafh.PrepositionList)
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var newBaseStruct = baseStructure.Clone();
                                    if (newBaseStruct.HasPrepositionalObject1)
                                    {
                                        newBaseStruct.HasPrepositionalObject2         = true;
                                        newBaseStruct.PrepositionalObjectPreposition2 = preposition;
                                    }
                                    else
                                    {
                                        newBaseStruct.HasPrepositionalObject1         = true;
                                        newBaseStruct.PrepositionalObjectPreposition1 = preposition;
                                    }
                                    newTempList.Add(newBaseStruct);
                                }
                            }
                        }

                        else if (valencySlot.ValencyType is MotammemQeidi)
                        {
                            var motammemQeidi = (MotammemQeidi)valencySlot.ValencyType;
                            foreach (string advCase in motammemQeidi.AdverbialCase)
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var newBaseStruct = baseStructure.Clone();
                                    newBaseStruct.HasMoq  = true;
                                    newBaseStruct.MoqType = advCase;
                                    newTempList.Add(newBaseStruct);
                                }
                            }
                        }

                        else if (valencySlot.ValencyType is BandMotammemi)
                        {
                            var band = (BandMotammemi)valencySlot.ValencyType;
                            if (band.Agreement == "مطابقت+/-" && band.Eltezami == "التزامی+/-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi          = true;
                                    baseStruct1.HasBandMotemmemiAgreement = true;
                                    baseStruct1.HasBandMotemmemiEltezami  = true;
                                    newTempList.Add(baseStruct1);
                                    var baseStruct2 = baseStruct1.Clone();
                                    baseStruct2.HasBandMotemmemiAgreement = false;
                                    newTempList.Add(baseStruct2);
                                    var baseStruct3 = baseStruct1.Clone();
                                    baseStruct3.HasBandMotemmemiEltezami = false;
                                    newTempList.Add(baseStruct3);
                                    var baseStruct4 = baseStruct1.Clone();
                                    baseStruct4.HasBandMotemmemiEltezami  = false;
                                    baseStruct4.HasBandMotemmemiAgreement = false;
                                    newTempList.Add(baseStruct4);
                                }
                            }
                            else if (band.Agreement == "مطابقت+/-" && band.Eltezami == "التزامی+")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi          = true;
                                    baseStruct1.HasBandMotemmemiAgreement = true;
                                    baseStruct1.HasBandMotemmemiEltezami  = true;
                                    newTempList.Add(baseStruct1);
                                    var baseStruct2 = baseStruct1.Clone();
                                    baseStruct2.HasBandMotemmemiAgreement = false;
                                    newTempList.Add(baseStruct2);
                                }
                            }
                            else if (band.Agreement == "مطابقت+/-" && band.Eltezami == "التزامی-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi          = true;
                                    baseStruct1.HasBandMotemmemiAgreement = true;
                                    baseStruct1.HasBandMotemmemiEltezami  = false;
                                    newTempList.Add(baseStruct1);
                                    var baseStruct2 = baseStruct1.Clone();
                                    baseStruct2.HasBandMotemmemiAgreement = false;
                                    newTempList.Add(baseStruct2);
                                }
                            }
                            else if (band.Agreement == "مطابقت+" && band.Eltezami == "التزامی+/-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi          = true;
                                    baseStruct1.HasBandMotemmemiAgreement = true;
                                    baseStruct1.HasBandMotemmemiEltezami  = true;
                                    newTempList.Add(baseStruct1);
                                    var baseStruct3 = baseStruct1.Clone();
                                    baseStruct3.HasBandMotemmemiEltezami = false;
                                    newTempList.Add(baseStruct3);
                                }
                            }
                            else if (band.Agreement == "مطابقت+" && band.Eltezami == "التزامی+")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi          = true;
                                    baseStruct1.HasBandMotemmemiAgreement = true;
                                    baseStruct1.HasBandMotemmemiEltezami  = true;
                                    newTempList.Add(baseStruct1);
                                }
                            }
                            else if (band.Agreement == "مطابقت+" && band.Eltezami == "التزامی-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi          = true;
                                    baseStruct1.HasBandMotemmemiAgreement = true;
                                    baseStruct1.HasBandMotemmemiEltezami  = false;
                                    newTempList.Add(baseStruct1);
                                }
                            }
                            else if (band.Agreement == "مطابقت-" && band.Eltezami == "التزامی+/-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi          = true;
                                    baseStruct1.HasBandMotemmemiAgreement = false;
                                    baseStruct1.HasBandMotemmemiEltezami  = true;
                                    newTempList.Add(baseStruct1);
                                    var baseStruct3 = baseStruct1.Clone();
                                    baseStruct3.HasBandMotemmemiEltezami = false;
                                    newTempList.Add(baseStruct3);
                                }
                            }
                            else if (band.Agreement == "مطابقت-" && band.Eltezami == "التزامی+")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct1 = baseStructure.Clone();
                                    baseStruct1.HasBandMotammemi          = true;
                                    baseStruct1.HasBandMotemmemiAgreement = false;
                                    baseStruct1.HasBandMotemmemiEltezami  = true;
                                    newTempList.Add(baseStruct1);
                                }
                            }
                            else if (band.Agreement == "مطابقت-" && band.Eltezami == "التزامی-")
                            {
                                foreach (BaseStructure baseStructure in baseStructureList)
                                {
                                    var baseStruct4 = baseStructure.Clone();
                                    baseStruct4.HasBandMotemmemiEltezami  = false;
                                    baseStruct4.HasBandMotemmemiAgreement = false;
                                    newTempList.Add(baseStruct4);
                                }
                            }
                        }
                        if (newTempList.Count > 0)
                        {
                            baseStructureList = newTempList;
                        }
                    }
                }
                foreach (BaseStructure baseStructure in baseStructureList)
                {
                    if (!BaseStrucDic[verbPlusValency.Key].Contains(baseStructure))
                    {
                        BaseStrucDic[verbPlusValency.Key].Add(baseStructure);
                    }
                }
            }
        }
コード例 #4
0
 public BaseStructure Clone()
 {
     var newStruct = new BaseStructure();
     newStruct.HasBandMotammemi = HasBandMotammemi;
     newStruct.HasBandMotemmemiAgreement = HasBandMotemmemiAgreement;
     newStruct.HasBandMotemmemiEltezami = HasBandMotemmemiEltezami;
     newStruct.HasEzafehObject = HasEzafehObject;
     newStruct.HasMoq = HasMoq;
     newStruct.HasMosnad = HasMosnad;
     newStruct.HasObject = HasObject;
     newStruct.HasPrepositionalObject1 = HasPrepositionalObject1;
     newStruct.HasPrepositionalObject2 = HasPrepositionalObject2;
     newStruct.HasRa = HasRa;
     newStruct.HasSecondObject = HasSecondObject;
     newStruct.HasSubject = HasSubject;
     newStruct.HasTammeez = HasTammeez;
     newStruct.PrepositionalObjectPreposition1 = PrepositionalObjectPreposition1;
     newStruct.PrepositionalObjectPreposition2 = PrepositionalObjectPreposition2;
     newStruct.MoqType = MoqType;
     return newStruct;
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: yassersouri/Corpus-Builder
        private static Article generateNewArticle(Article currentArticle, string verbDicPath)
        {
            Article newArticle = new Article();

            Sentence currentSentence = null;
            Sentence newSentence = null;
            String[] currentLexemes = null;
            String[] currentPOSTags = null;
            String[] currentLemmas = null;
            MorphoSyntacticFeatures[] currentFeatures = null;

            //generating new Sentence
            for(int sentence_index = 0; sentence_index < currentArticle.getSentences().Length; sentence_index++) //for each sentence in this article.
            {
                //initialize the new sentence
                newSentence = new Sentence();

                //load the current sentence
                currentSentence = currentArticle.getSentence(sentence_index);

                //load info about that sentence
                currentLexemes = currentSentence.getLexemes();
                currentPOSTags = currentSentence.getPOSTags();
                currentLemmas = currentSentence.getLemmas();
                currentFeatures = currentSentence.getFeatures();

                VerbBasedSentence currentSentenceVBS = SentenceAnalyzer.MakeVerbBasedSentence(currentLexemes, currentPOSTags, currentLemmas, currentFeatures, verbDicPath);
                List<DependencyBasedToken> list = currentSentenceVBS.SentenceTokens;
                Random randomNumberGenerator = new Random();
                Dictionary<VerbInSentence, BaseStructure> pickedBasedStructures = new Dictionary<VerbInSentence,BaseStructure>();

                //for each verb in sentence
                foreach(var currentVerbInSentence in currentSentenceVBS.VerbsInSentence)
                {
                    bool noSatisfiedBaseStructureExists = false;

                    List<BaseStructure> satisfiedBaseStructuresOfCurrentVerb = new List<BaseStructure>();
                    //special string representation of the verb
                    String currentVerbString = ValencyDicManager.GetVerbString(ref currentSentenceVBS, currentVerbInSentence);
                    if (ValencyDicManager.BaseStrucDic.ContainsKey(currentVerbString))
                    {
                        List<BaseStructure> baseStructuresForTheCurrentVerb = ValencyDicManager.BaseStrucDic[currentVerbString];
                        foreach (var currentBaseStructure in baseStructuresForTheCurrentVerb)
                        {
                            if(currentBaseStructure.Satisfy(currentSentenceVBS, currentVerbInSentence))
                            {
                                satisfiedBaseStructuresOfCurrentVerb.Add(currentBaseStructure);
                            }
                        }
                    }

                    if(satisfiedBaseStructuresOfCurrentVerb.Count == 0) noSatisfiedBaseStructureExists = true;

                    List<BaseStructure> candidateBaseStructuresOfCurrentVerb;

                    #region select one base structure of this verb

                    bool finishedChoosingPickedBaseStructure = false;

                    //no need to choose because nothing is there
                    if (noSatisfiedBaseStructureExists) finishedChoosingPickedBaseStructure = true;
                    #region HasPrepositionalObject2
                    candidateBaseStructuresOfCurrentVerb = new List<BaseStructure>();

                    if(!finishedChoosingPickedBaseStructure)
                    {
                        foreach (var currentSatisfiedBaseStructure in satisfiedBaseStructuresOfCurrentVerb)
                        {
                            if(currentSatisfiedBaseStructure.HasPrepositionalObject2)
                                candidateBaseStructuresOfCurrentVerb.Add(currentSatisfiedBaseStructure);
                        }
                        if(candidateBaseStructuresOfCurrentVerb.Count > 1)
                        {
                            int randomIndex = randomNumberGenerator.Next(0, candidateBaseStructuresOfCurrentVerb.Count);
                            pickedBasedStructures.Add(currentVerbInSentence, candidateBaseStructuresOfCurrentVerb[randomIndex]);
                            finishedChoosingPickedBaseStructure = true;
                        }
                        else if(candidateBaseStructuresOfCurrentVerb.Count == 1)
                        {
                            pickedBasedStructures.Add(currentVerbInSentence, candidateBaseStructuresOfCurrentVerb[0]);
                            finishedChoosingPickedBaseStructure = true;
                        }
                        else if(candidateBaseStructuresOfCurrentVerb.Count == 0)
                        {
                            finishedChoosingPickedBaseStructure = false;
                        }
                        else
                        {
                            throw new Exception("Error in picking BaseStructures for Verbs");
                        }
                    }
                    #endregion

                    #region HasPrepositionalObject1
                    candidateBaseStructuresOfCurrentVerb = new List<BaseStructure>();

                    if (!finishedChoosingPickedBaseStructure)
                    {
                        foreach (var currentSatisfiedBaseStructure in satisfiedBaseStructuresOfCurrentVerb)
                        {
                            if (currentSatisfiedBaseStructure.HasPrepositionalObject1)
                                candidateBaseStructuresOfCurrentVerb.Add(currentSatisfiedBaseStructure);
                        }
                        if (candidateBaseStructuresOfCurrentVerb.Count > 1)
                        {
                            int randomIndex = randomNumberGenerator.Next(0, candidateBaseStructuresOfCurrentVerb.Count);
                            pickedBasedStructures.Add(currentVerbInSentence, candidateBaseStructuresOfCurrentVerb[randomIndex]);
                            finishedChoosingPickedBaseStructure = true;
                        }
                        else if (candidateBaseStructuresOfCurrentVerb.Count == 1)
                        {
                            pickedBasedStructures.Add(currentVerbInSentence, candidateBaseStructuresOfCurrentVerb[0]);
                            finishedChoosingPickedBaseStructure = true;
                        }
                        else if (candidateBaseStructuresOfCurrentVerb.Count == 0)
                        {
                            finishedChoosingPickedBaseStructure = false;
                        }
                        else
                        {
                            throw new Exception("Error in picking BaseStructures for Verbs");
                        }
                    }
                    #endregion

                    #region HasRa
                    candidateBaseStructuresOfCurrentVerb = new List<BaseStructure>();

                    if (!finishedChoosingPickedBaseStructure)
                    {
                        foreach (var currentSatisfiedBaseStructure in satisfiedBaseStructuresOfCurrentVerb)
                        {
                            if (currentSatisfiedBaseStructure.HasRa)
                                candidateBaseStructuresOfCurrentVerb.Add(currentSatisfiedBaseStructure);
                        }
                        if (candidateBaseStructuresOfCurrentVerb.Count > 1)
                        {
                            int randomIndex = randomNumberGenerator.Next(0, candidateBaseStructuresOfCurrentVerb.Count);
                            pickedBasedStructures.Add(currentVerbInSentence, candidateBaseStructuresOfCurrentVerb[randomIndex]);
                            finishedChoosingPickedBaseStructure = true;
                        }
                        else if (candidateBaseStructuresOfCurrentVerb.Count == 1)
                        {
                            pickedBasedStructures.Add(currentVerbInSentence, candidateBaseStructuresOfCurrentVerb[0]);
                            finishedChoosingPickedBaseStructure = true;
                        }
                        else if (candidateBaseStructuresOfCurrentVerb.Count == 0)
                        {
                            finishedChoosingPickedBaseStructure = false;
                        }
                        else
                        {
                            throw new Exception("Error in picking BaseStructures for Verbs");
                        }
                    }
                    #endregion

                    #region HasBandMotammemi
                    candidateBaseStructuresOfCurrentVerb = new List<BaseStructure>();

                    if (!finishedChoosingPickedBaseStructure)
                    {
                        foreach (var currentSatisfiedBaseStructure in satisfiedBaseStructuresOfCurrentVerb)
                        {
                            if (currentSatisfiedBaseStructure.HasBandMotammemi || currentSatisfiedBaseStructure.HasBandMotemmemiAgreement || currentSatisfiedBaseStructure.HasBandMotemmemiEltezami)
                                candidateBaseStructuresOfCurrentVerb.Add(currentSatisfiedBaseStructure);
                        }
                        if (candidateBaseStructuresOfCurrentVerb.Count > 1)
                        {
                            int randomIndex = randomNumberGenerator.Next(0, candidateBaseStructuresOfCurrentVerb.Count);
                            pickedBasedStructures.Add(currentVerbInSentence, candidateBaseStructuresOfCurrentVerb[randomIndex]);
                            finishedChoosingPickedBaseStructure = true;
                        }
                        else if (candidateBaseStructuresOfCurrentVerb.Count == 1)
                        {
                            pickedBasedStructures.Add(currentVerbInSentence, candidateBaseStructuresOfCurrentVerb[0]);
                            finishedChoosingPickedBaseStructure = true;
                        }
                        else if (candidateBaseStructuresOfCurrentVerb.Count == 0)
                        {
                            finishedChoosingPickedBaseStructure = false;
                        }
                        else
                        {
                            throw new Exception("Error in picking BaseStructures for Verbs");
                        }
                    }
                    #endregion

                    #region Choose Randomly
                    if(!finishedChoosingPickedBaseStructure)
                    {
                        int randomNumberIndex = randomNumberGenerator.Next(0, satisfiedBaseStructuresOfCurrentVerb.Count);
                        pickedBasedStructures.Add(currentVerbInSentence, satisfiedBaseStructuresOfCurrentVerb[randomNumberIndex]);
                        finishedChoosingPickedBaseStructure = true;
                    }

                    #endregion

                    #endregion

                }

                #region select one base structure for the whole sentence from pickedBaseStructures

                bool finishedChoosingBaseStructure = false;
                bool nothingPicked = false;

                //don't choose base structure.
                if(pickedBasedStructures.Count == 0)
                {
                    finishedChoosingBaseStructure = true;
                    nothingPicked = true;
                }
                List<KeyValuePair<VerbInSentence, BaseStructure>> candidatesOfCurrentSentence;
                KeyValuePair<VerbInSentence, BaseStructure> SelectedKVP = new KeyValuePair<VerbInSentence,BaseStructure>();

                #region choose HasPrepositionalObject2

                if(!finishedChoosingBaseStructure){
                    candidatesOfCurrentSentence = new List<KeyValuePair<VerbInSentence,BaseStructure>>();

                    foreach(var currentKeyValuePair in pickedBasedStructures)
                    {
                        if(currentKeyValuePair.Value.HasPrepositionalObject2)
                            candidatesOfCurrentSentence.Add(currentKeyValuePair);
                    }

                    if(candidatesOfCurrentSentence.Count > 1)
                    {
                        //select the one which is at the end of the sentence
                        int maxLightVerbIndex = 0;
                        foreach(var currentKeyValuePair in candidatesOfCurrentSentence)
                        {
                            if(currentKeyValuePair.Key.LightVerbIndex >= maxLightVerbIndex){
                                maxLightVerbIndex = currentKeyValuePair.Key.LightVerbIndex;
                                SelectedKVP = currentKeyValuePair;
                            }
                        }
                        finishedChoosingBaseStructure = true;
                    }
                    else if(candidatesOfCurrentSentence.Count == 1)
                    {
                        SelectedKVP = candidatesOfCurrentSentence[0];
                        finishedChoosingBaseStructure = true;
                    }
                    else if (candidatesOfCurrentSentence.Count == 0)
                    {
                        finishedChoosingBaseStructure = false;
                    }
                    else
                    {
                        throw new Exception("Error in picking BaseStructures for Verbs");
                    }

                }
                #endregion

                #region choose HasPrepositionalObject1

                if (!finishedChoosingBaseStructure)
                {
                    candidatesOfCurrentSentence = new List<KeyValuePair<VerbInSentence, BaseStructure>>();

                    foreach (var currentKeyValuePair in pickedBasedStructures)
                    {
                        if (currentKeyValuePair.Value.HasPrepositionalObject1)
                            candidatesOfCurrentSentence.Add(currentKeyValuePair);
                    }

                    if (candidatesOfCurrentSentence.Count > 1)
                    {
                        //select the one which is at the end of the sentence
                        int maxLightVerbIndex = 0;
                        foreach (var currentKeyValuePair in candidatesOfCurrentSentence)
                        {
                            if (currentKeyValuePair.Key.LightVerbIndex >= maxLightVerbIndex)
                            {
                                maxLightVerbIndex = currentKeyValuePair.Key.LightVerbIndex;
                                SelectedKVP = currentKeyValuePair;
                            }
                        }
                        finishedChoosingBaseStructure = true;
                    }
                    else if (candidatesOfCurrentSentence.Count == 1)
                    {
                        SelectedKVP = candidatesOfCurrentSentence[0];
                        finishedChoosingBaseStructure = true;
                    }
                    else if (candidatesOfCurrentSentence.Count == 0)
                    {
                        finishedChoosingBaseStructure = false;
                    }
                    else
                    {
                        throw new Exception("Error in picking BaseStructures for Verbs");
                    }

                }
                #endregion

                #region choose HasRa

                if (!finishedChoosingBaseStructure)
                {
                    candidatesOfCurrentSentence = new List<KeyValuePair<VerbInSentence, BaseStructure>>();

                    foreach (var currentKeyValuePair in pickedBasedStructures)
                    {
                        if (currentKeyValuePair.Value.HasRa)
                            candidatesOfCurrentSentence.Add(currentKeyValuePair);
                    }

                    if (candidatesOfCurrentSentence.Count > 1)
                    {
                        //select the one which is at the end of the sentence
                        int maxLightVerbIndex = 0;
                        foreach (var currentKeyValuePair in candidatesOfCurrentSentence)
                        {
                            if (currentKeyValuePair.Key.LightVerbIndex >= maxLightVerbIndex)
                            {
                                maxLightVerbIndex = currentKeyValuePair.Key.LightVerbIndex;
                                SelectedKVP = currentKeyValuePair;
                            }
                        }
                        finishedChoosingBaseStructure = true;
                    }
                    else if (candidatesOfCurrentSentence.Count == 1)
                    {
                        SelectedKVP = candidatesOfCurrentSentence[0];
                        finishedChoosingBaseStructure = true;
                    }
                    else if (candidatesOfCurrentSentence.Count == 0)
                    {
                        finishedChoosingBaseStructure = false;
                    }
                    else
                    {
                        throw new Exception("Error in picking BaseStructures for Verbs");
                    }

                }
                #endregion

                #region choose HasBandMotammemi

                if (!finishedChoosingBaseStructure)
                {
                    candidatesOfCurrentSentence = new List<KeyValuePair<VerbInSentence, BaseStructure>>();

                    foreach (var currentKeyValuePair in pickedBasedStructures)
                    {
                        if (currentKeyValuePair.Value.HasBandMotammemi || currentKeyValuePair.Value.HasBandMotemmemiAgreement || currentKeyValuePair.Value.HasBandMotemmemiEltezami)
                            candidatesOfCurrentSentence.Add(currentKeyValuePair);
                    }

                    if (candidatesOfCurrentSentence.Count > 1)
                    {
                        //select the one which is at the end of the sentence
                        int maxLightVerbIndex = 0;
                        foreach (var currentKeyValuePair in candidatesOfCurrentSentence)
                        {
                            if (currentKeyValuePair.Key.LightVerbIndex >= maxLightVerbIndex)
                            {
                                maxLightVerbIndex = currentKeyValuePair.Key.LightVerbIndex;
                                SelectedKVP = currentKeyValuePair;
                            }
                        }
                        finishedChoosingBaseStructure = true;
                    }
                    else if (candidatesOfCurrentSentence.Count == 1)
                    {
                        SelectedKVP = candidatesOfCurrentSentence[0];
                        finishedChoosingBaseStructure = true;
                    }
                    else if (candidatesOfCurrentSentence.Count == 0)
                    {
                        finishedChoosingBaseStructure = false;
                    }
                    else
                    {
                        throw new Exception("Error in picking BaseStructures for Verbs");
                    }

                }
                #endregion

                #region choose the last verb

                if(!finishedChoosingBaseStructure)
                {
                    int maxLightVerbIndex = 0;
                    foreach(var currentKeyValuePair in pickedBasedStructures)
                    {
                        if(currentKeyValuePair.Key.LightVerbIndex >= maxLightVerbIndex)
                        {
                            SelectedKVP = currentKeyValuePair;
                            maxLightVerbIndex = currentKeyValuePair.Key.LightVerbIndex;
                        }
                    }
                    finishedChoosingBaseStructure = true;
                }

                #endregion

                #endregion

                //fitting one base structure

                if(nothingPicked)
                {
                    //nothing really picked.
                    if(currentSentenceVBS.VerbsInSentence.Count == 0)
                    {
                        //no verb exists in the sentense
                        //do nothing
                    }
                    else
                    {
                        VerbInSentence lastVerbInTheSentence = currentSentenceVBS.VerbsInSentence.Last();
                        BaseStructure emptyBaseStructure = new BaseStructure();
                        SelectedKVP = new KeyValuePair<VerbInSentence,BaseStructure>(lastVerbInTheSentence, emptyBaseStructure);
                        nothingPicked = false;
                    }
                }

                if(!nothingPicked)
                    SelectedKVP.Value.FitIntoBaseStructure(ref currentSentenceVBS, SelectedKVP.Key);

                //word index pointer in the current sentence
                int wordIndexInCurrentSentence = 0;

                Word currentWord = null;
                Word newWord = null;
                DependencyBasedToken currentDBT;

                #region upgrading the current sentence to a new sentence.
                for(int word_index = 0; word_index < list.Count() ; word_index++)
                {
                    currentDBT = list[word_index];

                    newWord = new Word();

                    newWord.num = currentDBT.Position;
                    newWord.lexeme = currentDBT.WordForm;
                    if(currentDBT.Lemma != "_")
                    {
                        //if lemma is changed
                        newWord.lemma = currentDBT.Lemma;
                        newWord.cpos = currentDBT.CPOSTag;
                        newWord.fpos = currentDBT.FPOSTag;

                        if(currentDBT.MorphoSyntacticFeats.Person != ShakhsType.Shakhs_NONE)
                            newWord.person = currentDBT.MorphoSyntacticFeats.Person.ToString();
                        else
                            newWord.person = "_";

                        if(currentDBT.MorphoSyntacticFeats.Number != NumberType.INVALID)
                            newWord.number = currentDBT.MorphoSyntacticFeats.Number.ToString();
                        else
                            newWord.number = "_";

                        if(currentDBT.MorphoSyntacticFeats.TenseMoodAspect != TenseFormationType.TenseFormationType_NONE)
                            newWord.tma = currentDBT.MorphoSyntacticFeats.TenseMoodAspect.ToString();
                        else
                            newWord.tma = "_";
                    }
                    else{
                        //lemma is unchanged
                        currentWord = currentSentence.getWord(wordIndexInCurrentSentence);

                        newWord.lemma = currentWord.lemma;
                        newWord.cpos = currentWord.cpos;
                        newWord.fpos = currentWord.fpos;
                        newWord.person = currentWord.person;
                        newWord.number = currentWord.number;
                        newWord.tma = "_";
                    }

                    //are changed any way
                    newWord.parentId = currentDBT.HeadNumber;
                    newWord.parentRelation = currentDBT.DependencyRelation;

                    newSentence.addWord(newWord);
                    wordIndexInCurrentSentence += currentDBT.TokenCount;
                }
                //sentence is now upgraded and more filled with information
                #endregion

                //adding the fitted base structure to the database as the main verb
                //add the selectedKVP's Verb to database
                //mongoSaveMainVerb();

                ////////////////////////
                //// Counting the Verbs
                ////    -----------

                List<VerbInSentence> verbsInSentence = currentSentenceVBS.VerbsInSentence;
                for(int verb_index = 0; verb_index < verbsInSentence.Count ; verb_index++)
                {
                    string verbStringRepresentation = getVerbStringRepresentation(verbsInSentence[verb_index], newSentence);
                    long article = currentArticle.getArticleNumber();
                    //sentence_index is already set
                    //verb_index is already set

                    if (verbStringRepresentation.Equals("شوند~_~_"))
                    {
                        mongoCountVerb(verbStringRepresentation, article, sentence_index, verb_index);
                    }
                    mongoCountVerb(verbStringRepresentation, article, sentence_index, verb_index);
                }

                ////
                ////////////////////////
                newArticle.addSentence(newSentence);
            }

            return newArticle;
        }