Skip to main content

A collection of reusable methods.

Project description

Readme

KPCommons is a collection of methods which are regularly needed.

Util

Util.py contains the following methods:

  • calculate_overlap is a method to calculate the overlap between two ranges.

    overlap = Util.calculate_overlap(0, 10, 5, 10)
    

    would return a result of 5. The first two arguments are the start and end position of the first range, and the last two arguments are the positions of the second range.

    Note: In case of no overlap, the distance between the two ranges is returned as a negative result.

  • calculate_overlap_ratios is a method to calculate the overlap ratios of two ranges.

    ratio_1, ratio_2 = Util.calculate_overlap_ratio(0, 10, 5, 10)
    

Footnote

Footnote.py contains a collection of methods for working with footnotes.

  • get_footnotes_ranges takes a text and returns two list of tuples of start and end character positions of footnote ranges, that is, text surrounded by '[[[' and ']]]'. The first list is without an offset, that is, the actual positions, and the second list is with an offset, that is, as if the footnotes were removed.
  • get_footnote_ranges_without_offset and get_footnote_ranges_with_offset are variants of get_footnotes_ranges which only return one of the lists.
  • is_position_in_ranges checks if a position is in one of the ranges.
  • is_range_in_ranges checks if a range given by a start and end position overlaps with one of the given ranges.
  • remove_footnotes removes footnotes from a text. Footnotes are marked by '[[[' and ']]]'.
  • map_to_real_pos maps start and end character positions of a text with footnotes removed to real positions, that is, positions before footnotes where removed.

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

kpcommons-0.0.5.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

KPCommons-0.0.5-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file kpcommons-0.0.5.tar.gz.

File metadata

  • Download URL: kpcommons-0.0.5.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for kpcommons-0.0.5.tar.gz
Algorithm Hash digest
SHA256 0c0732abbc60824753ebf91555f0f9e51c9542ad81546224bd7e068d9f946d4f
MD5 12a60a38fee19f526a4e4a96a7a44276
BLAKE2b-256 9a187c83ba98e6f6282d385933c8e0d9f2769380b186f59e1352cad6c8be9c4d

See more details on using hashes here.

File details

Details for the file KPCommons-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: KPCommons-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for KPCommons-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 44560d1ae1394aca2665cc83a45c6c929bf99130bbb160e9aad392900c5f7447
MD5 72dc3d26757a08434c499b68d83c4956
BLAKE2b-256 674e393c753267379394fe54fc2d047ec8d62b245555abe2d64c7505fe63aade

See more details on using hashes here.

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