Skip to content

Commit

Permalink
Fixes #249
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelloPerathoner committed Apr 30, 2024
1 parent 47c27d0 commit cb34521
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 23 deletions.
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ deploy_schemas:
# $(RSYNC) schemas $(PUBL)/schemata
$(RSYNC) bibl/*.rng bibl/*.sch $(PUBL)/bibl

upload_scripts:
$(RSYNC) --exclude='env' scripts $(HOST_PRJ_DIR)

upload_server:
cd $(SERVER) && $(MAKE) upload
deploy_server:
cd $(SERVER) && $(MAKE) deploy
$(RSYNC) Makefile* Variables.mak $(HOST_SERVER)/../

import_xml: import_mss import_capits
Expand Down Expand Up @@ -97,7 +94,7 @@ mysql-local:
.PHONY: server
server:
export PYTHONPATH=$(ROOT)/server; \
python3 -OO -m server.server -vvv
$(PYTHON) -OO -m server.server -vvv

dist/api.conf.js: client/src/api.conf.js
mkdir -p dist
Expand Down
1 change: 1 addition & 0 deletions Variables.mak
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ HOST_XSLT := $(HOST_PRJ_DIR)/xslt

NODE_MODULES := $(ROOT)/node_modules
NODE := $(NODE_MODULES)/.bin
PYTHON := $(ROOT)/.venv/bin/python3

NAT_EARTH := https://naciscdn.org/naturalearth

Expand Down
5 changes: 2 additions & 3 deletions server/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
include ../Variables.mak

IMPORT := python3 -m scripts.import_data -vvv -c ./server.conf
IMPORT := ../.venv/bin/python3 -m scripts.import_data -vvv -c ./server.conf

upload:
deploy:
$(RSYNCPY) --exclude "server.conf" ./* $(HOST_SERVER)
$(RSYNC) ../xslt/*.xsl ../xslt/Makefile $(HOST_XSLT)/

install_prereq:
sudo apt-get install python3-mapnik
Expand Down
3 changes: 2 additions & 1 deletion server/collator_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def preprocess(text: str, normalizations: Optional[List[str]] = None) -> List[Li
"""

text = text or ""
text = text.strip().lower()
text = common.RE_BRACKETS.sub("", text)
text = RE_WHITESPACE_EQUIV_CHARS.sub("", text)
Expand Down Expand Up @@ -204,7 +205,7 @@ def collate():
for w in json_in["collate"]:
u = urllib.parse.urlparse(w)
corresp, ms_id = u.path.split("/", 2)
hands = urllib.parse.parse_qs(u.query).get("hands") == "XYZ"
hands = urllib.parse.parse_qs(u.query).get("hands") == ["XYZ"]

catalog, no, chapter = common.normalize_corresp(corresp)

Expand Down
6 changes: 6 additions & 0 deletions server/scripts/import_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,9 @@ def import_corpus(conn, args):
ms_id = get_ns(tei, "xml:id")
filename = get_ns(tei, "cap:file")
siglum = None
# set bk-textzeuge's id
if filename.endswith("bk-textzeuge.xml"):
ms_id = common.BK_ZEUGE
if ms_id in processed_ms_ids:
log(
logging.ERROR,
Expand Down Expand Up @@ -854,6 +857,9 @@ def import_fulltext(conn, filenames, mode):
mscap_catalog = ""
mscap_no = ""
mscap_n = 1
# set bk-textzeuge's id
if fn.endswith("bk-textzeuge.xml"):
ms_id = common.BK_ZEUGE

for item in tei.xpath(
".//tei:div[@corresp]|.//tei:milestone[@unit]", namespaces=NS
Expand Down
37 changes: 25 additions & 12 deletions xslt/mss-transcript-phase-1.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ There are 2 classes of hands:
- The hands A - W are considered original scribes.
- The hands X - Z are considered later hands.
The "include-later-hand" parameter controls which text is selected for the
reader.
The "include-later-hand" tunneled parameter can be used to control which text is
output. If false, the text by the original hand is output, if true, the text corrected
by a later hand is output.
There are 3 classes of corrections:
Expand All @@ -73,8 +74,6 @@ The generated text of the footnote varies according to these cases.
default-mode="phase1"
exclude-result-prefixes="cap tei xs xsl">

<xsl:param name="include-later-hand" select="true ()" />

<!-- Needed for the correct determination of the word around an editorial
intervention. -->
<xsl:strip-space elements="subst choice"/>
Expand Down Expand Up @@ -364,6 +363,7 @@ The generated text of the footnote varies according to these cases.
<!-- If these hands made corrections we put them in
the apparatus and display the old text. -->
<xsl:param name="context" />
<xsl:param name="include-later-hand" />

<xsl:variable name="hand" select="cap:get-hand ($context)"/>
<xsl:sequence select="normalize-space ($hand) and contains ('XYZ', $hand) and not ($include-later-hand)"/>
Expand Down Expand Up @@ -538,6 +538,8 @@ The generated text of the footnote varies according to these cases.
</xsl:template>

<xsl:template match="add">
<xsl:param name="include-later-hand" select="true ()" tunnel="yes" />

<xsl:if test="not (parent::subst)">
<xsl:call-template name="generate-note"/>
</xsl:if>
Expand All @@ -546,7 +548,7 @@ The generated text of the footnote varies according to these cases.
<xsl:attribute name="data-note-id" select="generate-id ()"/>
</xsl:if>
<xsl:choose>
<xsl:when test="cap:is-later-hand (.)">
<xsl:when test="cap:is-later-hand (., $include-later-hand)">
<xsl:apply-templates mode="notes-only" />
</xsl:when>
<xsl:otherwise>
Expand Down Expand Up @@ -583,6 +585,8 @@ The generated text of the footnote varies according to these cases.
</xsl:template>

<xsl:template match="del">
<xsl:param name="include-later-hand" select="true ()" tunnel="yes" />

<!-- non-empty del -->
<xsl:if test="not (parent::subst)">
<xsl:call-template name="generate-note"/>
Expand All @@ -592,7 +596,7 @@ The generated text of the footnote varies according to these cases.
<xsl:attribute name="data-note-id" select="generate-id ()"/>
</xsl:if>
<xsl:choose>
<xsl:when test="cap:is-later-hand (.)">
<xsl:when test="cap:is-later-hand (., $include-later-hand)">
<xsl:call-template name="handle-rend">
<xsl:with-param name="extra-class" select="'tei-del'"/>
</xsl:call-template>
Expand All @@ -606,10 +610,12 @@ The generated text of the footnote varies according to these cases.
</xsl:template>

<xsl:template match="del[not (normalize-space ())]">
<xsl:param name="include-later-hand" select="true ()" tunnel="yes" />

<!-- empty del -->
<seg class="tei-del">
<xsl:choose>
<xsl:when test="parent::subst and cap:is-later-hand (.)">
<xsl:when test="parent::subst and cap:is-later-hand (., $include-later-hand)">
<xsl:call-template name="empty-del"/>
</xsl:when>
<xsl:when test="not (parent::subst)">
Expand Down Expand Up @@ -786,12 +792,15 @@ The generated text of the footnote varies according to these cases.
-->

<xsl:template match="subst" mode="auto-note">
<xsl:param name="include-later-hand" select="true ()" tunnel="yes" />

<xsl:variable name="before" select="cap:word-before (.)"/>
<xsl:variable name="after" select="cap:word-after (.)"/>
<xsl:variable name="rend" select="concat ('tei-mentioned', cap:get-rend-class (.))"/>


<xsl:choose>
<xsl:when test="cap:is-later-hand (.)">
<xsl:when test="cap:is-later-hand (., $include-later-hand)">
<xsl:variable name="phrase">
<xsl:copy-of select="$before"/>
<xsl:apply-templates select="del" mode="original"/>
Expand Down Expand Up @@ -837,12 +846,14 @@ The generated text of the footnote varies according to these cases.
</xsl:template>

<xsl:template match="add" mode="auto-note">
<xsl:param name="include-later-hand" select="true ()" tunnel="yes" />

<xsl:variable name="before" select="cap:word-before (.)"/>
<xsl:variable name="after" select="cap:word-after (.)"/>
<xsl:variable name="rend" select="concat ('tei-mentioned', cap:get-rend-class (.))"/>

<xsl:choose>
<xsl:when test="cap:is-later-hand (.)">
<xsl:when test="cap:is-later-hand (., $include-later-hand)">
<seg class="generated" data-shortcuts="0">
<xsl:choose>
<xsl:when test="cap:is-whole-word ($before, $after)">
Expand All @@ -866,7 +877,7 @@ The generated text of the footnote varies according to these cases.
</seg>
</xsl:when>
<xsl:otherwise>
<!-- not (cap:is-later-hand (.)) -->
<!-- not (cap:is-later-hand (., $include-later-hand)) -->
<xsl:variable name="phrase">
<!-- tentative fix for #125. A milestone gets a <seg display:none>
into $phrase but cap:shorten-phrase doesn't know enough to throw it out -->
Expand Down Expand Up @@ -905,6 +916,8 @@ The generated text of the footnote varies according to these cases.
</xsl:template>

<xsl:template match="del[normalize-space ()]" mode="auto-note">
<xsl:param name="include-later-hand" select="true ()" tunnel="yes" />

<xsl:variable name="before" select="cap:word-before (.)"/>
<xsl:variable name="after" select="cap:word-after (.)"/>
<xsl:variable name="rend" select="concat ('tei-mentioned', cap:get-rend-class (.))"/>
Expand All @@ -919,7 +932,7 @@ The generated text of the footnote varies according to these cases.
<xsl:when test="cap:is-whole-word ($before, $after)">
<!-- Whole word deleted. -->
<xsl:choose>
<xsl:when test="cap:is-later-hand (.)">
<xsl:when test="cap:is-later-hand (., $include-later-hand)">
<xsl:if test="cap:is-phrase ($phrase)">
<seg class="{$rend}">
<xsl:copy-of select="cap:shorten-phrase ($phrase)"/>
Expand Down Expand Up @@ -947,7 +960,7 @@ The generated text of the footnote varies according to these cases.
<xsl:otherwise>
<!-- Part of word deleted. -->
<xsl:choose>
<xsl:when test="cap:is-later-hand (.)">
<xsl:when test="cap:is-later-hand (., $include-later-hand)">
<seg class="generated" data-shortcuts="0">
<xsl:call-template name="hand-blurb"/>
<xsl:text> korr. zu </xsl:text>
Expand Down
4 changes: 3 additions & 1 deletion xslt/xslt.config.mak
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ROOT_DIR := /afs/rrz.uni-koeln.de/vol/www/projekt/capitularia/http/docs/cap
# Configures the XSLT process on the server and on the development machines
# DO NOT UPLOAD this to the server, but edit the copy on the server

ROOT_DIR := $(UNI_DIR)/remote_fs/cap
CACHE_DIR := $(UNI_DIR)/prj/capitularia/capitularia/cache

0 comments on commit cb34521

Please sign in to comment.