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.10.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.10-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for iuextract-1.0.10.tar.gz
Algorithm Hash digest
SHA256 e2ecaaa5738abb400e3bf6f04592c152e2af326fe4126547d642ea70d4c68f56
MD5 8883d59591319d524e64c4b36e670218
BLAKE2b-256 29f424e3f4f34300fb895a7b8a7b3771ace65af413a10e8f28aa59b525375ace

See more details on using hashes here.

File details

Details for the file iuextract-1.0.10-py3-none-any.whl.

File metadata

  • Download URL: iuextract-1.0.10-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for iuextract-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 5b3e78e2a34e25e49c589212fcaec91e7de71a97502e02046f66dff7657931c9
MD5 8b6ef83240e37fea5a610e8b2151fb0f
BLAKE2b-256 a7d2cdeb889a0c314b5ce00a9723692e8c109ef67f05306e553d3768a88513a5

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