blob: becf7069e8355c46b56bd0acbad62172d06c6cfa [file] [log] [blame]
Marc Kupietz1a422662024-03-16 09:34:10 +01001SRC_DIR ?= test/resources/DNB
2BUILD_DIR = build
3TARGET_DIR ?= target
4
Marc Kupietz3d82f562024-03-16 10:19:03 +01005.PHONY: all clean test krill
Marc Kupietz1a422662024-03-16 09:34:10 +01006
Marc Kupietz95bce0d2024-03-16 10:37:45 +01007.PRECIOUS: %.zip $(TARGET_DIR)/%.zip $(TARGET_DIR)/%.i5.xml $(TARGET_DIR)/%.tar
Marc Kupietz1a422662024-03-16 09:34:10 +01008
9all: $(TARGET_DIR)/dnb.i5.xml
10
Marc Kupietz3d82f562024-03-16 10:19:03 +010011krill: $(TARGET_DIR)/dnb.krill.tar
12
Marc Kupietzfa445da2024-03-16 10:46:22 +010013KORAPXML2CONLLU ?= java -jar lib/korapxml2conllu.jar
14
Marc Kupietz1a422662024-03-16 09:34:10 +010015$(TARGET_DIR)/dnb.i5.xml: $(patsubst $(SRC_DIR)/%.epub,$(TARGET_DIR)/%.i5.xml,$(wildcard $(SRC_DIR)/*.epub))
16 head -n -1 xslt/idsCorpus-template.xml > $@
17 cat $^ >> $@
18 tail -n 1 xslt/idsCorpus-template.xml >> $@
19
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010020test: $(TARGET_DIR)/dnb.i5.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010021 xmllint --noout --valid $<
22
23$(BUILD_DIR)/%: $(SRC_DIR)/%.epub
24 mkdir -p $@
25 echo "Converting $< to $@"
26 unzip -q -o $< -d $@
27
Marc Kupietzdfbc3f42024-03-16 11:46:41 +010028$(TARGET_DIR)/%.i5.xml: $(BUILD_DIR)/% xslt/epub2i5.xsl xslt/idsCorpus-template.xml
Marc Kupietz1a422662024-03-16 09:34:10 +010029 mkdir -p $(TARGET_DIR)
30 echo "Converting $< to $@"
31 java -jar lib/saxon9ee.jar -xsl:xslt/epub2i5.xsl $</*/content.opf > $@
32
33%.zip: %.i5.xml
34 tei2korapxml -l warn -s -tk - < $< > $@
35
36%.tree_tagger.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010037 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2treetagger -l german | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010038
39%.spacy.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010040 $(KORAPXML2CONLLU) $< | pv | docker run --rm -i korap/conllu2spacy | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010041
42%.ud.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010043 $(KORAPXML2CONLLU) $< | pv | ./scripts/udpipe2 | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010044
45%.cmc.zip: %.zip
Marc Kupietzfa445da2024-03-16 10:46:22 +010046 $(KORAPXML2CONLLU) $< | pv | conllu2cmc -s | conllu2korapxml > $@
Marc Kupietz1a422662024-03-16 09:34:10 +010047
Marc Kupietz3d82f562024-03-16 10:19:03 +010048%.krill.tar: %.zip
49 mkdir -p $(basename $@)
50 korapxml2krill archive --quiet -w -z -cfg krill-korap4dnb.cfg --non-word-tokens --meta I5 -i $< -o $(basename $@)
51# add annotations later
52# 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 +010053
54json: *.krill.tar
55 rm -rf json
56 mkdir -p json
57 for f in $^; do tar -C json -xf $$f; done
58
59clean:
60 rm -rf $(BUILD_DIR) $(TARGET_DIR)
61