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