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

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
segment_ius(text, mode='str')

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.7.tar.gz (17.4 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.7-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: iuextract-1.0.7.tar.gz
  • Upload date:
  • Size: 17.4 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.7.tar.gz
Algorithm Hash digest
SHA256 f86331518626eb4614e681454f10c15b992da513b342b6f823647144103b542d
MD5 6a515b5faf879ed7f37fe15ed0124416
BLAKE2b-256 bbeef6cb2e83efe36bdb054d3ca5aeb9c797b75dbad9ba3e1d8b1a6dfb6f77e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: IUExtract-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 19.9 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 3e98285d08f124b2aa1c07bd97b28c1b8313c59ec7b9e95c041e0ebe99ba11d8
MD5 d98a55adf4b5e830ba804f8b2e2e8081
BLAKE2b-256 701fcbb1e6553ab51d0f9ca314d2d57d0ecaf29dd453c61654a1ca899a8b1264

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