forked from nytimes/ingredient-phrase-tagger
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
164,630 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
sudo: required | ||
dist: trusty | ||
language: python | ||
python: | ||
- "2.7" | ||
services: docker | ||
script: ./docker_build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/sh | ||
|
||
# Exit build script on first failure | ||
set -e | ||
|
||
# Echo commands to stdout. | ||
set -x | ||
|
||
COUNT_TRAIN=20000 | ||
COUNT_TEST=2000 | ||
|
||
OUTPUT_DIR=$(mktemp -d) | ||
ACTUAL_CRF_TRAINING_FILE="${OUTPUT_DIR}/training_data.crf" | ||
ACTUAL_CRF_TESTING_FILE="${OUTPUT_DIR}/testing_data.crf" | ||
ACTUAL_CRF_MODEL_FILE="${OUTPUT_DIR}/model.crfmodel" | ||
ACTUAL_TESTING_OUTPUT_FILE="${OUTPUT_DIR}/testing_output" | ||
ACTUAL_EVAL_OUTPUT_FILE="${OUTPUT_DIR}/eval_output" | ||
|
||
bin/generate_data \ | ||
--data-path=nyt-ingredients-snapshot-2015.csv \ | ||
--count=$COUNT_TRAIN \ | ||
--offset=0 > "$ACTUAL_CRF_TRAINING_FILE" | ||
bin/generate_data \ | ||
--data-path=nyt-ingredients-snapshot-2015.csv \ | ||
--count=$COUNT_TEST \ | ||
--offset=$COUNT_TRAIN > "$ACTUAL_CRF_TESTING_FILE" | ||
|
||
crf_learn template_file "$ACTUAL_CRF_TRAINING_FILE" "$ACTUAL_CRF_MODEL_FILE" | ||
|
||
crf_test \ | ||
-m "$ACTUAL_CRF_MODEL_FILE" \ | ||
"$ACTUAL_CRF_TESTING_FILE" > "$ACTUAL_TESTING_OUTPUT_FILE" | ||
|
||
python bin/evaluate.py "$ACTUAL_TESTING_OUTPUT_FILE" > "$ACTUAL_EVAL_OUTPUT_FILE" | ||
|
||
# Check against golden output. | ||
GOLDEN_DIR=tests/golden | ||
GOLDEN_CRF_TRAINING_FILE="${GOLDEN_DIR}/training_data.crf" | ||
GOLDEN_CRF_TESTING_FILE="${GOLDEN_DIR}/testing_data.crf" | ||
GOLDEN_TESTING_OUTPUT_FILE="${GOLDEN_DIR}/testing_output" | ||
GOLDEN_EVAL_OUTPUT_FILE="${GOLDEN_DIR}/eval_output" | ||
|
||
diff --context=2 "$GOLDEN_CRF_TRAINING_FILE" "$ACTUAL_CRF_TRAINING_FILE" | ||
diff --context=2 "$GOLDEN_CRF_TESTING_FILE" "$ACTUAL_CRF_TESTING_FILE" | ||
diff --context=2 "$GOLDEN_TESTING_OUTPUT_FILE" "$ACTUAL_TESTING_OUTPUT_FILE" | ||
diff "$GOLDEN_EVAL_OUTPUT_FILE" "$ACTUAL_EVAL_OUTPUT_FILE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
# Exit on first failing command. | ||
set -e | ||
# Echo commands to console. | ||
set -x | ||
|
||
IMAGE_NAME="ingredient-phrase-tagger-image" | ||
CONTAINER_NAME="ingredient-phrase-tagger-container" | ||
|
||
docker build \ | ||
--tag "$IMAGE_NAME" \ | ||
. | ||
|
||
docker run \ | ||
--tty \ | ||
--detach \ | ||
--name "$CONTAINER_NAME" \ | ||
"$IMAGE_NAME" | ||
|
||
docker exec "$CONTAINER_NAME" ./build.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
Sentence-Level Stats: | ||
correct: 1493 | ||
total: 1999 | ||
% correct: 74.6873436718 | ||
|
||
Word-Level Stats: | ||
correct: 10402 | ||
total: 11450 | ||
% correct: 90.8471615721 |
Oops, something went wrong.