Skip to content
  • Mein (im Regionalzug schnell improvisierter) Python Ansatz für "," + Keyword ("Mag.", "Dr."...etc) Kommt das bei raus: <education> <item>Lateinschule Danzig</item> <item> Stud. philos., math., Physik Univ. Jena 1738-40 (u.a. bei Johann Ernst Schubert (1717-1774) u. Johann Peter Reusch (1691-1758))</item> <item> Stud. Rechts- und Staatswiss., Geschichte Univ. Halle 1740-41 (u.a. bei Johann Gottlieb Heineccius (1680-1751), Just Henning Böhmer (1674-1749), Johann Peter von Ludewig (1668-1743) u. Martin Schmeitzel (1679-1747))</item> <item> Stud. Jena 1741-42, imm. Univ. Leipzig 1742</item> <item> Mag. Leipzig 1746 (in absentia)</item> <item> Dr. iur. Göttingen 1762 </item> </education>

    HallerEdu.pyoutput.xml

    Edited by Andreas Mertgens
  • Also

    <education>
     <item>Lateinschule Danzig</item>
     <item> Stud. philos., math., Physik Univ. Jena 1738-40 (u.a. bei Johann Ernst Schubert (1717-1774) u. Johann Peter Reusch (1691-1758))</item>
     <item> Stud. Rechts- und Staatswiss., Geschichte Univ. Halle 1740-41 (u.a. bei Johann Gottlieb Heineccius (1680-1751), Just Henning Böhmer (1674-1749), Johann Peter von Ludewig (1668-1743) u. Martin Schmeitzel (1679-1747))</item>
     <item> Stud. Jena 1741-42, imm. Univ. Leipzig 1742</item>
     <item> Mag. Leipzig 1746 (in absentia)</item>
     <item> Dr. iur. Göttingen 1762 </item>
    </education>

    Der Keyword-list-Ansatz ist gut. Ich bin gerade dabei, eine Liste aller comma-led-tokens zu generieren, aus der diese Liste erweitert werden kann.

    Das gleiche lässt sich dann sehr leicht auch mit XSLT umsetzen.

    Edited by Peter Dängeli
  • <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns="http://www.tei-c.org/ns/1.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:hal="http://www.haller.unibe.ch/ns/1.0"
        exclude-result-prefixes="xs"
        version="3.0">
        
        <xsl:output indent="yes"/>
        
        <xsl:mode on-no-match="shallow-copy"/>
        
        <xsl:variable name="parselist">
            <!-- Including an externally stored list of values that, when preceded by a comma, justify a new item. The expression is constructed as a regex expression of the form '^term1|term2|term3' -->
            <xsl:text>^(</xsl:text>
            <xsl:for-each select="doc('../../education-parsing.xml')//term">
                <xsl:value-of select="replace(.,'\.','\\.')"/>
                <xsl:if test="not(position()=last())">
                    <xsl:text>|</xsl:text>
                </xsl:if>
            </xsl:for-each>
            <xsl:text>)</xsl:text>
        </xsl:variable>
        <!-- Temporary split token. -->
        <xsl:variable name="lbMarker" select="'£lb£'" visibility="public"/>
        
        <xsl:template match="*[@n='sn_16.030.000']">
            <!-- Building the element content. -->
            <xsl:copy>
                <xsl:copy-of select="@*"/>
                <note>
                    <list>
                        <xsl:for-each select="tokenize(string-join(hal:segmentEdu(.,', ')),$lbMarker)" expand-text="true">
                            <item>{.}</item>
                        </xsl:for-each>
                    </list>
                </note>
            </xsl:copy>
        </xsl:template>
        
        <xsl:function name="hal:segmentEdu">
            <xsl:param name="input"/>
            <xsl:param name="tokenizeOn" as="xs:string"/>
            <xsl:variable name="tokens" select="tokenize($input,$tokenizeOn)"/>
            <xsl:for-each select="$tokens" expand-text="true">
                <xsl:value-of select="."/>
                <xsl:variable name="currPos" select="position()"/>
                <xsl:variable name="upToNow" select="string-join($tokens[position() le $currPos])"/>
                <xsl:variable name="openingBracket" select="string-length($upToNow) - string-length(translate($upToNow, '(', ''))"/>
                <xsl:variable name="closingBracket" select="string-length($upToNow) - string-length(translate($upToNow, ')', ''))"/>
                <xsl:choose>
                    <!-- Case: next token after comma...
                        ...begins with a-z (case insensitive) and 
                        ...follows as many opened brackets as closed ones and 
                        ...is part of the initially created list of terms 
                    -->
                    <xsl:when test="matches($tokens[position()=$currPos+1],'^[a-z]','i') and 
                        $openingBracket=$closingBracket and 
                        matches($tokens[position()=$currPos+1],$parselist)">{$lbMarker}</xsl:when>
                    <!-- Otherwise print the tokenizing string unless it is the last token. -->
                    <xsl:otherwise>{if ($currPos=last()) then '' else $tokenizeOn}</xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
        </xsl:function>
        
    </xsl:stylesheet>

    mit einer Liste der Form

    <?xml version="1.0" encoding="UTF-8"?>
    <comma-led-terms>
       <term>"Dr.</term>
       <term>1-jähriger</term>
       <term>1718</term>
       <term>1722</term>
       <term>1727</term>
       <term>1728</term>
       <term>1730</term>
       <term>Advocat</term>
       <term>Advokatsexamen</term>
       <term>Akademie</term>
       <term>Akademisches</term>
       [etc]
    </comma-led-terms>

    Die Segmentierung ist mit diesem Ansatz viel besser:

    <education n="sn_16.030.000" hal:desc="korres_bildungsgang" instant="false">
        <note>
            <list>
                <item>Lateinschule Danzig</item>
                <item>Stud. philos., math., Physik Univ. Jena 1738-40 (u.a. bei Johann Ernst Schubert (1717-1774) u. Johann Peter Reusch (1691-1758))</item>
                <item>Stud. Rechts- und Staatswiss., Geschichte Univ. Halle 1740-41 (u.a. bei Johann Gottlieb Heineccius (1680-1751), Just Henning Böhmer (1674-1749), Johann Peter von Ludewig (1668-1743) u. Martin Schmeitzel (1679-1747))</item>
                <item>Stud. Jena 1741-42, imm. Univ. Leipzig 1742</item>
                <item>Mag. Leipzig 1746 (in absentia)</item>
                <item>Dr. iur. Göttingen 1762</item>
            </list>
        </note>
    </education>
    Edited by Peter Dängeli
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment