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 |
5065
|
aaronmk
|
vocab := VegCore.csv
|
13 |
|
|
dict := Veg+-VegCore.csv
|
14 |
895
|
aaronmk
|
|
15 |
785
|
aaronmk
|
##### General targets
|
16 |
|
|
|
17 |
7471
|
aaronmk
|
all: _always VegCore.csv Veg+-VegCore.csv VegCore.tables.redmine\
|
18 |
|
|
$(inputCoreMaps) ;
|
19 |
150
|
aaronmk
|
|
20 |
383
|
aaronmk
|
clean: _always
|
21 |
196
|
aaronmk
|
$(RM) $(all)
|
22 |
188
|
aaronmk
|
|
23 |
924
|
aaronmk
|
all :=
|
24 |
|
|
|
25 |
6845
|
aaronmk
|
##### Core maps
|
26 |
198
|
aaronmk
|
|
27 |
6845
|
aaronmk
|
VegCore.htm:
|
28 |
|
|
php -r 'fpassthru(fopen("https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore", "r"));' >$@
|
29 |
|
|
|
30 |
7040
|
aaronmk
|
VegCore.csv: VegCore.htm
|
31 |
7472
|
aaronmk
|
(echo VegCore; $(sed) -n 's/^.*<h[2-4][^>]*><a href="#[^>]+>(\??([a-z]|[A-Z]{2})[^<]*).*$$/\1/p')\
|
32 |
7040
|
aaronmk
|
<$< >$@
|
33 |
6845
|
aaronmk
|
|
34 |
7471
|
aaronmk
|
Veg+-VegCore.csv: VegCore.htm
|
35 |
|
|
(echo "Veg+,VegCore"; $(bin)/redmine_synonyms|grep -vE '^\??[A-Z][a-z]')\
|
36 |
|
|
<$< >$@
|
37 |
|
|
# Canonicalize alternatives of ambiguous terms using unambiguous mappings
|
38 |
|
|
$(bin)/in_place $@ $(bin)/translate 1 <(grep -vE '^\?' $(dict))
|
39 |
|
|
$(bin)/in_place $@ $(bin)/collapse_multimap
|
40 |
|
|
# Replace ambiguous terms with alternatives lists
|
41 |
|
|
$(bin)/in_place $@ $(bin)/translate 1 $(dict)
|
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 |
|
|
# VegCore.csv. This file is *not* svn:ignored, so it will show up with a ? when
|
51 |
|
|
# the user runs `svn st` if there are any unsourced terms.
|
52 |
|
|
VegCore-VegBIEN.unsourced_terms.csv: VegCore-VegBIEN.csv VegCore.csv
|
53 |
|
|
$(bin)/filter_out_ci 0 <$+ >$@
|
54 |
|
|
$(bin)/autoremove $@
|
55 |
|
|
|
56 |
895
|
aaronmk
|
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
|
57 |
3967
|
aaronmk
|
|
58 |
6597
|
aaronmk
|
.VegX-VegCore.csv.last_cleanup: .%.last_cleanup: % $(dict)
|
59 |
7435
|
aaronmk
|
$(bin)/in_place $< $(bin)/translate_ci 1 $(dict)
|
60 |
7460
|
aaronmk
|
$(bin)/in_place $< $(bin)/sort 0 1
|
61 |
6597
|
aaronmk
|
touch $@
|
62 |
|
|
.PRECIOUS: .VegX-VegCore.csv.last_cleanup
|
63 |
|
|
|
64 |
5065
|
aaronmk
|
.VegCore-VegBIEN.csv.last_cleanup: .%.last_cleanup: % $(dict) $(vocab)
|
65 |
7435
|
aaronmk
|
$(bin)/in_place $< $(bin)/translate_ci 0 $(dict)
|
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
|