Skip to content

Commit

Permalink
fix pmhfst path
Browse files Browse the repository at this point in the history
  • Loading branch information
reynoldsnlp committed Apr 22, 2021
1 parent e5ad036 commit dee55a4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
29 changes: 26 additions & 3 deletions dev/qa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,54 @@ shopt -s globstar

rm -f .coverage # can conflict with tox

echo -n "Upgrade HFST and vislcg3? (y/n) "

echo -n "Upgrade HFST and vislcg3 (root password may be required)? (y/n) "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ; then
echo "Type password: "
curl https://apertium.projectjj.com/osx/install-nightly.sh | sudo bash
case "$(uname -s)" in
Darwin)
curl https://apertium.projectjj.com/osx/install-nightly.sh | sudo bash
;;

Linux)
curl -sS https://apertium.projectjj.com/apt/install-nightly.sh | sudo bash
sudo apt-get -f install apertium-all-dev
;;

CYGWIN*|MINGW32*|MSYS*|MINGW*)
echo 'MS Windows, HFST will not be installed.'
;;

*)
echo 'Error: Unknown OS, HFST will not be installed.'
;;
esac
else
echo "Not upgrading hfst and vislcg3."
fi


echo "Versions with which tests passed for this commit:" \
> hfst_vislcg3_versions.txt
hfst-tokenize --version | grep hfst >> hfst_vislcg3_versions.txt
vislcg3 --version | grep VISL >> hfst_vislcg3_versions.txt


echo "Checking for unnecessary noqa's..."
egrep "^.{,76}[^\"]{3}# noqa: E501" test/*.py udar/**/*.py


echo "Running flake8..."
flake8 *.py test/**/*.py udar/**/*.py


echo "Running mypy..."
mypy udar


echo "Running pytest..."
pytest --cov=udar --cov-append --cov-report term-missing --doctest-modules


rm .coverage # can conflict with tox
echo "If everything passes, run tox."
2 changes: 1 addition & 1 deletion hfst_vislcg3_versions.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Versions with which tests passed for this commit:
hfst-tokenize 0.1 (hfst 3.15.4)
VISL CG-3 Disambiguator version 1.3.1.13891
VISL CG-3 Disambiguator version 1.3.2.13891
4 changes: 3 additions & 1 deletion scripts/post-commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ def tests():
'trigger a release on PyPI? (y/N) > ')
if response.strip() in {'Y', 'y', 'Yes', 'YES', 'yes'}:
pypi_version = get_pypi_version(test=TEST)
new_version = bump_python_version(pypi_version, beta=BETA)
print(f'Current {"Test " if TEST else ""}PyPI version:',
pypi_version, file=sys.stderr)
latest_tag = subprocess.run(['git', 'describe', '--tags'], capture_output=True).stdout
print(f'Latest git tag: {latest_tag}', file=sys.stderr)
new_version = bump_python_version(pypi_version, beta=BETA)
print('Suggested new version:', new_version, file=sys.stderr)
version = input(f'Please type the version number (default: {new_version}): ')
completed = subprocess.run(['git', 'tag', f'v{version}'])
Expand Down
5 changes: 3 additions & 2 deletions src/udar/sentence.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from .misc import destress
from .misc import result_names
from .misc import RSRC_DIR
from .misc import FST_DIR
from .misc import StressParams
from .misc import unspace_punct
from .tok import Token
Expand All @@ -47,7 +48,7 @@
def hfst_tokenize(input_str: str) -> List[str]:
try:
p = Popen(['hfst-tokenize',
f'{RSRC_DIR}/tokeniser-disamb-gt-desc.pmhfst'],
f'{FST_DIR}/tokeniser-disamb-gt-desc.pmhfst'],
stdin=PIPE,
stdout=PIPE,
universal_newlines=True)
Expand All @@ -68,7 +69,7 @@ class HFSTTokenizer:
tokenizer: 'pexpect.pty_spawn.spawn'

def __init__(self):
tokenizer_path = f'{RSRC_DIR}/tokeniser-disamb-gt-desc.pmhfst'
tokenizer_path = f'{FST_DIR}/tokeniser-disamb-gt-desc.pmhfst'
self.tokenizer = pexpect.spawn(f'hfst-tokenize {tokenizer_path}',
echo=False, encoding='utf8',
timeout=None)
Expand Down

0 comments on commit dee55a4

Please sign in to comment.