真的很差的答案(表明没有“理解”) - 但作为一个疯狂的刺,你可以(通过代码)点击谷歌(例如)“+钓鱼+运动”,“+钓鱼+烹饪”等(即交叉加入每个单词和类别) - 让谷歌战斗获胜!即选择具有最多“命中”的组合...
例如(结果优先):
weather: fish
sport: ball
weather: hat
fashion: trousers
weather: snowball
weather: tornado
使用代码(TODO:添加线程;-p):
static void Main() {
string[] words = { "fish", "ball", "hat", "trousers", "snowball","tornado" };
string[] categories = { "sport", "fashion", "weather" };
using(WebClient client = new WebClient()){
foreach(string word in words) {
var bestCategory = categories.OrderByDescending(
cat => Rank(client, word, cat)).First();
Console.WriteLine("{0}: {1}", bestCategory, word);
}
}
}
static int Rank(WebClient client, string word, string category) {
string s = client.DownloadString("http://www.google.com/search?q=%2B" +
Uri.EscapeDataString(word) + "+%2B" +
Uri.EscapeDataString(category));
var match = Regex.Match(s, @"of about \<b\>([0-9,]+)\</b\>");
int rank = match.Success ? int.Parse(match.Groups[1].Value, NumberStyles.Any) : 0;
Debug.WriteLine(string.Format("\t{0} / {1} : {2}", word, category, rank));
return rank;
}