-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
140 lines (114 loc) · 3.47 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
## makefile automates the build and deployment for python projects
## Build system
#
PROJ_TYPE = python
PROJ_MODULES = git python-resources python-cli python-doc python-doc-deploy markdown
INFO_TARGETS += appinfo
PY_DEP_POST_DEPS += modeldeps
## Project build
#
# additional cleanup
ADD_CLEAN += amr-bank-struct-v3.0-scored.csv \
corpus/amr-bank-struct-v3.0-parsed.txt
ADD_CLEAN_ALL += amr_graph models
CLEAN_DEPS += cleanexample
CLEAN_ALL_DEPS += cleanalldep
# file, models and entry point
MODEL_CONF_DIR = train-config
MODEL_FILE = corpus/amr-bank-struct-v3.0.txt
EVAL_FILE = target/corp/stage/dev/dev.txt
ABIN = ./amr
INF_CONF = resources/model/inference.conf
## Project data
#
# text to parse for run examples
TEST_TEXT = "Barack Obama is an American politician who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, he was the first African-American president of the United States."
## Includes
#
include ./zenbuild/main.mk
## Targets
#
.PHONY: appinfo
appinfo:
@echo "app-resources-dir: $(RESOURCES_DIR)"
# download [spacy models](https://spacy.io/models/en)
.PHONY: modeldeps
modeldeps:
$(PIP_BIN) install $(PIP_ARGS) -r $(PY_SRC)/requirements-model.txt
# requirements for scoring (i.e. WLK)
.PHONY: scoredeps
scoredeps:
$(PIP_BIN) install $(PIP_ARGS) -r $(PY_SRC)/requirements-score.txt
# test parsing text
.PHONY: testparse
testparse:
@echo "testing parse..."
@$(ABIN) parse $(TEST_TEXT) | \
diff - test-resources/inttest-should/parse.txt || \
exit 1
# test plotting text
.PHONY: testplot
testplot:
@echo "testing plots..."
@$(ABIN) plot $(TEST_TEXT)
@if [ ! `ls -l amr_graph/barack*/*.pdf | wc -l` -eq 2 ] ; then \
echo "error: missing plot PDF files" ; \
fi
@if [ ! `ls -l amr_graph/barack*/*.txt | wc -l` -eq 3 ] ; then \
echo "error: missing AMR text output files" ; \
fi
# run all examples
.PHONY: testexample
testexample:
@echo "testing examples..."
@( for i in example/*.py ; \
do PYTHONPATH=src/python ./$$i ; \
done ) | \
diff - test-resources/inttest-should/examples.txt || \
exit 1
# unit and integration testing
.PHONY: testall
testall: test testparse testplot testexample
# generate AMR plots of the little prince and the biomedical corpora
.PHONY: renderexamples
renderexamples:
$(ABIN) plotfile $(MODEL_FILE)
# train on the little prince corpus
.PHONY: trainmodel
trainmodel:
$(ABIN) --config $(MODEL_CONF_DIR)/parse-spring.conf \
train
# inference a new trained model
.PHONY: testmodel
testmodel:
$(ABIN) --config $(INF_CONF) parse $(TEST_TEXT)
# evaluation model "EVAL_MODEL"
.PHONY: evalmodel
evalmodel:
$(ABIN) prep
$(ABIN) parsefile $(EVAL_FILE) --config $(INF_CONF) \
--limit 50 \
--override amr_default.parse_model=$(EVAL_MODEL)
$(ABIN) score $(EVAL_FILE) --config $(INF_CONF) \
--override amr_default.parse_model=$(EVAL_MODEL)
# evaluate the corpus on the trained little prince corpus (test)
.PHONY: evalspring
evalspring:
make EVAL_MODEL=zsl_spring evalmodel
# stop any training
.PHONY: stop
stop:
ps -eaf | grep python | grep $(ABIN) | \
awk '{print $2}' | xargs kill
# additional clean up using the harness/API (data dir)
.PHONY: cleanalldep
cleanalldep:
rm -fr data
# clean data generated by examples
.PHONY: cleanexample
cleanexample: pycleancache
rm -fr example/data
# remove the ./data and ./corpus dir
.PHONY: vaporize
vaporize: cleanall
rm -rf corpus