blob: 707740c97814133b5bdf71a60d249126942f6821 [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 Kupietz1a422662024-03-16 09:34:10 +01009
Marc Kupietz157e0792024-04-13 12:46:42 +020010.PHONY: all clean test i5 i5valid krill index deploy server-log server-status
Marc Kupietz1a422662024-03-16 09:34:10 +010011
Marc Kupietz8ea92282024-03-24 14:55:55 +010012.PRECIOUS: %.zip %.tree_tagger.zip %.ud.zip %.marmot-malt.zip %.spacy.zip %.i5.xml %.tar
Marc Kupietz1a422662024-03-16 09:34:10 +010013
Marc Kupietzb7696992024-03-18 17:41:15 +010014.DELETE_ON_ERROR:
15
Marc Kupietzfeed26a2024-03-17 19:16:23 +010016all: index
Marc Kupietz1a422662024-03-16 09:34:10 +010017
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020018krill: $(TARGET_DIR)/dnb$(YY).krill.tar
19index: $(TARGET_DIR)/dnb$(YY).index.tar.xz
Marc Kupietz3d82f562024-03-16 10:19:03 +010020
Marc Kupietzfa445da2024-03-16 10:46:22 +010021KORAPXML2CONLLU ?= java -jar lib/korapxml2conllu.jar
22
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020023$(TARGET_DIR)/dnb$(YY).i5.xml: $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*.epub))
24 head -n -1 xslt/idsCorpus-template.xml | sed -e 's/{YY}/$(YY)/' > $@
25 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 +010026 tail -n 1 xslt/idsCorpus-template.xml >> $@
27
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020028test: $(TARGET_DIR)/dnb$(YY).i5.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010029 xmllint --noout --valid $<
30
Marc Kupietz157e0792024-04-13 12:46:42 +020031i5: $(TARGET_DIR)/dnb$(YY).i5.xml
32 xmllint --noout $<
33
34i5valid: $(TARGET_DIR)/dnb$(YY).i5.xml
35 xmllint --noout --valid $<
36
Marc Kupietz1a422662024-03-16 09:34:10 +010037$(BUILD_DIR)/%: $(SRC_DIR)/%.epub
38 mkdir -p $@
39 echo "Converting $< to $@"
40 unzip -q -o $< -d $@
Marc Kupietz51714ed2024-04-13 12:47:39 +020041 chmod -R ug+rwX $@
Marc Kupietz1a422662024-03-16 09:34:10 +010042
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010043$(TARGET_DIR)/%.i5.xml: $(BUILD_DIR)/% xslt/epub2i5.xsl xslt/idsCorpus-template.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010044 mkdir -p $(TARGET_DIR)
45 echo "Converting $< to $@"
Marc Kupietz0bf97da2024-04-10 16:28:39 +020046 java -jar lib/saxon9ee.jar -xsl:xslt/epub2i5.xsl $(shell find $< -name content.opf) > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010047
48%.zip: %.i5.xml
49 tei2korapxml -l warn -s -tk - < $< > $@
50
51%.tree_tagger.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010052 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2treetagger -l german | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010053
54%.spacy.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010055 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2spacy | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010056
Marc Kupietz8ea92282024-03-24 14:55:55 +010057models/de.marmot:
58 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010059 curl -sL -o $@ https://cistern.cis.lmu.de/marmot/models/CURRENT/spmrl/de.marmot
Marc Kupietz8ea92282024-03-24 14:55:55 +010060
61models/german.mco:
62 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010063 curl -sL -o $@ https://corpora.ids-mannheim.de/tools/$@
Marc Kupietz8ea92282024-03-24 14:55:55 +010064
65%.marmot-malt.zip: %.zip models/de.marmot models/german.mco
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020066 $(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 +010067
Marc Kupietz1a422662024-03-16 09:34:10 +010068%.ud.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010069 $(KORAPXML2CONLLU) $< | pv | ./scripts/udpipe2 | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010070
Marc Kupietz8ea92282024-03-24 14:55:55 +010071%.krill.tar: %.zip %.marmot-malt.zip %.tree_tagger.zip %.spacy.zip
Marc Kupietz3d82f562024-03-16 10:19:03 +010072 mkdir -p $(basename $@)
Marc Kupietz8ea92282024-03-24 14:55:55 +010073 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 +010074
Marc Kupietzfc328622024-03-16 14:31:34 +010075%.json: %.krill.tar
76 rm -rf $@
77 mkdir -p $@
78 for f in $<; do tar -C $@ -xf $$f; done
Marc Kupietz1a422662024-03-16 09:34:10 +010079
Marc Kupietz22ad4b72024-03-17 16:24:21 +010080%.index: %.json
81 rm -rf $@
Marc Kupietz012c7082024-03-17 16:40:47 +010082 java -jar lib/Krill-Indexer.jar -c lib/krill.conf -i $< -o $@
Marc Kupietz22ad4b72024-03-17 16:24:21 +010083
84%.index.tar.xz: %.index
85 tar -I 'xz -T0' -C $(dir $<) -cf $@ $(notdir $<)
86
Marc Kupietzb7696992024-03-18 17:41:15 +010087deploy: $(TARGET_DIR)/dnb.index.tar.xz korap4dnb-compose.yml
88 rsync -v $^ $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/
89 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"
90
91show-server-log:
92 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml logs -f"
93
94show-server-status:
95 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml ps"
96
Marc Kupietz1a422662024-03-16 09:34:10 +010097clean:
98 rm -rf $(BUILD_DIR) $(TARGET_DIR)
99