blob: 8b5e4c4eb8688cf81cafccc330cb9aa1e9783dfa [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 Kupietz1a422662024-03-16 09:34:10 +01008
Marc Kupietzb7696992024-03-18 17:41:15 +01009.PHONY: all clean test krill index deploy server-log server-status
Marc Kupietz1a422662024-03-16 09:34:10 +010010
Marc Kupietz8ea92282024-03-24 14:55:55 +010011.PRECIOUS: %.zip %.tree_tagger.zip %.ud.zip %.marmot-malt.zip %.spacy.zip %.i5.xml %.tar
Marc Kupietz1a422662024-03-16 09:34:10 +010012
Marc Kupietzb7696992024-03-18 17:41:15 +010013.DELETE_ON_ERROR:
14
Marc Kupietzfeed26a2024-03-17 19:16:23 +010015all: index
Marc Kupietz1a422662024-03-16 09:34:10 +010016
Marc Kupietz3d82f562024-03-16 10:19:03 +010017krill: $(TARGET_DIR)/dnb.krill.tar
Marc Kupietz012c7082024-03-17 16:40:47 +010018index: $(TARGET_DIR)/dnb.index.tar.xz
Marc Kupietz3d82f562024-03-16 10:19:03 +010019
Marc Kupietzfa445da2024-03-16 10:46:22 +010020KORAPXML2CONLLU ?= java -jar lib/korapxml2conllu.jar
21
Marc Kupietz1a422662024-03-16 09:34:10 +010022$(TARGET_DIR)/dnb.i5.xml: $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*.epub))
23 head -n -1 xslt/idsCorpus-template.xml > $@
24 cat $^ >> $@
25 tail -n 1 xslt/idsCorpus-template.xml >> $@
26
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010027test: $(TARGET_DIR)/dnb.i5.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010028 xmllint --noout --valid $<
29
30$(BUILD_DIR)/%: $(SRC_DIR)/%.epub
31 mkdir -p $@
32 echo "Converting $< to $@"
33 unzip -q -o $< -d $@
34
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010035$(TARGET_DIR)/%.i5.xml: $(BUILD_DIR)/% xslt/epub2i5.xsl xslt/idsCorpus-template.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010036 mkdir -p $(TARGET_DIR)
37 echo "Converting $< to $@"
Marc Kupietz0bf97da2024-04-10 16:28:39 +020038 java -jar lib/saxon9ee.jar -xsl:xslt/epub2i5.xsl $(shell find $< -name content.opf) > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010039
40%.zip: %.i5.xml
41 tei2korapxml -l warn -s -tk - < $< > $@
42
43%.tree_tagger.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010044 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2treetagger -l german | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010045
46%.spacy.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010047 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2spacy | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010048
Marc Kupietz8ea92282024-03-24 14:55:55 +010049models/de.marmot:
50 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010051 curl -sL -o $@ https://cistern.cis.lmu.de/marmot/models/CURRENT/spmrl/de.marmot
Marc Kupietz8ea92282024-03-24 14:55:55 +010052
53models/german.mco:
54 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010055 curl -sL -o $@ https://corpora.ids-mannheim.de/tools/$@
Marc Kupietz8ea92282024-03-24 14:55:55 +010056
57%.marmot-malt.zip: %.zip models/de.marmot models/german.mco
Marc Kupietz48c6a682024-03-24 15:27:08 +010058 $(KORAPXML2CONLLU) -T $(MAX_THREADS) -t marmot:models/de.marmot -P malt:models/german.mco $< | tee $(TARGET_DIR)/dnb.marmot-malt.conllu | conllu2korapxml > $@
Marc Kupietz8ea92282024-03-24 14:55:55 +010059
Marc Kupietz1a422662024-03-16 09:34:10 +010060%.ud.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010061 $(KORAPXML2CONLLU) $< | pv | ./scripts/udpipe2 | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010062
Marc Kupietz8ea92282024-03-24 14:55:55 +010063%.krill.tar: %.zip %.marmot-malt.zip %.tree_tagger.zip %.spacy.zip
Marc Kupietz3d82f562024-03-16 10:19:03 +010064 mkdir -p $(basename $@)
Marc Kupietz8ea92282024-03-24 14:55:55 +010065 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 +010066
Marc Kupietzfc328622024-03-16 14:31:34 +010067%.json: %.krill.tar
68 rm -rf $@
69 mkdir -p $@
70 for f in $<; do tar -C $@ -xf $$f; done
Marc Kupietz1a422662024-03-16 09:34:10 +010071
Marc Kupietz22ad4b72024-03-17 16:24:21 +010072%.index: %.json
73 rm -rf $@
Marc Kupietz012c7082024-03-17 16:40:47 +010074 java -jar lib/Krill-Indexer.jar -c lib/krill.conf -i $< -o $@
Marc Kupietz22ad4b72024-03-17 16:24:21 +010075
76%.index.tar.xz: %.index
77 tar -I 'xz -T0' -C $(dir $<) -cf $@ $(notdir $<)
78
Marc Kupietzb7696992024-03-18 17:41:15 +010079deploy: $(TARGET_DIR)/dnb.index.tar.xz korap4dnb-compose.yml
80 rsync -v $^ $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/
81 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"
82
83show-server-log:
84 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml logs -f"
85
86show-server-status:
87 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml ps"
88
Marc Kupietz1a422662024-03-16 09:34:10 +010089clean:
90 rm -rf $(BUILD_DIR) $(TARGET_DIR)
91