辞書データのインポート (1)
辞書データのフォーマットを解析する方法。
正規表現 (Regular Expression)を使う。Objective-Cには正規表現のクラスが用意されていない。以下のサードパーティー製のライブラリのいずれかを使う必要がある。
1. AGRegex, <http://sourceforge.net/projects/agkit/>
2. MOKit, <http://mokit.sourceforge.net/>
3. OmniFoundation, <http://www.omnigroup.com/developer/sourcecode/>
4. PCRE <http://www.pcre.org>
この中でも特に一般的な正規表現の使い方に近いPCRE (Perl Compatible Regular Expressions) を利用することにした。
PCREのインストール
インストール
./configure –enable-utf8
make
sudo make install
使うときには
regexec([str UTF8String]. …)
と思いきや… Cocoa上では異様に動作が重い。つかいかたがおかしいのか… 1時間ほど試行錯誤したが、理由がまったくわからないため、Cocoaから直接正規表現を使うことはあきらめる。
以前のポストでも書いた、Pythonの正規表現をつかって、辞書データをCSVファイルに書き換え、それをCocoaから呼ぶことにした。
Project Phonethica
Combining scientific technology and art, Phonethica is an interdisciplinary project which explores the diversity of the world, through the phonetics of its 6,000 languages.
Search
Archives
- November 2007
- September 2007
- August 2007
- April 2007
- March 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
- October 2005
- September 2005
- August 2005
- July 2005
- June 2005
- May 2005
No Responses to “辞書データのインポート (1)”
Please Wait
Leave a Reply