我没有找到任何官方的东西,所以我做了一个快速的 C# 程序来提取关键短语。
输出在这里:
我的代码是:
static void Main(string[] args)
{
ConcurrentDictionary<string,int> phrases = new ConcurrentDictionary<string,int>();
List<string> citiesOfUS = new List<string>()
{
"Chicago,IL",
"Los+Angeles,CA",
"Montgomery" + "," + "AL",
"Juneau" + "," + "AK",
"Phoenix" + "," + "AZ",
"Little+Rock" + "," + "AR",
"Sacramento" + "," + "CA",
"Denver" + "," + "CO",
"Hartford" + "," + "CT",
"Dover" + "," + "DE",
"Tallahassee" + "," + "FL",
"Atlanta" + "," + "GA",
"Honolulu" + "," + "HI",
"Boise" + "," + "ID",
"Springfield" + "," + "IL",
"Indianapolis" + "," + "IN",
"Des+Moines" + "," + "IA",
"Topeka" + "," + "KS",
"Frankfort" + "," + "KY",
"Baton+Rouge" + "," + "LA",
"Augusta" + "," + "ME",
"Annapolis" + "," + "MD",
"Boston" + "," + "MA",
"Lansing" + "," + "MI",
"St.+Paul" + "," + "MN",
"Jackson" + "," + "MS",
"Jefferson+City" + "," + "MO",
"Helena" + "," + "MT",
"Lincoln" + "," + "NE",
"Carson+City" + "," + "NV",
"Concord" + "," + "NH",
"Trenton" + "," + "NJ",
"Santa+Fe" + "," + "NM",
"Albany" + "," + "NY",
"Raleigh" + "," + "NC",
"Bismarck" + "," + "ND",
"Columbus" + "," + "OH",
"Oklahoma+City" + "," + "OK",
"Salem" + "," + "OR",
"Harrisburg" + "," + "PA",
"Providence" + "," + "RI",
"Columbia" + "," + "SC",
"Pierre" + "," + "SD",
"Nashville" + "," + "TN",
"Austin" + "," + "TX",
"Salt+Lake+City" + "," + "UT",
"Montpelier" + "," + "VT",
"Richmond" + "," + "VA",
"Olympia" + "," + "WA",
"Charleston" + "," + "WV",
"Madison" + "," + "WI",
"Cheyenne" + "," + "WY"
};
Parallel.ForEach(citiesOfUS, (string origin) =>
{
foreach (string destination in citiesOfUS)
{
string json = new WebClient().DownloadString("http://maps.googleapis.com/maps/api/directions/xml?origin=" + origin + "&destination=" + destination + "&sensor=false");
bool shouldExitLoop = false;
while (!shouldExitLoop)
{
int pos1 = json.IndexOf("<html_instructions>");
if (pos1 == -1) { shouldExitLoop = true; break; }
int pos2 = json.IndexOf("</html_instructions>");
if (pos2 == -1) { shouldExitLoop = true; break; }
string subString = json.Substring(pos1 + 19, pos2 - pos1 - 19);
json = json.Substring(pos2 + 20);
int posB1 = subString.IndexOf("<b");
while (posB1 != -1)
{
int posB2 = subString.IndexOf("</b");
string part1 = subString.Substring(0, posB1);
string part2 = subString.Substring(posB2 + 6);
subString = part1 + " SYM " + part2;
posB1 = subString.IndexOf("<b");
}
int posSpace = subString.IndexOf(">");
while (posSpace != -1)
{
string part1 = subString.Substring(0, posSpace);
string part2 = subString.Substring(posSpace + 4);
subString = part1 + part2;
posSpace = subString.IndexOf(">");
}
int posDiv1 = subString.IndexOf("<div");
while (posDiv1 != -1)
{
int posDiv2 = subString.IndexOf("</div");
string part1 = subString.Substring(0, posDiv1);
string part2 = subString.Substring(posDiv2 + 8);
subString = part1 + " SYM " + part2;
posDiv1 = subString.IndexOf("<div");
}
phrases.AddOrUpdate(subString, 1, (key, oldvalue) => oldvalue + 1 );
}
}
});
string[] lines = phrases.Keys.ToArray();
Array.Sort(lines);
System.IO.File.WriteAllLines(@"C:\Users\Xantix\Desktop\WriteLines.txt", lines);
return;
}
基本上,这些是您尝试从美国的每个首都到其他每个首都时得到的英语短语。
任何出现在粗体标签之间的东西都被替换为“SYM”这个词,比如左、右、街道名称等。
注意:我删除了出现在 html_instructions 内的 div 之间的内容,因此缺少诸如“部分收费公路”和“正在建设中直到 SomeDate”之类的内容。
随意修改我的代码以将其他城市添加到列表中或添加街道地址等。