hellog〜英語史ブログ     ChangeLog 最新    

levenshtein_distance - hellog〜英語史ブログ

最終更新時間: 2019-10-21 08:10

2018-08-24 Fri

#3406. Levenshtein distance [cgi][web_service][spelling][shakespeare][levenshtein_distance]

 文字列の類似度や相違度を測る有名な指標の1つに,標題の "Levenshtein distance" というものがある,「#3397. 後期中英語期の through のワースト綴字」 ([2018-08-15-1]),「#3398. 中英語期の such のワースト綴字」 ([2018-08-16-1]),「#3399. 綴字の類似度計算機」 ([2018-08-17-1]) でも前提としてきた指標であり,「#1163. オンライン語彙データベース DICT.ORG」 ([2012-07-03-1]) でもこの指標を利用して類似綴字語を取り出すオプションがある.
 考え方は難しくない.もとの文字列から目標の文字列に変換するには,いくつの編集工程(挿入,削除,置換)が必要かを数えればよい.例えば,kitten から sitting へ変換するには,kitten →(ks に置換)→ sitten →(ei に置換)→ sittin →(g を挿入)→ sitting という3工程を踏む必要があるので,両綴字間の Levenshtein distance は3ということになる.通常は挿入,削除,置換の編集工程にそれぞれ1の値を割り当てるが,各々に異なる値を与える計算の仕方もある.
 以下に,通常の重みづけで Levenshtein distance を計測する CGI を置いておく.試しに「#1720. Shakespeare の綴り方」 ([2014-01-11-1]) より25種類の異綴字を取り出して,カンマ区切りなどで下欄に入力してみてください(要するに以下をコピペ).Shakespeare, Schaksp, Shackespeare, Shackespere, Shackspeare, Shackspere, Shagspere, Shakespe, Shakespear, Shake-speare, Shakespere, Shakespheare, Shakp, Shakspe〜, Shakspear, Shakspeare, Shak-speare, Shaksper, Shakspere, Shaxberd, Shaxpeare, Shaxper, Shaxpere, Shaxspere, Shexpere

Input a batch of spellings separated by a newline, tab, or comma, with the first spelling being used as the basis of comparison.
Order of output: As input Sort by Levenshtein distance



 綴字間の類似度や相違度の計測は,曖昧検索やスペリングチェックなどの実用的な目的にも応用されている.標準的な綴字がなかった古い英語の研究にも,ときに役立つことがありそうだ.

[ | 固定リンク | 印刷用ページ ]

2018-08-17 Fri

#3399. 綴字の類似度計算機 [cgi][web_service][spelling][shakespeare][levenshtein_distance]

 この2日間の記事「#3397. 後期中英語期の through のワースト綴字」 ([2018-08-15-1]),「#3398. 中英語期の such のワースト綴字」 ([2018-08-16-1]) で,異綴字間の類似性を計算するスクリプトを利用して,throughsuch の様々な綴字を比較した.このスクリプトは,ある程度使い勝手があるかもしれないと思い,より汎用的な形で CGI を組んでみた.
 ところが,スクリプトの内部的な仕様の関係でサーバ上で動かないということが発覚.残念無念.公開しても無意味であることを承知のうえ,以下に置いておこうと思います(せっかく作ったのだし,私自身のローカルPCでは動いているので・・・).すみません.

Input a batch of spellings separated by a newline, tab, or comma, with the first spelling being used as the basis of comparison.
Order of output: As input Sort by similarity



 と,これではあんまりなので,Shakespeare の異綴字を比較した結果を披露しておきます.「#1720. Shakespeare の綴り方」 ([2014-01-11-1]) で挙げた25種類の異綴字 Shakespeare, Schaksp, Shackespeare, Shackespere, Shackspeare, Shackspere, Shagspere, Shakespe, Shakespear, Shake-speare, Shakespere, Shakespheare, Shakp, Shakspe〜, Shakspear, Shakspeare, Shak-speare, Shaksper, Shakspere, Shaxberd, Shaxpeare, Shaxper, Shaxpere, Shaxspere, Shexpere を入力して,ソートさせると,次のような出力が得られた.

