0

http://code.google.com/p/quickdic-dictionary/から辞書ファイルをダウンロードしましたが 、ファイル拡張子は.quickdicであり、プレーンテキストではありません。

簡単な単語クエリを作成するために、quickdic辞書(.quickdic)をc#にロードするにはどうすればよいですか?

4

1 に答える 1

4

gitコードを閲覧したところ、いくつかの問題が発生しました。

まず、DictionaryActivity.javaファイルでは、onCreate()に次のものがあります。

    final String name = application.getDictionaryName(dictFile.getName());
    this.setTitle("QuickDic: " + name);
    dictRaf = new RandomAccessFile(dictFile, "r");
    dictionary = new Dictionary(dictRaf);

そのディクショナリクラスはJavaの組み込みクラスではありませんが、インポートによるとここにあります。

    import com.hughes.android.dictionary.engine.Dictionary;

そこを見ると、RandomAccessFileをパラメーターとして使用する辞書のコンストラクターが表示されます。そのソースコードは次のとおりです。

public Dictionary(final RandomAccessFile raf) throws IOException {
dictFileVersion = raf.readInt();
if (dictFileVersion < 0 || dictFileVersion > CURRENT_DICT_VERSION) {
  throw new IOException("Invalid dictionary version: " + dictFileVersion);
}
creationMillis = raf.readLong();
dictInfo = raf.readUTF();

// Load the sources, then seek past them, because reading them later disrupts the offset.
try {
  final RAFList<EntrySource> rafSources = RAFList.create(raf, new EntrySource.Serializer(this), raf.getFilePointer());
  sources = new ArrayList<EntrySource>(rafSources);
  raf.seek(rafSources.getEndOffset());

  pairEntries = CachingList.create(RAFList.create(raf, new PairEntry.Serializer(this), raf.getFilePointer()), CACHE_SIZE);
  textEntries = CachingList.create(RAFList.create(raf, new TextEntry.Serializer(this), raf.getFilePointer()), CACHE_SIZE);
  if (dictFileVersion >= 5) {
    htmlEntries = CachingList.create(RAFList.create(raf, new HtmlEntry.Serializer(this), raf.getFilePointer()), CACHE_SIZE);
  } else {
    htmlEntries = Collections.emptyList();
  }
  indices = CachingList.createFullyCached(RAFList.create(raf, indexSerializer, raf.getFilePointer()));
} catch (RuntimeException e) {
  final IOException ioe = new IOException("RuntimeException loading dictionary");
  ioe.initCause(e);
  throw ioe;
}
final String end = raf.readUTF(); 
if (!end.equals(END_OF_DICTIONARY)) {
  throw new IOException("Dictionary seems corrupt: " + end);
}

とにかく、これは彼のJavaコードがでファイルを読み取る方法です。

うまくいけば、これはC#でこれをシミュレートするのに役立ちます。

ここから、彼がEntrySource、PairEntry、TextEntry、HtmlEntry、およびindexSerializerをどのようにシリアル化しているかを確認したいと思うでしょう。

次に、RAFList.create()がどのように機能するかを確認します。

次に、CachingList.create()を使用してCachingListを作成する際にその結果がどのように組み込まれるかを確認します。

免責事項:C#に組み込まれているシリアライザーがJavaと同じ形式を使用しているかどうかはわかりません。そのため、それもシミュレートする必要があります:)

于 2012-09-11T16:45:26.730 に答える