blob: 4122008776d749e81d1ab76ce46615bc9c883737 [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 Kupietz1a422662024-03-16 09:34:10 +010010
Marc Kupietz157e0792024-04-13 12:46:42 +020011.PHONY: all clean test i5 i5valid krill index deploy server-log server-status
Marc Kupietz1a422662024-03-16 09:34:10 +010012
Marc Kupietz8ea92282024-03-24 14:55:55 +010013.PRECIOUS: %.zip %.tree_tagger.zip %.ud.zip %.marmot-malt.zip %.spacy.zip %.i5.xml %.tar
Marc Kupietz1a422662024-03-16 09:34:10 +010014
Marc Kupietzb7696992024-03-18 17:41:15 +010015.DELETE_ON_ERROR:
16
Marc Kupietzfeed26a2024-03-17 19:16:23 +010017all: index
Marc Kupietz1a422662024-03-16 09:34:10 +010018
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020019krill: $(TARGET_DIR)/dnb$(YY).krill.tar
20index: $(TARGET_DIR)/dnb$(YY).index.tar.xz
Marc Kupietz3d82f562024-03-16 10:19:03 +010021
Marc Kupietzfa445da2024-03-16 10:46:22 +010022KORAPXML2CONLLU ?= java -jar lib/korapxml2conllu.jar
23
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020024$(TARGET_DIR)/dnb$(YY).i5.xml: $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*.epub))
25 head -n -1 xslt/idsCorpus-template.xml | sed -e 's/{YY}/$(YY)/' > $@
26 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 +010027 tail -n 1 xslt/idsCorpus-template.xml >> $@
28
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020029test: $(TARGET_DIR)/dnb$(YY).i5.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010030 xmllint --noout --valid $<
31
Marc Kupietz157e0792024-04-13 12:46:42 +020032i5: $(TARGET_DIR)/dnb$(YY).i5.xml
33 xmllint --noout $<
34
35i5valid: $(TARGET_DIR)/dnb$(YY).i5.xml
36 xmllint --noout --valid $<
37
Marc Kupietz1a422662024-03-16 09:34:10 +010038$(BUILD_DIR)/%: $(SRC_DIR)/%.epub
39 mkdir -p $@
40 echo "Converting $< to $@"
41 unzip -q -o $< -d $@
Marc Kupietz51714ed2024-04-13 12:47:39 +020042 chmod -R ug+rwX $@
Marc Kupietz1a422662024-03-16 09:34:10 +010043
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010044$(TARGET_DIR)/%.i5.xml: $(BUILD_DIR)/% xslt/epub2i5.xsl xslt/idsCorpus-template.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010045 mkdir -p $(TARGET_DIR)
46 echo "Converting $< to $@"
Marc Kupietz9d156832024-04-13 12:51:01 +020047 java -jar lib/saxon9ee.jar -xsl:xslt/epub2i5.xsl $(shell find $< -name "*.opf") > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010048
49%.zip: %.i5.xml
50 tei2korapxml -l warn -s -tk - < $< > $@
51
52%.tree_tagger.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010053 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2treetagger -l german | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010054
55%.spacy.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010056 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2spacy | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010057
Marc Kupietz8ea92282024-03-24 14:55:55 +010058models/de.marmot:
59 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010060 curl -sL -o $@ https://cistern.cis.lmu.de/marmot/models/CURRENT/spmrl/de.marmot
Marc Kupietz8ea92282024-03-24 14:55:55 +010061
62models/german.mco:
63 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010064 curl -sL -o $@ https://corpora.ids-mannheim.de/tools/$@
Marc Kupietz8ea92282024-03-24 14:55:55 +010065
66%.marmot-malt.zip: %.zip models/de.marmot models/german.mco
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020067 $(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 +010068
Marc Kupietz1a422662024-03-16 09:34:10 +010069%.ud.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010070 $(KORAPXML2CONLLU) $< | pv | ./scripts/udpipe2 | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010071
Marc Kupietz8ea92282024-03-24 14:55:55 +010072%.krill.tar: %.zip %.marmot-malt.zip %.tree_tagger.zip %.spacy.zip
Marc Kupietz3d82f562024-03-16 10:19:03 +010073 mkdir -p $(basename $@)
Marc Kupietz8ea92282024-03-24 14:55:55 +010074 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 +010075
Marc Kupietzfc328622024-03-16 14:31:34 +010076%.json: %.krill.tar
77 rm -rf $@
78 mkdir -p $@
79 for f in $<; do tar -C $@ -xf $$f; done
Marc Kupietz1a422662024-03-16 09:34:10 +010080
Marc Kupietz22ad4b72024-03-17 16:24:21 +010081%.index: %.json
82 rm -rf $@
Marc Kupietz012c7082024-03-17 16:40:47 +010083 java -jar lib/Krill-Indexer.jar -c lib/krill.conf -i $< -o $@
Marc Kupietz22ad4b72024-03-17 16:24:21 +010084
85%.index.tar.xz: %.index
86 tar -I 'xz -T0' -C $(dir $<) -cf $@ $(notdir $<)
87
Marc Kupietzb7696992024-03-18 17:41:15 +010088deploy: $(TARGET_DIR)/dnb.index.tar.xz korap4dnb-compose.yml
89 rsync -v $^ $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/
90 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"
91
92show-server-log:
93 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml logs -f"
94
95show-server-status:
96 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml ps"
97
Marc Kupietz1a422662024-03-16 09:34:10 +010098clean:
99 rm -rf $(BUILD_DIR) $(TARGET_DIR)
100
Marc Kupietz975996e2024-04-13 13:46:37 +0200101alli5:
102 for yy in {98..99} {00..23}; do \
103 $(MAKE) i5 YY=$$yy; \
104 done