Skip to content

09_命名實體標記 (NER)

EclairCJ edited this page Oct 25, 2022 · 35 revisions

命名實體標記 (Named Entity Recognition, NER) 是許多 NLP 高階應用中會使用到的標記。Articut 原生支援數十種命名實體的辨識。為了方便理解與利用,以下列出其標記以及說明。

微軟亞洲研究院 (Microsoft Research Lab Asia, MSRA) 提出有 26 種命名實體標記 (Named Entity Recognition, NER) 和 Articut 的對比如下:

說明 MSRA NER Articut NER Functions 說明
年紀 AGE Articut.NER.getAge(resultDICT)[jump] 一個 num 再加一個 ENTITY 歲
量測值 MEASURE Articut.NER.getMeasure(resultDICT)[jump] 在 measurement 裡的都是測量值
角度 ANGLE Articut.NER.getAngle(resultDICT)[jump] 在 measurement 裡有「度」
容量 CAPACTITY Articut.NER.getCapacity(resultDICT)[jump] 在 measurement 裡有「公升」或其它容量單位
分數 FRACTION Articut.NER.getFraction(resultDICT)[jump] 在 measurement 裡有「分之」
頻率 FREQUENCY Articut.NER.getFrequency(resultDICT)[jump] 在 measurement 裡有「赫茲」這類頻率單位
長度 LENGTH Articut.NER.getLength(resultDICT)[jump] 在 measurement 裡有「公分」這類長度單位
百分比 PERCENT Articut.NER.getPercent(resultDICT)[jump] 在 measurement 中有「百分之」
比例 RATE Articut.NER.getRate(resultDICT)[jump] 在 measurement 中有「倍」
速度 SPEED Articut.NER.getSpeed(resultDICT)[jump] 在 measurement 中有速度單位,或是 measurement 後跟著時間
溫度 TEMPERATURE Articut.NER.getTemperature(resultDICT)[jump] 在 measurement 中有溫度單位
重量 WEIGHT Articut.NER.getWeight(resultDICT)[jump] 在 measurement 中有重量單位
地點 LOCATION Articut.NER.getLocation(resultDICT)[jump] 在 LOCATION 裡的即為地點
地區 AREA Articut.NER.getArea(resultDICT)[jump] 一個 ENTITY 後有 RANGE_locality 表示前面的 ENTITY 空間的上下左右內外附近
日期 DATE Articut.NER.getDate(resultDICT)[jump] 一個 month 再加一個 day
時間 TIME Articut.NER.getTime(resultDICT)[jump] 在 TIME_ 的分類下有超過年的時間/年/季/月/週/日/短於一日的時間/假日。
時長 DURATION Articut.NER.getDuration(resultDICT)[jump] 可能為 justtime/day/week/month/season/year/decade,視時間長度而定
整數 INTEGER Articut.NER.getInteger(resultDICT)[jump] 在 num 裡,可兼容小數點、計位點和中文/阿拉伯數字夾雜及空格
小數 DECIMAL Articut.NER.getDecimal(resultDICT)[jump] 內含小數點的 num
序數 ORDINAL Articut.NER.getOrdinal(resultDICT)[jump] 在 DetPhrase 中有「第」
金額 MONEY Articut.NER.getMoney(resultDICT)[jump] 在 currency 裡的都是金額
PERSON Articut.NER.getPerson(resultDICT)[jump] 在 person 裡的即為人名
組織 ORGANIZATION <UserDefined>美國在台協會</UserDefined> 透過外部字典處理
電話 PHONE <無> 各地區格式不同,建議利用 regex 處理
郵遞區號 POSTALCODE <無> 各地區格式不同,建議字典處理
網址 WWW Articut.NER.getWWW(resultDICT)[jump] 在 KNOWLEDGE_url 中的即為網址

除了上述的 26 種外,Articut 另外還有幾種是 MSRA 沒有的:

