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.3.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

KPCommons-0.0.3-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kpcommons-0.0.3.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for kpcommons-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f4b03f963950e1c1d725c28a341f1a944aecdbe8dbfd4665dbe434ac151c38f6
MD5 13c1f0e2663cd0b5500f7762806c00bd
BLAKE2b-256 c743dbd53ec6286460c50fd761468d8ae124d06400c6b66028f4c55fd0547b07

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KPCommons-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for KPCommons-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 175528acb4e6d98a4becd6dfda35c85cf79d8907ca6d8746bbb8922c9a602c2d
MD5 6796f8d3b7279baa218d7233e71d0dc6
BLAKE2b-256 9d175b5a1f73f3ca14641b51c4aefcaf563910384d86bea0e3e538474dd8b14a

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