An experimental diff library for generating operation deltas that represent the difference between two sequences of comparable items.
Project description
Deltas
======
An open licensed (MIT) library for performing generating deltas (A.K.A sequences
of operations) representing the difference between two sequences of comparable
tokens.
* **Installation:** **TODO**
* **Repo**: `http://github.com/halfak/Deltas`_
* **Documentation**: `http://pythonhosted.org/deltas/`_
* Note this library requires Python 3.3 or newer
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 ' ' ''
======
An open licensed (MIT) library for performing generating deltas (A.K.A sequences
of operations) representing the difference between two sequences of comparable
tokens.
* **Installation:** **TODO**
* **Repo**: `http://github.com/halfak/Deltas`_
* **Documentation**: `http://pythonhosted.org/deltas/`_
* Note this library requires Python 3.3 or newer
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
deltas-0.3.1.zip
(27.6 kB
view details)
deltas-0.3.1.tar.gz
(15.8 kB
view details)
File details
Details for the file deltas-0.3.1.zip
.
File metadata
- Download URL: deltas-0.3.1.zip
- Upload date:
- Size: 27.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1177088186e06da7ceda412d5bc8fcd89f9d539f96a3906940fce893d8b67fd |
|
MD5 | cd5400a7e7632ee5fb1ef02989b3c6ca |
|
BLAKE2b-256 | 654922160b7015d357f9222975e8c4b46203e1357e32df3f3a73defc77e391b3 |
File details
Details for the file deltas-0.3.1.tar.gz
.
File metadata
- Download URL: deltas-0.3.1.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ca189779e0e4113df78c6301274550dc9c683e7ee70961e277247d083942d46 |
|
MD5 | 3f0c94099b32adaf2ff5a4e5860de5d3 |
|
BLAKE2b-256 | cd9ad6514a8688226e577e943016d59f086dd4ea62f076067179ccc5915e0afe |