blob: 9198048d4a701dd1b55c21c015bff366c78b9260 [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 Kupietz1a422662024-03-16 09:34:10 +01007
Marc Kupietzb7696992024-03-18 17:41:15 +01008.PHONY: all clean test krill index deploy server-log server-status
Marc Kupietz1a422662024-03-16 09:34:10 +01009
Marc Kupietzfc328622024-03-16 14:31:34 +010010.PRECIOUS: %.zip %.tree_tagger.zip %.ud.zip %.spacy.zip %.i5.xml %.tar
Marc Kupietz1a422662024-03-16 09:34:10 +010011
Marc Kupietzb7696992024-03-18 17:41:15 +010012.DELETE_ON_ERROR:
13
Marc Kupietzfeed26a2024-03-17 19:16:23 +010014all: index
Marc Kupietz1a422662024-03-16 09:34:10 +010015
Marc Kupietz3d82f562024-03-16 10:19:03 +010016krill: $(TARGET_DIR)/dnb.krill.tar
Marc Kupietz012c7082024-03-17 16:40:47 +010017index: $(TARGET_DIR)/dnb.index.tar.xz
Marc Kupietz3d82f562024-03-16 10:19:03 +010018
Marc Kupietzfa445da2024-03-16 10:46:22 +010019KORAPXML2CONLLU ?= java -jar lib/korapxml2conllu.jar
20
Marc Kupietz1a422662024-03-16 09:34:10 +010021$(TARGET_DIR)/dnb.i5.xml: $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*.epub))
22 head -n -1 xslt/idsCorpus-template.xml > $@
23 cat $^ >> $@
24 tail -n 1 xslt/idsCorpus-template.xml >> $@
25
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010026test: $(TARGET_DIR)/dnb.i5.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010027 xmllint --noout --valid $<
28
29$(BUILD_DIR)/%: $(SRC_DIR)/%.epub
30 mkdir -p $@
31 echo "Converting $< to $@"
32 unzip -q -o $< -d $@
33
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010034$(TARGET_DIR)/%.i5.xml: $(BUILD_DIR)/% xslt/epub2i5.xsl xslt/idsCorpus-template.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010035 mkdir -p $(TARGET_DIR)
36 echo "Converting $< to $@"
37 java -jar lib/saxon9ee.jar -xsl:xslt/epub2i5.xsl $</*/content.opf > $@
38
39%.zip: %.i5.xml
40 tei2korapxml -l warn -s -tk - < $< > $@
41
42%.tree_tagger.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010043 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2treetagger -l german | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010044
45%.spacy.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010046 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2spacy | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010047
48%.ud.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010049 $(KORAPXML2CONLLU) $< | pv | ./scripts/udpipe2 | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010050
Marc Kupietz22ad4b72024-03-17 16:24:21 +010051%.krill.tar: %.zip %.ud.zip %.tree_tagger.zip %.spacy.zip
Marc Kupietz3d82f562024-03-16 10:19:03 +010052 mkdir -p $(basename $@)
Marc Kupietzfc328622024-03-16 14:31:34 +010053 korapxml2krill archive --quiet -w -z -cfg krill-korap4dnb.cfg --non-word-tokens --meta I5 -i $< -i $(word 2,$^) -i $(word 3,$^) -o $(basename $@)
Marc Kupietz1a422662024-03-16 09:34:10 +010054
Marc Kupietzfc328622024-03-16 14:31:34 +010055%.json: %.krill.tar
56 rm -rf $@
57 mkdir -p $@
58 for f in $<; do tar -C $@ -xf $$f; done
Marc Kupietz1a422662024-03-16 09:34:10 +010059
Marc Kupietz22ad4b72024-03-17 16:24:21 +010060%.index: %.json
61 rm -rf $@
Marc Kupietz012c7082024-03-17 16:40:47 +010062 java -jar lib/Krill-Indexer.jar -c lib/krill.conf -i $< -o $@
Marc Kupietz22ad4b72024-03-17 16:24:21 +010063
64%.index.tar.xz: %.index
65 tar -I 'xz -T0' -C $(dir $<) -cf $@ $(notdir $<)
66
Marc Kupietzb7696992024-03-18 17:41:15 +010067deploy: $(TARGET_DIR)/dnb.index.tar.xz korap4dnb-compose.yml
68 rsync -v $^ $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/
69 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"
70
71show-server-log:
72 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml logs -f"
73
74show-server-status:
75 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml ps"
76
Marc Kupietz1a422662024-03-16 09:34:10 +010077clean:
78 rm -rf $(BUILD_DIR) $(TARGET_DIR)
79