Skip to content
Snippets Groups Projects
Commit 2012244c authored by Christian Boulanger's avatar Christian Boulanger
Browse files

Merge remote-tracking branch 'gwdg/main'

parents 9d74d363 48cb0887
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:cb631197c03a0768 tags:
# Convert AnyStyle training files to the Prodigy format
Converter functions written by GPT-4, see https://chat.openai.com/share/3f42ae1d-3066-4563-944d-3139b5e1e867
%% Cell type:markdown id:83bfc356ce72fe51 tags:
## Parser files
%% Cell type:code id:initial_id tags:
``` python
import xml.etree.ElementTree as ET
import json
def xml_to_jsonl(input_xml_path, output_jsonl_path):
tree = ET.parse(input_xml_path)
root = tree.getroot()
with open(output_jsonl_path, 'w', encoding='utf-8') as f:
for sequence in root.findall('sequence'):
text = ''
spans = []
current_pos = 0
for element in sequence:
content = (element.text or '').strip() + ' ' # Append a space for separation
if content:
start = current_pos
end = start + len(content) - 1 # Subtract 1 to account for the space added
spans.append({'start': start, 'end': end, 'label': element.tag})
text += content
current_pos = end + 1 # Move current position to right after the last character
# Store the reconstructed sequence and its spans in a dictionary
entry = {'text': text.strip(), 'spans': spans}
# Write the JSON formatted string to the file, ending with a newline
f.write(json.dumps(entry) + '\n')
```
%% Cell type:code id:fa9f2c194697a6b7 tags:
``` python
from pathlib import Path
for filename in [file.stem for file in Path('in').glob('*.xml')]:
xml_to_jsonl(f'in/{filename}.xml', f'out/{filename}-parser.jsonl')
```
%% Cell type:markdown id:2988615a1be96bb tags:
## Finder files
%% Cell type:code id:7764c66e149abd4f tags:
``` python
import json
def markup_to_jsonl(input_path, output_jsonl_path, break_tags_before=None, break_tags_after=None):
if break_tags_before is None:
break_tags_before = []
if break_tags_after is None:
break_tags_after = []
# Helper function to write blocks to JSONL, now takes a file handle
def write_block(full_text, spans, file_handle):
if full_text.strip(): # Ensure there's content to write
result = {
'text': full_text.rstrip(), # Remove trailing spaces
'spans': spans
}
file_handle.write(json.dumps(result) + '\n')
# Open the output file once at the beginning
with open(output_jsonl_path, 'w', encoding='utf-8') as f:
with open(input_path, 'r', encoding='utf-8') as file:
lines = file.readlines()
full_text = ''
spans = []
current_text = ''
text_start_pos = 0
current_tag = 'text' # Default initial tag
# Iterate through lines
for line in lines:
parts = line.strip().split('|', 1)
if len(parts) < 2:
continue
tag = parts[0].strip()
content = parts[1].strip()
if tag in break_tags_before:
# Finish the current text block before starting new due to break tag
if current_text:
full_text += current_text
spans.append({
'start': text_start_pos,
'end': text_start_pos + len(current_text),
'label': current_tag
})
write_block(full_text, spans, f)
full_text, spans, current_text = '', [], ''
current_tag = tag # Update to the new tag
text_start_pos = len(full_text)
# Append content with maintaining line break if the previous content was not empty
current_text += content + '\n' if current_text else content
if tag:
if current_text and current_text != content: # Ensures not to add just processed content span
# Finish the current span
full_text += current_text
spans.append({
'start': text_start_pos,
'end': text_start_pos + len(current_text) - 1, # -1 to not count the last \n for span
'label': current_tag
})
current_text = content + '\n' # Start new text content under the new tag
current_tag = tag
text_start_pos = len(full_text)
if tag in break_tags_after:
# Finalize current text and write it due to break tag
full_text += current_text
spans.append({
'start': text_start_pos,
'end': text_start_pos + len(current_text) - 1, # -1 as above
'label': current_tag
})
current_text = ''
write_block(full_text, spans, f)
full_text, spans = '', []
# Final write for any remaining text
if current_text:
full_text += current_text
spans.append({
'start': text_start_pos,
'end': text_start_pos + len(current_text) - 1, # -1 to adjust for the last newline character
'label': current_tag
})
write_block(full_text, spans, f)
# Example usage:
# markup_to_jsonl('input_text.txt', 'output.jsonl', ['header'], ['footer'])
```
%% Cell type:markdown id:8923ed5011c1d65f tags:
Since the finder files have no information on page breaks, document segmentation is done using the `meta` tag, which is a very simple heuristic and probably fails in many cases.
%% Cell type:code id:2b0ca72bbf70c829 tags:
``` python
from pathlib import Path
for filename in [file.stem for file in Path('in').glob('*.xml')]:
markup_to_jsonl(f'in/{filename}.ttx', f'out/{filename}-finder.jsonl', break_tags_before=['meta'])
```
%% Cell type:code id:46d7e63e53b441e3 tags:
``` python
```
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<dataset>
<sequence>
<citation-number>1</citation-number>
<author>Geiger</author>
<date>1964,</date>
<pages>insbesondere S. 65—83.</pages>
</sequence>
<sequence>
<citation-number>2</citation-number>
<signal>Vgl.</signal>
<author>Feest/Blankenburg,</author>
<date>1972.</date>
<signal>Die Konsequenz einer größeren Dunkelziffer bei den von der Polizei selbst entdeckten Straftaten entwickle ich ausführlicher in meinem Beitrag über </signal>
<title>,Nichtkriminalisierung als Struktur und Routine',</title>
<date>1976.</date>
</sequence>
<sequence>
<citation-number>3</citation-number>
<note>Angaben aus einer Befragung von Peter MacNaughton-Smith und Richard Rosellen zur</note>
<title>.Bereitschaft zur Anzeigeerstattung' </title>
<note>Manuskript</note>
<publisher> Max-Planck-Institut für Strafrecht,</publisher>
<location>Freiburg</location>
<date>1978.</date>
<signal>Der ausführliche Forschungsbericht von </signal>
<author>Richard Rosellen</author>
<note> erscheint in Kürze unter dem Titel</note>
<title>.Private Verbrechenskontrolle — eine empirische Untersuchung zur Anzeigeerstattung',</title>
<location>Berlin,</location>
<date>voraussichtlich 1980.</date>
</sequence>
<sequence>
<citation-number>4</citation-number>
<signal>Vgl.</signal>
<author>Blankenburg/Sessar/Steffen,</author>
<date>1978,</date>
<pages>S. 66-85.</pages>
</sequence>
<sequence>
<citation-number>5</citation-number>
<author>Black</author>
<date>1973,</date>
<pages>S. 125 ff.</pages>
</sequence>
<sequence>
<citation-number>6</citation-number>
<signal>Zur höheren Wahrscheinlichkeit der Normierung von Verhalten in weniger komplexen Beziehungen vgl. die Konflikttheorie von</signal>
<author>Gessner</author>
<date>1976,</date>
<pages>insbesondere S. 170—183.</pages>
</sequence>
<sequence>
<citation-number>7</citation-number>
<signal>Zum Konzept der .Thematisierung von Recht' vgl.</signal>
<journal>Luhmann</journal>
<date>1980,</date>
<pages>S. 99—112.</pages>
</sequence>
<sequence>
<citation-number>8</citation-number>
<signal>Ausführlicher bei</signal>
<author>Gessner</author>
<date>1976</date>
</sequence>
<sequence>
<citation-number>9</citation-number>
<signal>Vgl.</signal>
<author>Schönholz</author>
<date>1980.</date>
</sequence>
<sequence>
<citation-number>10</citation-number>
<author>Blankenburg/Schönholz; Rogowski</author>
<date>1979,</date>
<pages>S. 64 ff.</pages>
</sequence>
<sequence>
<citation-number>11</citation-number>
<author>Hilden</author>
<date>1976,</date>
<pages>S. 64 ff.</pages>
</sequence>
<sequence>
<citation-number>12</citation-number>
<author>Koch</author>
<date>1975,</date>
<pages>S. 75,</pages>
<note>der allerdings nur streitige Urteile und Vergleiche untersucht hat. </note>
</sequence>
<sequence>
<ignore>Mobilisierung von Recht 41</ignore>
</sequence>
<sequence>
<citation-number>13</citation-number>
<signal>Für Angaben der Zählkartenstatistik für die Familiengerichte siehe:</signal>
<author>Statistisches Bundesamt Wiesbaden,</author>
<title>Fachserie 10 (Rechtspflege) Reihe 2.1, Tabelle 10,</title>
<location>Wiesbaden</location>
<date>1978.</date>
</sequence>
<sequence>
<citation-number>14</citation-number>
<author>Blankenburg/Schönholz; Rogowski</author>
<date>1979,</date>
<pages>S. 78 ff.</pages>
</sequence>
<sequence>
<citation-number>15</citation-number>
<note>Steinbach 1979 hat in einer Erhebung von 1144 Amtsgerichtsprozessen in der Bundesrepublik ohne Berlin in den Jahren 1974—1976 ein Verhältnis von 1 Räumungsklage je 1,2 Forderungsklagen, in Berlin allerdings von 1 Räumungsklage je 0,12 Forderungsklagen ermittelt. Im folgenden auch als GMD-Erhebung zitiert.</note>
</sequence>
<sequence>
<citation-number>16</citation-number>
<author>Johnson</author>
<date>1979</date>
<note> berichtet von dem erfolgreichen Versuch einer Unfall-Schadensregulierung ohne Berücksichtigung einer Schuldzuschreibung in Neuseeland (no fault accident compensation),</note>
<pages>S. 90 ff.</pages>
</sequence>
<sequence>
<citation-number>17</citation-number>
<location>Steinbach</location>
<date>1979,</date>
<pages>S. 66 ff.;</pages>
<author>Blankenburg/Blankenburg/Morasch</author>
<date>1972,</date>
<pages>S. 82 ff.</pages>
</sequence>
<sequence>
<citation-number>18</citation-number>
<title>Projektbericht ,Rechtshilfebedürfnisse sozial Schwacher*,</title>
<author>(Blankenburg/Gorges/Reifner; Ticmann). </author>
<note>Befragt wurden im Januar bis März 1979 je eine Person in 835 Haushalten Westberlins. Veröffentlichung ist vorgesehen für Ende 1980. Quelle: Eigene Befragung in West-Berlin 1979, Zu falls auswähl aus allen Haushalten mit Deutschen. Mehrfachnennungen, % jeweils bezogen auf Personen, die im jeweiligen Bereich ein Problem nennen.</note>
</sequence>
<sequence>
<citation-number>19</citation-number>
<signal>Explizit bei</signal>
<author>Baumgärtei</author>
<date>1976,</date>
<pages>S. 113-128.</pages>
</sequence>
<sequence>
<citation-number>20</citation-number>
<note>Laut einer GMD-Erhebung aus der Zählkartenstatistik wurde in Baden-Württemberg 1978 in</note>
</sequence>
<sequence>
<citation-number>21</citation-number>
<signal>Projektbericht</signal>
<author>.Rechtsschutzversicherung* (Blankenburg; Fiedler),</author>
<title>Veröffentlichung voraussichtlich Mitte</title>
<date>1980.</date>
</sequence>
<sequence>
<citation-number>22</citation-number>
<signal>Vgl. auch</signal>
<author>Reifner/Gorges</author>
<date>1980.</date>
</sequence>
<sequence>
<citation-number>23</citation-number>
<author>Reifner</author>
<date>1979.</date>
</sequence>
<sequence>
<citation-number>24</citation-number>
<signal>Klassisch bei</signal>
<author>Carlin/Howard/Messinger</author>
<date>1967.</date>
</sequence>
<sequence>
<citation-number>25</citation-number>
<signal>Grundsätzlich vgl. hierzu den klassischen Beitrag von</signal>
<author>Galanter</author>
<date>1974,</date>
<pages>S. 95—160.</pages>
<note>Die grösseren Chancen von Firmen, insbesondere bei der großen Zahl von vorstreitigen Erledigungen zeigt </note>
<author>Sarat</author>
<date>1976,</date>
<pages>S. 339-375.</pages>
</sequence>
<sequence>
<citation-number>26</citation-number>
<author>Bender/Schumachcr</author>
<date>1980,</date>
<pages>S. 138.</pages>
</sequence>
<sequence>
<citation-number>2</citation-number>
<title>Eigene Erhebung,</title>
<location>Arbeitsgericht Berlin, Gerichtsregister</location>
<date>1976</date>
</sequence>
<sequence>
<citation-number>3</citation-number>
<author>Zählkarten-Statistik, Statist. Bundesamt:</author>
<title>Fachserie 10 (Rechtspflege), Reihe</title>
<volume>2, 1 (Zivilgerichte),</volume>
<date>1971 und 1978</date>
</sequence>
<sequence>
<citation-number>27</citation-number>
<location>Steinbach</location>
<date>1979,</date>
<pages>S. 96 ff,</pages>
<signal>vgl. auch</signal>
<author>Blankenburg/Blankenburg/Morasch</author>
<date>1972,</date>
<pages>S. 89, Fn. 17,</pages>
</sequence>
<sequence>
<citation-number>28</citation-number>
<author>Reifner</author>
<date>1978.</date>
</sequence>
<sequence>
<citation-number>29</citation-number>
<author>Blankenburg/Schönholz; Rogowski</author>
<date>1979,</date>
<pages>S. 102 ff.</pages>
</sequence>
<sequence>
<citation-number>30</citation-number>
<signal>Vgl. zum</signal>
<title>.Verrechtlichungs’begriff meinen Beitrag über: Recht als gradualisiertes Konzept</title>
<date>1980,</date>
<pages>S. 83—98.</pages>
</sequence>
<sequence>
<citation-number>31</citation-number>
<location>Steinbach</location>
<date>1979,</date>
<pages>S. 35;</pages>
<author>Bender/Schumacher</author>
<date>1980,</date>
<pages>S. 24 und S. 49.</pages>
</sequence>
<sequence>
<citation-number>32</citation-number>
<author>Wanner</author>
<date>1975,</date>
<pages>S. 293—306</pages>
<note>hebt dies deutlich hervor, ebenso Bender/Schumacher</note>
<date>1980, </date>
<pages>S. 72 ff.; </pages>
<signal>sowie</signal>
<author>Galanter</author>
<date>1974; </date>
<author>Sarat</author>
<date> 1976.</date>
</sequence>
<sequence>
<citation-number>33</citation-number>
<author>Blankenburg/Schönholz; Rogowski</author>
<date>1979,</date>
<pages>S. 78 ff.</pages>
</sequence>
<sequence>
<citation-number>34</citation-number>
<backref>Ebenda,</backref>
<pages>S. 138-186.</pages>
</sequence>
<sequence>
<citation-number>35</citation-number>
<author>Luhmann</author>
<date>1969.</date>
</sequence>
<sequence>
<citation-number>36</citation-number>
<signal>Für eine überaus positive Bewertung des .Vermeidens1 vgl.</signal>
<author>Felstiner und Danzig/Lowy</author>
<journal>in Law and Society Review,</journal>
<volume>vol. 9,</volume>
<date>1974/75.</date>
</sequence>
<sequence>
<author>Baumgärtei, Gottfried,</author>
<date>1976:</date>
<title>Gleicher Zugang zum Recht für alle.</title>
<location>Köln.</location>
</sequence>
<sequence>
<author>Bender, Rolf und Rolf Schumacher,</author>
<date>1980:</date>
<title>Erfolgsbarrieren vor Gericht. </title>
<location>Tübingen.</location>
<author>Black, Donald,</author>
<date>1973:</date>
<title>The Mobilization of Law,</title>
<journal>in: Journal of Legal Studies</journal>
<volume>2.</volume>
</sequence>
<sequence>
<author>Blankenburg, Erhard/Blankenburg, Viola/Morasch, Helmut,</author>
<date>1972:</date>
<title>Der lange Weg in die Berufung,</title>
<editor>in: Bender, Rolf (Hrsg.):</editor>
<container-title>Tatsachenforschung in der Justiz.</container-title>
<location>Tübingen.</location>
</sequence>
<sequence>
<author>Blankenburg, Erhard,</author>
<date>1976:</date>
<title>Nichtkriminalisierung als Struktur und Routine,</title>
<editor>in: Göppinger,</editor>
<title>Hans und Günter Kaiser: Kriminologie und Strafverfahren.</title>
<location>Stuttgart.</location>
</sequence>
<sequence>
<author>Blankenburg, Erhard/Sessar, Klaus/Steffen, Wiebke,</author>
<date>1978:</date>
<title>Die Staatsanwaltschaft im Prozeß strafrechtlicher Sozialkontrolle.</title>
<location>Berlin.</location>
</sequence>
<sequence>
<author>Blankenburg, Erhard; Schönholz, Siegfried, unter Mitarbeit von Ralf Rogowski,</author>
<date>1979:</date>
<title>Zur Soziologie des Arbeitsgerichtsverfahrens.</title>
<location>Neuwied und Darmstadt.</location>
</sequence>
<sequence>
<author>Blankenburg, Erhard,</author>
<date>1980:</date>
<title>Recht als gradualisiertes Konzept,</title>
<editor>in: Blankenburg, Erhard; Klausa, Ekkehard und Hubert Rottleuthner (Hrsg.):</editor>
<container-title>Alternative Rechtsformen und Alternativen zum Recht,</container-title>
<collection-title>Jahrbuch für Rechtssoziologie und Rechtstheorie</collection-title>
<volume>Bd. 6. Opladen.</volume>
</sequence>
<sequence>
<author>Carlin, Jerome-, Jan Howard und Sheldon Messinger,</author>
<date>1967:</date>
<title>Civil Justice and the Poor.</title>
<location>New York. Danzig, </location>
<author>Richard /Lowy, Michael,</author>
<date>1974/75;</date>
<title>Everday Disputes and Mediation in the United States: A Reply to Professor Felstiner,</title>
<journal>Law and Society Review,</journal>
<volume>vol. 9,</volume>
<pages>pp. 675—694.</pages>
</sequence>
<sequence>
<author>Feest, Johannes/Blankenburg, Erhard,</author>
<date>1972:</date>
<title>Die Definitionsmacht der Polizei.</title>
<location>Düsseldorf.</location>
</sequence>
<sequence>
<author>Felstiner, William L. F.,</author>
<date>1974/75:</date>
<title>Influences of Social Organization on Dispute processing,</title>
<journal>in: Law and Society Review,</journal>
<volume>vol. 9,</volume>
<pages>pp. 63—94.</pages>
</sequence>
<sequence>
<author>Felstiner, William L. F.,</author>
<date>1974/75:</date>
<title>Avoidance as Dispute Processing: An Elaboration,</title>
<journal>in: Law and Society Review,</journal>
<volume>vol. 9,</volume>
<pages>pp. 695-706.</pages>
</sequence>
<sequence>
<author>Galanter, Marc,</author>
<date>1974:</date>
<title>Why the ,Haves* Come out Ahead: Speculations on the Limits of Legal Change,</title>
<journal>in: Law and Society Review,</journal>
<volume>vol. 9,</volume>
<pages>pp. 95—160.</pages>
</sequence>
<sequence>
<author>Geiger, Theodor,</author>
<date>1964:</date>
<title>Vorstudien zu einer Soziologie des Rechts.</title>
<author>Neuwied. Gessner, Volkmar,</author>
<date>1976:</date>
<title>Recht und Konflikt.</title>
<location>Tübingen.</location>
</sequence>
<sequence>
<location>Hilden, Hartmut,</location>
<date>1976:</date>
<title>Rechtstatsachen im Räumungsstreit. Frankfurt/Main.</title>
</sequence>
<sequence>
<author>Johnson, Earl,</author>
<date>1979;</date>
<title>Thinking about Access: A Preliminary Typology of Possible Strategies.</title>
<editor>In: Cappelletti, Mauro und Bryant Garth (Hrsg.):</editor>
<container-title>Access to Justice,</container-title>
<volume>Bd. III.</volume>
<editor>Milan und Alphen/ Rijn.</editor>
</sequence>
<sequence>
<author>Koch, Hartmut,</author>
<date>1975:</date>
<title>Das Gerichtsverfahren als Konfliktlösungsprozeß — Einstellung von Klägern und Beklagten zu Mietprozessen.</title>
<location>Diss. Hamburg.</location>
</sequence>
<sequence>
<author>Luhmann, Niklas,</author>
<date>1969:</date>
<title>Legitimation durch Verfahren.</title>
<location>Neuwied und Darmstadt.</location>
</sequence>
<sequence>
<author>Luhmann, Niklas,</author>
<date>1980:</date>
<title>Kommunikation über Recht in Interaktionssystemen,</title>
<editor>in: Blankenburg, Erhard; Klausa, Ekkehard und Hubert Rottleuthner (Hrsg.):</editor>
<container-title>Alternative Rechtsformen und Alternativen zum Recht,</container-title>
<collection-title>Jahrbuch für Rechtssoziologie und Rechtstheorie</collection-title>
<volume>Bd. 6. Opladen.</volume>
</sequence>
<sequence>
<author>Reifner, Udo,</author>
<date>1978:</date>
<title>Rechtshilfebedürfnis und Verrechtlichung am Beispiel einer Berliner Mieterinitiative,</title>
<location>Wissenschaftszentrum Berlin,</location>
<pages>IIM-dp/78—70.</pages>
</sequence>
<sequence>
<author>Reifner, Udo,</author>
<date>1979:</date>
<title>Gewerkschaftlicher Rechtsschutz — Geschichte des freigewerkschaftlichen Rechtsschutzes und der Rechtsberatung der Deutschen Arbeitsfront von 1894—1945.</title>
<location>Wissenschaftszentrum Berlin</location>
<pages>IIM-dp/79—104.</pages>
</sequence>
<sequence>
<author>Reifner,</author>
<title>Udo und Irmela Gorges,</title>
<date>1980;</date>
<title>Alternativen der Rechtsberatung: Dienstleistung, Fürsorge und kollektive Selbsthilfe,</title>
<editor>in: Blankenburg, Erhard; Klausa, Ekkehard und Hubert Rottleuthner (Hrsg.):</editor>
<container-title>Alternative Rechtsformen und Alternativen zum Recht,</container-title>
<collection-title>Jahrbuch für Rechtssoziologie und Rechtstheorie</collection-title>
<volume>Bd. 6. Opladen.</volume>
</sequence>
<sequence>
<author>Sarat,</author>
<location>Austin,</location>
<date>1976:</date>
<title>Alternatives in Dispute Processing in a Small Claim Court,</title>
<journal>in: Law and Society Review,</journal>
<volume>vol. 10,</volume>
<pages>pp. 339—375.</pages>
</sequence>
<sequence>
<author>Schönholz, Siegfried,</author>
<date>1980:</date>
<title>Arbeitsplatzsicherung oder Kompensation - Rechtliche Formen des Bestandsschutzes im Vergleich</title>
<editor>in: Vereinigung für Rechtssoziologie (Hrsg.):</editor>
<container-title>Arbeitslosigkeit und Recht.</container-title>
<location>Baden-Baden.</location>
</sequence>
<sequence>
<author>Steinbach, E.,</author>
<date>1979:</date>
<title>GMD-Bericht, Manuskript. Gesellschaft für Mathematik und Datenverarbeitung.</title>
<location>Birlinghoven bei Bonn.</location>
</sequence>
<sequence>
<author>Wanner, Craig,</author>
<date>1975:</date>
<title>The Public Ordering of Private Cases; Winning Civil Court Cases,</title>
<journal>in: Law and Society Review,</journal>
<volume>vol. 9,</volume>
<pages>pp. 293-306.</pages>
</sequence>
</dataset>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment