You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Semantic/Snowball/StemmerOperations.cs

1031 lines
85 KiB

6 years ago
<EFBFBD><EFBFBD>/*
* Port of Snowball stemmers on C#
* Original stemmers can be found on http://snowball.tartarus.org
* Licence still BSD: http://snowball.tartarus.org/license.php
*
6 years ago
* Most of stemmers are ported from Java by Iveonik Systems ltd. (www.iveonik.com)
*/
6 years ago
using System.Text;
namespace Iveonik.Stemmers
{
public class StemmerOperations
{
// // current string
protected StringBuilder current;
6 years ago
protected int cursor;
protected int limit;
protected int limit_backward;
protected int bra;
protected int ket;
protected StemmerOperations()
{
current = new StringBuilder();
setCurrent("");
}
// /**
// * Set the current string.
// */
protected void setCurrent(string value)
{
// current.replace(0, current.length(), value);
//current=current.Replace(current.ToString(), value);
//current = StringBufferReplace(0, current.Length, current, value);
//current = StringBufferReplace(0, value.Length, current, value);
current.Remove(0, current.Length);
current.Append(value);
cursor = 0;
limit = current.Length;
limit_backward = 0;
bra = cursor;
ket = limit;
}
// /**
// * Get the current string.
// */
protected string getCurrent()
{
string result = current.ToString();
// Make a new StringBuffer. If we reuse the old one, and a user of
// the library keeps a reference to the buffer returned (for example,
// by converting it to a String in a way which doesn't force a copy),
// the buffer size will not decrease, and we will risk wasting a large
// amount of memory.
// Thanks to Wolfram Esser for spotting this problem.
//current = new StringBuilder();
return result;
}
protected void copy_from(StemmerOperations other)
{
current = other.current;
cursor = other.cursor;
limit = other.limit;
limit_backward = other.limit_backward;
bra = other.bra;
ket = other.ket;
}
protected bool in_grouping(char[] s, int min, int max)
{
if (cursor >= limit) return false;
// char ch = current.charAt(cursor);
int ch = current[cursor];
if (ch > max || ch < min) return false;
// ch -= min;
ch -= min;
if ((s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return false;
cursor++;
return true;
}
protected bool in_grouping_b(char[] s, int min, int max)
{
if (cursor <= limit_backward) return false;
// char ch = current.charAt(cursor - 1);
int ch = (int)current[cursor - 1];
if (ch > max || ch < min) return false;
ch -= min;
if ((s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return false;
cursor--;
return true;
}
protected bool out_grouping(char[] s, int min, int max)
{
if (cursor >= limit) return false;
// char ch = current.charAt(cursor);
int ch = current[cursor];
if (ch > max || ch < min)
{
cursor++;
return true;
}
ch -= min;
if ((s[ch >> 3] & (0X1 << (ch & 0X7))) == 0)
{
cursor++;
return true;
}
return false;
}
protected bool out_grouping_b(char[] s, int min, int max)
{
if (cursor <= limit_backward) return false;
// char ch = current.charAt(cursor - 1);
int ch = (int)current[cursor - 1];
if (ch > max || ch < min)
{
cursor--;
return true;
}
ch -= min;
if ((s[ch >> 3] & (0X1 << (ch & 0X7))) == 0)
{
cursor--;
return true;
}
return false;
}
protected bool in_range(int min, int max)
{
if (cursor >= limit) return false;
// char ch = current.charAt(cursor);
int ch = (int)current[cursor];
if (ch > max || ch < min) return false;
cursor++;
return true;
}
protected bool in_range_b(int min, int max)
{
if (cursor <= limit_backward) return false;
// char ch = current.charAt(cursor - 1);
int ch = (int)current[cursor - 1];
if (ch > max || ch < min) return false;
cursor--;
return true;
}
protected bool out_range(int min, int max)
{
if (cursor >= limit) return false;
// char ch = current.charAt(cursor);
int ch = (int)current[cursor];
if (!(ch > max || ch < min)) return false;
cursor++;
return true;
}
protected bool out_range_b(int min, int max)
{
if (cursor <= limit_backward) return false;
// char ch = current.charAt(cursor - 1);
int ch = (int)current[cursor - 1];
if (!(ch > max || ch < min)) return false;
cursor--;
return true;
}
protected bool eq_s(int s_size, string s)
{
if (limit - cursor < s_size) return false;
int i;
for (i = 0; i != s_size; i++)
{
if (current[cursor + i] != s[i]) return false;
// if (current[cursor + i] != s[i]) return false;
}
cursor += s_size;
return true;
}
protected bool eq_s_b(int s_size, string s)
{
if (cursor - limit_backward < s_size) return false;
int i;
for (i = 0; i != s_size; i++)
{
// if (current.charAt(cursor - s_size + i) != s.charAt(i)) return false;
if (current[cursor - s_size + i] != s[i]) return false;
}
cursor -= s_size;
return true;
}
protected bool eq_v(StringBuilder s)
{
return eq_s(s.Length, s.ToString());
}
protected bool eq_v_b(StringBuilder s)
{
return eq_s_b(s.Length, s.ToString());
}
internal int find_among(Among[] v, int v_size)
{
int i = 0;
int j = v_size;
int c = cursor;
int l = limit;
int common_i = 0;
int common_j = 0;
bool first_key_inspected = false;
while (true)
{
int k = i + ((j - i) >> 1);
int diff = 0;
int common = common_i < common_j ? common_i : common_j; // smaller
Among w = v[k];
int i2;
for (i2 = common; i2 < w.s_size; i2++)
{
if (c + common == l)
{
diff = -1;
break;
}
diff = current[c + common] - w.s[i2];
if (diff != 0) break;
common++;
}
if (diff < 0)
{
j = k;
common_j = common;
}
else
{
i = k;
common_i = common;
}
if (j - i <= 1)
{
if (i > 0) break; // v->s has been inspected
if (j == i) break; // only one item in v
// - but now we need to go round once more to get
// v->s inspected. This looks messy, but is actually
// the optimal approach.
if (first_key_inspected) break;
first_key_inspected = true;
}
}
while (true)
{
Among w = v[i];
if (common_i >= w.s_size)
{
cursor = c + w.s_size;
7 months ago
if (w.method == null!) return w.result;
6 years ago
//bool res;
//try
//{
// Object resobj = w.method.invoke(w.methodobject,new Object[0]);
// res = resobj.toString().equals("true");
//}
//catch (InvocationTargetException e)
//{
// res = false;
// // FIXME - debug message
//}
//catch (IllegalAccessException e)
//{
// res = false;
//// FIXME - debug message
//}
//cursor = c + w.s_size;
//if (res) return w.result;
}
i = w.substring_i;
if (i < 0) return 0;
}
}
// // find_among_b is for backwards processing. Same comments apply
internal int find_among_b(Among[] v, int v_size)
{
int i = 0;
int j = v_size;
int c = cursor;
int lb = limit_backward;
int common_i = 0;
int common_j = 0;
bool first_key_inspected = false;
while (true)
{
int k = i + ((j - i) >> 1);
int diff = 0;
int common = common_i < common_j ? common_i : common_j;
Among w = v[k];
int i2;
for (i2 = w.s_size - 1 - common; i2 >= 0; i2--)
{
if (c - common == lb)
{
diff = -1;
break;
}
// diff = current.charAt(c - 1 - common) - w.s[i2];
diff = current[c - 1 - common] - w.s[i2];
if (diff != 0) break;
common++;
}
if (diff < 0)
{
j = k;
common_j = common;
}
else
{
i = k;
common_i = common;
}
if (j - i <= 1)
{
if (i > 0) break;
if (j == i) break;
if (first_key_inspected) break;
first_key_inspected = true;
}
}
while (true)
{
Among w = v[i];
if (common_i >= w.s_size)
{
cursor = c - w.s_size;
7 months ago
if (w.method == null!) return w.result;
6 years ago
//boolean res;
//try
6 years ago
//{
// Object resobj = w.method.invoke(w.methodobject,
// new Object[0]);
// res = resobj.toString().equals("true");
// }
//catch (InvocationTargetException e)
6 years ago
//{
// res = false;
// // FIXME - debug message
// }
//catch (IllegalAccessException e)
6 years ago
//{
// res = false;
// // FIXME - debug message
// }
//cursor = c - w.s_size;
//if (res) return w.result;
}
i = w.substring_i;
if (i < 0) return 0;
}
}
// /* to replace chars between c_bra and c_ket in current by the
// * chars in s.
// */
protected int replace_s(int c_bra, int c_ket, string s)
{
int adjustment = s.Length - (c_ket - c_bra);
// current.replace(c_bra, c_ket, s);
current = StringBufferReplace(c_bra, c_ket, current, s);
limit += adjustment;
if (cursor >= c_ket) cursor += adjustment;
else if (cursor > c_bra) cursor = c_bra;
return adjustment;
}
private StringBuilder StringBufferReplace(int start, int end, StringBuilder s, string s1)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < start; i++)
{
sb.Insert(sb.Length, s[i]);
}
// for (int i = 1; i < end - start + 1; i++)
// {
sb.Insert(sb.Length, s1);
// }
for (int i = end; i < s.Length; i++)
{
sb.Insert(sb.Length, s[i]);
}
return sb;
//string temp = s.ToString();
//temp = temp.Substring(start - 1, end - start + 1);
//s = s.Replace(temp, s1, start - 1, end - start + 1);
//return s;
}
protected void slice_check()
{
if (bra < 0 ||
bra > ket ||
ket > limit ||
limit > current.Length) // this line could be removed
{
//System.err.println("faulty slice operation");
// FIXME: report error somehow.
/*
fprintf(stderr, "faulty slice operation:\n");
debug(z, -1, 0);
exit(1);
*/
}
}
protected void slice_from(string s)
{
slice_check();
replace_s(bra, ket, s);
}
protected void slice_from(StringBuilder s)
{
slice_from(s.ToString());
}
protected void slice_del()
{
slice_from("");
}
protected void insert(int c_bra, int c_ket, string s)
{
int adjustment = replace_s(c_bra, c_ket, s);
if (c_bra <= bra) bra += adjustment;
if (c_bra <= ket) ket += adjustment;
}
protected void insert(int c_bra, int c_ket, StringBuilder s)
{
insert(c_bra, c_ket, s.ToString());
}
// /* Copy the slice into the supplied StringBuffer */
protected StringBuilder slice_to(StringBuilder s)
{
slice_check();
int len = ket - bra;
// s.replace(0, s.length(), current.substring(bra, ket));
// int lengh = string.IsNullOrEmpty(s.ToString())!= true ? s.Length : 0;
// if (ket == current.Length) ket--;
//string ss = current.ToString().Substring(bra, len);
//StringBufferReplace(0, s.Length, s, ss);
//return s;
return StringBufferReplace(0, s.Length, s, current.ToString().Substring(bra, len));
// return StringBufferReplace(0, lengh, s, current.ToString().Substring(bra, ket));
// return s;
}
// /* Copy the slice into the supplied StringBuilder */
//protected StringBuilder slice_to(StringBuilder s)
//{
// slice_check();
// int len = ket - bra;
// s.replace(0, s.length(), current.substring(bra, ket));
// return s;
//}
protected StringBuilder assign_to(StringBuilder s)
{
//s.replace(0, s.length(), current.substring(0, limit));
//return s;
return StringBufferReplace(0, s.Length, s, current.ToString().Substring(0, limit));
}
// protected StringBuilder assign_to(StringBuilder s)
// {
// s.replace(0, s.length(), current.substring(0, limit));
// return s;
// }
///*
//extern void debug(struct SN_env * z, int number, int line_count)
//{ int i;
// int limit = SIZE(z->p);
// //if (number >= 0) printf("%3d (line %4d): '", number, line_count);
// if (number >= 0) printf("%3d (line %4d): [%d]'", number, line_count,limit);
// for (i = 0; i <= limit; i++)
// { if (z->lb == i) printf("{");
// if (z->bra == i) printf("[");
// if (z->c == i) printf("|");
// if (z->ket == i) printf("]");
// if (z->l == i) printf("}");
// if (i < limit)
// { int ch = z->p[i];
// if (ch == 0) ch = '#';
// printf("%c", ch);
// }
// }
// printf("'\n");
//}
//*/
//};
///////////////////////////// METHODS FOR CZECH STEMMER AGRESSIVE //////////////////////////////////
protected void removeDerivational()
{
int len = current.Length;
if ((len > 8) &&
current.ToString().Substring(len - 6, 6).Equals("obinec"))
{
current = current.Remove(len - 6, 6);
return;
}//len >8
if (len > 7)
{
if (current.ToString().Substring(len - 5, 5).Equals("ion\u00e1\u0159"))
{ // -ion<EFBFBD>Y
6 years ago
current = current.Remove(len - 4, 4);
palatalise();
return;
}
if (current.ToString().Substring(len - 5, 5).Equals("ovisk") ||
current.ToString().Substring(len - 5, 5).Equals("ovstv") ||
current.ToString().Substring(len - 5, 5).Equals("ovi\u0161t") || //-oviat
current.ToString().Substring(len - 5, 5).Equals("ovn\u00edk"))
{ //-ovn<EFBFBD>k
current = current.Remove(len - 5, 5);
return;
}
}//len>7
if (len > 6)
{
if (current.ToString().Substring(len - 4, 4).Equals("\u00e1sek") || // -<EFBFBD>sek
6 years ago
current.ToString().Substring(len - 4, 4).Equals("loun") ||
current.ToString().Substring(len - 4, 4).Equals("nost") ||
current.ToString().Substring(len - 4, 4).Equals("teln") ||
current.ToString().Substring(len - 4, 4).Equals("ovec") ||
current.ToString().Substring(len - 5, 5).Equals("ov\u00edk") || //-ov<EFBFBD>k
current.ToString().Substring(len - 4, 4).Equals("ovtv") ||
current.ToString().Substring(len - 4, 4).Equals("ovin") ||
current.ToString().Substring(len - 4, 4).Equals("\u0161tin"))
{ //-atin
current = current.Remove(len - 4, 4);
return;
}
if (current.ToString().Substring(len - 4, 4).Equals("enic") ||
current.ToString().Substring(len - 4, 4).Equals("inec") ||
current.ToString().Substring(len - 4, 4).Equals("itel"))
{
current = current.Remove(len - 3, 3);
palatalise();
return;
}
}//len>6
if (len > 5)
{
if (current.ToString().Substring(len - 3, 3).Equals("\u00e1rn"))
{ //-<EFBFBD>rn
current = current.Remove(len - 3, 3);
return;
}
if (current.ToString().Substring(len - 3, 3).Equals("\u011bnk"))
{ //-nk
current = current.Remove(len - 2, 2);
palatalise();
return;
}
if (current.ToString().Substring(len - 3, 3).Equals("i\u00e1n") || //-i<EFBFBD>n
current.ToString().Substring(len - 3, 3).Equals("ist") ||
current.ToString().Substring(len - 3, 3).Equals("isk") ||
current.ToString().Substring(len - 3, 3).Equals("i\u0161t") || //-iat
current.ToString().Substring(len - 3, 3).Equals("itb") ||
current.ToString().Substring(len - 3, 3).Equals("\u00edrn"))
{ //-<EFBFBD>rn
current = current.Remove(len - 2, 2);
palatalise();
return;
}
if (current.ToString().Substring(len - 3, 3).Equals("och") ||
current.ToString().Substring(len - 3, 3).Equals("ost") ||
current.ToString().Substring(len - 3, 3).Equals("ovn") ||
current.ToString().Substring(len - 3, 3).Equals("oun") ||
current.ToString().Substring(len - 3, 3).Equals("out") ||
current.ToString().Substring(len - 3, 3).Equals("ou\u0161"))
{ //-oua
current = current.Remove(len - 3, 3);
return;
}
if (current.ToString().Substring(len - 3, 3).Equals("u\u0161k"))
{ //-uak
current = current.Remove(len - 3, 3);
return;
}
if (current.ToString().Substring(len - 3, 3).Equals("kyn") ||
current.ToString().Substring(len - 3, 3).Equals("\u010dan") || //- an
current.ToString().Substring(len - 3, 3).Equals("k\u00e1\u0159") || //k<EFBFBD>Y
current.ToString().Substring(len - 3, 3).Equals("n\u00e9\u0159") || //n<EFBFBD>Y
current.ToString().Substring(len - 3, 3).Equals("n\u00edk") || //-n<EFBFBD>k
current.ToString().Substring(len - 3, 3).Equals("ctv") ||
current.ToString().Substring(len - 3, 3).Equals("stv"))
{
current = current.Remove(len - 3, 3);
return;
}
}//len>5
if (len > 4)
{
if (current.ToString().Substring(len - 2, 2).Equals("\u00e1\u010d") || // -<EFBFBD> 
current.ToString().Substring(len - 2, 2).Equals("a\u010d") || //-a 
current.ToString().Substring(len - 2, 2).Equals("\u00e1n") || //-<EFBFBD>n
current.ToString().Substring(len - 2, 2).Equals("an") ||
current.ToString().Substring(len - 2, 2).Equals("\u00e1\u0159") || //-<EFBFBD>Y
current.ToString().Substring(len - 2, 2).Equals("as"))
{
current = current.Remove(len - 2, 2);
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("ec") ||
current.ToString().Substring(len - 2, 2).Equals("en") ||
current.ToString().Substring(len - 2, 2).Equals("\u011bn") || //-n
current.ToString().Substring(len - 2, 2).Equals("\u00e9\u0159"))
{ //-<EFBFBD>Y
current = current.Remove(len - 1, 1);
palatalise();
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("\u00ed\u0159") || //-<EFBFBD>Y
current.ToString().Substring(len - 2, 2).Equals("ic") ||
current.ToString().Substring(len - 2, 2).Equals("in") ||
current.ToString().Substring(len - 2, 2).Equals("\u00edn") || //-<EFBFBD>n
current.ToString().Substring(len - 2, 2).Equals("it") ||
current.ToString().Substring(len - 2, 2).Equals("iv"))
{
current = current.Remove(len - 1, 1);
palatalise();
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("ob") ||
current.ToString().Substring(len - 2, 2).Equals("ot") ||
current.ToString().Substring(len - 2, 2).Equals("ov") ||
current.ToString().Substring(len - 2, 2).Equals("o\u0148"))
{ //-oH
6 years ago
current = current.Remove(len - 2, 2);
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("ul"))
{
current = current.Remove(len - 2, 2);
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("yn"))
{
current = current.Remove(len - 2, 2);
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("\u010dk") || //- k
current.ToString().Substring(len - 2, 2).Equals("\u010dn") || //- n
current.ToString().Substring(len - 2, 2).Equals("dl") ||
current.ToString().Substring(len - 2, 2).Equals("nk") ||
current.ToString().Substring(len - 2, 2).Equals("tv") ||
current.ToString().Substring(len - 2, 2).Equals("tk") ||
current.ToString().Substring(len - 2, 2).Equals("vk"))
{
current = current.Remove(len - 2, 2);
return;
}
}//len>4
if (len > 3)
{
if (current.ToString()[current.Length - 1] == 'c' ||
current.ToString()[current.Length - 1] == '\u010d' || //- 
current.ToString()[current.Length - 1] == 'k' ||
current.ToString()[current.Length - 1] == 'l' ||
current.ToString()[current.Length - 1] == 'n' ||
current.ToString()[current.Length - 1] == 't')
{
current = current.Remove(len - 1, 1);
return;
}
}//len>3
6 years ago
}//removeDerivational
protected void removeAugmentative()
{
int len = current.Length;
//
if ((len > 6) &&
current.ToString().Substring(len - 4, 4).Equals("ajzn"))
{
current = current.Remove(len - 4, 4);
return;
}
if ((len > 5) &&
(current.ToString().Substring(len - 3, 3).Equals("izn") ||
current.ToString().Substring(len - 3, 3).Equals("isk")))
{
current = current.Remove(len - 2, 2);
palatalise();
return;
}
if ((len > 4) &&
current.ToString().Substring(len - 2, 2).Equals("\00e1k"))
{ //-<EFBFBD>k
current = current.Remove(len - 2, 2);
return;
}
}
protected void removeDiminutive()
{
int len = current.Length;
//
6 years ago
if ((len > 7) &&
current.ToString().Substring(len - 5, 5).Equals("ou\u0161ek"))
{ //-ouaek
current = current.Remove(len - 5, 5);
return;
}
if (len > 6)
{
if (current.ToString().Substring(len - 4, 4).Equals("e\u010dek") || //-e ek
current.ToString().Substring(len - 4, 4).Equals("\u00e9\u010dek") || //-<EFBFBD> ek
current.ToString().Substring(len - 4, 4).Equals("i\u010dek") || //-i ek
current.ToString().Substring(len - 4, 4).Equals("\u00ed\u010dek") || //<EFBFBD> ek
current.ToString().Substring(len - 4, 4).Equals("enek") ||
current.ToString().Substring(len - 4, 4).Equals("\u00e9nek") || //-<EFBFBD>nek
current.ToString().Substring(len - 4, 4).Equals("inek") ||
current.ToString().Substring(len - 4, 4).Equals("\u00ednek"))
{ //-<EFBFBD>nek
current = current.Remove(len - 3, 3);
palatalise();
return;
}
if (current.ToString().Substring(len - 4, 4).Equals("\u00e1\u010dek") || //<EFBFBD> ek
current.ToString().Substring(len - 4, 4).Equals("a\u010dek") || //a ek
current.ToString().Substring(len - 4, 4).Equals("o\u010dek") || //o ek
current.ToString().Substring(len - 4, 4).Equals("u\u010dek") || //u ek
current.ToString().Substring(len - 4, 4).Equals("anek") ||
current.ToString().Substring(len - 4, 4).Equals("onek") ||
current.ToString().Substring(len - 4, 4).Equals("unek") ||
current.ToString().Substring(len - 4, 4).Equals("\u00e1nek"))
{ //-<EFBFBD>nek
current = current.Remove(len - 4, 4);
return;
}
}//len>6
if (len > 5)
{
if (current.ToString().Substring(len - 3, 3).Equals("e\u010dk") || //-e k
current.ToString().Substring(len - 3, 3).Equals("\u00e9\u010dk") || //-<EFBFBD> k
6 years ago
current.ToString().Substring(len - 3, 3).Equals("i\u010dk") || //-i k
current.ToString().Substring(len - 3, 3).Equals("\u00ed\u010dk") || //-<EFBFBD> k
current.ToString().Substring(len - 3, 3).Equals("enk") || //-enk
current.ToString().Substring(len - 3, 3).Equals("\u00e9nk") || //-<EFBFBD>nk
6 years ago
current.ToString().Substring(len - 3, 3).Equals("ink") || //-ink
current.ToString().Substring(len - 3, 3).Equals("\u00ednk"))
{ //-<EFBFBD>nk
current = current.Remove(len - 3, 3);
palatalise();
return;
}
if (current.ToString().Substring(len - 3, 3).Equals("\u00e1\u010dk") || //-<EFBFBD> k
current.ToString().Substring(len - 3, 3).Equals("au010dk") || //-a k
current.ToString().Substring(len - 3, 3).Equals("o\u010dk") || //-o k
current.ToString().Substring(len - 3, 3).Equals("u\u010dk") || //-u k
6 years ago
current.ToString().Substring(len - 3, 3).Equals("ank") ||
current.ToString().Substring(len - 3, 3).Equals("onk") ||
current.ToString().Substring(len - 3, 3).Equals("unk"))
{
current = current.Remove(len - 3, 3);
return;
}
if (current.ToString().Substring(len - 3, 3).Equals("\u00e1tk") || //-<EFBFBD>tk
current.ToString().Substring(len - 3, 3).Equals("\u00e1nk") || //-<EFBFBD>nk
current.ToString().Substring(len - 3, 3).Equals("u\u0161k"))
{ //-uak
current = current.Remove(len - 3, 3);
return;
}
}//len>5
if (len > 4)
{
if (current.ToString().Substring(len - 2, 2).Equals("ek") ||
current.ToString().Substring(len - 2, 2).Equals("\u00e9k") || //-<EFBFBD>k
current.ToString().Substring(len - 2, 2).Equals("\u00edk") || //-<EFBFBD>k
current.ToString().Substring(len - 2, 2).Equals("ik"))
{
current = current.Remove(len - 1, 1);
palatalise();
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("\u00e1k") || //-<EFBFBD>k
current.ToString().Substring(len - 2, 2).Equals("ak") ||
current.ToString().Substring(len - 2, 2).Equals("ok") ||
current.ToString().Substring(len - 2, 2).Equals("uk"))
{
current = current.Remove(len - 1, 1);
return;
}
}
if ((len > 3) &&
current.ToString().Substring(len - 1, 1).Equals("k"))
{
current = current.Remove(len - 1, 1);
return;
}
}//removeDiminutives
protected void removeComparative()
{
int len = current.Length;
//
6 years ago
if ((len > 5) &&
(current.ToString().Substring(len - 3, 3).Equals("ej\u0161") || //-eja
current.ToString().Substring(len - 3, 3).Equals("\u011bj\u0161")))
{ //-ja
current = current.Remove(len - 2, 2);
palatalise();
return;
}
}
private void palatalise()
{
int len = current.Length;
if (current.ToString().Substring(len - 2, 2).Equals("ci") ||
current.ToString().Substring(len - 2, 2).Equals("ce") ||
current.ToString().Substring(len - 2, 2).Equals("\u010di") || //- i
current.ToString().Substring(len - 2, 2).Equals("\u010de"))
{ //- e
current = StringBufferReplace(len - 2, len, current, "k");
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("zi") ||
current.ToString().Substring(len - 2, 2).Equals("ze") ||
current.ToString().Substring(len - 2, 2).Equals("\u017ei") || //-~i
current.ToString().Substring(len - 2, 2).Equals("\u017ee"))
{ //-~e
current = StringBufferReplace(len - 2, len, current, "h");
return;
}
if (current.ToString().Substring(len - 3, 3).Equals("\u010dt\u011b") || //- t
current.ToString().Substring(len - 3, 3).Equals("\u010dti") || //- ti
current.ToString().Substring(len - 3, 3).Equals("\u010dt\u00ed"))
{ //- t<EFBFBD>
current = StringBufferReplace(len - 3, len, current, "ck");
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("\u0161t\u011b") || //-at
current.ToString().Substring(len - 2, 2).Equals("\u0161ti") || //-ati
current.ToString().Substring(len - 2, 2).Equals("\u0161t\u00ed"))
{ //-at<EFBFBD>
current = StringBufferReplace(len - 2, len, current, "sk");
return;
}
current = current.Remove(len - 1, 1);
return;
}//palatalise
protected void removePossessives()
{
int len = current.Length;
if (len > 5)
{
if (current.ToString().Substring(len - 2, 2).Equals("ov"))
{
current = current.Remove(len - 2, 2);
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("\u016fv"))
{ //-ov
current = current.Remove(len - 2, 2);
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("in"))
{
current = current.Remove(len - 1, 1);
palatalise();
return;
}
}
}//removePossessives
protected void removeCase()
{
int len = current.Length;
//
6 years ago
if ((len > 7) &&
current.ToString().Substring(len - 5, 5).Equals("atech"))
{
current = current.Remove(len - 5, 5);
return;
}//len>7
if (len > 6)
{
if (current.ToString().Substring(len - 4, 4).Equals("\u011btem"))
{ //-tem
current = current.Remove(len - 3, 3);
palatalise();
return;
}
if (current.ToString().Substring(len - 4, 4).Equals("at\u016fm"))
{ //-atom
current = current.Remove(len - 4, 4);
return;
}
}
if (len > 5)
{
if (current.ToString().Substring(len - 3, 3).Equals("ech") ||
current.ToString().Substring(len - 3, 3).Equals("ich") ||
current.ToString().Substring(len - 3, 3).Equals("\u00edch"))
{ //-<EFBFBD>ch
current = current.Remove(len - 2, 2);
palatalise();
return;
}
if (current.ToString().Substring(len - 3, 3).Equals("\u00e9ho") || //-<EFBFBD>ho
current.ToString().Substring(len - 3, 3).Equals("\u011bmi") || //-mu
current.ToString().Substring(len - 3, 3).Equals("emi") ||
current.ToString().Substring(len - 3, 3).Equals("\u00e9mu") || // -<EFBFBD>mu current.substring( len-3,len).equals("ete")||
current.ToString().Substring(len - 3, 3).Equals("eti") ||
current.ToString().Substring(len - 3, 3).Equals("iho") ||
current.ToString().Substring(len - 3, 3).Equals("\u00edho") || //-<EFBFBD>ho
current.ToString().Substring(len - 3, 3).Equals("\u00edmi") || //-<EFBFBD>mi
current.ToString().Substring(len - 3, 3).Equals("imu"))
{
current = current.Remove(len - 2, 2);
palatalise();
return;
}
if (current.ToString().Substring(len - 3, 3).Equals("\u00e1ch") || //-<EFBFBD>ch
current.ToString().Substring(len - 3, 3).Equals("ata") ||
current.ToString().Substring(len - 3, 3).Equals("aty") ||
current.ToString().Substring(len - 3, 3).Equals("\u00fdch") || //-<EFBFBD>ch
current.ToString().Substring(len - 3, 3).Equals("ama") ||
current.ToString().Substring(len - 3, 3).Equals("ami") ||
current.ToString().Substring(len - 3, 3).Equals("ov\u00e9") || //-ov<EFBFBD>
current.ToString().Substring(len - 3, 3).Equals("ovi") ||
current.ToString().Substring(len - 3, 3).Equals("\u00fdmi"))
{ //-<EFBFBD>mi
current = current.Remove(len - 3, 3);
return;
}
}
if (len > 4)
{
if (current.ToString().Substring(len - 2, 2).Equals("em"))
{
current = current.Remove(len - 1, 1);
palatalise();
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("es") ||
current.ToString().Substring(len - 2, 2).Equals("\u00e9m") || //-<EFBFBD>m
current.ToString().Substring(len - 2, 2).Equals("\u00edm"))
{ //-<EFBFBD>m
current = current.Remove(len - 2, 2);
palatalise();
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("\u016fm"))
{
current = current.Remove(len - 2, 2);
return;
}
if (current.ToString().Substring(len - 2, 2).Equals("at") ||
current.ToString().Substring(len - 2, 2).Equals("\u00e1m") || //-<EFBFBD>m
current.ToString().Substring(len - 2, 2).Equals("os") ||
current.ToString().Substring(len - 2, 2).Equals("us") ||
current.ToString().Substring(len - 2, 2).Equals("\u00fdm") || //-<EFBFBD>m
current.ToString().Substring(len - 2, 2).Equals("mi") ||
current.ToString().Substring(len - 2, 2).Equals("ou"))
{
current = current.Remove(len - 2, 2);
return;
}
}//len>4
if (len > 3)
{
if (current.ToString().Substring(len - 1, 1).Equals("e") ||
current.ToString().Substring(len - 1, 1).Equals("i"))
{
palatalise();
return;
}
if (current.ToString().Substring(len - 1, 1).Equals("\u00ed") || //-<EFBFBD>
current.ToString().Substring(len - 1, 1).Equals("\u011b"))
{ //-
palatalise();
return;
}
if (current.ToString().Substring(len - 1, 1).Equals("u") ||
current.ToString().Substring(len - 1, 1).Equals("y") ||
current.ToString().Substring(len - 1, 1).Equals("\u016f"))
{ //-o
current = current.Remove(len - 1, 1);
return;
}
if (current.ToString().Substring(len - 1, 1).Equals("a") ||
current.ToString().Substring(len - 1, 1).Equals("o") ||
current.ToString().Substring(len - 1, 1).Equals("\u00e1") || // -<EFBFBD>
current.ToString().Substring(len - 1, 1).Equals("\u00e9") || //-<EFBFBD>
current.ToString().Substring(len - 1, 1).Equals("\u00fd"))
{ //-<EFBFBD>
current = current.Remove(len - 1, 1);
return;
}
}//len>3
}
}
}

Powered by TurnKey Linux.