說明 Articut NER Functions 說明
食物 Articut.NER.getFood(resultDICT, withLocation=False)[jump] 取得文本中的食物名稱,若 withLocation 為 True,則連食物前的地方特色詞一起取得。
Emoji Articut.NER.getEmoji(resultDICT)[jump] 在 oov 中的即為 Emoji 的符號
臺灣地址 Articut.getAddTWLIST(resultDICT)[jump] 在 KNOWLEDGE_addTW 裡的即為台灣地址字串
化學 Articut.getChemicalLIST(resultDICT)[jump] 在 KNOWLEDGE_chemical 裡的即為化學物質
景點 Articut.getOpenDataPlaceLIST(resultDICT)[jump] 在 KNOWLEDGE_place 裡的即為政府開放資料中的景點
WikiData Articut.getWikiDataLIST(resultDICT)[jump] 在 KNOWLEDGE_wikiData 裡的即為收錄於 WikiData 中的條目。特別適用於文本中有許多昆蟲生物名稱時使用。
代名詞 Articut.getPersonLIST(resultDICT, includePronounBOOL=True)[jump] 在 pronoun 中的即為代名詞
顏色 Articut.getColorLIST(resultDICT)[jump] 在 color 中的即為顏色
問題 Articut.getQuestionLIST(resultDICT)[jump] 取出句子含有疑問成份的句子。

操作示範

Articut 相容 MSRA 的 NER 功能

取得年紀

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "今年十歲的彼德有一個八歲的弟弟和一個十四歲的姐姐" 
resultDICT = articut.parse(inputSTR)

ageLIST = articut.NER.getAge(resultDICT)
pprint(ageLIST)

#若要取得所有的數字部份,並轉為數值資料型,可利用 Articut 的 "lv3" 功能:
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["number"])

取得量測值

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "在10立方公尺的箱子裡裝滿3公分長的鉛筆怎麼秤起來只有594.87公克?" 
resultDICT = articut.parse(inputSTR)

measureLIST = articut.NER.getMeasure(resultDICT)
pprint(measureLIST)

#若要取得所有的數字部份,並轉為數值資料型,可利用 Articut 的 "lv3" 功能:
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["number"])

#此外,也可利用 Articut 的 "lv3" 功能取出單位的部份
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["unit"])

取得角度

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "cos45° 和 tan60度哪一個大?" 
resultDICT = articut.parse(inputSTR)

angleLIST = articut.NER.getAngle(resultDICT)
pprint(angleLIST)

#若要取得所有的數字部份,並轉為數值資料型,可利用 Articut 的 "lv3" 功能:
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["number"])

#此外,也可利用 Articut 的 "lv3" 功能取出單位的部份
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["unit"])

取得容量

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "容量1公升的牛奶紙盒裡只能裝 995.5毫升的水" 
resultDICT = articut.parse(inputSTR)

capacityLIST = articut.NER.getCapacity(resultDICT)
pprint(capacityLIST)

#若要取得所有的數字部份,並轉為數值資料型,可利用 Articut 的 "lv3" 功能:
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["number"])

#此外,也可利用 Articut 的 "lv3" 功能取出單位的部份
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["unit"])

取得分數

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "成年的貓一天有三分之二的時間在睡覺,小貓睡覺的時間更高達5/6" 
#注意!因 [數字/數字] 可能代表的意義過於分歧 (e.g., 分數、日期…等) 故 NER.getFraction() 工具不予處理。但可自行藉由前處理將「5/6」取代為「六分之五」來處理。
resultDICT = articut.parse(inputSTR)

fractionLIST = articut.NER.getFraction(resultDICT)
pprint(fractionLIST)

取得頻率

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "調頻廣播電台頻道為100至108兆赫,每三年一次重審執照" 
#注意!同義句亦可為「每三年重審一次執照」,但因動詞「重審」夾在「每三年」和「一次」之間,為免影響字串索引值,故此處未加以處理。
resultDICT = articut.parse(inputSTR)

frequencyLIST = articut.NER.getFrequency(resultDICT)
pprint(frequencyLIST)

取得長度

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "標準中式餐桌多為4.2尺、4.5尺、5尺三種規格最常見;6人餐桌,長x寬約140公分x80公分"
resultDICT = articut.parse(inputSTR)

lengthLIST = articut.NER.getLength(resultDICT)
pprint(lengthLIST)

#若要取得所有的數字部份,並轉為數值資料型,可利用 Articut 的 "lv3" 功能:
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["number"])

#此外,也可利用 Articut 的 "lv3" 功能取出單位的部份
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["unit"])

取得百分比

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "上述提到的歐美人血栓發生率為千分之一,亞洲人應該更低"
resultDICT = articut.parse(inputSTR)

percentLIST = articut.NER.getPercent(resultDICT)
pprint(percentLIST)

取得比例

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "雙方比數為40比8,相差五倍"
resultDICT = articut.parse(inputSTR)

rateLIST = articut.NER.getRate(resultDICT)
pprint(rateLIST)

