Last active
September 1, 2018 14:32
-
-
Save linwoodc3/fc7d986401671159484266c937d53b9c to your computer and use it in GitHub Desktop.
Bash script that successfully installs the polyglot multilingual text (NLP) processing toolkit on a MacOSX computer with Python 2.7 and Anaconda.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: | |
# Linwood Creekmore | |
# email: valinvescap@gmail.com | |
# navigate to home directory; just for clean start | |
cd ~ && | |
# exit out of whatever conda environment you are in | |
# start from root | |
source deactivate && | |
# update conda | |
conda update conda -y && | |
# create a new conda environment for test; python 3 | |
conda create -n icutestenv2 python=2 --no-deps -y && | |
# enter the test environment | |
source activate icutestenv2 && | |
# install the icu library; must be version 54.1 | |
conda install -c ccordoba12 icu=54.1 -y && | |
# install notebook related libraries | |
conda install ipython jupyter notebook -y && | |
# create your kernel | |
python -m ipykernel install --user && | |
# clone pyicu | |
pip install pyicu && | |
pip install pycld2 && | |
pip install morfessor && | |
pip install futures && | |
# now install polyglot | |
pip install polyglot ; | |
# run a test of polyglot | |
# polyglot test from http://polyglot.readthedocs.io/en/latest/index.html | |
# python-in-bash-script concept from http://unix.stackexchange.com/questions/184726/how-to-include-python-script-inside-a-bash-script | |
cat << EOF > pyscript.py && | |
#!/usr/bin/python | |
import polyglot | |
from polyglot.text import Text, Word | |
text = Text("Bonjour, Mesdames.") | |
print("Language Detected: Code={}, Name={}\n".format(text.language.code, text.language.name)) | |
EOF | |
chmod 755 pyscript.py && | |
python ./pyscript.py && | |
# if you made it to this line, print Success | |
echo "Successfully running polyglot with Python 2.7!!!" | |
rm ./pyscript.py && | |
echo -n "Would you like to delete this environment [yes or no]:? " | |
read instruction | |
if [[ ("$instruction" = 'yes') || ("$instruction" = "y")]]; then | |
source deactivate | |
conda env remove -n icutestenv2 -y && | |
cd ~ && | |
rm -rf pycld2 && | |
rm -rf pyicu && | |
echo "Successfully removed icutestenv2." | |
exit 1 | |
elif [[("$instruction" = "n" ) || ("$instruction" = "no")]]; then | |
echo "You opted to keep the environment." | |
source activate icutestenv2 | |
echo "Use 'source activate icutestenv2' to switch to the environment" | |
else | |
echo "You opted to keep the environment." | |
source activate icutestenv2 | |
echo "Use 'source activate icutestenv2' to switch to the environment" | |
fi | |
source activate icutestenv2 | |
The simplest way to install by far:
conda install -c conda-forge pyicu morfessor icu -y && pip install pycld2 polyglot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This can likely be super simplified to: