Nostril

raw JSON →
1.2.2 verified Fri May 01 auth: no python

Nostril (Nonsense String Evaluator) is a Python 3 module that infers whether a given word or text string is likely nonsense or meaningful text. It is primarily used to distinguish program identifiers from natural language. Current version 1.2.2, released 2023-12-31. Release cadence is low, with no recent updates.

pip install nostril-detector
error ModuleNotFoundError: No module named 'nostril'
cause You pip installed 'nostril-detector' but tried to import 'nostril_detector' or another name.
fix
Use 'from nostril import detect_nonsense'. The package name and import module differ.
error ImportError: cannot import name 'detect_nonsense' from 'nostril'
cause Outdated version or wrong pip package. The package 'nostril' on PyPI is a different library (text encoding detector).
fix
Uninstall 'nostril' if installed, then 'pip install nostril-detector'.
gotcha The import module is 'nostril', not 'nostril_detector'. Uninstalling 'nostril-detector' and installing 'nostril' leads to a different package (a text encoding detector).
fix Use 'from nostril import detect_nonsense' after 'pip install nostril-detector'.
gotcha The detect_nonsense function returns True for nonsense input and False for meaningful input. This is contrary to intuition (non-nonsense = meaningful).
fix Remember: detect_nonsense('hello') -> False (meaningful); detect_nonsense('xzy') -> True (nonsense).
deprecated The command-line option '-v' for version was changed to '-V' in v1.1.0.
fix Use '-V' for version, or '--version'.

Basic usage: call detect_nonsense(string) which returns True if the string is likely nonsense, False otherwise.

from nostril import detect_nonsense

# Test a meaningful string
test_string = 'hello world'
result = detect_nonsense(test_string)
print(f'{test_string!r}: nonsense={result}')

# Test a nonsense string (e.g., program identifier)
test_string2 = 'xzyqwk'
result2 = detect_nonsense(test_string2)
print(f'{test_string2!r}: nonsense={result2}')