From b0262a809be2f9fa46f236ba0f3260da4034fb88 Mon Sep 17 00:00:00 2001 From: mh-northlander Date: Tue, 3 Sep 2024 18:15:34 +0900 Subject: [PATCH 1/2] add benchmark scripts --- benchmark/.gitignore | 1 + benchmark/README.md | 73 +++++++++++ benchmark/benchmark_multithread.sh | 39 ++++++ benchmark/benchmark_run.sh | 34 +++++ benchmark/benchmark_setup.sh | 62 +++++++++ benchmark/commoncrawl.sh | 36 +++++ benchmark/jawikipedia.sh | 36 +++++ benchmark/kyoto-leads-corpus.sh | 18 +++ benchmark/process_warc.py | 53 ++++++++ .../benchmark/TokenizeMultiThread.java | 123 ++++++++++++++++++ 10 files changed, 475 insertions(+) create mode 100644 benchmark/.gitignore create mode 100644 benchmark/README.md create mode 100755 benchmark/benchmark_multithread.sh create mode 100755 benchmark/benchmark_run.sh create mode 100755 benchmark/benchmark_setup.sh create mode 100755 benchmark/commoncrawl.sh create mode 100755 benchmark/jawikipedia.sh create mode 100755 benchmark/kyoto-leads-corpus.sh create mode 100644 benchmark/process_warc.py create mode 100644 benchmark/src/com/worksap/nlp/sudachi/benchmark/TokenizeMultiThread.java diff --git a/benchmark/.gitignore b/benchmark/.gitignore new file mode 100644 index 00000000..8fce6030 --- /dev/null +++ b/benchmark/.gitignore @@ -0,0 +1 @@ +data/ diff --git a/benchmark/README.md b/benchmark/README.md new file mode 100644 index 00000000..bbbe7779 --- /dev/null +++ b/benchmark/README.md @@ -0,0 +1,73 @@ +# Sudachi Benchmark + +Sudachi に大規模なテキストを解析させ、実行速度の計測やバグの検出を行う。 + +## Base Scripts + +### benchmark_setup.sh + +Sudachi のビルドおよび Sudachi 辞書のビルドを行う。 + +- ビルドした `sudachi-executable-[VERSION].zip` を `../build/distributions/sudachi/` 以下に展開する +- `data/` 以下に `system_small.dic`, `system_core.dic`, `system_full.dic` をビルドする + - `data/dictdata/` 以下にダウンロードした Sudachi 辞書データを格納する + +command: `benchmark_setup.sh [dict_version]` + +- `dict_version`: Sudachi 辞書バージョン (default "20240716") + +### benchmark_run.sh + +指定のテキストファイルを各辞書タイプ・分割単位で解析する。 +解析結果は `/dev/null` に出力、対象ファイルや開始/終了時刻情報を `data/benchmark.log` に追記する。 + +command: `benchmark_run.sh corpus_file` + +- `corpus_file`: 解析対象とするテキストファイル + +### benchmark_multithread.sh + +指定のテキストファイルを解析するスレッドを複数同時に実行する。 +解析結果は `/dev/null` に出力、対象ファイルや開始/終了時刻情報を `data/benchmark.log` に追記する。 + +command: `benchmark_multithread.sh corpus_file [num_thread [dict_type]]` + +- `corpus_file`: 解析対象とするテキストファイル +- `num_thread`: 作成するスレッド数 (default 3) +- `dict_type`: 使用する辞書タイプ (default "small") + +## Scripts + +### kyoto-leads-corpus.sh + +[Kyoto University Web Document Leads Corpus](https://github.com/ku-nlp/KWDLC) を取得し、setup および run を実行する。 + +command: `kyoto-leads-corpus.sh` + +### jawikipedia.sh + +[Wikipedia 日本語版ダンプデータ](https://ja.wikipedia.org/wiki/Wikipedia:%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89)を取得し、setup および run を実行する。 +サイズが非常に大きいため、先頭から指定サイズのみを対象とする。 + +- `data/jawiki_[DUMP_DATE]/` 以下にデータを格納する。 + +command: `jawikipedia.sh [dump_date [size]]` + +- `dump_date`: ダンプデータの生成日時 (default "20240801") +- `size`: 使用するテキストのサイズ (default 100M) + +### commoncrawl.sh + +[CommonCrawl](https://commoncrawl.org/get-started) データを取得し、setup および run を実行する。 +サイズが非常に大きいため、指定数のページのみを対象とする。 + +非日本語のサンプルとして利用するため、言語判別は行わず、また HTML を抽出して使用する。 + +- `data/cc[CRAWL_DATE]/` 以下にデータを格納する。 + +command: `commoncrawl.sh [crawl_date [file_index [num_records]]]` + +- `crawl_date`: クロールデータの生成日時 (CC-MAIN-\*, default "2024-33") +- `file_index`: 使用する WARC ファイルの warc.paths ファイル中の行数 (default 1) +- `num_records`: 使用するレコード数(対象 WARC の先頭から取得) (default 1000) + - 2024-33 では 1000 レコードでおよそ 50M diff --git a/benchmark/benchmark_multithread.sh b/benchmark/benchmark_multithread.sh new file mode 100755 index 00000000..8dced07e --- /dev/null +++ b/benchmark/benchmark_multithread.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Analyze given file n-times in multithread. +# assume `benchmark_setup.sh` is called beforehand. + +set -eux +DIR=$(dirname "$(readlink -f "$0")") +cd "${DIR}/.." + +SUDACHI_VERSION=$(./gradlew properties --console=plain -q | grep "^version:" | awk '{printf $2}') + +CORPUS_FILE=$1 +NUM_THREAD=${2:-3} +DICT_TYPE=${3:-"small"} + +# Build code +BUILD_DIR="$DIR/../build/distributions" +JAR_FILE="$BUILD_DIR/sudachi/sudachi-${SUDACHI_VERSION}.jar" +SRC_ROOT="${DIR}/src" +SRC_DIR="${SRC_ROOT}/com/worksap/nlp/sudachi/benchmark" +SRC_NAME="TokenizeMultiThread" + +if [ ! -e "${SRC_DIR}/${SRC_NAME}.class" ]; then + javac -cp ${JAR_FILE} ${SRC_DIR}/${SRC_NAME}.java +fi + +# Run +cd ${DIR} +DATA_DIR=$DIR/data +LOGFILE="$DATA_DIR/benchmark.log" + +echo "$(date), $SUDACHI_VERSION, multithread ${NUM_THREAD}, ${DICT_TYPE}, begin" >> $LOGFILE +echo $(ls -l $CORPUS_FILE) >> $LOGFILE + +java -Dfile.encoding=UTF-8 -cp ${SRC_ROOT}:${JAR_FILE} \ + com.worksap.nlp.sudachi.benchmark.${SRC_NAME} \ + --systemDict ${DIR}/data/system_${DICT_TYPE}.dic \ + -p "$NUM_THREAD" "$CORPUS_FILE" > /dev/null + +echo "$(date), $SUDACHI_VERSION, multithread ${NUM_THREAD}, ${DICT_TYPE}, end" >> $LOGFILE diff --git a/benchmark/benchmark_run.sh b/benchmark/benchmark_run.sh new file mode 100755 index 00000000..142ae47e --- /dev/null +++ b/benchmark/benchmark_run.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Tokenize given file, with each of small/core/full dict and A/B/C mode. + +set -eux +DIR=$(dirname "$(readlink -f "$0")") +cd "${DIR}/.." + +CORPUS_FILE=$1 +TASK=${2:-"benchmark"} + +SUDACHI_VERSION=$(./gradlew properties --console=plain -q | grep "^version:" | awk '{printf $2}') + +# Run benchmark +DATA_DIR=$DIR/data +JAR_DIR="$DIR/../build/distributions/sudachi" +LOGFILE="$DATA_DIR/benchmark.log" + +DICT_TYPES=("small" "core" "full") +SPLIT_MODES=("A" "B" "C") + +echo "" >> $LOGFILE +echo "$(date), $SUDACHI_VERSION, $TASK, begin" >> $LOGFILE +echo $(ls -l $CORPUS_FILE) >> $LOGFILE +for TYPE in ${DICT_TYPES[@]}; do + DICT_FILE="$DATA_DIR/system_${TYPE}.dic" + for MODE in ${SPLIT_MODES[@]}; do + echo "$(date), $TYPE, $MODE, begin" >> $LOGFILE + java -Dfile.encoding=UTF-8 -jar "$JAR_DIR/sudachi-${SUDACHI_VERSION}.jar" \ + --systemDict "$DICT_FILE" -m ${MODE} -a \ + "$CORPUS_FILE" > /dev/null + echo "$(date), $TYPE, $MODE, end" >> $LOGFILE + done +done +echo "$(date), $SUDACHI_VERSION, $TASK, end" >> $LOGFILE diff --git a/benchmark/benchmark_setup.sh b/benchmark/benchmark_setup.sh new file mode 100755 index 00000000..ddee5a63 --- /dev/null +++ b/benchmark/benchmark_setup.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# Build Sudachi and build small/core/full dictionary with it. + +set -eux +DIR=$(dirname "$(readlink -f "$0")") +cd "${DIR}/.." + +SUDACHI_VERSION=$(./gradlew properties --console=plain -q | grep "^version:" | awk '{printf $2}') + +DICT_VERSION=${1:-"20240716"} + +# Build Sudachi +./gradlew build +BUILD_DIR="$DIR/../build/distributions" +JAR_DIR="$BUILD_DIR/sudachi" +if [ -e "$JAR_DIR" ]; then + rm -r "$JAR_DIR" +fi +unzip -d "$JAR_DIR" "$BUILD_DIR/sudachi-executable-$SUDACHI_VERSION.zip" + +# Get dictionary data +DATA_DIR=$DIR/data +DICT_DIR=$DIR/data/dictdata +mkdir -p "$DICT_DIR" + +RAW_DICT_BASEURL="http://sudachi.s3-website-ap-northeast-1.amazonaws.com/sudachidict-raw" + +DICT_FILES=("small_lex" "core_lex" "notcore_lex") +for TYPE in ${DICT_FILES[@]}; do + if [ ! -e "$DICT_DIR/${TYPE}.csv" ]; then + ZIPFILE=${TYPE}.zip + if [ ! -e "$DICT_DIR/$ZIPFILE" ]; then + wget "$RAW_DICT_BASEURL/$DICT_VERSION/$ZIPFILE" -P $DICT_DIR + fi + unzip -d $DICT_DIR $DICT_DIR/$ZIPFILE + fi +done + +MATRIX_FILE="matrix.def" +if [ ! -e "$DICT_DIR/$MATRIX_FILE" ]; then + ZIPFILE=${MATRIX_FILE}.zip + if [ ! -e "$ZIPFILE" ]; then + wget "$RAW_DICT_BASEURL/$ZIPFILE" -P $DICT_DIR + fi + unzip -d $DICT_DIR $DICT_DIR/$ZIPFILE +fi + +# Build dictionary +DICT_TYPES=("small" "core" "full") + +for i in $(seq 0 2); do + TYPE=${DICT_TYPES[$i]} + DICT_FILE="$DATA_DIR/system_${TYPE}.dic" + if [ ! -e "$DICT_FILE" ]; then + FILES=$(for v in ${DICT_FILES[@]:0:$(expr $i+1)}; do echo "$DICT_DIR/${v}.csv"; done) + java -Dfile.encoding=UTF-8 -cp "$JAR_DIR/sudachi-${SUDACHI_VERSION}.jar" \ + com.worksap.nlp.sudachi.dictionary.DictionaryBuilder \ + -o "$DICT_FILE" \ + -m "$DICT_DIR/$MATRIX_FILE" \ + $FILES + fi +done diff --git a/benchmark/commoncrawl.sh b/benchmark/commoncrawl.sh new file mode 100755 index 00000000..af12c3e0 --- /dev/null +++ b/benchmark/commoncrawl.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Run benchmark with CommonCrawl (raw HTML) + +set -eux +DIR=$(dirname "$(readlink -f "$0")") + +CRAWL_DATE=${1:-"2024-33"} +LINE=${2:-"1"} # use n-th file in path file +NUM_RECORDS=${3:-"1000"} # take first n records + +# Download CommonCrawl +DATA_DIR="$DIR/data/cc${CRAWL_DATE}" +mkdir -p "$DATA_DIR" + +CCURL="https://data.commoncrawl.org" +BASEURL="${CCURL}/crawl-data/CC-MAIN-${CRAWL_DATE}" + +PATHFILE="${DATA_DIR}/warc.paths" +if [ ! -e "${PATHFILE}" ]; then + curl -L "${BASEURL}/warc.paths.gz" | gzip -dc > $PATHFILE +fi + +CORPUS_WARC="$DATA_DIR/${LINE}.warc" +FILEURL="${CCURL}/$(head ${PATHFILE} -n ${LINE} | tail -n 1)" +if [ ! -e "${CORPUS_WARC}" ]; then + curl -L "$FILEURL" | gzip -dc > $CORPUS_WARC +fi + +# extract HTML +CORPUS_WARC="$DATA_DIR/${LINE}.warc" +CORPUS_FILE="$DATA_DIR/${LINE}.txt" +python process_warc.py -i ${CORPUS_WARC} -o ${CORPUS_FILE} -n ${NUM_RECORDS} + +# setup & run +$DIR/benchmark_setup.sh +$DIR/benchmark_run.sh $CORPUS_FILE "commoncrawl_${CRAWL_DATE}_${LINE}_${NUM_RECORDS}" diff --git a/benchmark/jawikipedia.sh b/benchmark/jawikipedia.sh new file mode 100755 index 00000000..ae8dd4aa --- /dev/null +++ b/benchmark/jawikipedia.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Run benchmark with Japanese Wikipedia (first 100M articles) + +set -eux +DIR=$(dirname "$(readlink -f "$0")") + +DUMP_DATE=${1:-"20240801"} +SIZE=${2:-"100M"} + +# Download Wikipedia dump (ja) +DATA_DIR=$DIR/data/jawiki_${DUMP_DATE} +mkdir -p "$DATA_DIR" + +## full dump is too large (>15GB), take first split. +BASEURL="https://dumps.wikimedia.org/jawiki/${DUMP_DATE}" +FILEURL="${BASEURL}/jawiki-${DUMP_DATE}-pages-articles1.xml-p1p114794.bz2" +CORPUS_XML="$DATA_DIR/jawiki_${DUMP_DATE}_1.xml" + +if [ ! -e "$CORPUS_XML" ]; then + curl -L $FILEURL | bzip2 -dc > $CORPUS_XML +fi + +# extract +CORPUS_FILE="$DATA_DIR/wiki_00" + +## assume wikiextracutor is installed (https://github.com/attardi/wikiextractor) +if [ ! -e "$CORPUS_FILE" ]; then + python -m wikiextractor.WikiExtractor $CORPUS_XML -o $DATA_DIR -b ${SIZE} + mv $DATA_DIR/AA/* $DATA_DIR + rm -r "$DATA_DIR/AA" +fi + +# setup & run +$DIR/benchmark_setup.sh +$DIR/benchmark_run.sh $CORPUS_FILE "jawiki_${DUMP_DATE}_${SIZE}" + diff --git a/benchmark/kyoto-leads-corpus.sh b/benchmark/kyoto-leads-corpus.sh new file mode 100755 index 00000000..7faf6bdc --- /dev/null +++ b/benchmark/kyoto-leads-corpus.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Run benchmark with Kyoto Leads Corpus + +set -eux +DIR=$(dirname "$(readlink -f "$0")") + +# Download Kyoto Leads corpus original texts +DATA_DIR=$DIR/data +mkdir -p "$DATA_DIR" + +CORPUS_FILE="$DATA_DIR/leads.txt" +if [ ! -e "$CORPUS_FILE" ]; then + curl -L https://github.com/ku-nlp/KWDLC/releases/download/release_1_0/leads.org.txt.gz | gzip -dc > $CORPUS_FILE +fi + +# Setup & run +$DIR/benchmark_setup.sh +$DIR/benchmark_run.sh $CORPUS_FILE "kyoto-leads" diff --git a/benchmark/process_warc.py b/benchmark/process_warc.py new file mode 100644 index 00000000..53881daf --- /dev/null +++ b/benchmark/process_warc.py @@ -0,0 +1,53 @@ +""" +Extract HTML from .warc file. +""" + +import argparse as ap +from pathlib import Path +from tqdm import tqdm + +from warcio.archiveiterator import ArchiveIterator + + +def parse_args() -> ap.Namespace: + parser = ap.ArgumentParser() + parser.add_argument("-i", "--input", type=Path, + help="input warc file") + parser.add_argument("-o", "--output", type=Path, default="output.txt", + help="output text file") + parser.add_argument("-n", "--num-records", type=int, default=None, + help="how many records to dump. dump all if not set.") + + args = parser.parse_args() + return args + + +def main(): + args = parse_args() + + with args.input.open("rb") as fi, args.output.open("wb") as fo: + count = 0 + for record in tqdm(ArchiveIterator(fi)): + if (args.num_records is not None) and (count >= args.num_records): + break + + try: + if record.rec_type != "response": + continue + contenttype = record.http_headers.get_header("Content-Type") + if not contenttype.startswith("text/html"): + continue + + # dump raw html + content = record.content_stream().read() + fo.write(content) + + count += 1 + except: + continue + print(f"count: {count}") + return + + +if __name__ == "__main__": + main() diff --git a/benchmark/src/com/worksap/nlp/sudachi/benchmark/TokenizeMultiThread.java b/benchmark/src/com/worksap/nlp/sudachi/benchmark/TokenizeMultiThread.java new file mode 100644 index 00000000..c2fd6276 --- /dev/null +++ b/benchmark/src/com/worksap/nlp/sudachi/benchmark/TokenizeMultiThread.java @@ -0,0 +1,123 @@ +package com.worksap.nlp.sudachi.benchmark; + +import java.io.BufferedReader; +import java.io.Console; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.io.IOException; +import java.io.PrintStream; +import java.lang.InterruptedException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import com.worksap.nlp.sudachi.Config; +import com.worksap.nlp.sudachi.Dictionary; +import com.worksap.nlp.sudachi.DictionaryFactory; +import com.worksap.nlp.sudachi.MorphemeList; +import com.worksap.nlp.sudachi.Morpheme; +import com.worksap.nlp.sudachi.PathAnchor; +import com.worksap.nlp.sudachi.Settings; +import com.worksap.nlp.sudachi.SudachiCommandLine; +import com.worksap.nlp.sudachi.Tokenizer; + +public class TokenizeMultiThread { + private int numThread; + + private TokenizeMultiThread(int numThread) { + this.numThread = numThread; + } + + static void printUsage() { + Console console = System.console(); + console.printf("usage: TokenizeMultiThread [-p numThread] [--systemDict file] file"); + console.printf("\t-p numThread\thow many threads to create tokenize task\n"); + console.printf("\t--systemDict file\tpath to a system dictionary (overrides everything)\n"); + } + + void tokenize_multithread(PrintStream output, Dictionary dict, String filepath) + throws IOException, InterruptedException { + ExecutorService exs = Executors.newFixedThreadPool(numThread); + for (int i = 0; i < numThread; i++) { + exs.submit(new Task(i, dict.create(), output, filepath)); + } + exs.shutdown(); + + PrintStream err = System.err; + if (!exs.awaitTermination(30, TimeUnit.MINUTES)) { + err.printf("terminate by timeout\n"); + } + } + + class Task implements Callable { + int id; + Tokenizer tok; + PrintStream output; + String filepath; + + Task(int id, Tokenizer tok, PrintStream output, String filepath) { + this.id = id; + this.tok = tok; + this.output = output; + this.filepath = filepath; + } + + @Override + public Void call() throws IOException { + try ( + FileInputStream input = new FileInputStream(filepath); + InputStreamReader inputReader = new InputStreamReader(input, StandardCharsets.UTF_8); + BufferedReader reader = new BufferedReader(inputReader);) { + String line; + while ((line = reader.readLine()) != null) { + MorphemeList ms = tok.tokenize(line); + output.println( + String.join(" ", ms.stream().map(Morpheme::surface).collect(Collectors.toList()))); + } + } + return null; + } + } + + public static void main(String[] args) throws IOException, InterruptedException { + int numThread = 1; + String filepath; + + PathAnchor anchor = PathAnchor.classpath().andThen(PathAnchor.none()); + Config additional = Config.empty(); + Settings current = Settings.resolvedBy(anchor) + .read(SudachiCommandLine.class.getClassLoader().getResource("sudachi.json")); + + int i; + for (i = 0; i < args.length; i++) { + if (args[i].equals("-h")) { + printUsage(); + return; + } else if (args[i].equals("-p") && i + 1 < args.length) { + numThread = Integer.parseInt(args[++i]); + } else if (args[i].equals("--systemDict") && i + 1 < args.length) { + Path resolved = anchor.resolve(args[++i]); + additional = additional.systemDictionary(resolved); + } else { + break; + } + } + if (i >= args.length) { + System.err.println("target text file is required."); + return; + } + filepath = args[i]; + + Config config = additional.withFallback(Config.fromSettings(current)); + + try (Dictionary dict = new DictionaryFactory().create(config)) { + PrintStream output = System.out; + TokenizeMultiThread runner = new TokenizeMultiThread(numThread); + runner.tokenize_multithread(output, dict, filepath); + } + } +} From a816fff05c373ede515f61d6060ecbe8e541ece2 Mon Sep 17 00:00:00 2001 From: mh-northlander Date: Tue, 15 Oct 2024 17:57:03 +0900 Subject: [PATCH 2/2] fix comments --- benchmark/README.md | 11 ++++++++--- benchmark/benchmark_run.sh | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/benchmark/README.md b/benchmark/README.md index bbbe7779..b1a686da 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -27,7 +27,8 @@ command: `benchmark_run.sh corpus_file` ### benchmark_multithread.sh -指定のテキストファイルを解析するスレッドを複数同時に実行する。 +指定のテキストファイルを解析するスレッドを指定数同時に実行する。 +各スレッドは一つの辞書インスタンスから生成した個別のトークナイザーインスタンスを持たせる。 解析結果は `/dev/null` に出力、対象ファイルや開始/終了時刻情報を `data/benchmark.log` に追記する。 command: `benchmark_multithread.sh corpus_file [num_thread [dict_type]]` @@ -36,7 +37,7 @@ command: `benchmark_multithread.sh corpus_file [num_thread [dict_type]]` - `num_thread`: 作成するスレッド数 (default 3) - `dict_type`: 使用する辞書タイプ (default "small") -## Scripts +## Corpus scripts ### kyoto-leads-corpus.sh @@ -44,11 +45,14 @@ command: `benchmark_multithread.sh corpus_file [num_thread [dict_type]]` command: `kyoto-leads-corpus.sh` +- 引数なし + ### jawikipedia.sh [Wikipedia 日本語版ダンプデータ](https://ja.wikipedia.org/wiki/Wikipedia:%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89)を取得し、setup および run を実行する。 サイズが非常に大きいため、先頭から指定サイズのみを対象とする。 +- 事前に [wikiextracutor](https://github.com/attardi/wikiextractor) のインストールが必要 - `data/jawiki_[DUMP_DATE]/` 以下にデータを格納する。 command: `jawikipedia.sh [dump_date [size]]` @@ -63,6 +67,7 @@ command: `jawikipedia.sh [dump_date [size]]` 非日本語のサンプルとして利用するため、言語判別は行わず、また HTML を抽出して使用する。 +- 事前に python および [warcio](https://pypi.org/project/warcio/) のインストールが必要 - `data/cc[CRAWL_DATE]/` 以下にデータを格納する。 command: `commoncrawl.sh [crawl_date [file_index [num_records]]]` @@ -70,4 +75,4 @@ command: `commoncrawl.sh [crawl_date [file_index [num_records]]]` - `crawl_date`: クロールデータの生成日時 (CC-MAIN-\*, default "2024-33") - `file_index`: 使用する WARC ファイルの warc.paths ファイル中の行数 (default 1) - `num_records`: 使用するレコード数(対象 WARC の先頭から取得) (default 1000) - - 2024-33 では 1000 レコードでおよそ 50M + - 目安として、2024-33 では 1000 レコードでおよそ 50M diff --git a/benchmark/benchmark_run.sh b/benchmark/benchmark_run.sh index 142ae47e..1475d2bd 100755 --- a/benchmark/benchmark_run.sh +++ b/benchmark/benchmark_run.sh @@ -1,5 +1,6 @@ #!/bin/bash # Tokenize given file, with each of small/core/full dict and A/B/C mode. +# assume `benchmark_setup.sh` is called beforehand. set -eux DIR=$(dirname "$(readlink -f "$0")")