Sequitur algorithm for inferring hierarchies
Project description
SciKit Sequitur is an Apache2 licensed Python module for inferring compositional hierarchies from sequences.
Sequitur detects repetition and factors it out by forming rules in a grammar. The rules can be composed of non-terminals, giving rise to a hierarchy. It is useful for recognizing lexical structure in strings, and excels at very long sequences. The Sequitur algorithm was originally developed by Craig Nevill-Manning and Ian Witten.
>>> from sksequitur import Parser
>>> parser = Parser()
>>> parser.parse('hello hello')
>>> print(parser.grammar())
0 -> 1 _ 1
1 -> hello
SciKit Sequitur works on strings, lines, or any sequence of Python objects.
Features
Pure-Python
Developed on Python 3.8
Tested on CPython 3.6, 3.7, 3.8
Tested using GitHub Actions on Linux, Mac, and Windows
Quickstart
Installing scikit-sequitur is simple with pip:
$ pip install scikit-sequitur
You can access documentation in the interpreter with Python’s built-in help function:
>>> import sksequitur
>>> help(sksequitur) # doctest: +SKIP
Tutorial
The scikit-sequitur module provides utilities for parsing and interacting with grammars.
>>> from sksequitur import Parser
>>> parser = Parser()
>>> parser.parse('hello hello')
>>> print(parser.grammar())
0 → 1 ␣ 1
1 → hello
Reference
License
Copyright 2020 Grant Jenks
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
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
Built Distribution
File details
Details for the file scikit-sequitur-0.0.2.tar.gz
.
File metadata
- Download URL: scikit-sequitur-0.0.2.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3004ab85f859a95fffaee07d2eb465707dadccf2413cd5f6b344582a52a25a58 |
|
MD5 | 8b0c534d558acd4e5507af0ee14592ea |
|
BLAKE2b-256 | 8dd4e31e6659dd55f714e3827e051505e4c8dee616f0518739a0c9d75394e144 |
File details
Details for the file scikit_sequitur-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: scikit_sequitur-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 150f3d4914b2da435a406b535428e5104181ee4174d0a7d6c4cd1dd726301d33 |
|
MD5 | 613fb58c324f59d814e2f6b7d8cdda15 |
|
BLAKE2b-256 | aca4e84f129dae958911ca8ed2218053670bd47e6d909a579c09b1e105688dc9 |