blob: 209b19b9100ad90c041dd1edad499040a8bb591d [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 Kupietz43cbb112024-04-14 07:32:48 +020010KORAPXML2CONLLU ?= java -jar lib/korapxml2conllu.jar
Marc Kupietzf62bc902024-04-14 15:59:44 +020011SAXON ?= java -cp lib/saxon9ee.jar:lib/xml-resolver-1.2.jar net.sf.saxon.Transform -expand:off -catalog:"lib/dtds/xhtml11/xhtmlcatalog.xml;lib/dtds/xhtml/dtd/xhtmlcatalog.xml"
Marc Kupietz1a422662024-03-16 09:34:10 +010012
Marc Kupietz157e0792024-04-13 12:46:42 +020013.PHONY: all clean test i5 i5valid krill index deploy server-log server-status
Marc Kupietz1a422662024-03-16 09:34:10 +010014
Marc Kupietz8ea92282024-03-24 14:55:55 +010015.PRECIOUS: %.zip %.tree_tagger.zip %.ud.zip %.marmot-malt.zip %.spacy.zip %.i5.xml %.tar
Marc Kupietz1a422662024-03-16 09:34:10 +010016
Marc Kupietzb7696992024-03-18 17:41:15 +010017.DELETE_ON_ERROR:
18
Marc Kupietzfeed26a2024-03-17 19:16:23 +010019all: index
Marc Kupietz1a422662024-03-16 09:34:10 +010020
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020021krill: $(TARGET_DIR)/dnb$(YY).krill.tar
22index: $(TARGET_DIR)/dnb$(YY).index.tar.xz
Marc Kupietz3d82f562024-03-16 10:19:03 +010023
Marc Kupietzfa445da2024-03-16 10:46:22 +010024
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020025$(TARGET_DIR)/dnb$(YY).i5.xml: $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*.epub))
Marc Kupietzd101e472024-04-14 11:54:34 +020026 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*0.epub)) > $(TARGET_DIR)/filelist$(YY).txt
27 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*1.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
28 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*2.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
29 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*3.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
30 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*4.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
31 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*5.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
32 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*6.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
33 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*7.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
34 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*8.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
35 @echo $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*9.epub)) >> $(TARGET_DIR)/filelist$(YY).txt
36 sed -i -e 's/ /\n/g' $(TARGET_DIR)/filelist$(YY).txt
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020037 head -n -1 xslt/idsCorpus-template.xml | sed -e 's/{YY}/$(YY)/' > $@
Marc Kupietzb926f252024-04-14 08:57:11 +020038 @while IFS= read -r f; do \
39 if head -500 "$$f" | grep -Eq '<pubDate type="year">..$(YY)'; then \
40 cat "$$f" >> $@; \
41 fi; \
42 done < $(TARGET_DIR)/filelist$(YY).txt
Marc Kupietz1a422662024-03-16 09:34:10 +010043 tail -n 1 xslt/idsCorpus-template.xml >> $@
44
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020045test: $(TARGET_DIR)/dnb$(YY).i5.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010046 xmllint --noout --valid $<
47
Marc Kupietz157e0792024-04-13 12:46:42 +020048i5: $(TARGET_DIR)/dnb$(YY).i5.xml
49 xmllint --noout $<
50
51i5valid: $(TARGET_DIR)/dnb$(YY).i5.xml
52 xmllint --noout --valid $<
53
Marc Kupietz1a422662024-03-16 09:34:10 +010054$(BUILD_DIR)/%: $(SRC_DIR)/%.epub
55 mkdir -p $@
56 echo "Converting $< to $@"
57 unzip -q -o $< -d $@
Marc Kupietz51714ed2024-04-13 12:47:39 +020058 chmod -R ug+rwX $@
Marc Kupietz1a422662024-03-16 09:34:10 +010059
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010060$(TARGET_DIR)/%.i5.xml: $(BUILD_DIR)/% xslt/epub2i5.xsl xslt/idsCorpus-template.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010061 mkdir -p $(TARGET_DIR)
62 echo "Converting $< to $@"
Marc Kupietz1a370e02024-04-14 14:22:46 +020063 $(SAXON) -xsl:xslt/epub2i5.xsl $(shell find $< -name "*.opf") | $(SAXON) -xsl:xslt/unnest_p.xsl - > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010064
65%.zip: %.i5.xml
66 tei2korapxml -l warn -s -tk - < $< > $@
67
68%.tree_tagger.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010069 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2treetagger -l german | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010070
71%.spacy.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010072 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2spacy | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010073
Marc Kupietz8ea92282024-03-24 14:55:55 +010074models/de.marmot:
75 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010076 curl -sL -o $@ https://cistern.cis.lmu.de/marmot/models/CURRENT/spmrl/de.marmot
Marc Kupietz8ea92282024-03-24 14:55:55 +010077
78models/german.mco:
79 mkdir -p models
Marc Kupietze8c80f32024-03-24 15:27:28 +010080 curl -sL -o $@ https://corpora.ids-mannheim.de/tools/$@
Marc Kupietz8ea92282024-03-24 14:55:55 +010081
82%.marmot-malt.zip: %.zip models/de.marmot models/german.mco
Marc Kupietz94bbe6b2024-04-10 20:35:48 +020083 $(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 +010084
Marc Kupietz1a422662024-03-16 09:34:10 +010085%.ud.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010086 $(KORAPXML2CONLLU) $< | pv | ./scripts/udpipe2 | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010087
Marc Kupietz8ea92282024-03-24 14:55:55 +010088%.krill.tar: %.zip %.marmot-malt.zip %.tree_tagger.zip %.spacy.zip
Marc Kupietz3d82f562024-03-16 10:19:03 +010089 mkdir -p $(basename $@)
Marc Kupietz8ea92282024-03-24 14:55:55 +010090 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 +010091
Marc Kupietzfc328622024-03-16 14:31:34 +010092%.json: %.krill.tar
93 rm -rf $@
94 mkdir -p $@
95 for f in $<; do tar -C $@ -xf $$f; done
Marc Kupietz1a422662024-03-16 09:34:10 +010096
Marc Kupietz22ad4b72024-03-17 16:24:21 +010097%.index: %.json
98 rm -rf $@
Marc Kupietz012c7082024-03-17 16:40:47 +010099 java -jar lib/Krill-Indexer.jar -c lib/krill.conf -i $< -o $@
Marc Kupietz22ad4b72024-03-17 16:24:21 +0100100
101%.index.tar.xz: %.index
102 tar -I 'xz -T0' -C $(dir $<) -cf $@ $(notdir $<)
103
Marc Kupietzb7696992024-03-18 17:41:15 +0100104deploy: $(TARGET_DIR)/dnb.index.tar.xz korap4dnb-compose.yml
105 rsync -v $^ $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/
106 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"
107
108show-server-log:
109 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml logs -f"
110
111show-server-status:
112 ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml ps"
113
Marc Kupietz1a422662024-03-16 09:34:10 +0100114clean:
115 rm -rf $(BUILD_DIR) $(TARGET_DIR)
116
Marc Kupietz975996e2024-04-13 13:46:37 +0200117alli5:
Marc Kupietza5167622024-04-13 14:18:10 +0200118 for yy in $(shell seq -f "%02.f" 95 99) $(shell seq -f "%02.f" 0 24); do \
Marc Kupietz975996e2024-04-13 13:46:37 +0200119 $(MAKE) i5 YY=$$yy; \
120 done