2009年11月30日 星期一

使用Python NLTK讀取WordNet

from nltk.corpus import wordnet as wn
wn.synsets('dog')

http://nltk.googlecode.com/svn/trunk/doc/howto/wordnet.html

2009年11月25日 星期三

Google AppEngine架站說明

若要將完成的應用程式上傳到「Google 應用服務引擎」,請執行下列命令:
appcfg.py update helloworld/

測試應用程式
使用處理常式指令碼和設定檔,將每個 URL 對應到處理常式,便完成應用程式。您現在可以用包括「應用服務引擎 SDK」的網頁伺服器來測試它。

使用下列命令啟動網頁伺服器,切換到 helloworld 目錄:
dev_appserver.py helloworld/

網頁伺服器現在已經執行,並接聽連接埠 8080 的要求。使用您的網頁瀏覽器瀏覽下列 URL,以測試應用程式:
http://localhost:8080/

2009年11月23日 星期一

人體預測系統

今天人類受限於時間而對很多事情無法做出正確的決定。
譬如說,我們不知道每天吃蘋果會不會讓身體健康一點。
若是有一個資訊系統,在一群人身上裝身體狀況感應器,蒐集各種身體狀況資訊
蒐集十幾二十年後,應該就有足夠資訊可以建立出數學模型來知道吃蘋果有沒有用、或者預測每天吃蘋果十年後的身體狀況。

2009年11月22日 星期日

自動建Domain WordNet

研究Paser做法?查SLP
試驗Verb Pattern(JC?)

Google自動化作法:Hearst(1992)文獻...
 1.Literal Exact Match(以...V...,一種...方式,parallel->有某種relation)

Automatic Assignment of Wikipedia Encyclopedic Entries to WordNet Synsets(Ruiz-Casado1 ,Alfonseca1 & Castells, 2005)

Vivaldi等Domain WordNet建置經驗

Word in WordNet Issue
 English: Word = Stem + Morpheme (Affix)
 英文不同詞類的字算不同字嗎(e.g., fluid vs. fluidity?)
 Chinese: 部件
 用Literal Exact Match解決
 (以...V...,一種...方式,parallel->有某種relation)

2009年11月21日 星期六

Domain WordNet的意義

Domain WordNet的Knowledge可用來作Domain Document的WSD

「登陸」這個詞從最初的字面意義(從海上登上陸地,landing)
變成後來太空任務中「登陸月球」的用法(從空中降落月球表面)
現在還可用於商業領域企業「進入中國大陸」的用法
所以在商業的Domain裡「登陸」的意義有必要另外區分
因此有Domain WordNet的需要。

2009年11月20日 星期五

建置Domain WordNet要點

‧建立Domain Synset
‧建立Relation詞意關係
‧如何區分Domain WordNet與Generic WordNet
 -兩者如何連結?
 -兩者的關係?重疊?從lexico-syntactic pattern找到重複者怎麼辦

2009年11月19日 星期四

中英WordNet詞意關係比較

Introduction
WordNet出現二十年以來,相關研究與應用很多,但同時也應檢視WordNet的想法

WordNet and Lexical Semantics

(Fellbaum, 1998, xvi)
...
Componential semantics approaches the meaning of a word in much the same way it approaches the meaning of a sentence: the meaning of a sentence should be decomposable into the meanings of its constituents, and the meaning of a word should be similarly decomposable into certain semantic primitives, or conceptual atoms. Philip N. Johnson-Laird and I [Fellbaum] had explored componential semantics with much enthusiasm in our 1976 book, Language and Perception, but in 1985 we still did not have a definitive list of the conceptual atoms and it was beginning to look as if, whatever otehr virtures componential lexical semantics might have, it was not the best theory for natural language processing by computers.
Was there an alternative? In 1985 many cognitive psychologists and computational linguists were formulating word meanings in terms of networks, diagrams with nodes to represent meanings and darts to represent relations between the meanings. For exampole, table and furniture would label two nodes and a dart between them would represent the proposition that "a table is a kind of furniture." IS-A-KIND-OF is a semantic relation; no claim is made that the meaning of furniture is a component of the meaning of table. As workers became more self-conscious about the assumptions that are involved in these network representations, it became increasingly obvious that relational lexical semantics is one possible alternative to componential lexical semantics. And Jerry Fodor pointed out that many years earlier Rudolph Carnap had proposed a similar type of relational semantics.
...

