blob: 5d11932550396f09c0c5faf3d06c768b0c666ee7 [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 Kupietz43cbb112024-04-14 07:32:48 +020010KORAPXML2CONLLU ?= java -jar lib/korapxml2conllu.jar
Marc Kupietz2a3e4ee2024-04-14 08:34:12 +020011SAXON ?= java -cp lib/saxon9ee.jar:lib/xml-resolver-1.2.jar net.sf.saxon.Transform -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 Kupietzfa445da2024-03-16 10:46:22 +010024
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020025$(TARGET_DIR)/dnb$(YY).i5.xml: $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*.epub))
Marc Kupietzb926f252024-04-14 08:57:11 +020026 echo "$^" | sed -e 's/ /\n/g' > $(TARGET_DIR)/filelist$(YY).txt
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020027 head -n -1 xslt/idsCorpus-template.xml | sed -e 's/{YY}/$(YY)/' > $@
Marc Kupietzb926f252024-04-14 08:57:11 +020028 @while IFS= read -r f; do \
29 if head -500 "$$f" | grep -Eq '<pubDate type="year">..$(YY)'; then \
30 cat "$$f" >> $@; \
31 fi; \
32 done < $(TARGET_DIR)/filelist$(YY).txt
Marc Kupietz1a422662024-03-16 09:34:10 +010033 tail -n 1 xslt/idsCorpus-template.xml >> $@
34
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020035test: $(TARGET_DIR)/dnb$(YY).i5.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010036 xmllint --noout --valid $<
37
Marc Kupietz157e0792024-04-13 12:46:42 +020038i5: $(TARGET_DIR)/dnb$(YY).i5.xml
39 xmllint --noout $<
40
41i5valid: $(TARGET_DIR)/dnb$(YY).i5.xml
42 xmllint --noout --valid $<
43
Marc Kupietz1a422662024-03-16 09:34:10 +010044$(BUILD_DIR)/%: $(SRC_DIR)/%.epub
45 mkdir -p $@
46 echo "Converting $< to $@"
47 unzip -q -o $< -d $@
Marc Kupietz51714ed2024-04-13 12:47:39 +020048 chmod -R ug+rwX $@
Marc Kupietz1a422662024-03-16 09:34:10 +010049
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010050$(TARGET_DIR)/%.i5.xml: $(BUILD_DIR)/% xslt/epub2i5.xsl xslt/idsCorpus-template.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010051 mkdir -p $(TARGET_DIR)
52 echo "Converting $< to $@"
Marc Kupietz43cbb112024-04-14 07:32:48 +020053 $(SAXON) -xsl:xslt/epub2i5.xsl $(shell find $< -name "*.opf") > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010054
55%.zip: %.i5.xml
56 tei2korapxml -l warn -s -tk - < $< > $@
57
58%.tree_tagger.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010059 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2treetagger -l german | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010060
61%.spacy.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010062 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2spacy | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010063
Marc Kupietz8ea92282024-03-24 14:55:55 +010064models/de.marmot:
65 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010066 curl -sL -o $@ https://cistern.cis.lmu.de/marmot/models/CURRENT/spmrl/de.marmot
Marc Kupietz8ea92282024-03-24 14:55:55 +010067
68models/german.mco:
69 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010070 curl -sL -o $@ https://corpora.ids-mannheim.de/tools/$@
Marc Kupietz8ea92282024-03-24 14:55:55 +010071
72%.marmot-malt.zip: %.zip models/de.marmot models/german.mco
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020073 $(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 +010074
Marc Kupietz1a422662024-03-16 09:34:10 +010075%.ud.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010076 $(KORAPXML2CONLLU) $< | pv | ./scripts/udpipe2 | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010077
Marc Kupietz8ea92282024-03-24 14:55:55 +010078%.krill.tar: %.zip %.marmot-malt.zip %.tree_tagger.zip %.spacy.zip
Marc Kupietz3d82f562024-03-16 10:19:03 +010079 mkdir -p $(basename $@)
Marc Kupietz8ea92282024-03-24 14:55:55 +010080 korapxml2krill archive --quiet -w -z -cfg krill-korap4dnb.cfg --non-word-tokens --meta I5 -i $< -i $(word 2,$^) -i $(word 3,$^) -i $(word 4,$^) -o $(basename $@)
Marc Kupietz1a422662024-03-16 09:34:10 +010081
Marc Kupietzfc328622024-03-16 14:31:34 +010082%.json: %.krill.tar
83 rm -rf $@
84 mkdir -p $@
85 for f in $<; do tar -C $@ -xf $$f; done
Marc Kupietz1a422662024-03-16 09:34:10 +010086
Marc Kupietz22ad4b72024-03-17 16:24:21 +010087%.index: %.json
88 rm -rf $@
Marc Kupietz012c7082024-03-17 16:40:47 +010089 java -jar lib/Krill-Indexer.jar -c lib/krill.conf -i $< -o $@
Marc Kupietz22ad4b72024-03-17 16:24:21 +010090
91%.index.tar.xz: %.index
92 tar -I 'xz -T0' -C $(dir $<) -cf $@ $(notdir $<)
93
Marc Kupietzb7696992024-03-18 17:41:15 +010094deploy: $(TARGET_DIR)/dnb.index.tar.xz korap4dnb-compose.yml
95 rsync -v $^ $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/
96 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"
97
98show-server-log:
99 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml logs -f"
100
101show-server-status:
102 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml ps"
103
Marc Kupietz1a422662024-03-16 09:34:10 +0100104clean:
105 rm -rf $(BUILD_DIR) $(TARGET_DIR)
106
Marc Kupietz975996e2024-04-13 13:46:37 +0200107alli5:
Marc Kupietza5167622024-04-13 14:18:10 +0200108 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 +0200109 $(MAKE) i5 YY=$$yy; \
110 done