Skip to main content

seqsim

PyPI CI Documentation Status

Python library for computing measures of distance and similarity for sequences of hashable data types.

scriptorium

While developed as a general-purpose library, seqsim is mostly designed for usage in research within the field of cultural evolution, and particularly of the cultural evolution of textual traditions. Some methods act as a thin-wrapper to either the standard Python library or of to other libraries such as textdistance.

Installation

In any standard Python environment, seqsim can be installed with:

$ pip install seqsim

Usage

The library offers different methods to compare sequences of arbitrary hashable elements. It is possible to mix sequence and element types.

Full documentation is offered at ReadTheDocs and code with almost complete coverage is offered in the tests. For most common usages, a wrapper .distance() function can be used.

>>> import seqsim
>>> seqsim.edit.levenshtein_dist("kitten", "string")
5
>>> seqsim.edit.levenshtein_dist("kitten", "string", normal=True)
>>> 0.8333333333333334
>>> seqsim.sequence.ratcliff_obershelp([1,2,3,4], [2,4,3,5])
0.5
>>> seqsim.compression.entropy_ncd([1,2,3,4], [2,4,3,5])
0.08333333333333333

Demonstration

The core of the library are the metrics for sequence distance/similarity on arbitrary data types, as in the table below.

Method "kitten" / "sitting" (1, 2, 3, 4) / (3, 4, 2, 1)
arith_ncd 1.25 0.888889
arith_ncd_normal 1.25 0.888889
birnbaum 0.666667 0.7
birnbaum_normal 0.666667 0.7
birnbaum_simil 7 3
birnbaum_simil_normal 0.25 0.3
bulk_delete 3 3
bulk_delete_normal 0.428571 0.75
damerau 3 4
damerau_normal 0.428571 1
entropy 0.101341 0
entropy_normal 0.101341 0
fragile_ends_simil 3 3.5
fragile_ends_simil_normal 0.5 1
jaccard 0.7 0
jaccard_normal 0.7 0
jaro 0.253968 0.5
jaro_normal 0.253968 0.5
jaro_winkler 0.253968 0.5
jaro_winkler_normal 0.253968 0.5
levenshtein 3 4
levenshtein_normal 0.428571 1
mmcwpa 0.538462 0.387628
mmcwpa_normal 0.538462 0.387628
ratcliff_obershelp 0.384615 0.5
ratcliff_obershelp_normal 0.384615 0.5
sorensen 0.384615 0
sorensen_normal 0.384615 0
stemmatological_simil 3 3
stemmatological_simil_normal 0.428571 0.75
subseq_jaccard 0.751556 0.547008
subseq_jaccard_normal 0.751556 0.547008

Changelog

Version 0.3.1:

  • Fixed bug due to typo in one of the methods
  • Selected one Birnbaum implementation

Version 0.3:

  • Improvements to code quality, documentation, and references
  • Added new methods and scaffolding for future expansions

Version 0.2:

  • First release for new roadmap supporting sequences of any hashable Python datatype, importing code from other projects (mostly from titivillus)

Community guidelines

While the authors can be contacted directly for support, it is recommended that third parties use GitHub standard features, such as issues and pull requests, to contribute, report problems, or seek support.

Contributing guidelines, including a code of conduct, can be found in the CONTRIBUTING.md file.

Authors and citation

The library is developed in the context of "Cultural Evolution of Text", project, with funding from the Riksbankens Jubileumsfond (grant agreement ID: MXM19-1087:1).

If you use seqsim, please cite it as:

Tresoldi, Tiago; Maurits, Luke; Dunn, Michael. (2021). seqsim, a library for computing measures of distance and similarity for sequences of hashable data types. Version 0.3.2. Uppsala: Uppsala universitet. Available at: https://github.com/evotext/seqsim

In BibTeX:

@misc{Tresoldi2021seqsim,
  author = {Tresoldi, Tiago; Maurits, Luke; Dunn, Michael},
  title = {seqsim, a library for computing measures of distance and similarity for sequences of hashable data types. Version 0.3.2},
  howpublished = {\url{https://github.com/evotext/seqsim}},
  address = {Uppsala},
  publisher = {Uppsala universitet},
  year = {2021},
}

References

The image at the top of this file is derived from Yves de Saint-Denis, Vie et martyre de saint Denis et de ses compagnons, versions latine et française. It is available in high resolution from Bibliothèque nationale de France, Département des Manuscrits, Français 2090, fol. 12v.

References to the various implementation are available in the source code comments and in the online documentation.

Metadata

Release files for seqsim 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for seqsim 0.3.2
File Size Uploaded
seqsim-0.3.2.tar.gz 22.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for seqsim 0.3.2
File Interpreter ABI Platform
seqsim-0.3.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 45.5 kB

Release files / seqsim-0.3.2.tar.gz

Download URL seqsim-0.3.2.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dccd4849443421b32160f95ba8e7c0d33029d1e029420e72e9018b7b92602297
BLAKE2b-256 checksum
How to use checksums
08599299bb47a6b6b93a4efe2732081033892da19579e1916dbc02fe380fee59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.6

Release files / seqsim-0.3.2-py2.py3-none-any.whl

Download URL seqsim-0.3.2-py2.py3-none-any.whl
Size 23.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
cbb4105dd4027730c59a561e7b63893bb636f632a827b3297246cc104ee58521
BLAKE2b-256 checksum
How to use checksums
ea8cf5c69f77226e7097cec002bf3b49ad133c6cf5b9fc7913eedce67ec0a582
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.6

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3

2 release files

0.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page