This is the workbook associated to a test run to build LFT Text-Fabric using the XML import function of Text-Fabric.
Example code.
Documentation: tf.convert.xml
import os
from tf.convert.xml import XML
dn = os.path.abspath('')
TEST_SET = set(
"""
26-jude.xml
""".strip().split()
)
AUTHOR = "Evangelists and apostles"
TITLE = "Greek New Testament"
INSTITUTE = "ETCBC (Eep Talstra Centre for Bible and Computer)"
GENERIC = dict(
author=AUTHOR,
title=TITLE,
institute=INSTITUTE,
language="nl",
converters="Dirk Roorda et al. (Text-Fabric)",
sourceFormat="XML (lowfat)",
descriptionTf="Nestle 1904 edition",
)
def task(self, check=False, convert=False, load=False, test=True):
return
def transform(text):
print (text)
return text
X = XML(
sourceVersion="input_xml",
testSet=TEST_SET,
generic=GENERIC,
transform=transform,
tfVersion="0.1",
)
#X.run(os.path.abspath(''))
X.run(__file__)
Working in repository Read_from_lowfat/. in backend my_new_Jupyter_folder Convert XML to TF. There are also commands to check the XML and to load the TF. python3 C:/Users/tonyj/my_new_Jupyter_folder/Read_from_lowfat [tasks/flags] [--help] --help: show this text and exit tasks: a sequence of tasks: check: just reports on the elements in the source. convert: just converts XML to TF load: just loads the generated TF; flags: test: run in test mode Illegal argument `-f` Illegal argument `C:/Users/tonyj/AppData/Roaming/jupyter/runtime/kernel-0061e8fa-12fe-4856-a035-9fe8ffb4894a.json`
An exception has occurred, use %tb to see the full traceback. SystemExit: -1
%tb
--------------------------------------------------------------------------- SystemExit Traceback (most recent call last) Input In [16], in <cell line: 42>() 31 return text 34 X = XML( 35 sourceVersion="input_xml", 36 testSet=TEST_SET, (...) 39 tfVersion="0.1", 40 ) ---> 42 X.run(os.path.abspath('')) File ~\anaconda3\lib\site-packages\tf\convert\xml.py:1026, in XML.run(self, program) 1024 for arg in illegalArgs: 1025 console(f"Illegal argument `{arg}`") -> 1026 sys.exit(-1) 1028 tasks = {arg: True for arg in args if arg in possibleTasks} 1029 flags = {arg: True for arg in args if arg in possibleFlags} SystemExit: -1
! python3 Read_from_lowfat [tasks/flags] [--help]
python3: can't open file 'C:\\Users\\tonyj\\my_new_Jupyter_folder\\Read_from_lowfat\\Read_from_lowfat': [Errno 2] No such file or directory