Skip to main content

Transfer annotations from source text to destination using diff match patch.

Project description

antx - Annotation Transfer

Transfer annotations from source text to destination using diff match patch.

Test PyPI version

Usage

Install using pip.

$ pip install antx

Import

from antx import transfer

Transfer

new_target = transfer(source_text, annotations, target_text, output="txt")

source_text := contains source text

annotations := contains list of annotations in source text that you want to transfer to target text

target_text := contains target text

output := Flag to indicate type of output. It can be txt or yaml.

Example

source_text =  """༄༅། །ཕྱག་ཆེན་སྔོན་འགྲོ་བཞི་སྦྱོར་དང་དངོས་གཞིའི་ཁྲིད་རིམ་མདོར་བསྡུས་ངེས་དོན་སྒྲོན་མེ་ཞེས་བྱ་བ་བཞུགས་སོ། །
<𰵀auམཛད་པ་པོ། འཇམ་མགོན་ཀོང་སྤྲུལ་བློ་གྲོས་མཐའ་ཡས། །>
༄༅། །ཕྱག་ཆེན་སྔོན་འགྲོ་བཞི་སྦྱོར་དང་དངོས་གཞིའི་ཁྲིད་རིམ་མདོར་བསྡུས་ངེས་དོན་སྒྲོན་མེ་ཞེས་བྱ་བ་བཞུགས་སོ། །
""
target_text =  """༄༅། །ཕྱག་ཆེན་སྔོན་འགྲོ་བཞི་སྦྱོར་དང་དངོས་གཞིའི་ཁྲིད་རིམ་མདོར་བསྡུས་ངེས་དོན་སྒྲོན་མེ་ཞེས་བྱ་བ་བཞུགས་སོ། །
མཛད་པ་པོ། འཇམ་མགོན་ཀོང་སྤྲུལ་བློ་གྲོས་མཐའ་ཡས། །
༄༅། །ཕྱག་ཆེན་སྔོན་འགྲོ་བཞི་སྦྱོར་དང་དངོས་གཞིའི་ཁྲིད་རིམ་མདོར་བསྡུས་ངེས་དོན་སྒྲོན་མེ་ཞེས་བྱ་བ་བཞུགས་སོ། །
༄༅། །གྲུབ་བརྒྱའི་སྤྱི་མེས་མར་མི་དྭགས་གསུམ་ནས། །དཔལ་ལྡན་དུས་གསུམ་མཁྱེན་པའི་བཀའ་བརྒྱུད་ནི།
"""
annotations = [['author_start', r"(\<[𰵀-󴉱]?au)"], ['author_end', r"(\>)"]]
result = transfer(src, annotations, trg, output="txt")

Annotation transfer started...
Mapping annotations to tofu-IDs
[INFO] Computing diffs ...
[INFO] Diff computed!
Transfering annotations...
print(result)
༄༅། ཕྱགཆེནསྔོནའགྲོབཞིསྦྱོརདངདངོསགཞིའིཁྲིདརིམམདོརབསྡུསངེསདོནསྒྲོནམེཞེསབྱབཞུགསསོ 
<𰵀auམཛདཔོ འཇམམགོནཀོངསྤྲུལབློགྲོསམཐའཡས >
༄༅། ཕྱགཆེནསྔོནའགྲོབཞིསྦྱོརདངདངོསགཞིའིཁྲིདརིམམདོརབསྡུསངེསདོནསྒྲོནམེཞེསབྱབཞུགསསོ 
༄༅། གྲུབབརྒྱའིསྤྱིམེསམརམིདྭགསགསུམནས དཔལལྡནདུསགསུམམཁྱེནཔའིབཀའབརྒྱུདནི

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

antx-0.1.11.tar.gz (9.5 kB view hashes)

Uploaded Source

Built Distribution

antx-0.1.11-py3-none-any.whl (10.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page