Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ライブラリ API 概要

wicket クレートは、Wikipedia XML ダンプファイルからプレーンテキストを抽出する Rust API を提供します。

インストール

[dependencies]
wicket = "0.1.0"

モジュール一覧

モジュール主な型用途
wicket::dumpArticle, DumpReader, open_dump()ストリーミング XML ダンプパース
wicket::cleanerclean_wikitext()Wikitext → プレーンテキスト変換
wicket::extractorOutputFormat, format_page(), make_url()出力フォーマット
wicket::outputOutputConfig, OutputSplitterファイル分割とローテーション
wicket::errorErrorエラー型定義

使用例

use wicket::{open_dump, clean_wikitext, format_page, make_url, OutputFormat};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let reader = open_dump("dump.xml.bz2".as_ref(), &[0])?;
    let url_base = reader.url_base().to_string();

    for result in reader {
        let article = result?;
        let text = clean_wikitext(&article.text);
        let url = make_url(&url_base, &article.title);
        let output = format_page(
            article.id, &article.title, &url, &text, OutputFormat::Doc,
        );
        print!("{}", output);
    }

    Ok(())
}

API ドキュメント

完全な API ドキュメントは docs.rs/wicket で参照できます。