取得速度

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "颱風彩雲以每小時20公里速度向北進行,近中心最大風速每秒18公尺,瞬間最大陣風每秒25公尺。"
resultDICT = articut.parse(inputSTR)

speedLIST = articut.NER.getSpeed(resultDICT)
pprint(speedLIST)

#若要取得所有的數字部份,並轉為數值資料型,可利用 Articut 的 "lv3" 功能:
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["number"])

#此外,也可利用 Articut 的 "lv3" 功能取出單位的部份
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["unit"])

取得溫度

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "高燒至39℃以上,甚至燒到四十度以上,需立即處理"
resultDICT = articut.parse(inputSTR)

temperatureLIST = articut.NER.getTemperature(resultDICT)
pprint(temperatureLIST)

#若要取得所有的數字部份,並轉為數值資料型,可利用 Articut 的 "lv3" 功能:
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["number"])

#此外,也可利用 Articut 的 "lv3" 功能取出單位的部份
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["unit"])

取得重量

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "桃園河川魚隻大量死亡舖滿河面,一周清出30噸"
resultDICT = articut.parse(inputSTR)

weightLIST = articut.NER.getWeight(resultDICT)
pprint(weightLIST)

#若要取得所有的數字部份,並轉為數值資料型,可利用 Articut 的 "lv3" 功能:
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["number"])

#此外,也可利用 Articut 的 "lv3" 功能取出單位的部份
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["unit"])

取得地點

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "日本對台灣提供疫苗在政界與民間輿論有共識,但仍有多個技術性問題"
resultDICT = articut.parse(inputSTR)

locationLIST = articut.NER.getLocation(resultDICT)
pprint(locationLIST)

Droidtown 另外有提供 SPACE 的 [地點 <-> GPS] 的雙向反查服務。只要地點是台灣境內的地名、地址,都可以轉為相對應的 GPS 座標。相對地,GPS 座標則可以回傳至行政區級的資訊。[參考連結]

取得地區

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "藥局門前擠滿了搶購酒精的民眾,隊伍一路排到大街上"
resultDICT = articut.parse(inputSTR)

areaLIST = articut.NER.getArea(resultDICT)
pprint(areaLIST)

取得日期

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "其實早在五月15日開始突破百例之前,這起社區大爆發疫情就已經有一些端倪。"
resultDICT = articut.parse(inputSTR)

dateLIST = articut.NER.getDate(resultDICT)
pprint(dateLIST)

#若要轉換所有時間字串成為更好處理的機讀格式 (e.g., datetime 格式),可利用 Articut 的 "lv3" 功能
resultDICT = articut.parse(inputSTR, level="lv3") 
pprint(resultDICT["time"])

取得時間

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "上星期我們約好了,這件事情今天下午六點到八點要討論"
resultDICT = articut.parse(inputSTR)

timeLIST = articut.NER.getTime(resultDICT)
pprint(timeLIST)

#若要轉換所有時間字串成為更好處理的機讀格式 (e.g., datetime 格式),可利用 Articut 的 "lv3" 功能
resultDICT = articut.parse(inputSTR, level="lv3") 
pprint(resultDICT["time"])

取得時段

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "上星期我們約好了,這件事情今天下午六點到八點要討論"
resultDICT = articut.parse(inputSTR)

durationLIST = articut.NER.getDuration(resultDICT)
pprint(durationLIST)

#若要轉換所有時間字串成為更好處理的機讀格式 (e.g., datetime 格式),可利用 Articut 的 "lv3" 功能
resultDICT = articut.parse(inputSTR, level="lv3") 
pprint(resultDICT["time"])

取得整數

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "他們兄弟共三個人,其中兩人是雙胞胎,都是十歲"
resultDICT = articut.parse(inputSTR)

#注意「三個人」的「三」並不是獨立的整數,它是量/分類詞系統「三個」的一部份。
integerLIST = articut.NER.getInteger(resultDICT)
pprint(integerLIST)

#若要取得所有的數字部份,並轉為數值資料型,可利用 Articut 的 "lv3" 功能:
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["number"])

取得小數

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "如果你需要買美元美金,在臺灣郵政購買(匯率:28.23)會比較便宜。"   
resultDICT = articut.parse(inputSTR)

decimalLIST = articut.NER.getDecimal(resultDICT)
pprint(decimalLIST)

#若要取得所有的數字部份,並轉為數值資料型,可利用 Articut 的 "lv3" 功能:
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["number"])

