From 371aa29f10aab1d4acdf94f81c116ec2e84fc6f9 Mon Sep 17 00:00:00 2001 From: David Thomas Date: Thu, 8 Mar 2018 15:06:29 -0500 Subject: [PATCH] pip cltk setup added, readme updated --- README.md | 10 +++++----- dhelp/text/_bases_mixins.py | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 502da44..e0aea97 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Requires [Python 3.x](https://python.org) # Table of Contents * [Installation](#installation) -* [Quickstart Guide](#quickstart-guide) +* [Language Setup](#language-setup) * [Web Module](#web-module) * [WebPage](#webpage) * [File Module](#file-module) @@ -75,14 +75,14 @@ easy_install setup.py ``` -## Greek & Latin Users +# Language Setup -If you want to work with Greek and Latin, you need to install cltk via pip... +The first time you use a language-specific text object, you need to run its .setup() method ```sh +from dhelp import EnglishText -# you may need admin privileges -pip install cltk +EnglishText('').setup() ``` diff --git a/dhelp/text/_bases_mixins.py b/dhelp/text/_bases_mixins.py index d75772e..d5d0823 100644 --- a/dhelp/text/_bases_mixins.py +++ b/dhelp/text/_bases_mixins.py @@ -1,5 +1,6 @@ #!/usr/bin/python +import pip import re from collections import UserString @@ -421,6 +422,9 @@ def setup(self): Example: >>> LatinText('').setup() """ + # first, download the cltk module from pip + pip.main(['install', 'cltk']) + # import cltk inline as global import errors for non-cltk users from cltk.corpus.utils.importer import CorpusImporter corpus_importer = CorpusImporter(self.options['language']) # loop through and attempt to download, skip any errors