<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EvoTalk &#187; 工作日誌</title>
	<atom:link href="http://evotalk.net/blog/category/work/feed" rel="self" type="application/rss+xml" />
	<link>http://evotalk.net/blog</link>
	<description></description>
	<lastBuildDate>Mon, 07 Jun 2010 03:01:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use TeraTerm Script</title>
		<link>http://evotalk.net/blog/2007/06/use-teraterm-script.html</link>
		<comments>http://evotalk.net/blog/2007/06/use-teraterm-script.html#comments</comments>
		<pubDate>Wed, 27 Jun 2007 08:03:53 +0000</pubDate>
		<dc:creator>asd</dc:creator>
				<category><![CDATA[工作日誌]]></category>
		<category><![CDATA[科技新知]]></category>
		<category><![CDATA[軟體使用]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://evotalk.net/blog/?p=363</guid>
		<description><![CDATA[需求：欲使用程式模擬 modem 三方通話的功能。
起初是打開 WinXP 內建的超級終端機，然後手動鍵入at command，測試 ok ，想寫成自動化的程式，本來是想說用 C 或 perl 來寫，打開 COM port，然後再送出 message。網路部門的同事建議使用 TeraTerm，它內建Tera Term Langauge(TTL)，可以達到自動化的目的。
使用 TeraTerm 打開 serial port COM3，對 modem 作at command 測試
寫了如下的 script
view plain

CODE:




sendln 'ate1'&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;# 打開 echo


sendln 'atx0'&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;# 關掉 dialtone detection


&#160;


while 1


wait 'RING'


sendln 'ath1'&#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>需求：欲使用程式模擬 modem 三方通話的功能。</p>
<p>起初是打開 WinXP 內建的超級終端機，然後手動鍵入at command，測試 ok ，想寫成自動化的程式，本來是想說用 C 或 perl 來寫，打開 COM port，然後再送出 message。網路部門的同事建議使用 <a href="http://hp.vector.co.jp/authors/VA002416/teraterm.html">TeraTerm</a>，它內建Tera Term Langauge(TTL)，可以達到自動化的目的。</p>
<p>使用 <a href="http://hp.vector.co.jp/authors/VA002416/teraterm.html">TeraTerm</a> 打開 serial port COM3，對 modem 作at command 測試</p>
<p>寫了如下的 script</p>
<div class="igBar"><span id="lcode-2"><a href="#" onclick="javascript:showCodeTxt('code-2'); return false;">view plain</a></span></div>
<div class="shadow">
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-2">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sendln <span style="color:#CC0000;">'ate1'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 打開 echo</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sendln <span style="color:#CC0000;">'atx0'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 關掉 dialtone detection</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">while <span style="color:#800000;color:#800000;">1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">wait <span style="color:#CC0000;">'RING'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sendln <span style="color:#CC0000;">'ath1'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 接聽電話</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">wait <span style="color:#CC0000;">'OK'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pause <span style="color:#800000;color:#800000;">1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sendln <span style="color:#CC0000;">'atdt !;'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# flashhook</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">wait <span style="color:#CC0000;">'OK'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pause <span style="color:#800000;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sendln <span style="color:#CC0000;">'atdt **,5462;'</span>&nbsp; #先按prefix **，再停頓一下再播號</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">wait <span style="color:#CC0000;">'OK'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pause <span style="color:#800000;color:#800000;">1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sendln <span style="color:#CC0000;">'atdt!;'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#flashhook</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">wait <span style="color:#CC0000;">'OK'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pause <span style="color:#800000;color:#800000;">30</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #通話時間 <span style="color:#800000;color:#800000;">30</span>秒</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sendln <span style="color:#CC0000;">'ath'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#掛斷電話</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">endwhile </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p><img src="http://i69.photobucket.com/albums/i46/asd98537/teraterm_ui.png" alt="ui" /> <img src="http://i69.photobucket.com/albums/i46/asd98537/teraterm_macro.png" alt="macro" /></p>
]]></content:encoded>
			<wfw:commentRss>http://evotalk.net/blog/2007/06/use-teraterm-script.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use AT Command to Make Conference Call</title>
		<link>http://evotalk.net/blog/2007/06/use-at-command-to-make-conference-call.html</link>
		<comments>http://evotalk.net/blog/2007/06/use-at-command-to-make-conference-call.html#comments</comments>
		<pubDate>Tue, 26 Jun 2007 09:53:20 +0000</pubDate>
		<dc:creator>asd</dc:creator>
				<category><![CDATA[工作日誌]]></category>

		<guid isPermaLink="false">http://evotalk.net/blog/?p=362</guid>
		<description><![CDATA[用 RJ-11 電話線將 nb 的數據機接孔接上公司的 5484 電話孔，打開超級終端機，若你打的指令在螢幕上看不到，可先下ATE1，打開 echo 回應，就會看到你打的指令。這時別的分機(假設是5488)打5484，終端機視窗就會顯示RING的訊息，此時下ATH1，接聽電話，再打 ATDT !; ，會看到NO DialTone 訊息，此時下ATX0，關閉偵測 dial tone。再打 ATDT **,5462，一會兒後分機 5462 就會聽到鈴鈴的聲音，此時再下 ATDT !; 就可以實現 5488、5484、5462 三方通話了。
]]></description>
			<content:encoded><![CDATA[<p>用 RJ-11 電話線將 nb 的數據機接孔接上公司的 5484 電話孔，打開超級終端機，若你打的指令在螢幕上看不到，可先下ATE1，打開 echo 回應，就會看到你打的指令。這時別的分機(假設是5488)打5484，終端機視窗就會顯示RING的訊息，此時下ATH1，接聽電話，再打 ATDT !; ，會看到NO DialTone 訊息，此時下ATX0，關閉偵測 dial tone。再打 ATDT **,5462，一會兒後分機 5462 就會聽到鈴鈴的聲音，此時再下 ATDT !; 就可以實現 5488、5484、5462 三方通話了。</p>
]]></content:encoded>
			<wfw:commentRss>http://evotalk.net/blog/2007/06/use-at-command-to-make-conference-call.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>COM&#8217;s Global Variable</title>
		<link>http://evotalk.net/blog/2007/06/coms-global-variable.html</link>
		<comments>http://evotalk.net/blog/2007/06/coms-global-variable.html#comments</comments>
		<pubDate>Mon, 04 Jun 2007 08:27:10 +0000</pubDate>
		<dc:creator>asd</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[工作日誌]]></category>
		<category><![CDATA[程式設計]]></category>
		<category><![CDATA[com]]></category>

		<guid isPermaLink="false">http://evotalk.net/blog/?p=355</guid>
		<description><![CDATA[使用 ATL 作的 COM ，create 兩個 instance ，其中的 global 變數會互相影響
例如:
view plain

JavaScript:




var asr1 = new ActiveXObject&#40;"DeltaASRCom.DeltaAsrObj"&#41;;


asr1.Init&#40;"config/Master.cfg", "config/cfgSound-10ms.txt"&#41;; // 預設是點歌的domain


asr1.Streaming&#40;&#41;;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;//&#160; ex: 張惠妹


asr1.ChangeDomain&#40;"Stock"&#41;;&#160; &#160;//現在是股票domain


asr1.Streaming&#40;&#41;;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;// ex: 台達電


&#160;


var asr2 = new ActiveXObject&#40;"DeltaASRCom.DeltaAsrObj"&#41;; //預設是點歌的domain


asr2.AsrFile&#40;"Test.pcm"&#41;;&#160; &#160; &#160; &#160;// ex: she 大女人主義


&#160;


asr1.Streaming&#40;&#41;;&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>使用 ATL 作的 COM ，create 兩個 instance ，其中的 global 變數會互相影響<br />
例如:</p>
<div class="igBar"><span id="ljavascript-4"><a href="#" onclick="javascript:showCodeTxt('javascript-4'); return false;">view plain</a></span></div>
<div class="shadow">
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-4">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> asr1 = <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"DeltaASRCom.DeltaAsrObj"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">asr1.<span style="color: #006600;">Init</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"config/Master.cfg"</span>, <span style="color: #3366CC;">"config/cfgSound-10ms.txt"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// 預設是點歌的domain</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">asr1.<span style="color: #006600;">Streaming</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900; font-style: italic;">//&nbsp; ex: 張惠妹</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">asr1.<span style="color: #006600;">ChangeDomain</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"Stock"</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;<span style="color: #009900; font-style: italic;">//現在是股票domain</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">asr1.<span style="color: #006600;">Streaming</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900; font-style: italic;">// ex: 台達電</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> asr2 = <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"DeltaASRCom.DeltaAsrObj"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">//預設是點歌的domain</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">asr2.<span style="color: #006600;">AsrFile</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"Test.pcm"</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900; font-style: italic;">// ex: she 大女人主義</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">asr1.<span style="color: #006600;">Streaming</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// 照理說 asr1 應該是股票domain，結果卻是點歌，被asr2影響到了 </span></div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p>
但是用 vb 作的 COM 卻沒有全域變數共享的問題，微軟的討論群組有人提到，參考<a href="http://groups.google.com.tw/group/microsoft.public.vc.activextemplatelib/browse_thread/thread/b01050cf283646c1/9d9cef6a73fed622?lnk=gst&amp;q=TlsAlloc&amp;rnum=2&amp;hl=zh-TW#9d9cef6a73fed622">global variables &amp; MTS</a></p>
<p>有人說可以在變數前面加上 __declspec( thread ) 如</p>
<blockquote><p>__declspec( thread ) int tls_i = 1;</p></blockquote>
<p>或是使用 TlsAlloc(), TlsFree(), TlsGetValue() and TlsSetValue() 函式來解決 multiple thread-global variable in VC/ATL 的問題，都試過了，存取時會發生 access violation，看來好像無解的樣子。</p>
<p>如何使用 TlsAlloc(), TlsFree(), TlsGetValue() and TlsSetValue() 參考<br />
<a href="http://www.codeproject.com/threads/threaddata.asp">Simplify the Use of Thread Local Storage</a></p>
]]></content:encoded>
			<wfw:commentRss>http://evotalk.net/blog/2007/06/coms-global-variable.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>修正 &#8211; Catch Google Suggest Keyword</title>
		<link>http://evotalk.net/blog/2007/05/modify-catch-google-suggest-keyword.html</link>
		<comments>http://evotalk.net/blog/2007/05/modify-catch-google-suggest-keyword.html#comments</comments>
		<pubDate>Thu, 24 May 2007 02:50:28 +0000</pubDate>
		<dc:creator>asd</dc:creator>
				<category><![CDATA[工作日誌]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://evotalk.net/blog/?p=351</guid>
		<description><![CDATA[之前一篇 「Catch Google Suggest Keyword 」，抓到的熱門中文詞常包含簡體中文，若要抓繁體中文的話，需要在 google suggestion web api 加入額外的參數。google suggestion web api 的網址可透過抓封包的軟體查看。
http://www.google.com.tw/complete/search?hl=zh-TW&#38;client=suggest&#38;js=true&#38;qu=
如上，需要加入參數 hl=zh-TW ，否則預設會抓到簡體中文的 hot word，qu= 就輸入欲查詢字詞的 utf8 編碼。另外抓到的熱門詞也經常包含一些雜七雜八的詞，用人工篩選需要耗費很多的時間及精神。可以透過中文 wiki 將這些熱門詞輸入查詢，若找得到就保留下來，找不到就剔除。底下的 code 和之前那一篇大同小異，多了一道手續將熱門詞送往 wiki 篩選。需注意的是 perl 的 regular expression 的 pattern 如何處理 big5，可參考 JeffHung.Blog - Perl with UTF-8 mode ，目前是採用此篇文章後面評論員的方法 :
呼叫 metaquote 函式將 big5 傳入，傳回值當作 regular expression 的 pattern。
view plain

PERL:




# gsuggest.pl - Google suggest


#


# c [...]]]></description>
			<content:encoded><![CDATA[<p>之前一篇 <a href="http://127.0.0.1/blog/?p=316">「Catch Google Suggest Keyword 」</a>，抓到的熱門中文詞常包含簡體中文，若要抓繁體中文的話，需要在 google suggestion web api 加入額外的參數。google suggestion web api 的網址可透過抓封包的軟體查看。</p>
<blockquote><p>http://www.google.com.tw/complete/search?hl=zh-TW&amp;client=suggest&amp;js=true&amp;qu=</p></blockquote>
<p>如上，需要加入參數 hl=zh-TW ，否則預設會抓到簡體中文的 hot word，qu= 就輸入欲查詢字詞的 utf8 編碼。另外抓到的熱門詞也經常包含一些雜七雜八的詞，用人工篩選需要耗費很多的時間及精神。可以透過中文 wiki 將這些熱門詞輸入查詢，若找得到就保留下來，找不到就剔除。底下的 code 和之前那一篇大同小異，多了一道手續將熱門詞送往 wiki 篩選。需注意的是 perl 的 regular expression 的 pattern 如何處理 big5，可參考 <a href="http://www.jeffhung.net/blog/articles/jeffhung/417/">JeffHung.Blog - Perl with UTF-8 mode</a> ，目前是採用此篇文章後面評論員的方法 :</p>
<blockquote><p>呼叫 metaquote 函式將 big5 傳入，傳回值當作 regular expression 的 pattern。</p></blockquote>
<div class="igBar"><span id="lperl-6"><a href="#" onclick="javascript:showCodeTxt('perl-6'); return false;">view plain</a></span></div>
<div class="shadow">
<div class="syntax_hilite"><span class="langName">PERL:</span>
<div id="perl-6">
<div class="perl">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># gsuggest.pl - Google suggest</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># c Copyright, 2004-2005 By John Bokma, http://johnbokma.com/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># Last updated: 2007-04-26 17:56:35 -0600</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># §什acao§?google suggest keyword ao perl script</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># ??-^?崦|raoIR?A?餘google suggest keywords</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#!/usr/bin/perl -w</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">use</span> strict;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">use</span> warnings;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#use URI::Escape;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">use</span> LWP::<span style="color: #006600;">UserAgent</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">use</span> URI;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">use</span> Encode <a href="http://www.perldoc.com/perl5.6/pod/func/qw.html"><span style="color: #000066;">qw</span></a>/encode decode/;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$count</span> = <span style="color: #cc66cc;color:#800000;">1</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/open.html"><span style="color: #000066;">open</span></a><span style="color: #66cc66;">&#40;</span>FOUT, <span style="color: #ff0000;">"&amp;gt;cht_filter.txt"</span><span style="color: #66cc66;">&#41;</span> || $!;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">sub</span> GetKeyWords</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$key</span><span style="color: #66cc66;">&#41;</span> = <span style="color: #0000ff;">@_</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$utf_data</span> = encode<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"utf8"</span>, decode<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"big5"</span>, <span style="color: #0000ff;">$key</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#print &quot;n==&amp;gt; $utf_datan&quot;;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$url</span> = <span style="color: #ff0000;">'http://www.google.com.tw/complete/search?hl=zh-TW&amp;amp;client=suggest&amp;amp;js=true&amp;amp;qu='</span> . URI-&amp;gt;new<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"$utf_data"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#uri_escape( join ' ' =&amp;gt; @ARGV );</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ua</span> = LWP::<span style="color: #006600;">UserAgent</span>-&amp;gt;new<span style="color: #66cc66;">&#40;</span> agent =&amp;gt; <span style="color: #ff0000;">'Mozilla/5.0'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$response</span> = <span style="color: #0000ff;">$ua</span>-&amp;gt;get<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$url</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #0000ff;">$response</span>-&amp;gt;is_success<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">"$url: "</span>, <span style="color: #0000ff;">$response</span>-&amp;gt;status_line;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/return.html"><span style="color: #000066;">return</span></a> <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$content</span> = <span style="color: #0000ff;">$response</span>-&amp;gt;content;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># extract the information from the JavaScript file response</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># note that the first &quot; and the last &quot; in the Arrays are</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># excluded (if data is present)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$element</span>, <span style="color: #0000ff;">$array1</span>, <span style="color: #0000ff;">$array2</span> <span style="color: #66cc66;">&#41;</span> = <span style="color: #0000ff;">$content</span> =~</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/<span style="color: #ff0000;">"(.+?)"</span>.+?Array<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"(.+?)"</span><span style="color: #66cc66;">&#41;</span>.+?Array<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"(.+?)"</span><span style="color: #66cc66;">&#41;</span>/;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">unless</span> <span style="color: #66cc66;">&#40;</span> <a href="http://www.perldoc.com/perl5.6/pod/func/defined.html"><span style="color: #000066;">defined</span></a> <span style="color: #0000ff;">$array1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">"No resultsn"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#exit;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/return.html"><span style="color: #000066;">return</span></a> <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># split the first &quot;array&quot; on the item separator (the very first &quot;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># and the very last &quot; are already removed)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@suggestions</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/split.html"><span style="color: #000066;">split</span></a> /<span style="color: #ff0000;">", "</span>/, <span style="color: #0000ff;">$array1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># remove the result(s) string from the number of results</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># remove   if present (no results known)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># and split the second &quot;array&quot;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># note that a negative limit is used to catch trailing empty</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># results (caused by removing  )</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$array2</span> =~ <a href="http://www.perldoc.com/perl5.6/pod/func/s.html"><span style="color: #000066;">s</span></a>/ results?//g;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$array2</span> =~ <a href="http://www.perldoc.com/perl5.6/pod/func/s.html"><span style="color: #000066;">s</span></a>/ //g;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@results</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/split.html"><span style="color: #000066;">split</span></a> /<span style="color: #ff0000;">", "</span>/, <span style="color: #0000ff;">$array2</span>, -<span style="color: #cc66cc;color:#800000;">1</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># make suggestion =&amp;gt; result(s) pairs.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># note that the number of results is turned into a right justified string</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@pairs</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/map.html"><span style="color: #000066;">map</span></a> <span style="color: #66cc66;">&#123;</span> <span style="color: #66cc66;">&#91;</span> <a href="http://www.perldoc.com/perl5.6/pod/func/sprintf.html"><span style="color: #000066;">sprintf</span></a> <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">"%12s"</span>, <a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span style="color: #000066;">shift</span></a> <span style="color: #0000ff;">@results</span> <span style="color: #66cc66;">&#41;</span> =&amp;gt; <span style="color: #0000ff;">$_</span> <span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #0000ff;">@suggestions</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># print the pairs in suggested order</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#print &quot;@$_n&quot;&nbsp; for @pairs;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># print the pairs sorted on the number of results for each suggestion,</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># largest &quot;number&quot; first since the numbers are right justified strings.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#print &quot;nsorted:n&quot;;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">LookupWiki<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"$$_[1]"</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">for</span> <a href="http://www.perldoc.com/perl5.6/pod/func/sort.html"><span style="color: #000066;">sort</span></a> <span style="color: #66cc66;">&#123;</span> <span style="color: #0000ff;">$b</span>-&amp;gt;<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#93;</span> <span style="color: #b1b100;">cmp</span> <span style="color: #0000ff;">$a</span>-&amp;gt;<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #0000ff;">@pairs</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/sleep.html"><span style="color: #000066;">sleep</span></a> <span style="color: #cc66cc;color:#800000;">1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">sub</span> LookupWiki</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$key</span><span style="color: #66cc66;">&#41;</span> = <span style="color: #0000ff;">@_</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">"$count : $key&nbsp; =&amp;gt;&nbsp; "</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$key</span> =~ <a href="http://www.perldoc.com/perl5.6/pod/func/s.html"><span style="color: #000066;">s</span></a>/<a href="http://www.perldoc.com/perl5.6/pod/func/s.html"><span style="color: #000066;">s</span></a>+/_/g;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$url</span> = <span style="color: #ff0000;">"http://zh.wikipedia.org/w/index.php?title=$key&amp;amp;variant=zh-tw"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ua</span> = LWP::<span style="color: #006600;">UserAgent</span>-&amp;gt;new<span style="color: #66cc66;">&#40;</span> agent =&amp;gt; <span style="color: #ff0000;">'Mozilla/5.0'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$response</span> = <span style="color: #0000ff;">$ua</span>-&amp;gt;get<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$url</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">next</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #0000ff;">$response</span>-&amp;gt;is_success<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$content_big5</span> = encode<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"big5"</span>, decode<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"utf8"</span>, <span style="color: #0000ff;">$response</span>-&amp;gt;content<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$regex1</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/quotemeta.html"><span style="color: #000066;">quotemeta</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'沒有找到標題'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$regex2</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/quotemeta.html"><span style="color: #000066;">quotemeta</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'維基百科目前還沒有與此同名的條目'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$content_big5</span>&nbsp; =~ <a href="http://www.perldoc.com/perl5.6/pod/func/m.html"><span style="color: #000066;">m</span></a>/<span style="color: #0000ff;">$regex1</span>/o || <span style="color: #0000ff;">$content_big5</span>&nbsp; =~ <a href="http://www.perldoc.com/perl5.6/pod/func/m.html"><span style="color: #000066;">m</span></a>/<span style="color: #0000ff;">$regex2</span>/o<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">"Xn"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span style="color: #000066;">print</span></a> FOUT <span style="color: #ff0000;">"X $keyn"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">"On"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span style="color: #000066;">print</span></a> FOUT <span style="color: #ff0000;">"O $keyn"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$count</span>++;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$count</span> = <span style="color: #cc66cc;color:#800000;">1</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/open.html"><span style="color: #000066;">open</span></a><span style="color: #66cc66;">&#40;</span>W1, <span style="color: #ff0000;">"1w.txt"</span><span style="color: #66cc66;">&#41;</span> || <a href="http://www.perldoc.com/perl5.6/pod/func/die.html"><span style="color: #000066;">die</span></a> $!;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/chomp.html"><span style="color: #000066;">chomp</span></a> ;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">GetKeyWords<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/close.html"><span style="color: #000066;">close</span></a> W1;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/open.html"><span style="color: #000066;">open</span></a><span style="color: #66cc66;">&#40;</span>W2, <span style="color: #ff0000;">"2w.txt"</span><span style="color: #66cc66;">&#41;</span> || <a href="http://www.perldoc.com/perl5.6/pod/func/die.html"><span style="color: #000066;">die</span></a> $!;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/chomp.html"><span style="color: #000066;">chomp</span></a> ;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">GetKeyWords<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/close.html"><span style="color: #000066;">close</span></a> W2;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/close.html"><span style="color: #000066;">close</span></a> FOUT; </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://evotalk.net/blog/2007/05/modify-catch-google-suggest-keyword.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MS SAPI Releated Resources</title>
		<link>http://evotalk.net/blog/2007/05/ms-sapi-releated-resources.html</link>
		<comments>http://evotalk.net/blog/2007/05/ms-sapi-releated-resources.html#comments</comments>
		<pubDate>Tue, 22 May 2007 09:01:51 +0000</pubDate>
		<dc:creator>asd</dc:creator>
				<category><![CDATA[工作日誌]]></category>
		<category><![CDATA[科技新知]]></category>
		<category><![CDATA[軟體使用]]></category>

		<guid isPermaLink="false">http://evotalk.net/blog/?p=350</guid>
		<description><![CDATA[ 
Speech SDK 5.1 : Download speech sdk 5.1
Designing Grammar Rules : xml grammar spec.
SAPI 5.0 Tutorial
I . An Introduction to SAPI
II. Text-to-Speech
III. Dynamic Grammar
IIII. Inline Dictation and Advanced Grammar Modifiers
V. Voice Control
Speech Synthesis &#38; Speech Recognition Using SAPI 5.1
C# example
I. Simple Speech Recognition
II. Speech Recognition
MFC speaks easily !
Grammar Compiler : How to compile the grammar from xml (txt) to cfg (bin)
MSDN Example
I. Word Recognition &#38;&#38; Free [...]]]></description>
			<content:encoded><![CDATA[<p> </p>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&amp;DisplayLang=en">Speech SDK 5.1</a> : Download speech sdk 5.1</li>
<li><a href="http://msdn2.microsoft.com/en-us/library/ms723630.aspx">Designing Grammar Rules</a> : xml grammar spec.</li>
<li>SAPI 5.0 Tutorial<br />
I . <a href="http://www.generation5.org/content/2001/sr00.asp">An Introduction to SAPI</a><br />
II. <a href="http://www.generation5.org/content/2001/sr01.asp">Text-to-Speech</a><br />
III. <a href="http://www.generation5.org/content/2001/sr02.asp">Dynamic Grammar</a><br />
IIII. <a href="http://www.generation5.org/content/2001/sr03.asp">Inline Dictation and Advanced Grammar Modifiers</a><br />
V. <a href="http://www.generation5.org/content/2002/sr04.asp">Voice Control</a></li>
<li><a href="http://dn.codegear.com/tw/article/29583">Speech Synthesis &amp; Speech Recognition Using SAPI 5.1</a></li>
<li>C# example<br />
I. <a href="http://www.codeproject.com/useritems/Speech_Recognition.asp">Simple Speech Recognition</a><br />
II. <a href="http://www.codeproject.com/cs/media/tambiSR.asp">Speech Recognition</a></li>
<li><a href="http://www.codeproject.com/useritems/MFCSpeaksEasily.asp">MFC speaks easily !</a></li>
<li><a href="http://msdn2.microsoft.com/en-us/library/ms720180.aspx">Grammar Compiler</a> : How to compile the grammar from xml (txt) to cfg (bin)</li>
<li>MSDN Example<br />
I. <a href="http://msdn2.microsoft.com/en-us/library/ms722087.aspx">Word Recognition &amp;&amp; Free Word Recognition</a><br />
II. <a href="http://msdn2.microsoft.com/en-us/library/ms717060.aspx">Persisting Recognized WAV Audio from the SR Engine</a><br />
III. <a href="http://msdn2.microsoft.com/en-us/library/ms717071.aspx">Using WAV File Input with SR Engines</a></li>
<li>Event Interest<br />
I. <a href="http://msdn2.microsoft.com/en-us/library/ms720826.aspx">SR Event - SpeechRecoEvents</a> : Lists the event interests for the recognition context.<br />
II. <a href="http://msdn2.microsoft.com/en-us/library/ms720886.aspx">SV Event - SpeechVoiceEvents</a> : Enumerates the types of events which the SpVoice object can raise</li>
<li><a href="http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.speech_tech.sdk">MS Speech SDK Discussion Group</a></li>
]]></content:encoded>
			<wfw:commentRss>http://evotalk.net/blog/2007/05/ms-sapi-releated-resources.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
