このページに、入力した単語の得点計算をするだけのアプリを添付しました。
.NET Framework 3.5以降で動作します(多分)。
ご利用は自己責任で。
以下点数計算部分のソースコードです。
int WordToPoint(string w)
{
string dull = "がぎぐげござじずぜぞだぢづでどばびぶべぼ"; //濁音
string hdull = "ぱぴぷぺぽぁぃぅぇぉっゃゅょ"; //半濁音・捨て仮名
int s = w.Length; //単語の総文字数
int t = w.Distinct().ToArray().Length; //単語の文字種類数
int b = (25 * s + 75 * t) * t; //基本点
int n = CountChar(w, 'ん'); //「ん」の数
int l = CountChar(w,'ー'); //「ー」の数
int n_down = 0; //「ん」による減点
int l_down = 0; //「ー」による減点
if (n != 0) n_down = (52 + 18 * n) * t;
if (l != 0) l_down = (52 + 18 * l) * t;
double point = b - n_down - l_down;
//濁音による加点
foreach(char d in dull)
{
int d_n = CountChar(w, d);
if (d_n != 0) point += (38 + 12 * d_n) * t;
}
//半濁音・捨て仮名による加点
foreach (char d in hdull)
{
int hd_n = CountChar(w, d);
if (hd_n != 0) point += (57 + 18 * hd_n) * t;
}
if (s == 2) point /= 2; //総文字数が2文字の場合の減点
if (w.EndsWith("ん")) point /= 2; //最後の文字が「ん」である場合の減点
return (int)Math.Ceiling(point); //1点未満の端数は切り上げ
}
// 文字の出現回数をカウント
public static int CountChar(string s, char c)
{
return s.Length - s.Replace(c.ToString(), "").Length;
}
最終更新:2014年12月27日 18:17