-
Notifications
You must be signed in to change notification settings - Fork 38
02.3 工具包:LocalRE 中文地址資訊擷取工具
Droidtown Linguistic. Tech. Co., Ltd edited this page Jun 28, 2021
·
3 revisions
此頁說明 LocalRE 中文地址 資訊擷取工具操作方式:
- 首先利用取得 Articut 處理文本,取得 resultDICT:
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 = """位於台南的50年老房子,
地址是台南市東區長榮路3段30巷3號。
這裡承載著曾經是學生宿舍的使命。
我們繼續把這樣的溫度傳遞,
讓往來的人都把這裡當做家,
用緩慢的步調體驗台南的在地生活。""".replace(" ", "")
resultDICT = articut.parse(inputSTR)- 接下來就能使用 localRE 工具取得地址分段細節
# getAddressCounty() 取出是哪個「縣」
countyResult = articut.localRE.getAddressCounty(resultDICT)
print("\n##localRE: 縣")
pprint(countyResult)
# getAddressCity() 取出是哪個「市」
cityResult = articut.localRE.getAddressCity(resultDICT)
print("\n##localRE: 市")
pprint(cityResult)
# getAddressDistrict() 取出是哪個「區」
districtResult = articut.localRE.getAddressDistrict(resultDICT)
print("\n##localRE: 區")
pprint(districtResult)
# getAddressTownship() 取出是哪個「鄉」或「里」
townshipResult = articut.localRE.getAddressTownship(resultDICT)
print("\n##localRE: 鄉里")
pprint(townshipResult)
# getAddressTown() 取出是哪個「鎮」
townResult = articut.localRE.getAddressTown(resultDICT)
print("\n##localRE: 鎮")
pprint(townResult)
# getAddressVillage() 取出是哪個「村」
villageResult = articut.localRE.getAddressVillage(resultDICT)
print("\n##localRE: 村")
pprint(villageResult)
# getAddressNeighborhood() 取出是哪個「鄰」
neighborhoodResult = articut.localRE.getAddressNeighborhood(resultDICT)
print("\n##localRE: 鄰")
pprint(neighborhoodResult)
# getAddressRoad() 取出是哪條「路」
roadResult = articut.localRE.getAddressRoad(resultDICT)
print("\n##localRE: 路")
pprint(roadResult)
# getAddressSection() 取出是哪一「段」
sectionResult = articut.localRE.getAddressSection(resultDICT)
print("\n##localRE: 段")
pprint(sectionResult)
# getAddressAlley() 取出是哪一「巷弄」
alleyResult = articut.localRE.getAddressAlley(resultDICT)
print("\n##localRE: 巷、弄")
pprint(alleyResult)
# getAddressNumber() 取出是幾「號」
numberResult = articut.localRE.getAddressNumber(resultDICT)
print("\n##localRE: 號")
pprint(numberResult)
# getAddressFloor() 取出是幾「樓」
floorResult = articut.localRE.getAddressFloor(resultDICT)
print("\n##localRE: 樓")
pprint(floorResult)
# getAddressRoom() 取出「室」的編號
roomResult = articut.localRE.getAddressRoom(resultDICT)
print("\n##localRE: 室")
pprint(roomResult)有了分段的細節以後,就能在設計人機互動的 Chatbot (聊天機器人) 或是空間地址相關服務的網站應用時候有更細膩的互動模式。
除了將地址資訊擷取出來以外,此功能也可以搭配 articut.getLocationStemLIST(resultDICT) 來取出完整的地址字串。並再使用我們的 SPACE GIS 台灣地址-座標雙向轉換服務來繪製到地圖上。詳情請參考說明文件[連結]。
Droidtown Linguistic Tech.
Document | Blog | Twitter @DroidtownLing | Facebook @Articut | Website