Three Hypotheses of WordNet

Separability Hypothesis
the lexical component of language can be isolated and studied in its own right

Patterning Hypothesis
people could not master and have readily available all the lexical knowledge needed to use a natural language unless they could take advantage of systematic patterns and relations among the meanings that words can be used to express

Comprehensiveness Hypothesis
computational linguistics, if it were ever to process natural languages as people do, would need to have available a store of lexicla knowledge as extensive as people have

Introduction to WordNet

(Fellbaum, 1998, p. 6)
...
People often draw the distinction between word (or lexical) knowledge and world (or encyclopedia) knowledge. Two kinds of books reflect this distinction: dictionaries are generally the repository of word knowledge, and encyclopedias the repository of world knowledge. The boundaries between the two are in fact fuzzy. We can probably all agree that knowing that hitting someone is a hostile act constitutes world knowledge, whereas knowing that the verb hit is a strong verb, that it is more or less synonymous with strike, and that it takes a direct argument constitutes word knowledge. It is less clear how knowing that the direct argument of hit must be a solid object (as opposed to, say, a gas) should be classified. But there is no question that understanding the meaning and uses of a word requires both kinds of knowledge. Kay (1989) points out that our mental lexicon must contain both word and world knowledge, and that only those lexicons that contain both kinds of knowledge are likely to yield successful applications. Encyclopedic knowledge is vast and difficult to assemble, although Lenat and his colleagues (Lenat and Guha 1990) have been working for a number of years on constructing an intelligent system that has all facts pertaining to words and concepts at its disposition. WordNet does not attempt to include encyclopedic knowledge, although the definitions that accompany the synonym sets (synsets) provide information about the concepts that is not strictly part of their lexical structure. G. A. Miller points out in the foreword that, although WordNet's synsets were initially intended to contain no information other than pointers to other synsets, it was found that definitions and illustrative sentences were needed to distinguish closely related synsets whose members were polysemous. And in the case of many technical concepts, such as uncommon plants and animals, lexical and encyclopedic knowledge are merged in the definitions, which are likely to constitute all the knowledge everyday speakers need to access.
Knowledge beyond htat usually given in dictionaries is needed for reasoning and making inferences about states and events referred to by sentences. Harabagiu and Moldovan (chapter 16) show how the information in WordNet can be augmented to create a knowledge base that can be successfully used for inferencing.
...

2009年11月18日 星期三

WordNet的好處

WordNet:結合辭典和本體論的文字百科全書(2004,張俊盛)

...
再回頭來談WordNet有什麼好處。以自動詢答這個熱門的研究題目為例,我們可以問電腦"Who invented electric light?"電腦由WordNet中,知道"electric light"和"lightbulb"在WordNet中同屬一個同義集(synset),指的是同一個東西。因此可以在「大英百科全書」檔案中,找到發明電燈泡的一段相關文字(He [Edison]…invented…the incandescent lightbulb),來正確回答問題。WordNet還提供廣義、狹義、相似、部份、全體等18種詞彙語意關係。有了WordNet,電腦就能應付變化多端的問題。
...


本文轉載自2004年5月號科學人

Language and Thought(續)

延續前文,討論語言language以及思想thought的關係之前
什麼是language?什麼是thought?

什麼是language這個問題應該是語言學想回答的,目前可能還沒有一個明確的答案
那什麼是thought呢?人類真的有思想嗎

萬物之靈覺得自己特別的地方在於擁有智慧、能思考、有創造力
那其他動物沒有嗎?或者電腦有思想嗎?

首先我們可以討論什麼是思想
思想是一種本能?還是本能反應算是思想的一種?(動物皆具有本能反應)

當我們覺得人類會思考時,電腦難道不會思考嗎?

中文的WordNet又是什麼呢

WordNet從字面來看的話是由Word形成的一個網路
然而Word是什麼呢?

抓(zhuaㄓㄨㄚ3)是一個Word嗎?
爪(zhuaㄓㄨㄚ)和抓有關係嗎?
可能有關係。

也許可以從英語言學對Word的定義出發:
Word is ...

那麼中文的WordNet應該提供抓與爪的關係嗎

