Now, let me back up just for a minute and talk about software engineering in general
rather than talking about specific AI techniques.
What I'm showing here is a small excerpt from the spelling correction code
from a project called Htdig, which is an open-source search engine. It's a great search engine.
If you ever have need of one, you might want to check it out.
All the code is very straightforward and easy to deal with.
It has several thousand lines of code dealing with spelling correction.
Here we see a little bit of code.
It has the good idea of saying one word might be misspelled for another if they sound alike,
and so let's go through each word and figure out what each letter is sounding like
and see if there are other words that sound similar.
So for example, here it's saying what does a "c" sound like.
Well, "c" is ambiguous in English.
It has this "x" sound, the "ch" sound, this "s" or "k" sound,
and there's all these possibilities about how it can have one sound or another.
Now imagine you're in charge of maintaining this program.
In order for you to make sure that it's right you have to do several things.
First, you could look at this comment and say, well, does this comment
accurately reflect the rules for English pronunciation?
Here, it's talking about pronouncing a "c" as an "s" in the context of an "i," "e," or "y."
What about the other vowels--"a" and "o?"
Were they left out by accident or is this correct?
So you'd have to do some work to check that out.
Then you'd have to do more work to say if this comment correct,
is the comment correctly implemented in this code here?
In fact, just this sort of one page of code just dealing with a couple letters
is about the same as all the code that we use to implement the probabilistic model.
But I think the most important difficulty in maintaining code like this
is that it's so specific to the English language.
Imagine you're in charge of maintaining it, and you're boss or professor comes to you and says,
"Great job. Now I'd like you to make this work for
German and French and Azerbaijani and 50 other languages."
You'd have to go through and understand the pronunciation rules in each of those languages
and edit a version of this code for each particular language.
That would be quite tedious.
But if you were dealing with a probabilistic model
and you were asked to work in another language,
all you would have to do is go out and collect a large corpus of words in that language.
Then you'd have the probability of the individuals words.
And then find a corpus of spelling errors.
Then you'd have the probability of the spelling edits.
And so gathering that data is much faster, much easier software engineering process
than writing this code by hand.
In sense, you could say that machine learning over probabilistic models
is the ultimate in agile programming.
ここで少し補足する意味で
人工知能の技術に特化せず
一般的なソフトウエア工学について話します
こちらはスペル修正のプログラムコードを
一部抜粋したものです
とても優秀なオープンソースの検索エンジン
ht://Digのプロジェクトで使われました
検索エンジンが必要ならぜひ試してみてください
コードはすべて簡潔で扱いやすくなっています
スペル修正に関係するコードは数千行に及びます
こちらがそのコードの一部です
発音が似ている単語にスペルミスが
起こりやすいことに着目し
それぞれの単語を調べ
文字の発音を見ていきましょう
そして発音が類似する単語を探してみます
例えばここにはcがどんな発音か書かれています
英語ではcはあいまいな文字です
ここにはx、ch、s、kといったcの発音も含め
すべての可能な発音と現れ方が書かれています
では自分がこのプログラムを管理しているとします
正しい判断をするために実行すべきことがあります
まずはこのコードの記述を見て
英語の発音規則に準拠しているか
疑問を持ちましょう
ここにはi、eまたはyを含む文脈において
cはsのように発音すると書かれています
aとoなどの他の母音は?
偶然に抜けてしまったのでしょうか?
確認するための作業が必要です
ここにある記述が正しいと判断するには
このコードで正確に実装できるか
調べる必要があります
実際1ページのコードに
いくつかの文字についての記述があり
確率モデルの実装に使われるコードと
同じようなものになっています
こうしたコードを整理する上で
最も重要で困難な点は
これが英語特有のものであるということです
皆さんがこのプログラムの管理者で
上司や教授にこう言われるとします
“よくできたプログラムだが君にはこれを”
“ドイツ語、フランス語、アゼルバイジャン語など
50の言語に対応させてほしい”
この場合それぞれの言語の発音規則を調査し
理解する必要があり
言語に合わせてコードを編集しなければなりません
途方もない作業です
しかし確率モデルを扱うことができるなら
他言語の作業を依頼されても
その言語の単語のコーパスを
たくさん集めればいいのです
そこから各単語の確率を得ることができ
スペルエラーのコーパスを見つけられるでしょう
またスペル編集の確率も求められます
データ収集は手でコードを書くより速くて簡単な
ソフトウエア工学のプロセスなのです
ある意味確率モデルを使った機械学習は
究極のアジャイル・プログラミングなのです