Last active
January 23, 2023 03:28
-
-
Save linwoodc3/8704bbf6d1c6130dda02bbc28967a9e6 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 3 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: [email protected] | |
# 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 icutestenv python=3.5.2 --no-deps -y && | |
# enter the test environment | |
source activate icutestenv && | |
# install the icu library; must be version 54.1 | |
conda install -c ccordoba12 icu=54.1 -y && | |
# install notebook related libraries | |
conda install ipython numpy scipy jupyter notebook -y && | |
# create your kernel | |
python -m ipykernel install --user && | |
# run easy_install of pyicu | |
# pip installs pyicu with no error, but easy_install does something different | |
easy_install pyicu && | |
pip install morfessor && | |
pip install pycld2 && | |
# 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 3!!!" | |
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 icutestenv -y && | |
echo "Successfully removed icutestenv." | |
exit 1 | |
elif [[("$instruction" = "n" ) || ("$instruction" = "no")]]; then | |
echo "You opted to keep the environment." | |
source activate icutestenv | |
echo "Use 'source activate icutestenv' to switch to the environment" | |
else | |
echo "You opted to keep the environment." | |
source activate icutestenv | |
echo "Use 'source activate icutestenv' to switch to the environment" | |
fi | |
source activate icutestenv | |
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: