public static string MatraSreni(string Sequence, int target) { string s = ""; int tot = 0; if (Sequence.Length < target) { return(""); } for (int i = 0; i < Sequence.Length; i++) { if (tot > target) { return(null); } if (tot == target) { tot = 0; s = s + "-"; } tot = tot + (StringPlus.CharAt(Sequence, i) == '|' ? 1 : 2); s = s + StringPlus.CharAt(Sequence, i); } if (tot > target) { return(""); } return(s); }
private static bool CanSplit2(string items, int x, int y) { int tot = 0; int target = x; if (items.Length < target) { return(false); } int done = 0; for (int i = 0; i < items.Length; i++) { if (tot > target) { return(false); } if (tot == target) { tot = 0; target = (target == x) ? y : x; done++; } tot = tot + (StringPlus.CharAt(items, i) == '|' ? 1 : 2); } if (done < 2) { return(false); } return(true); }
public static int GetGWeight2(string p) { int w = 0; //Script Sahrp Fix for (int i = 0; i < p.Length; i++) { w = w + GetSymbolWeight(StringPlus.CharAt(p, i).ToString()); } return(w); }
private Errors CheckPrasaPoorva2(YatiPrasaChecker2 Y, Prasa p1, Prasa p2) { char SUNNA = 'ం'; char VISARGA = 'ః'; if (StringPlus.CharAt(p1.Poorva, p1.Poorva.Length - 1) == SUNNA) { if (StringPlus.CharAt(p2.Poorva, p2.Poorva.Length - 1) == SUNNA) { Y.LastName = (Y.LastName == null) ? "బిందుపూర్వక ప్రాసము" : Y.LastName + "(విసర్గపూర్వక ప్రాసము)"; return(null); } else { Errors E = new Errors(); E.Actual = p1.Value; E.Expected = "'" + SUNNA + "' తో కూడిన అక్షరం"; E.Mismatch = p1.IsAnthyaPrasa ? Mismatch.AnthyaPrasaPoorvaBindu : Mismatch.PrasaPoorvaBindu; return(E); } } else { if (StringPlus.CharAt(p1.Poorva, p1.Poorva.Length - 1) == VISARGA) { if (StringPlus.CharAt(p2.Poorva, p2.Poorva.Length - 1) == VISARGA) { Y.LastName = (Y.LastName == null) ? "విసర్గపూర్వక ప్రాసము" : Y.LastName + "(విసర్గపూర్వక ప్రాసము)"; return(null); } else { Errors E = new Errors(); E.Actual = p1.Value; E.Expected = "'" + VISARGA + "' తో కూడిన అక్షరం"; E.Mismatch = p1.IsAnthyaPrasa ? Mismatch.AnthyaPrasaPoorvaVisarga : Mismatch.PrasaPoorvaVisarga; return(E); } } } return(null); }
private static bool CanSplit(string items, int target) { if (items.Length < target) { return(false); } int tot = 0; for (int i = 0; i < items.Length; i++) { if (tot > target) { return(false); } if (tot == target) { tot = 0; } tot = tot + (StringPlus.CharAt(items, i) == '|' ? 1 : 2); } return(true); }
private static string MatraSreni2(string Sequence, int x, int y) { string s = ""; int tot = 0; int target = x; if (Sequence.Length < target) { return(""); } int done = 0; for (int i = 0; i < Sequence.Length; i++) { if (tot > target) { return(""); } if (tot == target) { tot = 0; s = s + "-"; target = (target == x) ? y : x; done++; } tot = tot + (StringPlus.CharAt(Sequence, i) == '|' ? 1 : 2); s = s + StringPlus.CharAt(Sequence, i); } if (tot > target || done < 2) { return(""); } return(s); }
public IndicAkshar[] Split(string s) { IndicAkshar[] IA = null; try { string[] retVal = new string[s.Length]; int cnt = 0; string lockedString = ""; char lastChar = ' '; string lastCharNature = "a"; bool released = false; for (int i = 0; i < s.Length; i++) { released = false; char currChar = StringPlus.CharAt(s, i); IndicChar I = _ic.NewChar; I.CharSet = CharSet; I.BaseChar = currChar; if (currChar == this.CharSet.Special2) { if (cnt >= 1) { retVal[cnt - 1] = retVal[cnt - 1] + currChar; continue; } } string currCharNature = I.CharNature; bool CanIRelase = CanRelease(currCharNature, lastCharNature); if (CanIRelase) { bool CanImmRelase = IsImmRelease(currCharNature); if (CanImmRelase) { if (lockedString != "") { retVal[cnt++] = lockedString; } lockedString = currChar.ToString(); released = false; } else { #region NotImmRElease if (I.IsSpecialFinishing || I.IsNeutral) { #region SpecialCharFinishing if (lockedString == "") { try { retVal[cnt - 1] = retVal[cnt - 1] + lockedString + currChar; } catch { throw new Exception("Invalid Lang Char "); } } else { retVal[cnt++] = lockedString + currChar; } #endregion } else { if (!I.CanIgonre) { lockedString = lockedString + currChar; if (lockedString != "") { retVal[cnt++] = lockedString; } } else { if (lockedString != "") { retVal[cnt++] = lockedString; } retVal[cnt++] = currChar.ToString(); } } lockedString = ""; released = true; #endregion } lastChar = ' '; lastCharNature = currCharNature; } else { lastChar = currChar; lockedString = lockedString + currChar; lastCharNature = currCharNature; } } if (!released) { retVal[cnt++] = lockedString; } IA = new IndicAkshar[cnt]; for (int i = 0; i < cnt; i++) { IA[i] = new IndicAkshar(); IA[i].SetChars(retVal[i], this.CharSet); } } catch { } return(IA); }
public static bool IsMatched(string s2, int index, char match) { return(StringPlus.CharAt(s2, 0) == match); }
public bool IsYatiMatched(string s1, string s2) { //HARD FIX.. s1 = s1.Replace("ై", "ై"); s2 = s2.Replace("ై", "ై"); //Algo to be modified to improve Performance //భిన్న యతి,వికల్పవిరమణలు..Not Handled.. //బహుయతి నిరతి Can be implemented.. on the wrapper.. bool f = false; //Preparing for లుప్తవిసర్గస్వరవళి: Very Rude way of doing this. s1 = s1.Replace("ఽ", "అ"); s2 = s2.Replace("ఽ", "అ"); #region ౠత్వసౌమ్యవళి,ఋత్వసంబంధవళి { bool f1 = StringPlus.Contains(s1, RuKaaram); bool f2 = StringPlus.Contains(s2, RuKaaram); if (f1 && f2) { LastName = "ౠత్వసౌమ్యవళి"; return(true); // No need to check Further } if (f1 || f2) { f = StringPlus.Contains(RuGroup, s1); if (f) { LastName = "ఋత్వసంబంధవళి"; return(true); // No need to check Further } } } #endregion #region వళి { //రి-రీ-రె-రే-"ి"-"ీ"-"ె"-"ే"=ఋ-"ృ" bool f1 = StringPlus.Contains(s1, Ru) || StringPlus.Contains(s1, RuKaaram); bool f2 = StringPlus.Contains(s2, Ru) || StringPlus.Contains(s2, RuKaaram); if (f1 || f2) { char c1 = StringPlus.CharAt(f1 ? s2 : s1, 0); if (c1 == 'ర') { char c2 = StringPlus.CharAt(f1 ? s2 : s1, f1 ? (s2.Length - 1) : (s1.Length - 1)); if (c2 == 'ి' || c2 == 'ీ' || c2 == 'ె' || c2 == 'ే') { LastName = "ఋవళి"; return(true); } } } } #endregion #region స్వరప్రధానవళి { List <string> C1 = ExtractVowelorFinish(s1); List <string> C2 = ExtractVowelorFinish(s2); for (int i = 0; i < C1.Count; i++) { for (int j = 0; j < C2.Count; j++) { string c1 = C1[i]; string c2 = C2[j]; if (c1 == c2) { if (!(StringPlus.Contains(F, c1) && StringPlus.Contains(F, c2))) { //Don't MAtch Finish and Finish LastName = "స్వరప్రధానవళి"; return(true); //No need to Check Further } } bool t = MatchGroups(VowelAndFinishGroups, c1, c2); if (t) { if (!(StringPlus.Contains(F, c1) && StringPlus.Contains(F, c2))) { LastName = "స్వరప్రధానవళి"; return(true); //No need to Check Further } } } } } #endregion #region స్వరమైత్రివళి,ఋజు యతులు,వర్గ జయతులు,తద్భవవ్యాజ విశ్రమములు,విశేషవళి,బిందు యతులు,అనునాసికాక్షర యతులు,అనుస్వార సంబంధ యతులు,ప్రత్యేక యతి { List <string> C1 = ExtractConso(s1); List <string> C2 = ExtractConso(s2); #region య,హ,అ if (C1.Count == 0 || C2.Count == 0) { string c1 = C1.Count > 0 ? C1[0] : ""; string c2 = C2.Count > 0 ? C2[0] : ""; if (c1 == "య" || c1 == "హ") { if (StringPlus.Contains(s2, "అ")) { //ప్రత్యేక యతి LastName = "ప్రత్యేక యతి"; return(true); //No more checks } } if (c2 == "య" || c2 == "హ") { if (StringPlus.Contains(s1, "అ")) { //ప్రత్యేక యతి LastName = "ప్రత్యేక యతి"; return(true); } } } #endregion for (int i = 0; i < C1.Count; i++) { for (int j = 0; j < C2.Count; j++) { string c1 = C1[i]; string c2 = C2[j]; if (c1 == c2) { f = true; LastName = "సమాన హల్లు"; break; } if (c1 == "య" || c1 == "హ") { if (StringPlus.Contains(s2, "అ")) { //ప్రత్యేక యతి LastName = "ప్రత్యేక యతి"; return(true); //No more checks } } if (c2 == "య" || c2 == "హ") { if (StringPlus.Contains(s1, "అ")) { //ప్రత్యేక యతి LastName = "ప్రత్యేక యతి"; return(true); } } f = MatchGroups(ConsoGroups, c1, c2); if (f) { LastName = "స్వరమైత్రివళి/ఋజు యతులు/ఏకతరయతులు/అభేద విరతులు/అభేద వర్గ విరతులు/ఊష్మ విశ్రాంతులు/సరసయతి"; break; } } if (f) { break; } } } if (!f) { bool f1 = StringPlus.Contains(s1, "ఙ"); bool f2 = StringPlus.Contains(s2, "ఙ"); if (f1 || f2) { bool _f = StringPlus.Contains("ంక,ంఖ,ంగ,ంఘ", f1 ? s2 : s1); if (_f) { //విశేషవళి LastName = "విశేషవళి"; f = true; } } } if (!f) { bool f1 = StringPlus.Contains(s1, "న") || StringPlus.Contains(s1, "ణ"); bool f2 = StringPlus.Contains(s2, "న") || StringPlus.Contains(s2, "ణ"); if (f1 || f2) { bool _f = StringPlus.Contains(f1 ? s2 : s1, "ఙ"); if (_f) { //తద్భవవ్యాజ విశ్రమములు LastName = "తద్భవవ్యాజ విశ్రమములు"; f = true; } } } #region Probables:బిందు యతులు,అనునాసికాక్షర యతులు,అనుస్వార సంబంధ యతులు if (!f) { //ం+హల్లు Group= 5th Letter; char c1 = StringPlus.CharAt(s1, 0); char c2 = StringPlus.CharAt(s2, 0); bool f1 = (c1 == SUNNA); bool f2 = (c2 == SUNNA); if (f1 || f2) { string c2_1 = ""; string c1_1 = ""; if (f1) { c2_1 = StringPlus.CharAt(s2, 0).ToString(); c1_1 = s1.Length > 1 ? StringPlus.CharAt(s1, 1).ToString() : ""; } else { c2_1 = StringPlus.CharAt(s1, 0).ToString(); c1_1 = s2.Length > 1 ? StringPlus.CharAt(s2, 1).ToString() : ""; } switch (c2_1) { default: { f = AnuSeriesYati(s1, s2); if (!f) { f = AnuSeriesYati(s2, s1); } } if (!f) { bool _f1 = StringPlus.Contains("ంయ,ంర,ంల,ంవ,ంశ,ంస,ంష,ంహ", f1 ? s1 : s2); if (_f1) { bool _f = StringPlus.Contains("మ", f1 ? s2 : s1); if (_f) { //మువర్ణ విరామం LastName = "మువర్ణ విరామం"; return(true); //No need to check further } } } break; case "ఙ": f = StringPlus.Contains("క,ఖ,గ,ఘ", c1_1); if (f) { f = true; } break; case "ఞ": f = StringPlus.Contains("చ,ఛ,జ,ఝ", c1_1); if (f) { f = true; } break; case "ణ": f = StringPlus.Contains("త,థ,ద,ధ", c1_1) || StringPlus.Contains("ట,ఠ,డ,ఢ", c1_1); //+అనునాసికాక్షర యతులు if (f) { f = true; } break; case "న": f = StringPlus.Contains("త,థ,ద,ధ", c1_1) || StringPlus.Contains("ట,ఠ,డ,ఢ", c1_1); //+అనునాసికాక్షర యతులు if (f) { f = true; } break; case "మ": f = StringPlus.Contains("ప,ఫ,బ,భ", c1_1) || StringPlus.Contains("య,ర,ల,వ,శ,స,ష,హ", c1_1); //+మువర్ణ విరామం if (f) { f = true; } break; } } } #endregion if (f) { #region Confirm Above one's //Conso Groups Matched Now it's time to Match if their Finish matches. f = MatchYatiFinishGroups(s1, s2); #endregion } #endregion #region మువిభక్తియతి,ముకారయతి { //char c10= StringPlus.CharAt ( s1 , 0 ); //char c1n= StringPlus.CharAt ( s1 , s1.Length - 1 ); //char c20= StringPlus.CharAt ( s2 , 0 ); //char c2n= StringPlus.CharAt ( s2 , s2.Length - 1 ); //bool f1=( c10 == 'మ' && c1n == 'ు' ); //bool f2=( c20 == 'మ' && c2n == 'ు' ); //if ( f1 || f2 ) //{ // bool _f1 = StringPlus.Contains ( "పఫభబ" , ( f1 ? c20 : c10 ).ToString ( ) ); // bool _f2 = StringPlus.Contains ( "ుూొో" , ( f1 ? c2n : c1n ).ToString ( ) ); // if ( _f1 && _f2 ) // { // LastName = "మువిభక్తియతి లేదా ముకారయతి"; // return true; // } //} char c10 = StringPlus.CharAt(s1, 0); char c1n = StringPlus.CharAt(s1, s1.Length - 1); char c20 = StringPlus.CharAt(s2, 0); char c2n = StringPlus.CharAt(s2, s2.Length - 1); bool f1 = (c10 == 'మ' && StringPlus.Contains("ుూొో", c1n.ToString())); bool f2 = (c20 == 'మ' && StringPlus.Contains("ుూొో", c2n.ToString())); if (f1 || f2) { bool _f1 = StringPlus.Contains("పఫభబమ", (f1 ? c20 : c10).ToString()); bool _f2 = StringPlus.Contains("ుూొో", (f1 ? c2n : c1n).ToString()); if (_f1 && _f2) { LastName = "మువిభక్తియతి లేదా ముకారయతి"; return(true); } } } #endregion #region అంత్యోష్మ సంధి కళులు { bool f1 = StringPlus.Contains(s1, HA); bool f2 = StringPlus.Contains(s2, HA); if (f1 || f2) { if (f1 && s2.Length >= 3) { char c1 = StringPlus.CharAt(s2, 0); char c2 = StringPlus.CharAt(s2, 1); char c3 = StringPlus.CharAt(s2, 2); if (c2 == Virama) { f = IsJhuyMatch(c1, c3); if (f) { LastName = "అంత్యోష్మ సంధి కళులు"; return(true); } } } if (f2 && s1.Length >= 3) { char c1 = StringPlus.CharAt(s1, 0); char c2 = StringPlus.CharAt(s1, 1); char c3 = StringPlus.CharAt(s1, 2); if (c2 == Virama) { f = IsJhuyMatch(c1, c3); if (f) { LastName = "అంత్యోష్మ సంధి కళులు"; return(true); } } } } } #endregion if (SoundexSandhi) { f = MatchYatiFinishGroups(s1, s2); } return(f); }
public string CheckPrasa(string s1, string s2, bool allowSantiPrasa) { YatiPrasaChecker2 Y = new YatiPrasaChecker2(); s1 = s1.Replace(" ", ""); s2 = s2.Replace(" ", ""); Y.AllowSantiPrasa = allowSantiPrasa; Y.SoundexSandhi = false; GanaVibhajana G1 = new GanaVibhajana(s1, lang); GanaVibhajana G2 = new GanaVibhajana(s2, lang); if (G1.GWiseString.Count == 0) { return("<span class='gName'>Group-1 is not valid</span>"); } if (G2.GWiseString.Count == 0) { return("<span class='gName'>Group-2 is not valid</span>"); } bool f = false; if (G1.GWiseString.Count > 1 && G2.GWiseString.Count > 1) { p1 = G1.GWiseString[0] + "<u>" + G1.GWiseString[1] + "</u>"; p2 = G2.GWiseString[0] + "<u>" + G2.GWiseString[1] + "</u>"; Prasa P1 = new Prasa(StringPlus.CharAt(G1.SymbolsStream, 0).ToString(), false, G1.GWiseString[1], G1.GWiseString[0]); Prasa P2 = new Prasa(StringPlus.CharAt(G2.SymbolsStream, 0).ToString(), false, G2.GWiseString[1], G2.GWiseString[0]); f = Y.IsPrasaMatched3(P1, P2); if (f && Y.NoMoreChecks) { return(Success(p1, p2, PRASA, Y.LastName)); } if (f) { if (P1.Symbol == Symbols.LAGHUVU) { //Nothing to do.. } else { f = (P1.Symbol == P2.Symbol); } } if (f) { Errors E = CheckPrasaPoorva2(Y, P1, P2); if (E == null) { return(Success(p1, p2, PRASA, Y.LastName)); } return(FailWith(p1, p2, E, PRASA)); } else { return(FailWith(p1, p2, null, PRASA)); } } else { p1 = G1.GWiseString[0]; p2 = G2.GWiseString[0]; f = Y.IsPrasaMatched(p1, p2); if (f) { return(Success(p1, p2, PRASA, Y.LastName)); } } return(FailWith(p1, p2, null, PRASA)); }