blob: 8f6ea6036a275b4967408de7884e0d1d59060ff3 [file] [log] [blame]
Marc Kupietz1a422662024-03-16 09:34:10 +01001SRC_DIR ?= test/resources/DNB
2BUILD_DIR = build
3TARGET_DIR ?= target
Marc Kupietzb7696992024-03-18 17:41:15 +01004DEPLOY_HOST ?= compute.ids-mannheim.de
5DEPLOY_USER ?= korap
6DEPLOY_PATH ?= /export/netapp/korap4dnb
Marc Kupietz48c6a682024-03-24 15:27:08 +01007MAX_THREADS ?= $(shell nproc)
Marc Kupietz94bbe6b2024-04-10 20:35:48 +02008YY ?= 18
Marc Kupietz975996e2024-04-13 13:46:37 +02009MAKE ?= make -j $(shell nproc)
Marc Kupietz09619942024-04-15 18:35:09 +020010KORAPXML2CONLLU ?= java -Xmx$(shell $$((1625 * $$(nproc))))m -jar lib/korapxml2conllu.jar
Marc Kupietzf62bc902024-04-14 15:59:44 +020011SAXON ?= java -cp lib/saxon9ee.jar:lib/xml-resolver-1.2.jar net.sf.saxon.Transform -expand:off -catalog:"lib/dtds/xhtml11/xhtmlcatalog.xml;lib/dtds/xhtml/dtd/xhtmlcatalog.xml"
Marc Kupietz1a422662024-03-16 09:34:10 +010012
Marc Kupietz157e0792024-04-13 12:46:42 +020013.PHONY: all clean test i5 i5valid krill index deploy server-log server-status
Marc Kupietz1a422662024-03-16 09:34:10 +010014
Marc Kupietz8ea92282024-03-24 14:55:55 +010015.PRECIOUS: %.zip %.tree_tagger.zip %.ud.zip %.marmot-malt.zip %.spacy.zip %.i5.xml %.tar
Marc Kupietz1a422662024-03-16 09:34:10 +010016
Marc Kupietzb7696992024-03-18 17:41:15 +010017.DELETE_ON_ERROR:
18
Marc Kupietzfeed26a2024-03-17 19:16:23 +010019all: index
Marc Kupietz1a422662024-03-16 09:34:10 +010020
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020021krill: $(TARGET_DIR)/dnb$(YY).krill.tar
22index: $(TARGET_DIR)/dnb$(YY).index.tar.xz
Marc Kupietz3d82f562024-03-16 10:19:03 +010023
Marc Kupietz13c986a2024-04-15 06:47:50 +020024$(TARGET_DIR)/dnb$(YY).i5.xml: $(TARGET_DIR)/dnb$(YY).pre.i5.xml xslt/pass2.xsl xslt/pass3.xsl
Marc Kupietz28f48e12024-04-14 16:17:05 +020025 $(SAXON) -xsl:xslt/pass2.xsl $< | $(SAXON) -xsl:xslt/pass3.xsl - > $@
Marc Kupietzfa445da2024-03-16 10:46:22 +010026
Marc Kupietz28f48e12024-04-14 16:17:05 +020027
28$(TARGET_DIR)/dnb$(YY).pre.i5.xml: $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*.epub))
Marc Kupietzd101e472024-04-14 11:54:34 +020029 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*0.epub)) > $(TARGET_DIR)/filelist$(YY).txt
30 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*1.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
31 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*2.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
32 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*3.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
33 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*4.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
34 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*5.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
35 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*6.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
36 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*7.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
37 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*8.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
38 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*9.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
Marc Kupietz28f48e12024-04-14 16:17:05 +020039 sed -i -e 's/ /\n/g; /^$$/d' $(TARGET_DIR)/filelist$(YY).txt
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020040 head -n -1 xslt/idsCorpus-template.xml | sed -e 's/{YY}/$(YY)/' > $@
Marc Kupietzb926f252024-04-14 08:57:11 +020041 @while IFS= read -r f; do \
42 if head -500 "$$f" | grep -Eq '<pubDate type="year">..$(YY)'; then \
43 cat "$$f" >> $@; \
44 fi; \
45 done < $(TARGET_DIR)/filelist$(YY).txt
Marc Kupietz1a422662024-03-16 09:34:10 +010046 tail -n 1 xslt/idsCorpus-template.xml >> $@
47
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020048test: $(TARGET_DIR)/dnb$(YY).i5.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010049 xmllint --noout --valid $<
50
Marc Kupietz157e0792024-04-13 12:46:42 +020051i5: $(TARGET_DIR)/dnb$(YY).i5.xml
52 xmllint --noout $<
53
54i5valid: $(TARGET_DIR)/dnb$(YY).i5.xml
55 xmllint --noout --valid $<
56
Marc Kupietz1a422662024-03-16 09:34:10 +010057$(BUILD_DIR)/%: $(SRC_DIR)/%.epub
58 mkdir -p $@
59 echo "Converting $< to $@"
60 unzip -q -o $< -d $@
Marc Kupietz51714ed2024-04-13 12:47:39 +020061 chmod -R ug+rwX $@
Marc Kupietz1a422662024-03-16 09:34:10 +010062
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010063$(TARGET_DIR)/%.i5.xml: $(BUILD_DIR)/% xslt/epub2i5.xsl xslt/idsCorpus-template.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010064 mkdir -p $(TARGET_DIR)
65 echo "Converting $< to $@"
Marc Kupietz28f48e12024-04-14 16:17:05 +020066 $(SAXON) -xsl:xslt/epub2i5.xsl $(shell find $< -name "*.opf") > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010067
68%.zip: %.i5.xml
69 tei2korapxml -l warn -s -tk - < $< > $@
70
71%.tree_tagger.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010072 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2treetagger -l german | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010073
74%.spacy.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010075 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2spacy | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010076
Marc Kupietz8ea92282024-03-24 14:55:55 +010077models/de.marmot:
78 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010079 curl -sL -o $@ https://cistern.cis.lmu.de/marmot/models/CURRENT/spmrl/de.marmot
Marc Kupietz8ea92282024-03-24 14:55:55 +010080
81models/german.mco:
82 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010083 curl -sL -o $@ https://corpora.ids-mannheim.de/tools/$@
Marc Kupietz8ea92282024-03-24 14:55:55 +010084
85%.marmot-malt.zip: %.zip models/de.marmot models/german.mco
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020086 $(KORAPXML2CONLLU) -T $(MAX_THREADS) -t marmot:models/de.marmot -P malt:models/german.mco $< | tee $(TARGET_DIR)/dnb$(YY).marmot-malt.conllu | conllu2korapxml > $@
Marc Kupietz8ea92282024-03-24 14:55:55 +010087
Marc Kupietz1a422662024-03-16 09:34:10 +010088%.ud.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010089 $(KORAPXML2CONLLU) $< | pv | ./scripts/udpipe2 | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010090
Marc Kupietz8ea92282024-03-24 14:55:55 +010091%.krill.tar: %.zip %.marmot-malt.zip %.tree_tagger.zip %.spacy.zip
Marc Kupietz87597512024-04-15 18:31:34 +020092 mkdir -p ${BUILD_DIR}/krill/$(basename $@)
Marc Kupietz3d82f562024-03-16 10:19:03 +010093 mkdir -p $(basename $@)
Marc Kupietz87597512024-04-15 18:31:34 +020094 korapxml2krill archive --quiet -w -z -cfg krill-korap4dnb.cfg -c ${BUILD_DIR}/krill/$(basename $@)/korapxml2krill.cache -j $(MAX_THREADS) -te ${BUILD_DIR}/krill/$(basename $@) --non-word-tokens --meta I5 -i $< -i $(word 2,$^) -i $(word 3,$^) -i $(word 4,$^) -o $(basename $@)
Marc Kupietz1a422662024-03-16 09:34:10 +010095
Marc Kupietzfc328622024-03-16 14:31:34 +010096%.json: %.krill.tar
97 rm -rf $@
98 mkdir -p $@
99 for f in $<; do tar -C $@ -xf $$f; done
Marc Kupietz1a422662024-03-16 09:34:10 +0100100
Marc Kupietz22ad4b72024-03-17 16:24:21 +0100101%.index: %.json
102 rm -rf $@
Marc Kupietz012c7082024-03-17 16:40:47 +0100103 java -jar lib/Krill-Indexer.jar -c lib/krill.conf -i $< -o $@
Marc Kupietz22ad4b72024-03-17 16:24:21 +0100104
105%.index.tar.xz: %.index
106 tar -I 'xz -T0' -C $(dir $<) -cf $@ $(notdir $<)
107
Marc Kupietzb7696992024-03-18 17:41:15 +0100108deploy: $(TARGET_DIR)/dnb.index.tar.xz korap4dnb-compose.yml
109 rsync -v $^ $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/
110 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "mkdir -p $(DEPLOY_PATH) && cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f $(notdir $(word 2,$^)) up -d --dry-run && docker compose -p korap4dnb stop && (mv -f dnb.index dnb.index.bak || true) && tar Jxvf $(notdir $<) && docker compose -p korap4dnb --profile=lite -f $(notdir $(word 2,$^)) up -d"
111
112show-server-log:
113 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml logs -f"
114
115show-server-status:
116 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml ps"
117
Marc Kupietz1a422662024-03-16 09:34:10 +0100118clean:
119 rm -rf $(BUILD_DIR) $(TARGET_DIR)
120
Marc Kupietz87597512024-04-15 18:31:34 +0200121alli5: i5
Marc Kupietza5167622024-04-13 14:18:10 +0200122 for yy in $(shell seq -f "%02.f" 95 99) $(shell seq -f "%02.f" 0 24); do \
Marc Kupietz975996e2024-04-13 13:46:37 +0200123 $(MAKE) i5 YY=$$yy; \
124 done
Marc Kupietz87597512024-04-15 18:31:34 +0200125
126allindex: i5
127 for yy in $(shell seq -f "%02.f" 95 99) $(shell seq -f "%02.f" 0 24); do \
128 $(MAKE) index YY=$$yy & \
129 done