Skip to main content

Rule-based Idea Unit segmentation algorithm for the English language.

Project description

IUExtract

Rule-based Idea Unit segmentation algorithm for the English language.

Example Segmentation

My dog, Chippy, just won its first grooming competition.

Will be segmented into the following Idea Units:

D1|My dog,
2|Chippy,
D1|just won its first grooming competition.

Each line denotes a segment. At the beginning of each line there is an Idea Unit index. Each Unit is assigned an index in sequential order. Discontinuous Units are prefixed by the character "D". Naturally, these indexes can be found on multiple lines and the complete Idea Unit can be obtained by joining the lines with the same index.

Installation

Installation as standalone executable via pipx

To install the package as a command line tool first install pipx. Specific instructions for your operative system can be found here. If you have python installed, you can install pipx with the following commands:

python3 -m pip install -U pipx
python3 -m pipx ensurepath

After pipx is installed, you can install IUExtract with the following command:

pipx install iuextract

If the install fails you might want to try to pin a specific python version with the following command:

pipx install iuextract --python 3.9

Note: on first run, the program will download the Spacy model en_core_web_lg. This could take some time. A custom Spacy model can be selected if you install iuextract as a python module.

Installation as a python module

If you want to use IUExtract in your python projects you will need to install it as a regular python module. First of all, you need to install the dependencies:

pip install spacy
python -m spacy download en_core_web_lg

You can then install IUExtract.

pip install iuextract

Command Line Interface (CLI) Usage

Once installed via pipx, you can run iuextract directly from the CLI.

Example:

iuextract My dog, Chippy, just won its first grooming competition.

will output

D1|My dog,
2|Chippy,
D1|just won its first grooming competition.

If you installed iuextract as a python module, you can still run the program via CLI with the following command:

python -m iuextract My dog, Chippy, just won its first grooming competition.

Note: When running from CLI, all positional arguments are grouped into a single string and parsed as input text. If you need to use named arguments put them before the input text or use the -i argument to parse a file as input.

Input text from file

You can run iuextract with the -i argument to parse a file. For example

iuextract -i input_file.txt

will read input_file.txt from the working directory and output the segmentation to the console.

Output file

You can specify an output file with the -o parameter.

iuextract -i input_file.txt -o output_file.txt

This command will segment input_file.txt and put the resulting segmentation into output_file.txt.

Additional arguments

For additional arguments, such as specifying the separator between the IUs and the index, you can call iuextract with the help argument and get a list of possible arguments.

iuextract -h

Usage as module

Simple text segmentation:

from iuextract.extract import segment_ius

text = "My dog, Chippy, just won its first grooming competition."
print(segment_ius(text, mode='str'))
D1|My dog, 
2|Chippy, 
D1|just won its first grooming competition.

For more examples check example.ipynb

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

iuextract-1.0.9.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

IUExtract-1.0.9-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file iuextract-1.0.9.tar.gz.

File metadata

  • Download URL: iuextract-1.0.9.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.13

File hashes

Hashes for iuextract-1.0.9.tar.gz
Algorithm Hash digest
SHA256 64aa861f5d605529a6d5bf8c7906d91a7ade2f3f90218e310fe164db36d3590c
MD5 0a320575370d90c12414857983a88a16
BLAKE2b-256 e2355aeb80780bb2ab431945a830c0e2515eee5af3f54ef7d3c1f28625406358

See more details on using hashes here.

File details

Details for the file IUExtract-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: IUExtract-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.13

File hashes

Hashes for IUExtract-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 23dca720ff59b7b67f6f49b22c6489b6c412cc922a5317801210a107cd9f4f0d
MD5 0a0f3368deb58a3c4e248acd55561c54
BLAKE2b-256 19d75800630cc45c9ef94b1b943f1e4269aac0f528f95632f1d55da304aeeb21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page