public void CountValencies(string path) { var reader = new StreamReader(path); string sentence; var valDic = new Dictionary<string, int>(); while ((sentence = reader.ReadLine()) != null) { var valencyFrame = new ValencyFrame(new List<ValencySlot>(), ""); var split = sentence.Split("\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var valency = split[split.Length - 1].Trim(); string newValency = valency.Substring(1, valency.Length - 2); valencyFrame.ValencyString = newValency; var valParts = newValency.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < valParts.Length; i++) { var valencySlot = new ValencySlot(new Fael(), true); string valPart = valParts[i]; bool obligat = true; if (valPart.Contains("(")) { obligat = false; valPart = valPart.Replace("(", ""); valPart = valPart.Replace(")", ""); } string ValValue = valPart; var features = ""; if (valPart.Contains("[")) { valPart = valPart.Replace("]", ""); var splitedVal = valPart.Split("[".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); ValValue = splitedVal[0]; features = splitedVal[1]; } switch (ValValue) { case "فا": valencySlot = new ValencySlot(new Fael(), obligat); break; case "مف": valencySlot = new ValencySlot(new Mafool(features), obligat); break; case "مفح": List<string> prepList = features.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); valencySlot = new ValencySlot(new MafoolHarfeEzafeh(prepList), obligat); break; case "مفن": valencySlot = new ValencySlot(new MafoolNeshanehEzafi(), obligat); break; case "مس": valencySlot = new ValencySlot(new Mosnad(), obligat); break; case "بند": int index = features.IndexOf("مطا"); string agreement = features.Substring(index, features.Length - index); string eltezami = features.Substring(0, index - 1); valencySlot = new ValencySlot(new BandMotammemi(agreement, eltezami), obligat); break; case "تم": valencySlot = new ValencySlot(new Tameez(), obligat); break; case "مفد": valencySlot = new ValencySlot(new MafoolDovvom(), obligat); break; case "مق": List<string> advCase = features.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); valencySlot = new ValencySlot(new MotammemQeidi(advCase), obligat); break; } } if (valDic.ContainsKey(valency)) { valDic[valency]++; } else { valDic.Add(valency, 1); } } }
public void CountValencies(string path) { var reader = new StreamReader(path); string sentence; var valDic = new Dictionary <string, int>(); while ((sentence = reader.ReadLine()) != null) { var valencyFrame = new ValencyFrame(new List <ValencySlot>(), ""); var split = sentence.Split("\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var valency = split[split.Length - 1].Trim(); string newValency = valency.Substring(1, valency.Length - 2); valencyFrame.ValencyString = newValency; var valParts = newValency.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < valParts.Length; i++) { var valencySlot = new ValencySlot(new Fael(), true); string valPart = valParts[i]; bool obligat = true; if (valPart.Contains("(")) { obligat = false; valPart = valPart.Replace("(", ""); valPart = valPart.Replace(")", ""); } string ValValue = valPart; var features = ""; if (valPart.Contains("[")) { valPart = valPart.Replace("]", ""); var splitedVal = valPart.Split("[".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); ValValue = splitedVal[0]; features = splitedVal[1]; } switch (ValValue) { case "فا": valencySlot = new ValencySlot(new Fael(), obligat); break; case "مف": valencySlot = new ValencySlot(new Mafool(features), obligat); break; case "مفح": List <string> prepList = features.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); valencySlot = new ValencySlot(new MafoolHarfeEzafeh(prepList), obligat); break; case "مفن": valencySlot = new ValencySlot(new MafoolNeshanehEzafi(), obligat); break; case "مس": valencySlot = new ValencySlot(new Mosnad(), obligat); break; case "بند": int index = features.IndexOf("مطا"); string agreement = features.Substring(index, features.Length - index); string eltezami = features.Substring(0, index - 1); valencySlot = new ValencySlot(new BandMotammemi(agreement, eltezami), obligat); break; case "تم": valencySlot = new ValencySlot(new Tameez(), obligat); break; case "مفد": valencySlot = new ValencySlot(new MafoolDovvom(), obligat); break; case "مق": List <string> advCase = features.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); valencySlot = new ValencySlot(new MotammemQeidi(advCase), obligat); break; } } if (valDic.ContainsKey(valency)) { valDic[valency]++; } else { valDic.Add(valency, 1); } } }
public static ValencyFrame GetValencyFrame(string valencyStr) { var valencyFrame = new ValencyFrame(new List<ValencySlot>(), ""); var split = valencyStr.Split("\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var valency = split[split.Length - 1].Trim(); string newValency = valency.Substring(1, valency.Length - 2); valencyFrame.ValencyString = newValency; var valParts = newValency.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < valParts.Length; i++) { var valencySlot = new ValencySlot(new NULLSlot(), true); string valPart = valParts[i]; bool obligat = true; if (valPart.Contains("(")) { obligat = false; valPart = valPart.Replace("(", ""); valPart = valPart.Replace(")", ""); } string ValValue = valPart; var features = ""; if (valPart.Contains("[")) { valPart = valPart.Replace("]", ""); var splitedVal = valPart.Split("[".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); ValValue = splitedVal[0]; features = splitedVal[1]; } switch (ValValue) { case "فا": valencySlot = new ValencySlot(new Fael(), obligat); break; case "مف": valencySlot = new ValencySlot(new Mafool(features), obligat); break; case "مفح": List<string> prepList = features.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); valencySlot = new ValencySlot(new MafoolHarfeEzafeh(prepList), obligat); break; case "مفن": valencySlot = new ValencySlot(new MafoolNeshanehEzafi(), obligat); break; case "مس": valencySlot = new ValencySlot(new Mosnad(), obligat); break; case "بند": int index = features.IndexOf("مطا"); string agreement = features.Substring(index, features.Length - index); string eltezami = features.Substring(0, index); valencySlot = new ValencySlot(new BandMotammemi(agreement, eltezami), obligat); break; case "تم": valencySlot = new ValencySlot(new Tameez(), obligat); break; case "مفد": valencySlot = new ValencySlot(new MafoolDovvom(), obligat); break; case "مق": List<string> advCase = features.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); valencySlot = new ValencySlot(new MotammemQeidi(advCase), obligat); break; } valencyFrame.ValencyList.Add(valencySlot); } return valencyFrame; }
public static ValencyFrame GetValencyFrame(string valencyStr) { var valencyFrame = new ValencyFrame(new List <ValencySlot>(), ""); var split = valencyStr.Split("\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var valency = split[split.Length - 1].Trim(); string newValency = valency.Substring(1, valency.Length - 2); valencyFrame.ValencyString = newValency; var valParts = newValency.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < valParts.Length; i++) { var valencySlot = new ValencySlot(new NULLSlot(), true); string valPart = valParts[i]; bool obligat = true; if (valPart.Contains("(")) { obligat = false; valPart = valPart.Replace("(", ""); valPart = valPart.Replace(")", ""); } string ValValue = valPart; var features = ""; if (valPart.Contains("[")) { valPart = valPart.Replace("]", ""); var splitedVal = valPart.Split("[".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); ValValue = splitedVal[0]; features = splitedVal[1]; } switch (ValValue) { case "فا": valencySlot = new ValencySlot(new Fael(), obligat); break; case "مف": valencySlot = new ValencySlot(new Mafool(features), obligat); break; case "مفح": List <string> prepList = features.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); valencySlot = new ValencySlot(new MafoolHarfeEzafeh(prepList), obligat); break; case "مفن": valencySlot = new ValencySlot(new MafoolNeshanehEzafi(), obligat); break; case "مس": valencySlot = new ValencySlot(new Mosnad(), obligat); break; case "بند": int index = features.IndexOf("مطا"); string agreement = features.Substring(index, features.Length - index); string eltezami = features.Substring(0, index); valencySlot = new ValencySlot(new BandMotammemi(agreement, eltezami), obligat); break; case "تم": valencySlot = new ValencySlot(new Tameez(), obligat); break; case "مفد": valencySlot = new ValencySlot(new MafoolDovvom(), obligat); break; case "مق": List <string> advCase = features.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); valencySlot = new ValencySlot(new MotammemQeidi(advCase), obligat); break; } valencyFrame.ValencyList.Add(valencySlot); } return(valencyFrame); }