openvanilla / McBopomofo

小麥注音輸入法
http://mcbopomofo.openvanilla.org/
MIT License
615 stars 76 forks source link

Add missing administrative regions of Taiwan #501

Closed ChiahongHong closed 1 month ago

ChiahongHong commented 1 month ago

This PR is a follow-up to https://github.com/openvanilla/McBopomofo/pull/500, adding the missing administrative regions of Taiwan to the list.

The data was sourced from 政府資料開放平臺 under the dataset 地名資料行政區域類.

wget -O town.csv https://data.moi.gov.tw/MoiOD/System/DownloadFile.aspx\?DATA\=FACA075F-B21F-4C7E-8D07-F07A3714651A
import csv

with open('BPMFMappings.txt', 'r', encoding='utf-8') as f:
    lines = f.readlines()
    BPMFMappings = set()
    for line in lines:
        BPMFMappings.add(line.split()[0])

with open('town.csv', 'r', encoding='utf-8-sig', newline='') as f:
    lines = csv.DictReader(f)
    towns = set()
    for line in lines:
        town = line['town']
        # skip empty field
        if not town:
            continue
        towns.add(town)
        # remove 鎮、鄉、市、區
        pure = town[:-1]
        # exclude single character like 中(區)
        if len(pure) > 1:
            towns.add(pure)

diff = sorted(towns.difference(BPMFMappings))
print('\n'.join(diff))
七堵區
七美鄉
七股區
三地門鄉
三灣
三芝區
下營
下營區
中埔
中壢區
中西區
二崙
二崙鄉
五結
五股區
仁德區
仁愛區
仁武區
來義
信義鄉
元長
元長鄉
內門區
八德區
八里區
六甲區
六腳鄉
六龜區
冬山
前金
北竿鄉
北門區
卓蘭鎮
南化
南化區
南州
南州鄉
南竿鄉
口湖鄉
古坑
后里區
和美鎮
員山鄉
員林市
四湖
坪林區
壽豐
大內區
大同鄉
大園區
大城鄉
大埔鄉
大埤
大寮區
大樹區
大武
大武鄉
大湖鄉
大溪區
大社
大社區
太麻里鄉
學甲
學甲區
安南區
安定區
安平區
安樂區
官田區
富里
富里鄉
將軍區
山上區
岡山區
左鎮區
平溪區
平鎮
平鎮區
彌陀區
後壁區
復興區
新化區
新園
新屋區
新營區
旗山區
春日鄉
暖暖
暖暖區
杉林區
東勢鄉
東山區
東引鄉
東河鄉
東港鎮
東石鄉
柳營區
桃園區
桃源區
梓官區
楊梅區
楠西
楠西區
樹林區
歸仁區
民雄鄉
水林
水林鄉
水里鄉
永安區
永康區
永靖
汐止區
池上鄉
泰安鄉
泰山區
泰武
泰武鄉
海端鄉
深坑區
湖內區
湖西鄉
溪口鄉
潮州鎮
烏來區
烏坵鄉
燕巢區
牡丹鄉
獅子鄉
獅潭
獅潭鄉
玉井區
琉球鄉
瑪家
田寮區
甲仙區
番路
番路鄉
白河區
石碇區
石門區
福興
秀林鄉
秀水鄉
竹塘
竹塘鄉
竹崎
竹田
綠島鄉
線西
線西鄉
義竹
義竹鄉
臺東
臺東市
臺西
臺西鄉
苓雅
茂林區
茄萣區
莒光鄉
莿桐
萬丹鄉
萬榮
萬榮鄉
萬里區
蘆竹區
蘭嶼鄉
西港
西港區
觀音區
貢寮區
路竹區
車城鄉
達仁
里港鄉
金寧
金寧鄉
金山區
金峰
金峰鄉
金沙鎮
金湖
金湖鎮
關山鎮
關廟區
阿蓮
阿蓮區
雙溪區
霧臺
頭份市
頭屋
香山區
高樹
鳥松區
鳳林
鳳林鎮
鶯歌區
鹽埔鄉
鹽水區
麟洛
麟洛鄉
麥寮
麻豆區
龍崎區
龍潭區
龜山區
xatier commented 1 month ago

@ChiahongHong awesome work! Thank you so much! :tada: