Project

General

Profile

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