LoginSignup
0
0

アイヌ語の「方言間距離」を単語リストの主成分分析で3D可視化する

Posted at

アイヌ民族財団アイヌ語教材テキストの単語リスト(千歳美幌幌別静内十勝沙流石狩川カラフト)をもとに、アイヌ語の「方言間距離」をbinary word vectorの主成分分析で3次元に圧縮し、Google Colaboratory上のplotlyで3D可視化してみた。

!pip install scikit-learn pdfminer plotly
import os,re,numpy
from sklearn.decomposition import PCA
from plotly.express import scatter_3d
d=[("千歳","chitose.txt","chitose_tyukyu.pdf"),
   ("美幌","bihoro.txt","bihoro_tyukyu.pdf"),
   ("幌別","horobetsu.txt","horobetsu_tyukyu.pdf"),
   ("静内","shizunai.txt","shizunai_tango.pdf"),
   ("十勝","tokachi.txt","tokachi_tango.pdf"),
   ("沙流","saru.txt","saru_tango.pdf"),
   ("石狩川","ishikari.txt","ishikari_tango.pdf"),
   ("カラフト","karahuto.txt","karahuto_tango.pdf")]
v=[]
for h,t,p in d:
  os.system(f"test -f {p} || curl --ciphers DEFAULT@SECLEVEL=1 -LO https://www.ff-ainu.or.jp/teach/files/{p}")
  if p.endswith("tyukyu.pdf"):
    os.system(f"test -s {t} || ( pdf2txt.py {p} | sed -e 1,/単語リスト$/d -e /発行年月/q > {t} )")
  else:
    os.system(f"test -s {t} || ( pdf2txt.py {p} | fgrep -v indd > {t} )")
  with open(t,"r",encoding="utf-8") as r:
    v.append(re.findall(r"[a-z=]+",r.read()))
w={j:i for i,j in enumerate(set(sum(v,[])))}
m=numpy.zeros((len(d),len(w)))
for i,k in enumerate(v):
  for j in k:
    m[i,w[j]]=1.0
v=PCA(n_components=3).fit_transform(m)
f=scatter_3d(x=v[:,0],y=v[:,1],z=v[:,2],text=[h for h,t,p in d],opacity=0.5,labels={"x":"","y":"","z":""},width=1600,height=1600)
q={"tickfont":{"color":"white"}}
f.update_scenes(xaxis=q,yaxis=q,zaxis=q)
f.show()

ainu-wordlist.png

PDF中の単語リストから、ローマ字のアイヌ語を取り出してword vectorに仕立てたのが、そこそこうまくいっているようだ。少なくともSzymkiewicz-Simpson係数を使うより、いい結果に見える。さて、この手法を、服部四郎・知里真志保『アイヌ語諸方言の基礎語彙統計学的研究』(民族學硏究, Vol.24, No.4 (1960年11月), pp.307-342)の19方言に適用するには、どこをどうしたらいいのかな。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0