tei_tools

This file will become your README and also the index of your documentation.

Install

pip install tei_tools

How to use

See the documentation for full details of the API Client.

# !mkdir example
# !wget https://www.hi.u-tokyo.ac.jp/collection/degitalgallary/wakozukan/tei/data/main.xml -O example/main.xml 
input_path = "example/main.xml"
results = TeiTools.analyze(input_path)
# TeiTools.visualize(results)
results
{'teiHeader': {'fileDesc': {'none': 3},
  'titleStmt': {'none': 3},
  'title': {'none': 3},
  'publicationStmt': {'none': 3},
  'publisher': {'none': 3},
  'sourceDesc': {'none': 3},
  'listPerson': {'none': 3},
  'person': {'xml:id': 27},
  'persName': {'none': 27},
  'note': {'type': 81, 'subtype': 3, 'source': 3},
  'listPlace': {'none': 3},
  'place': {'xml:id': 15},
  'placeName': {'none': 15}},
 'text': {'body': {'none': 3},
  'div': {'type': 9, 'none': 6},
  'ab': {'style': 42, 'type': 45, 'xml:id': 45, 'none': 6},
  'lb': {'style': 42, 'none': 18},
  'seg': {'type': 69, 'xml:id': 69},
  'add': {'xml:id': 30},
  'note': {'target': 12, 'type': 12},
  'p': {'none': 18},
  'persName': {'corresp': 27},
  'name': {'type': 9, 'xml:id': 9},
  'placeName': {'corresp': 15}},
 'facsimile': {'surface': {'source': 3},
  'zone': {'xml:id': 42, 'ulx': 42, 'uly': 42, 'lrx': 42, 'lry': 42}}}

Wordタグの付与

XMLファイルに含まれる文字列に対して、wタグを付与します。

input_path = "example/main.xml"
results = TeiTools.addWordElement(input_path)
TeiTools.save("example/main_with_word.xml", results)