SimilaritySpellings
1.0000Shakespeare
0.9565Shackespeare, Shake-speare, Shakespheare
0.9524Shakespear, Shakespere, Shakspeare
0.9091Shackespere, Shackspeare, Shak-speare
0.9000Shakspear, Shakspere
0.8571Shackspere
0.8421Shakespe, Shaksper
0.8000Shagspere, Shaxpeare, Shaxspere
0.7368Shaxpere, Shexpere
0.7000Shakspe〜
0.6667Schaksp, Shaxper
0.6250Shakp
0.5263Shaxberd


 類似度が0.7以下のものは,およそ省略である.0.7を超えるものは,およそ許せるように感じられるのがおもしろい.

Referrer (Inside): [2018-08-24-1]

[ | 固定リンク | 印刷用ページ ]

2018-08-16 Thu

#3398. 中英語期の such のワースト綴字 [spelling][eme][lme][me_dialect][levenshtein_distance]

 昨日の記事「#3397. 後期中英語期の through のワースト綴字」 ([2018-08-15-1]) に引き続き,今回は such の異綴字について.「#2520. 後期中英語の134種類の "such" の異綴字」 ([2016-03-21-1]),「#2521. 初期中英語の113種類の "such" の異綴字」 ([2016-03-22-1]) で見たように,私の調べた限り,中英語全体では such を表記する異綴字が212種類ほど確認される.そのうちの208種について,昨日と同じ方法で現代標準綴字の such にどれだけ類似しているかを計算し,似ている順に列挙してみた.

SimilaritySpellings
1.0000such
0.8889sƿuch, shuch, succh, suche, sucht, suech, suich, sulch, suuch, suych, swuch
0.8571suc
0.8000sƿucch, sƿuche, schuch, scuche, shuche, souche, sucche, suchee, suchet, suchte, sueche, suiche, suilch, sulche, sutche, suuche, suuech, suyche, swuche, swulch
0.7500sƿuc, scht, sech, shuc, sich, soch, sueh, suhc, suhe, suic, sulc, suth, suyc, swch, swuh, sych
0.7273sƿucche, sƿuchne, sƿulche, schuche, suecche, suueche, suweche
0.6667hsƿucche, sƿche, sƿich, sƿucches, sƿulc, schch, schuc, schut, seche, shich, shoch, shych, siche, soche, suicchne, suilc, svche, svich, swche, swech, swich, swlch, swulchen, swych, syche, zuich, zuych
0.6154swulchere
0.6000asoche, sƿiche, sƿilch, sƿlche, sƿuilc, sƿulce, schech, schute, scoche, scwche, secche, shiche, shoche, sowche, soyche, sqwych, suilce, sviche, sweche, swhych, swiche, swlche, swyche, zuiche, zuyche
0.5714sec, sic, sug, swc, syc
0.5455aswyche, sƿicche, sƿichne, sƿilche, sƿi~lch, scheche, schiche, schilke, schoche, sewyche, sqwyche, sswiche, swecche, swhiche, swhyche, swichee, swyeche, zuichen
0.5333sucheȝ
0.5000sƿic, sɩͨh, scli, secc, sick, silc, slic, solchere, sulk, swic, swlc, swlchere, swulcere
0.4444sƿilc, sclik, sclyk, suilk, sulke, suylk, swics, swilc
0.4000sƿillc, sclike, sclyke, squike, squilk, squylk, suilke, suwilk, suylke, swilce, swlcne, swulke, swulne
0.3636sƿilcne, suilkin, swhilke
0.3333swisɩͨhe
0.2857sik, sli, slk, sly, syk
0.2500selk, sike, silk, slik, slyk, swil, swlk, swyk, swyl, syge, syke, sylk
0.2222sƿilk, selke, sliik, slike, slilk, slyke, swelk, swilk, swlke, swyke, swylk, sylke
0.2000slieke, slkyke, swilke, swylke, swylle
0.1818sƿillke, swilkee, swilkes


 これによると,歴史的なワースト綴字は sƿillke, swilkee, swilkes の3つということになる.確かに・・・.

