Skip to main content

super fast cpp implementation of longest common subsequence

Project description

pylcs

pylcs is a super fast c++ library which adopts dynamic programming(DP) algorithm to solve two classic LCS problems as below .

The longest common subsequence problem is the problem of finding the longest subsequence common to all sequences in a set of sequences (often just two sequences).

The longest common substring problem is to find the longest string (or strings) that is a substring (or are substrings) of two or more strings.

Levenshtein distance, aka edit distance is also supported. Emm...forget the package name. Example usage is in tests.

We also support Chinese(or any UTF-8) string.

Install

To install, simply do pip install pylcs to pull down the latest version from PyPI.

Python code example

import pylcs

#  finding the longest common subsequence length of string A and string B
A = 'We are shannonai'
B = 'We like shannonai'
pylcs.lcs(A, B)
"""
>>> pylcs.lcs(A, B)
14
"""

#  finding the longest common subsequence length of string A and a list of string B
A = 'We are shannonai'
B = ['We like shannonai', 'We work in shannonai', 'We are not shannonai']
pylcs.lcs_of_list(A, B)
"""
>>> pylcs.lcs_of_list(A, B)
[14, 14, 16]
"""

# finding the longest common substring length of string A and string B
A = 'We are shannonai'
B = 'We like shannonai'
pylcs.lcs2(A, B)
"""
>>> pylcs.lcs2(A, B)
11
"""

#  finding the longest common substring length of string A and a list of string B
A = 'We are shannonai'
B = ['We like shannonai', 'We work in shannonai', 'We are not shannonai']
pylcs.lcs2_of_list(A, B)
"""
>>> pylcs.lcs2_of_list(A, B)
[11, 10, 10]
"""

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pylcs, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size pylcs-0.0.6-cp36-cp36m-macosx_10_9_x86_64.whl (48.7 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pylcs-0.0.6.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page