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