TEI阅读器

tei-reader的Python项目详细描述


Build Status

python 3库,用于读取tei p5(lite)文件的文本内容和元数据

库的重点是从文件中提取主文本内容,并提供有关文本的可用元数据。

tl;dr

pip install tei-reader
fromtei_readerimportTeiReaderreader=TeiReader()corpora=reader.read_file('example-tei.xml')# or read_stringprint(corpora.text)# show element attributes before the actual element textprint(corpora.tostring(lambdax,text:str(list(a.key+'='+a.textforainx.attributes))+text))

更多说明

可以使用TeiReader()打开读卡器。然后可以调用read_file(file_name)read_string(str)。两者都将返回包含以下属性的Corpora对象:

PropertyDescription
^{}A corpora can contain sub-corpora.
^{}The ^{} objects directly part of this corpora.

CorporaDocument都继承自Element。在由此派生的所有对象中,都可以调用:

PropertyDescription
^{}Contain attributes applicable to this element. If an attribute contains attributes these are also returned. (e.g. ^{})
^{}Get the entire text content as ^{}
^{}Recursively get all the text divisions in document order. If an element contains parts or text without tag. Those will be returned in order and wrapped with a ^{}.
^{}Recursively get the parts in document order constituting the entire text e.g. if something has emphasis, a footnote or is marked as foreign. Text without a container element will be returned in order and wrapped with a ^{}.

AttributePlaceholderDivisionPlaceholderPart都支持与Element相同的属性。

上传到pypi

python setup.py sdist
twine upload dist/*

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在sqlite数据库中保存特定列的历史记录   java如何更改/更新timeseriechart名称(JFreeChart)   java如何将整数转换为可绘制的   汇编什么解释Java的字节码   java查找已编译的类版本号   我应该什么时候在ColdFusion应用程序中使用Java?   java当一个实体的两个字段为(unique=true)时,如何处理JPA异常?   java为什么在所有其他实例都正确的情况下返回错误的布尔值?   java Hibernate每次都准备语句   java停留在平均字长上   对Java和日语字符进行编码   java如何将导致异常的方法的错误消息传递给侦听器中的onTestFailure方法   java代码没有打印结果   java为什么私有内部接口的方法必须是公共的?   休眠发生错误。有关详细信息,请参阅错误日志。JAVAlang.NullPointerException