blob: 475a863db0726ef29060219ffe0a140e0794081c [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 Kupietzb7696992024-03-18 17:41:15 +010010.PHONY: all clean test 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
31$(BUILD_DIR)/%: $(SRC_DIR)/%.epub
32 mkdir -p $@
33 echo "Converting $< to $@"
34 unzip -q -o $< -d $@
35
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010036$(TARGET_DIR)/%.i5.xml: $(BUILD_DIR)/% xslt/epub2i5.xsl xslt/idsCorpus-template.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010037 mkdir -p $(TARGET_DIR)
38 echo "Converting $< to $@"
Marc Kupietz0bf97da2024-04-10 16:28:39 +020039 java -jar lib/saxon9ee.jar -xsl:xslt/epub2i5.xsl $(shell find $< -name content.opf) > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010040
41%.zip: %.i5.xml
42 tei2korapxml -l warn -s -tk - < $< > $@
43
44%.tree_tagger.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010045 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2treetagger -l german | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010046
47%.spacy.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010048 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2spacy | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010049
Marc Kupietz8ea92282024-03-24 14:55:55 +010050models/de.marmot:
51 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010052 curl -sL -o $@ https://cistern.cis.lmu.de/marmot/models/CURRENT/spmrl/de.marmot
Marc Kupietz8ea92282024-03-24 14:55:55 +010053
54models/german.mco:
55 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010056 curl -sL -o $@ https://corpora.ids-mannheim.de/tools/$@
Marc Kupietz8ea92282024-03-24 14:55:55 +010057
58%.marmot-malt.zip: %.zip models/de.marmot models/german.mco
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020059 $(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 +010060
Marc Kupietz1a422662024-03-16 09:34:10 +010061%.ud.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010062 $(KORAPXML2CONLLU) $< | pv | ./scripts/udpipe2 | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010063
Marc Kupietz8ea92282024-03-24 14:55:55 +010064%.krill.tar: %.zip %.marmot-malt.zip %.tree_tagger.zip %.spacy.zip
Marc Kupietz3d82f562024-03-16 10:19:03 +010065 mkdir -p $(basename $@)
Marc Kupietz8ea92282024-03-24 14:55:55 +010066 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 +010067
Marc Kupietzfc328622024-03-16 14:31:34 +010068%.json: %.krill.tar
69 rm -rf $@
70 mkdir -p $@
71 for f in $<; do tar -C $@ -xf $$f; done
Marc Kupietz1a422662024-03-16 09:34:10 +010072
Marc Kupietz22ad4b72024-03-17 16:24:21 +010073%.index: %.json
74 rm -rf $@
Marc Kupietz012c7082024-03-17 16:40:47 +010075 java -jar lib/Krill-Indexer.jar -c lib/krill.conf -i $< -o $@
Marc Kupietz22ad4b72024-03-17 16:24:21 +010076
77%.index.tar.xz: %.index
78 tar -I 'xz -T0' -C $(dir $<) -cf $@ $(notdir $<)
79
Marc Kupietzb7696992024-03-18 17:41:15 +010080deploy: $(TARGET_DIR)/dnb.index.tar.xz korap4dnb-compose.yml
81 rsync -v $^ $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/
82 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"
83
84show-server-log:
85 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml logs -f"
86
87show-server-status:
88 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml ps"
89
Marc Kupietz1a422662024-03-16 09:34:10 +010090clean:
91 rm -rf $(BUILD_DIR) $(TARGET_DIR)
92