blob: 2c174d995c1fea8c9634c42f5097b9684e2145c5 [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))
26 head -n -1 xslt/idsCorpus-template.xml | sed -e 's/{YY}/$(YY)/' > $@
27 for f in $^; do if head -500 $$f | grep -Eq '<pubDate type="year">..$(YY)'; then cat $$f >> $@; fi; done
Marc Kupietz1a422662024-03-16 09:34:10 +010028 tail -n 1 xslt/idsCorpus-template.xml >> $@
29
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020030test: $(TARGET_DIR)/dnb$(YY).i5.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010031 xmllint --noout --valid $<
32
Marc Kupietz157e0792024-04-13 12:46:42 +020033i5: $(TARGET_DIR)/dnb$(YY).i5.xml
34 xmllint --noout $<
35
36i5valid: $(TARGET_DIR)/dnb$(YY).i5.xml
37 xmllint --noout --valid $<
38
Marc Kupietz1a422662024-03-16 09:34:10 +010039$(BUILD_DIR)/%: $(SRC_DIR)/%.epub
40 mkdir -p $@
41 echo "Converting $< to $@"
42 unzip -q -o $< -d $@
Marc Kupietz51714ed2024-04-13 12:47:39 +020043 chmod -R ug+rwX $@
Marc Kupietz1a422662024-03-16 09:34:10 +010044
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010045$(TARGET_DIR)/%.i5.xml: $(BUILD_DIR)/% xslt/epub2i5.xsl xslt/idsCorpus-template.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010046 mkdir -p $(TARGET_DIR)
47 echo "Converting $< to $@"
Marc Kupietz43cbb112024-04-14 07:32:48 +020048 $(SAXON) -xsl:xslt/epub2i5.xsl $(shell find $< -name "*.opf") > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010049
50%.zip: %.i5.xml
51 tei2korapxml -l warn -s -tk - < $< > $@
52
53%.tree_tagger.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010054 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2treetagger -l german | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010055
56%.spacy.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010057 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2spacy | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010058
Marc Kupietz8ea92282024-03-24 14:55:55 +010059models/de.marmot:
60 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010061 curl -sL -o $@ https://cistern.cis.lmu.de/marmot/models/CURRENT/spmrl/de.marmot
Marc Kupietz8ea92282024-03-24 14:55:55 +010062
63models/german.mco:
64 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010065 curl -sL -o $@ https://corpora.ids-mannheim.de/tools/$@
Marc Kupietz8ea92282024-03-24 14:55:55 +010066
67%.marmot-malt.zip: %.zip models/de.marmot models/german.mco
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020068 $(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 +010069
Marc Kupietz1a422662024-03-16 09:34:10 +010070%.ud.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010071 $(KORAPXML2CONLLU) $< | pv | ./scripts/udpipe2 | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010072
Marc Kupietz8ea92282024-03-24 14:55:55 +010073%.krill.tar: %.zip %.marmot-malt.zip %.tree_tagger.zip %.spacy.zip
Marc Kupietz3d82f562024-03-16 10:19:03 +010074 mkdir -p $(basename $@)
Marc Kupietz8ea92282024-03-24 14:55:55 +010075 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 +010076
Marc Kupietzfc328622024-03-16 14:31:34 +010077%.json: %.krill.tar
78 rm -rf $@
79 mkdir -p $@
80 for f in $<; do tar -C $@ -xf $$f; done
Marc Kupietz1a422662024-03-16 09:34:10 +010081
Marc Kupietz22ad4b72024-03-17 16:24:21 +010082%.index: %.json
83 rm -rf $@
Marc Kupietz012c7082024-03-17 16:40:47 +010084 java -jar lib/Krill-Indexer.jar -c lib/krill.conf -i $< -o $@
Marc Kupietz22ad4b72024-03-17 16:24:21 +010085
86%.index.tar.xz: %.index
87 tar -I 'xz -T0' -C $(dir $<) -cf $@ $(notdir $<)
88
Marc Kupietzb7696992024-03-18 17:41:15 +010089deploy: $(TARGET_DIR)/dnb.index.tar.xz korap4dnb-compose.yml
90 rsync -v $^ $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/
91 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"
92
93show-server-log:
94 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml logs -f"
95
96show-server-status:
97 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml ps"
98
Marc Kupietz1a422662024-03-16 09:34:10 +010099clean:
100 rm -rf $(BUILD_DIR) $(TARGET_DIR)
101
Marc Kupietz975996e2024-04-13 13:46:37 +0200102alli5:
Marc Kupietza5167622024-04-13 14:18:10 +0200103 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 +0200104 $(MAKE) i5 YY=$$yy; \
105 done