GithubHelp home page GithubHelp logo

eric-seekas / python-ngram Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gpoulter/python-ngram

0.0 1.0 0.0 215 KB

Set that supports searching by ngram similarity

License: GNU Lesser General Public License v3.0

Python 100.00%

python-ngram's Introduction

The NGram class extends the Python 'set' class with efficient fuzzy search for members by means of an N-gram similarity measure. It also has static methods to compare a pair of strings.

The N-grams are character based not word-based, and the class does not implement a language model, merely searching for members by string similarity.

The documentation, tutorial and release notes are on the PyPI package documentation site. Please use the GitHub issue tracker to report issues.

Installation

Install python-ngram from PyPI using pip installer:

pip install ngram

It should run on Python 2.6, Python 2.7 and Python 3.6

How does it work?

The set stores arbitrary items, but for non-string items a key function (such as str) must be specified to provide a string represenation. The key function can also be used to normalise string items (e.g. lower-casing) prior to N-gram indexing.

To index a string it pads the string with a specified dummy character, then splits it into overlapping substrings of N (default N=3) characters in length and associates each N-gram to the items that use it.

To find items similar to a query string, it splits the query into N-grams, collects all items sharing at least one N-gram with the query, and ranks the items by score based on the ratio of shared to unshared N-grams between strings.

History

In 2007, Michel Albert (exhuma) wrote the python-ngram module based on Perl's String::Trigram module by Tarek Ahmed, and committed the code for 2.0.0b2 to a now-disused Sourceforge subversion repo.

Since late 2008, Graham Poulter has maintained python-ngram, initially refactoring it to build on the set class, and also adding features, documentation, tests, performance improvements and Python 3 support.

Primary development takes place on GitHub, but changes are also pushed to the earlier repo on Google Code.

python-ngram's People

Contributors

gpoulter avatar exhuma avatar esbullington avatar tirkarthi avatar humburg avatar shaneikennedy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.