取得序數

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "第一名和第二名之間的差距實在是太大了"   
resultDICT = articut.parse(inputSTR)

ordinalLIST = articut.NER.getOrdinal(resultDICT)
pprint(ordinalLIST)

取得金額

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "並自104 年度起分年核編計畫經費,總經費 6,500 萬3 千元"   
resultDICT = articut.parse(inputSTR)

moneyLIST = articut.NER.getMoney(resultDICT)
pprint(moneyLIST)

#若要取得所有的數字部份,並轉為數值資料型,可利用 Articut 的 "lv3" 功能:
resultDICT = articut.parse(inputSTR, level="lv3")
pprint(resultDICT["number"])

取得人名

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "陳時中親探視遭砍護理師。蔡英文表示「攻擊醫護一定嚴辦」"   
resultDICT = articut.parse(inputSTR)

personLIST = articut.NER.getPerson(resultDICT, includePronounBOOL=False)
pprint(personLIST)

取得各種網路連結列表

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "延伸閱讀:日本。愛上近江牛https://freshweekly.tw/?pn=vw&id=8rz2cm81o670" 
resultDICT = articut.parse(inputSTR)

linkLIST = articut.NER.getWWW(resultDICT)
pprint(linkLIST)

Articut 特有 NER 功能

取得食物名稱列表

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "《小糧倉》菜單販售品項十分多元,雞白湯拉麵、咖哩飯、鐵板漢堡排定食等"
resultDICT = articut.parse(inputSTR)

foodLIST = articut.NER.getFood(resultDICT)
pprint(foodLIST)

取得_Emoji_符號

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "很有風味的香港茶餐廳👍,超級推😊"
resultDICT = articut.parse(inputSTR)

emojiLIST = articut.NER.getEmoji(resultDICT)
pprint(emojiLIST)

取得地址列表

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "《勝王》於2018年底獨立出來,最初開在中山北路上,長安西路、長安東路、華陰街中間後來搬家至現今的新地址:台北市中山區林森北路306號,不遠處的《烹星》同為老闆老葛的拉麵品牌"     
resultDICT = articut.parse(inputSTR)

addLIST = articut.getAddTWLIST(resultDICT)
pprint(addLIST)

若需要更詳細的「縣市、鄉鎮、里鄰…」等分析,請參考 localRE 工具[連結]

取得化學物質

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "麵餅添加物包含味精(穀氨酸鈉)、碳酸鉀、碳酸鈉、三聚磷酸鈉、六偏磷酸鈉、焦磷酸鈉、黃原膠、薑黃素、梔子黃、核黃素,共10種。"   
resultDICT = articut.parse(inputSTR)

chemicalLIST = articut.getChemicalLIST(resultDICT)
pprint(chemicalLIST)

取得_OpenData_中收錄的景點地名

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "下午去參觀巧克力工廠"   

#注意!要把 openDataPlaceAccessBOOL=False 的預設值改為 True
resultDICT = articut.parse(inputSTR, openDataPlaceAccessBOOL=True)

placeLIST = articut.getOpenDataPlaceLIST(resultDICT)
pprint(placeLIST)

取得_WikiData_中收錄的條目

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "觀察到一隻阿里山刷角星斑天牛"   

#注意!要把 wikiDataBOOL=False 的預設值改為 True
resultDICT = articut.parse(inputSTR, wikiDataBOOL=True)

wikiDataLIST = articut.getWikiDataLIST(resultDICT)
pprint(wikiDataLIST)

取得代名詞

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "你看他一個人先走了,都沒等我們"   
resultDICT = articut.parse(inputSTR)

pronounDataLIST = articut.getPersonLIST(resultDICT, includePronounBOOL=True)
pprint(pronounDataLIST)

取得顏色

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "外面烏漆抹黑的,你又穿一身黑衣,要是小黃司機沒看到你怎麼辦?"   

#若要取得最完整的顏色字串,請使用 "lv1" 的設定
resultDICT = articut.parse(inputSTR, level="lv1")

colorLIST = articut.getColorLIST(resultDICT)
pprint(colorLIST)

取得問句

from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey   = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。

articut = Articut(username, apikey)
inputSTR = "天這麼黑,他為什麼不來接我,他有想過我的感受嗎"   
resultDICT = articut.parse(inputSTR, level="lv2")

questionLIST = articut.getQuestionLIST(resultDICT)
pprint(questionLIST)
Clone this wiki locally