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 |
7521
|
aaronmk
|
(echo VegCore; $(sed) -n 's/^<h[2-4][^>]*>(<img [^>]*>)? *<a href="#[^>]*>(([a-z]|[A-Z]{2})[^<]*)<\/a>.*<a href="#[^"-]+".*$$/\2/p'\
|
31 |
7480
|
aaronmk
|
|sort -u) <$< >$@
|
32 |
6845
|
aaronmk
|
|
33 |
7484
|
aaronmk
|
$(thesaurus): VegCore.htm
|
34 |
7486
|
aaronmk
|
(echo "Veg+,VegCore"; $(bin)/redmine_synonyms|grep -vE '^\??[A-Z][a-z]';\
|
35 |
|
|
true) <$< >$@ # true: ignore errors if grep found no match
|
36 |
7471
|
aaronmk
|
# Canonicalize alternatives of ambiguous terms using unambiguous mappings
|
37 |
7484
|
aaronmk
|
$(bin)/in_place $@ $(bin)/translate 1 <(grep -vE '^\?' $(thesaurus))
|
38 |
7471
|
aaronmk
|
$(bin)/in_place $@ $(bin)/collapse_multimap
|
39 |
|
|
# Replace ambiguous terms with alternatives lists
|
40 |
7484
|
aaronmk
|
$(bin)/in_place $@ $(bin)/translate 1 $(thesaurus)
|
41 |
7481
|
aaronmk
|
$(bin)/in_place $@ $(bin)/sort 0 1
|
42 |
7432
|
aaronmk
|
|
43 |
6849
|
aaronmk
|
VegCore.tables.csv: VegCore.htm
|
44 |
7438
|
aaronmk
|
<$< $(sed) -n 's/^.*<h1 *><a href="#[^>]+>([^?<][^<]*).*$$/\1/p' >$@
|
45 |
6849
|
aaronmk
|
|
46 |
6851
|
aaronmk
|
VegCore.tables.redmine: VegCore.tables.csv
|
47 |
|
|
$(sed) -n 's/^.*$$/[[VegCore#&|&]]/p' <$< >$@
|
48 |
|
|
|
49 |
5045
|
aaronmk
|
# This tracks VegCore terms that are mapped to VegBIEN but not documented in
|
50 |
7483
|
aaronmk
|
# $(vocab). This file is *not* svn:ignored, so it will show up with a ? when
|
51 |
5045
|
aaronmk
|
# the user runs `svn st` if there are any unsourced terms.
|
52 |
7483
|
aaronmk
|
VegCore-VegBIEN.unsourced_terms.csv: VegCore-VegBIEN.csv $(vocab)
|
53 |
5045
|
aaronmk
|
$(bin)/filter_out_ci 0 <$+ >$@
|
54 |
|
|
$(bin)/autoremove $@
|
55 |
|
|
|
56 |
895
|
aaronmk
|
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
|
57 |
3967
|
aaronmk
|
|
58 |
7484
|
aaronmk
|
.VegX-VegCore.csv.last_cleanup: .%.last_cleanup: % $(thesaurus)
|
59 |
|
|
$(bin)/in_place $< $(bin)/translate_ci 1 $(thesaurus)
|
60 |
7460
|
aaronmk
|
$(bin)/in_place $< $(bin)/sort 0 1
|
61 |
6597
|
aaronmk
|
touch $@
|
62 |
|
|
.PRECIOUS: .VegX-VegCore.csv.last_cleanup
|
63 |
|
|
|
64 |
7484
|
aaronmk
|
.VegCore-VegBIEN.csv.last_cleanup: .%.last_cleanup: % $(thesaurus) $(vocab)
|
65 |
|
|
$(bin)/in_place $< $(bin)/translate_ci 0 $(thesaurus)
|
66 |
5065
|
aaronmk
|
$(bin)/in_place $< $(bin)/canon 0 $(vocab)
|
67 |
1132
|
aaronmk
|
$(bin)/in_place $< $(bin)/sort_map
|
68 |
895
|
aaronmk
|
touch $@
|
69 |
4692
|
aaronmk
|
$(bin)/review 1 <$< >for_review/$<
|
70 |
5045
|
aaronmk
|
$(MAKE) VegCore-VegBIEN.unsourced_terms.csv
|
71 |
5253
|
aaronmk
|
.PRECIOUS: .VegCore-VegBIEN.csv.last_cleanup
|
72 |
3967
|
aaronmk
|
|
73 |
895
|
aaronmk
|
else
|
74 |
1824
|
aaronmk
|
$(inputCoreMaps): _always
|
75 |
895
|
aaronmk
|
$(MAKE) $(@:%=.%.last_cleanup)
|
76 |
5254
|
aaronmk
|
.PRECIOUS: $(inputCoreMaps)
|
77 |
895
|
aaronmk
|
endif
|