Skip to content

Commit

Permalink
added toNFC and toNFD command-line scripts and bumped version to 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jtauber committed Oct 22, 2019
1 parent fa65d50 commit 191f8ec
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ sudo: false
python:
- "3.6"
- "3.7"
- "3.8"
install:
- pip install flake8
- pip install coveralls
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ pip install greek-normalisation
## Documentation / Tests

See `tests.rst` for usage examples.

Also, two command-line utilities `toNFC` and `toNFD` are installed which can be used to do unicode normalisation on files (e.g. `toNFC source.txt > nfc_version.txt`).
27 changes: 27 additions & 0 deletions greek_normalisation/convert_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3

import fileinput
import sys

from .utils import nfc, nfd


def convert(func):
lines_changed = 0

with fileinput.input() as f:
for line in f:
text = func(line)
print(text, end="")
if text != line:
lines_changed += 1

print(f"{lines_changed} lines changed", file=sys.stderr)


def to_nfc():
convert(nfc)


def to_nfd():
convert(nfd)
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name="greek-normalisation",
version="0.2.1",
version="0.3",
description="Python 3 utilities for validating and normalising Ancient Greek text",
url="http://github.com/jtauber/greek-normalisation",
author="James Tauber",
Expand All @@ -16,12 +16,19 @@
long_description_content_type="text/markdown",
license="MIT",
packages=["greek_normalisation"],
entry_points={
"console_scripts": [
"toNFC = greek_normalisation.convert_files:to_nfc",
"toNFD = greek_normalisation.convert_files:to_nfd",
],
},
zip_safe=False,
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Text Processing :: Linguistic",
],
)

0 comments on commit 191f8ec

Please sign in to comment.