Referrer (Inside): [2018-08-24-1] [2018-08-17-1]

[ | 固定リンク | 印刷用ページ ]

2018-08-15 Wed

#3397. 後期中英語期の through のワースト綴字 [spelling][lme][me_dialect][levenshtein_distance]

 「#53. 後期中英語期の through の綴りは515通り」 ([2009-06-20-1]),「#54. through 異綴りベスト10(ワースト10?)」 ([2009-06-21-1]) で紹介したように,後期中英語の through の綴字は,著しくヴァリエーションが豊富である.そこではのべ515通りの綴字を集めたが,ハイフン(語の一部であるもの),イタリック体(省略符号などを展開したもの),上付き文字,大文字小文字の違いの有無を無視すれば,444通りとなる.この444通りの綴字について,現代の標準綴字 through にどれだけ近似しているかを,String::Similarity という Perl のモジュールを用いて計算させてみた.類似性の程度を求めるアルゴリズムは,文字変換の工程数 (Levenshtein edit distance) に基づくものである.完全に一致していれば 1.0000 の値を取り,まったく異なると 0.0000 を示す.では,「似ている」順に列挙しよう.

SimilaritySpellings
1.0000through
0.9333thorough, throughe, throught
0.9231throgh, throug, throuh, thrugh, trough
0.8750thoroughe, thorought
0.8571thorogh, thorouh, thorugh, thourgh, throȝgh, throghe, throght, throwgh, thrughe, thrught
0.8333thogh, throu, thrug, thruh, trogh, trugh
0.8000thoroghe, thoroght, thorouȝh, thorowgh, thorughe, thorught, thourghe, thourght, throȝghe, throghet, throghte, throighe, throuȝht, throuche, throwght, thrughte
0.7692þrough, thorgh, thorou, thoruh, thourh, throȝh, throch, throuȝ, throue, throwg, throwh, thruch, thruth, thrwgh, thrygh, thurgh, thwrgh, troght, trowgh, trughe, trught
0.7500thorowghe, thorowght
0.7273thro
0.7143þorough, þrought, thorȝoh, thorghe, thorght, thorghw, thorgth, thorohe, thorouȝ, thorowg, thorowh, thorrou, thoruȝh, thoruth, thorwgh, thourhe, thourth, thourwg, thowrgh, throȝhe, throcht, throuȝe, throwth, thruȝhe, thrwght, thurgeh, thurghe, thurght, thurgth, thurhgh, trowght, yorough
0.6667þorought, þough, þrogh, þroughte, þrouh, þrugh, thorg, thorghwe, thorh, thoro, thorowth, thorowut, thoru, thour, throȝ, throw, thruȝ, thrue, thuht, thurg, thurghte, thurh, thuro, thuru, torgh, yrogh, yrugh
0.6154þorogh, þorouh, þorugh, þourgh, þroȝgh, þroghe, þrouȝh, þrouhe, þrouht, þrowgh, þurugh, thorȝh, thorch, thoroo, thorow, thorth, thoruȝ, thorue, thorur, thorwh, thourȝ, thoure, thourr, thourw, thowur, throȝe, throȝt, throve, throwȝ, throwe, throwr, thruȝe, thrvoo, thurȝh, thurch, thurge, thurhe, thurow, thurth, torghe, trghug, yhurgh, yorugh, yourgh
0.5714þoroghe, þorouȝh, þorowgh, þorught, þourght, þrouȝth, þrowghe, þurughe, thorowȝ, thorowe, thorrow, thorthe, thourȝe, thourow, thowrow, thrawth, throwȝe, thurȝhg, thurȝth, thurgwe, thurhge, thurowe, thurthe, yhurght, yourghe
0.5455þrou, þruh, thow, thrw, thur, trow, yrou
0.5333þorowghe, þorrughe, thorowȝt
0.5000þorgh, þorou, þorug, þoruh, þourg, þourh, þroȝh, þroth, þrouȝ, þrowh, þurgh, þwrgh, ȝorgh, thorȝ, thorv, thorw, thowe, thowr, threw, thrwe, thurȝ, thurv, thurw, thwrw, trowe, yhorh, yhoru, yhrow, yorgh, yorou, yoruh, yourh, yurgh
0.4615þhorow, þorghȝ, þorghe, þorght, þorguh, þorouȝ, þoroue, þorour, þorowh, þoruȝh, þorugȝ, þoruhg, þoruth, þorwgh, þourȝh, þourgȝ, þourth, þroȝth, þrouȝe, þrouȝt, þurgȝh, þurghȝ, þurghe, þurght, þuruch, dorwgh, dourȝh, drowgȝ, durghe, tþourȝ, thorȝe, thorȝt, thorȝw, thorew, thorwȝ, thorwe, thurȝe, thurȝt, thurew, thurwe, yorghe, yoroue, yorour, yourch, yurghe, yurght
0.4286þorouȝe, þorouȝt, þorouwȝ, þorowth, þrouȝte, thorȝwe, thorewe, thorffe, thorwȝe, thowffe, trowffe
0.4000þro
0.3636ðoru, þorg, þorh, þoro, þoru, þouȝ, þour, þroȝ, þrow, þruȝ, þurg, þurh, þuro, þuru, ȝoru, ȝour, torw, twrw, yorh, yoro, yoru, your, yrow, yruȝ, yurg, yurh, yuru
0.3333þerow, þerue, þhurȝ, þorȝh, þorch, þoreu, þorgȝ, þoroȝ, þorow, þorth, þoruþ, þoruȝ, þorue, þorwh, þouȝt, þourþ, þourȝ, þourt, þourw, þroȝe, þroȝt, þrowþ, þrowȝ, þrowe, þruȝe, þurȝg, þurȝh, þurch, þureh, þurhg, þurht, þurow, þurru, þurth, þuruȝ, þurut, ȝoruȝ, ȝurch, doruȝ, torwe, yoȝou, yorch, yorow, yoruȝ, yourȝ, yourw, yurch, yurhg, yurht, yurth, yurwh
0.3077þorȝhȝ, þorowþ, þorowe, þorrow, þoruȝe, þoruȝt, þorwgȝ, þorwhe, þorwth, þourȝe, þourȝt, þourȝw, þourow, þouruȝ, þourwe, þrorow, þrowȝe, þurȝhg, þurȝth, þurthe, ȝoruȝt, yerowe, yorowe, yurowe, yurthe
0.2857þrorowe
0.2000þor, þur
0.1818þarȝ, þorþ, þorȝ, þore, þorv, þorw, þowr, þurþ, þurȝ, þurf, þurw, ȝorw, ȝowr, dorw, yorȝ, yora, yorw, yowr, yurȝ, yurw
0.1667þerew, þorȝe, þorȝt, þoreȝ, þorew, þorwȝ, þorwe, þowre, þurȝe, þurȝt, þureȝ, þurwȝ, þurwe, dorwe, durwe, yorwe, yowrw, yurȝe
0.1538þorewȝ, þorewe, þorwȝe, þorwtȝ


 これによると,最も through とは似ていない,とんでもない綴字は,þorewȝ, þorewe, þorwȝe, þorwtȝ の4種類ということになる.そんなに似ていないかなあと思ってしまうのは,中英語のとんでもない綴字に見慣れてしまったせいだろうか・・・.ちなみに,現在アメリカ英語で省略綴字として用いられる thru は,後期中英語には,ありそうでなかったようだ.

[ | 固定リンク | 印刷用ページ ]

Powered by WinChalow1.0rc4 based on chalow