Skip to main content

pypi badge WNF tests 3.9 WNF tests 3.10 WNF linter License: AGPL v3 Generic badge

WORDS N FUN : Semantic analysis module

The purpose of this project is two folds:

  1. To normalize tools and how tos of semantic analysis projects
  2. To offer end to end pipelines to speed up the time to market of NLP services

Licence

This project is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE V3.0. Please check the LICENSE file.


Philosophy of this package

This package used to contain two main parts:

  1. Preprocessing : to speed up the application of numerous preprocessing routines to text data
  2. Modelling : to speed up the developpement of NLP machine learning models The later has been refactored into what is now called the NLP framework.

Preprocessing

One of the main goals of the project was to build a pipeline that could accomodate several data types:

  • str
  • list
  • np.array
  • pd.Series
  • pd.DataFrame
  • csv file (where the supplied data is the path to the actual file)

Whatever the supplied data type, it will kept along the pipeline, meaning that if a csv file is given, a new csv file will be created as the output. If the input is a pd.Series, another pd.Series of the same shape will be returned. This feature is controled by the utils.data_agnostic function.

Main scripts

utils.py

Contains utils functions and tools, mainly the data agnostic feature.

basic.py

Contains the main data transformation functions.

api.py

Contains the main entry point of the package controlling how one could create an end to end transformation pipeline.


Getting started

Requirements & setup

Coming soon: CI pipeline to push this package to pypi

  • Python 3.X (tests are ran on python 3.8)
  • Set up module dependencies : pip install -r requirements.txt
  • Set up the actual module : pip install -e words_n_fun or python setup.py develop
  • Download nltk stopwords data:
import nltk
nltk.download('stopwords')

How to use this module

A notebook tutorial is provided in the tutorial directory. Roughly speaking, her is what a basic use case should look like:

 # Module import
from words_n_fun.preprocessing import api

# Definition of the desired transformation pipeline
pipeline = ['remove_non_string', 'get_true_spaces', 'to_lower', 'remove_punct',
			'remove_numeric', 'remove_stopwords', 'lemmatize', 'remove_accents',
			'trim_string', 'remove_leading_and_ending_spaces']

#### example 1 : csv file ####

# Input file
input_file = "path/to/my/file.csv"
# Column containing the text to preprocess
col = "myText"
# Separator character
sep = ';'
# Instanciation of a preprocessor object
preprocessor = api.get_preprocessor(pipeline=pipeline, prefered_column=col, sep=sep)
# Process data
output_file = preprocessor.transform(input_file)


#### example 2 : list  ####
# Input data
input_list = ["First text to transform", "Second text to pocess"]
# Instanciation of a preprocessor object
preprocessor = api.get_preprocessor(pipeline=pipeline)
# Process data
output_list = preprocessor.transform(input_list)

Best Practices & guidelines

Contributors must try their best to follow these mainstream guidelines :

  1. Module management https://docs.python.org/3.9/tutorial/modules.html
  2. Python development https://github.com/google/styleguide/blob/gh-pages/pyguide.md, https://www.python.org/dev/peps/pep-0008/
  3. All the preprocessing functions must take pd.Series data as input. The built-in utils.data_agnostic decorator allows the user to send different types of data but the actual function carrying out these transformation should be built around pd.Series.

Numerous unit tests have been included in tests:

  • Please make sure to run them before trying to submit a merge request
  • New features must be shipped with their corresponding tests

Metadata

Release files for words-n-fun 1.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for words-n-fun 1.6.1
File Size Uploaded
words_n_fun-1.6.1.tar.gz 42.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for words-n-fun 1.6.1
File Interpreter ABI Platform
words_n_fun-1.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 89.9 kB

Release files / words_n_fun-1.6.1.tar.gz

Download URL words_n_fun-1.6.1.tar.gz
Size 42.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2782e9ba9b5d49851dcc552a81ea85e6bc3aa5726437c7567c321f22cfb2c7fc
BLAKE2b-256 checksum
How to use checksums
ec77e7f67caa074410f0ad0dea47fdc5fbcf4e0ec17e9d61eadc2491b7a76a3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.19

Release files / words_n_fun-1.6.1-py3-none-any.whl

Download URL words_n_fun-1.6.1-py3-none-any.whl
Size 47.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6d661fed8b441d002c7ff9d4ec92ba98ddf8f6798aa3d8ebe8605d4985fe4c1
BLAKE2b-256 checksum
How to use checksums
1904bbf472ac89588ddef121bc9e63d9684f8f758b617026a8417905db3ca701
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.19

Release history Release notifications | RSS feed

This release

1.6.1 This release

2 release files

1.6.0

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page