1 |
3793
|
aaronmk
|
include ../lib/common.Makefile
|
2 |
|
|
|
3 |
|
|
|
4 |
785
|
aaronmk
|
##### Vars/functions
|
5 |
|
|
|
6 |
7459
|
aaronmk
|
# Make
|
7 |
|
|
SHELL := /bin/bash
|
8 |
|
|
|
9 |
1272
|
aaronmk
|
# Paths
|
10 |
895
|
aaronmk
|
bin := ../bin
|
11 |
7471
|
aaronmk
|
inputCoreMaps := VegCore-VegBIEN.csv VegX-VegCore.csv
|
12 |
7485
|
aaronmk
|
vocab := VegCore.vocab.csv
|
13 |
|
|
thesaurus := VegCore.thesaurus.csv
|
14 |
895
|
aaronmk
|
|
15 |
785
|
aaronmk
|
##### General targets
|
16 |
|
|
|
17 |
7484
|
aaronmk
|
all: _always $(vocab) $(thesaurus) VegCore.tables.redmine $(inputCoreMaps) ;
|
18 |
150
|
aaronmk
|
|
19 |
383
|
aaronmk
|
clean: _always
|
20 |
196
|
aaronmk
|
$(RM) $(all)
|
21 |
188
|
aaronmk
|
|
22 |
924
|
aaronmk
|
all :=
|
23 |
|
|
|
24 |
6845
|
aaronmk
|
##### Core maps
|
25 |
198
|
aaronmk
|
|
26 |
6845
|
aaronmk
|
VegCore.htm:
|
27 |
|
|
php -r 'fpassthru(fopen("https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore", "r"));' >$@
|
28 |
|
|
|
29 |
7483
|
aaronmk
|
$(vocab): VegCore.htm
|
30 |
8233
|
aaronmk
|
(echo VegCore; $(sed) -n 's/^<h[2-4][^>]*>(<del>)?(<img [^>]*>)? *<a href="#[^>]*>(\??([a-z]|[A-Z]{2})[^<]*)<\/a>.*<a href="#[^"-]+".*$$/\3/p') \
|
31 |
7525
|
aaronmk
|
<$< >$@
|
32 |
|
|
$(bin)/in_place $@ $(bin)/sort_ci
|
33 |
6845
|
aaronmk
|
|
34 |
7484
|
aaronmk
|
$(thesaurus): VegCore.htm
|
35 |
7486
|
aaronmk
|
(echo "Veg+,VegCore"; $(bin)/redmine_synonyms|grep -vE '^\??[A-Z][a-z]';\
|
36 |
|
|
true) <$< >$@ # true: ignore errors if grep found no match
|
37 |
7471
|
aaronmk
|
# Canonicalize alternatives of ambiguous terms using unambiguous mappings
|
38 |
7484
|
aaronmk
|
$(bin)/in_place $@ $(bin)/translate 1 <(grep -vE '^\?' $(thesaurus))
|
39 |
7808
|
aaronmk
|
$(bin)/in_place $@ uniq
|
40 |
7471
|
aaronmk
|
$(bin)/in_place $@ $(bin)/collapse_multimap
|
41 |
|
|
# Replace ambiguous terms with alternatives lists
|
42 |
7484
|
aaronmk
|
$(bin)/in_place $@ $(bin)/translate 1 $(thesaurus)
|
43 |
7481
|
aaronmk
|
$(bin)/in_place $@ $(bin)/sort 0 1
|
44 |
7432
|
aaronmk
|
|
45 |
6849
|
aaronmk
|
VegCore.tables.csv: VegCore.htm
|
46 |
7438
|
aaronmk
|
<$< $(sed) -n 's/^.*<h1 *><a href="#[^>]+>([^?<][^<]*).*$$/\1/p' >$@
|
47 |
6849
|
aaronmk
|
|
48 |
6851
|
aaronmk
|
VegCore.tables.redmine: VegCore.tables.csv
|
49 |
|
|
$(sed) -n 's/^.*$$/[[VegCore#&|&]]/p' <$< >$@
|
50 |
|
|
|
51 |
5045
|
aaronmk
|
# This tracks VegCore terms that are mapped to VegBIEN but not documented in
|
52 |
7483
|
aaronmk
|
# $(vocab). This file is *not* svn:ignored, so it will show up with a ? when
|
53 |
5045
|
aaronmk
|
# the user runs `svn st` if there are any unsourced terms.
|
54 |
7483
|
aaronmk
|
VegCore-VegBIEN.unsourced_terms.csv: VegCore-VegBIEN.csv $(vocab)
|
55 |
5045
|
aaronmk
|
$(bin)/filter_out_ci 0 <$+ >$@
|
56 |
|
|
$(bin)/autoremove $@
|
57 |
|
|
|
58 |
895
|
aaronmk
|
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
|
59 |
3967
|
aaronmk
|
|
60 |
7484
|
aaronmk
|
.VegX-VegCore.csv.last_cleanup: .%.last_cleanup: % $(thesaurus)
|
61 |
|
|
$(bin)/in_place $< $(bin)/translate_ci 1 $(thesaurus)
|
62 |
7460
|
aaronmk
|
$(bin)/in_place $< $(bin)/sort 0 1
|
63 |
6597
|
aaronmk
|
touch $@
|
64 |
|
|
.PRECIOUS: .VegX-VegCore.csv.last_cleanup
|
65 |
|
|
|
66 |
7484
|
aaronmk
|
.VegCore-VegBIEN.csv.last_cleanup: .%.last_cleanup: % $(thesaurus) $(vocab)
|
67 |
|
|
$(bin)/in_place $< $(bin)/translate_ci 0 $(thesaurus)
|
68 |
5065
|
aaronmk
|
$(bin)/in_place $< $(bin)/canon 0 $(vocab)
|
69 |
1132
|
aaronmk
|
$(bin)/in_place $< $(bin)/sort_map
|
70 |
895
|
aaronmk
|
touch $@
|
71 |
4692
|
aaronmk
|
$(bin)/review 1 <$< >for_review/$<
|
72 |
5045
|
aaronmk
|
$(MAKE) VegCore-VegBIEN.unsourced_terms.csv
|
73 |
5253
|
aaronmk
|
.PRECIOUS: .VegCore-VegBIEN.csv.last_cleanup
|
74 |
3967
|
aaronmk
|
|
75 |
895
|
aaronmk
|
else
|
76 |
1824
|
aaronmk
|
$(inputCoreMaps): _always
|
77 |
895
|
aaronmk
|
$(MAKE) $(@:%=.%.last_cleanup)
|
78 |
5254
|
aaronmk
|
.PRECIOUS: $(inputCoreMaps)
|
79 |
895
|
aaronmk
|
endif
|