以上是從character的觀點出發討論word的概念
再從更大的單位compound的話
甚至從phrase和word有什麼關係

2009年11月17日 星期二

Lexico-Syntactic Pattern for Domain WordNet

Clostridium 雖為絕對厭氧菌,但對於氧的容忍度很大,不用產生芽苞也可以輕易在空氣中生存,該菌種適合生長的 pH 為 6.5-7.0 之間,此菌種對於溫度的忍受性也很大,從 15-69℃皆能生長。
S(theme:NP(Head:Nb:Clostridium)|concession:Cbba:雖|Head:VG2:為|range:NP(property:A:絕對|Head:Na:厭氧菌))

Bacteroides 為厭氧菌,行化學異營,經由代謝碳水化合物以及胰化蛋白腖 peptone 產生能量。
S(theme:NP(Head:Nb:Bacteroides)|Head:VG2:為|range:NP(Head:Na:厭氧菌))

Propionibacterium 包含厭氧菌以及兼性樣氧菌,這類屬的菌種皆能夠產生丙酸(propionic),乙酸以及少量的甲酸,最適宜的成長條件為 pH 7 溫度 37℃,其中 Propionibacterium acnes 會產生indole(Zhu, et al., 1999)。
S(theme:NP(Head:Nb:Propionibacterium)|Head:VJ3:包含|range:NP(property:VP(DUMMY1:VP(Head:VJ1:厭|goal:NP(Head:Na:氧菌))|Head:Caa:以及|DUMMY2:VP(Head:VG2:兼|range:NP(Head:Na:性樣)))|Head:Na:氧菌))

Escherichia 最著名的菌種就是大腸菌 E.coli,為好氧或者是兼性厭氧菌,利用葡萄糖或者其他碳水化合物來產生丙酮酸鹽 pyruvate,進而轉化為甲酸,乙酸以及乳酸等有機酸,該菌種的理想生長環境接近中性,溫度為 37℃,但是在 pH 4.4-9.0 之間仍然能生長,幾乎所有的菌種皆能夠產生 indole 類,該種化合物臭味甚為劇烈,為主要臭味之一(Zhu, et al.,1997)。
S(apposition:NP(property:Nb:Escherichia|property:VP‧的(head:VP(degree:Dfa:最|Head:VH11:著名)|Head:DE:的)|Head:Naa:菌種)|reason:Cbba:就是|Head:NP(apposition:Naa:大腸菌|Head:Nb:E.coli))

Lactobacillus 為對氧有容忍性或者是絕對厭氧的菌種,為嗜酸菌,偏好在偏酸的環境下生存,利用葡萄糖作為碳源,Lactobacillus 分兩種發酵方式,同源發酵以及異源發酵。
S(theme:NP(Head:Nb:Lactobacillus)|Head:VG2:為|range:NP(predication:VP‧的(head:VP(DUMMY1:VP(target:PP(Head:P31:對|DUMMY:NP(Head:Naa:氧))|Head:V_2:有|range:NP(Head:Na:容忍性))|Head:Caa:或者|DUMMY2:VP(Head:V_11:是|range:NP(property:VH11:絕對|Head:Na:厭氧)))|Head:DE:的)|Head:Naa:菌種))

Eubacteria 為一種絕對厭氧的細菌,行化學異營,經由代謝胰化蛋白腖 peptone 或是碳水化合物,產生各類有機酸以及揮發性有機酸。
S(theme:NP(Head:Nb:Eubacteria)|Head:VG2:為|range:NP(quantifier:DM:一種|property:NP‧的(head:NP(property:A:絕對|Head:Na:厭氧)|Head:DE:的)|Head:Nab:細菌))

