Skip to main content

An experimental diff library for generating operation deltas that represent the difference between two sequences of comparable items.

Project description

An open licensed (MIT) library for performing generating deltas (A.K.A sequences of operations) representing the difference between two sequences of comparable tokens.

This library is intended to be used to make experimental difference detection strategies more easily available. There are currently two strategies available:

deltas.sequence_matcher.diff(a, b):

A shameless wrapper around difflib.SequenceMatcher to get it to work within the structure of deltas.

deltas.segment_matcher.diff(a, b, segmenter=None):

A generalized difference detector that is designed to detect block moves and copies based on the use of a Segmenter.

Example:
>>> from deltas import segment_matcher, text_split
>>>
>>> a = text_split.tokenize("This is some text.  This is some other text.")
>>> b = text_split.tokenize("This is some other text.  This is some text.")
>>> operations = segment_matcher.diff(a, b)
>>>
>>> for op in operations:
...     print(op.name, repr(''.join(a[op.a1:op.a2])),
...           repr(''.join(b[op.b1:op.b2])))
...
equal 'This is some other text.' 'This is some other text.'
insert ' ' '  '
equal 'This is some text.' 'This is some text.'
delete '  ' ''

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

deltas-0.3.7.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

deltas-0.3.7-py2.py3-none-any.whl (27.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file deltas-0.3.7.tar.gz.

File metadata

  • Download URL: deltas-0.3.7.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for deltas-0.3.7.tar.gz
Algorithm Hash digest
SHA256 5206c68eb7b4a0d8baf51097b7179ca4472e380ef84230b76dd58ba2e3cdd3c6
MD5 1c81f2614635ba774a91974a08c08281
BLAKE2b-256 805d9c954f2968ec220474a3f57477e4cba9c5a1c6454735fef8d9954db5ce11

See more details on using hashes here.

File details

Details for the file deltas-0.3.7-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for deltas-0.3.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 805d5dc60fba97bd8e1a4d367708456a0dc0327a40560128909d25c40d8d5981
MD5 5d17b9bb36eb445f2af90c68ab5c0d35
BLAKE2b-256 5151b2614aa3ae65fb328399acbbd5dc856b7b93ce3eafe1f36742219aaaea2e

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