Peptostreptococcus 為化學異營菌,可經由代謝胰化蛋白腖 peptone 以及氨機酸來轉化成甲酸,乙酸,丁酸以及其他有機酸,以及一些揮發性胺類,此外還會產生醇類等。
S(theme:NP(Head:Nb:Peptostreptococcus)|Head:VG2:為|range:NP(apposition:Nad:化學|Head:Nb:&#)|range:DM:63842)

Streptococcus 大部分的菌種為兼性厭氧菌,理想生長環境為 37℃,pH 接近中性的環境,pH低於 4 或高於 9.6 都會使其停止生長,為化學異營菌藉利用降解有機物來產生能量,主要產物為乳酸,以及少部分的乙酸、酒精、二氧化碳等,大部分的菌種也會產生氨(Zhu, 2000)。
S(theme:NP(property:Nb:Streptococcus|quantifier:N‧的(head:Neqa:大部分|Head:DE:的)|Head:Naa:菌種)|Head:VG2:為|range:VP(Head:VG2:兼|range:NP(property:Na:性厭|property:Naa:氧|Head:Nab:菌)))

2009年11月14日 星期六

Domain WordNet

語言學試圖回答語言是什麼這個問題
計算語言學則從語言如何運作來瞭解語言是什麼?
WordNet是計算語言學領域中用來設計language understanding system一項重要的資源
例如在Q&A系統中問"Who invented electric light?"電腦由WordNet中,知道"electric light"和"lightbulb"在WordNet中同屬一個同義集(synset),指的是同一個東西。因此可以在「大英百科全書」檔案中,找到發明電燈泡的一段相關文字(He [Edison]…invented…the incandescent lightbulb),來正確回答問題。WordNet還提供廣義、狹義、相似、部份、全體等18種詞彙語意關係。有了WordNet,電腦就能應付變化多端的問題。(張俊盛,2004)

WordNet似乎不是那麼Ambitious想找出語言共通的lexical knowledge
比較有點像是人類為了做出machinese translation、因為需要這項資源而發展出wordnet

Domain WordNet則是因為原始的wordnet無法普遍應用(譬如說專業領域)而有所需求
wordnet本來希望是能用於各種應用的。

作語言資源這件事比較像是人類找不出語言中的general rules
而乾脆把它們全部列出來。

2009年11月13日 星期五

WordNet所包含的lexical knowledge

中文「龍」這個字代表這什麼意思呢
似乎具有正面(吉祥)的意思

英文的「龍」呢
好像就比較邪惡的感覺(譬如說噴火龍之類的)

那這種正面或負面涵義是lexical knowledge的一部分嗎
我們有辦法區分lexcial knowledge跟enclopedia knowledge嗎

假如中文的龍是具有正面意義,而英文的龍則具負面意義
那麼lexical knowledge是否包含文化層面的knowledge呢
中英文化knowledge不就會算是enclopedia knowledge的一種了嗎

這樣的話,lexical knowledge和enclcypeida knowledge似乎至少有部分重疊
因而沒辦法區分
所以語言是受各種因素(例如文化因素)影響、沒辦法分開討論lexical knowledge的
我們只能看某些knowledge是比較跟language本身直接關聯,稱他們為core knowledge吧

所以WordNet可以只包含這些core knowledge
或者是試圖把所有knowledge包含進去



蕃茄1:mildly acid red or yellow pulpy fruit eaten as a vegetable
hypernym
solanaceous_vegetable茄科蔬菜:any of several fruits of plants of the family Solanaceae; especially of the genera Solanum; Capsicum; Lycopersicon
hypernym
vegetable

蕃茄2:native to South America; widely cultivated in many varieties
hypernym
herb

鯨魚1cetacean:large aquatic carnivorous mammal with fin-like forelimbs no hind limbs, including: whales; dolphins; porpoises; narwhals
hypernym=>acquatic_mammal
hyponym=>whale

鯨魚2whale:any of the larger cetacean mammals having a streamlined body and breathing through a blowhole on the head
hypernym=>cetacean
hyponym=>spouter, toothed_whale, narwhale, baleen_whale, narwhal, Monodon_monoceros, narwal, whalebone_whale

龍dragon:a creature of Teutonic mythology; usually represented as breathing fire and having a reptilian body and sometimes wings
hypernym:mythical creature/monster
hyponym:wivern,Fafnir,wyvern

恐龍1dinosaur:any of numerous extinct terrestrial reptiles of the Mesozoic era
hypernym:archosaur, archosaurian, archosaurian_reptile
hyponym:ground-shaker, saurischian_dinosaur, seismosaur, argentinosaur, ornithischian_dinosaur, titanosaurian, saurischian, ornithischian, titanosaur, iguanodon, diplodocus

恐龍2carnosaur:large carnivorous bipedal dinosaur having huge claws
hypernym:theropod_dinosaur, theropod, bird-footed_dinosaur
member holonym:Carnosaura, suborder_Carnosaura

中英WordNet所表達的詞彙知識

語言是什麼呢
會說一種語言代表著什麼呢
有人認為會說一種語言代表你具有該語言的linguistic knowledge

那linguistic knowledge又是什麼呢
有人認為包含grammatical knowledge, phonological knowledge, 甚至lexical knowledge
也就是說當你只會英文文法時,並不代表你講英文
文法並不是linguistic knowledge的全部,只學文法英文並沒辦法講得好
一個英文說得很流利的人(譬如native speaker)是具備至少前述三種linguistic knowledge的

那lexical knowledge又是什麼呢
WordNet試圖表現lexical knowledge
當我們說The manager was murdered.這句話時
蘊含(entail)著The manage is dead.這件事
所以murder和dead這兩個字存在著某種關係
有人認為這種關係是屬於lexical knowledge

這樣看起來lexical knowledge和encyclopedia knowledge有點像
從encyclopedia knowledge的角度來看lexical knowledge
假如不具備某種knowledge但依然不影響語言的使用的話
該knowledge應該算是encyclopedia knowledge
反之缺少lexical knowledge(linguistic knowledge的一部分)則會影響語言的表達

所以若WordNet是lexical knowledge的表現的話,
WordNet提供哪些知識呢
譬如說一個人知不知道「鯨魚是不是魚/蕃茄是不是水果」會不會影響他對「鯨魚/蕃茄」這個字的理解呢
假如會影響的話這些知識就算lexical knowledge,應該在WordNet找得到
不影響的話就算是encyclopedia knowledge,不應該出現在WordNet裡面

不過以上都是假設encyclopedia和lexical knowledge是可區分的,完全沒有重疊
然而真的是這樣嗎

Language and Thought

當別人跟你說這碗綠豆湯很甜時,你可能回應說是有點甜
然而你們兩人所指的甜是同樣的東西嗎
我們是如何得知甜這個味道呢
也許藉由嚐過諸如砂糖、黑糖、白糖、方糖等事物,我們可以發現他們之間的共通點「甜」
因而知道甜是指什麼味道(那麼當初又是誰把發現這個味道、並命名為甜的呢)

不過因為甜是比較抽象的概念,今天若大家是討論魚、桌子等實物,應該比較容易確認雙方的共識

人類使用language試圖將自己的thought告訴別人
可是你如何確定對方瞭解你所用的語言、因而知道你的想法呢
有辦法確定嗎

也許兩句對話並沒有辦法確定
對方可能瞭解你的意思、也有可能誤解了
藉由不斷地對話,我們會覺得對方有沒有懂、雙方是不是在談同一件事

考慮獨立事件
假設每句問答的對方理解你的機會只有七成
第一句誤解你的機會就是三成
第二句也是三成
若雙方對話了十句
那麼對方誤解你的機會就變成0.3^10=0.000006
當然還是有可能誤解,可是機會很低、接近零,不大可能
不過我們還是沒辦法完全確定第一句對話時對方就理解你,也沒辦法確認整個對話是環繞在相同的話題

從刺激反應論來看,人類的對話可能是單純的刺激與反應,當我發現這麼回應時符合我的目的時,就會選擇這麼回應,也許我們並沒有心智這回事。不過從有人一時想不開這件事來看,心智似乎存在。

2009年11月12日 星期四

Keyphrase Extraction in a Document

  1. position
  2. cue phrases
  3. word informativeness
  4. sentence length
  5. cohesion

OntoClean的問題

OntoClean有沒有可能太robust?
根據OntoClean蘋果因為在爛掉的時候不是食物
所以蘋果並不算食物

但若在沒有任何context的情況下問人蘋果是不是食物
有可能會回答是

這樣是不是因為蘋果有多重涵義
在植物果實這一義時不一定是食物
但在水果這一義時卻是食物(對人類來說水果是食物)

2009年11月11日 星期三

Why WordNet

why建立語意關係
why建置wordnet(計算語言學需要lexcal knowledge)
wordnet在cl扮演什麼角色(不明顯、頂多是輔助的角色,例如用來improve最後QA的performance)
why做計算語言學(回答語言如何運作)
why做語言學研究(回答what is language)