From 81e37fe6419b7b4ca75891fc9d8f1542ed6feab6 Mon Sep 17 00:00:00 2001 From: stephenhky Date: Thu, 3 Nov 2016 21:21:35 -0400 Subject: [PATCH] fix path module bugs --- setup.py | 6 +++++- shorttext/__init__.py | 5 +++++ shorttext/classifiers/AutoencoderEmbedVecClassification.py | 4 ++-- shorttext/classifiers/CNNEmbedVecClassification.py | 4 ++-- shorttext/classifiers/SumWord2VecClassification.py | 2 +- shorttext/classifiers/VarNNEmbedVecClassification.py | 4 ++-- shorttext/classifiers/__init__.py | 2 ++ 7 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 shorttext/__init__.py diff --git a/setup.py b/setup.py index bc0a65c0..8abd823d 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,11 @@ def readme(): author="Kwan-Yuet Ho", author_email="stephenhky@yahoo.com.hk", license='MIT', - packages=['shorttext'], + packages=['shorttext', + 'shorttext.classifiers', + 'shorttext.data', + 'shorttext.nnlib', + 'shorttext.utils',], install_requires=[ 'numpy', 'scipy', 'keras', 'theano', 'nltk', 'gensim', 'pandas', ], diff --git a/shorttext/__init__.py b/shorttext/__init__.py new file mode 100644 index 00000000..ec44b5c7 --- /dev/null +++ b/shorttext/__init__.py @@ -0,0 +1,5 @@ +from .classifiers.CNNEmbedVecClassification import CNNEmbeddedVecClassifier +from .classifiers.SumWord2VecClassification import SumEmbeddedVecClassifier +from .classifiers.VarNNEmbedVecClassification import VarNNEmbeddedVecClassifier + +from .utils.classification_exceptions import ModelNotTrainedException, Word2VecModelNotExistException, AlgorithmNotExistException \ No newline at end of file diff --git a/shorttext/classifiers/AutoencoderEmbedVecClassification.py b/shorttext/classifiers/AutoencoderEmbedVecClassification.py index 22eec02c..adf621a8 100644 --- a/shorttext/classifiers/AutoencoderEmbedVecClassification.py +++ b/shorttext/classifiers/AutoencoderEmbedVecClassification.py @@ -8,8 +8,8 @@ from nltk import word_tokenize from scipy.spatial.distance import cosine -import utils.kerasmodel_io as kerasio -from utils import ModelNotTrainedException +from ..utils import kerasmodel_io as kerasio +from ..utils import ModelNotTrainedException # Reference: Francois Chollet, "Building Autoencoders in Keras" diff --git a/shorttext/classifiers/CNNEmbedVecClassification.py b/shorttext/classifiers/CNNEmbedVecClassification.py index e09b903c..42d4387e 100644 --- a/shorttext/classifiers/CNNEmbedVecClassification.py +++ b/shorttext/classifiers/CNNEmbedVecClassification.py @@ -1,6 +1,6 @@ -import nnlib.frameworks as fr +from ..nnlib import frameworks as fr -import classifiers.VarNNEmbedVecClassification as vnn +import VarNNEmbedVecClassification as vnn # wrapper for VarNNEmbedVecClassification for using CNN only diff --git a/shorttext/classifiers/SumWord2VecClassification.py b/shorttext/classifiers/SumWord2VecClassification.py index 61de430f..45197278 100644 --- a/shorttext/classifiers/SumWord2VecClassification.py +++ b/shorttext/classifiers/SumWord2VecClassification.py @@ -5,7 +5,7 @@ from nltk import word_tokenize from scipy.spatial.distance import cosine -from utils import ModelNotTrainedException +from .. utils import ModelNotTrainedException class SumEmbeddedVecClassifier: diff --git a/shorttext/classifiers/VarNNEmbedVecClassification.py b/shorttext/classifiers/VarNNEmbedVecClassification.py index a5a5e3f1..011b288e 100644 --- a/shorttext/classifiers/VarNNEmbedVecClassification.py +++ b/shorttext/classifiers/VarNNEmbedVecClassification.py @@ -1,8 +1,8 @@ import numpy as np from nltk import word_tokenize -import utils as kerasio -from utils import ModelNotTrainedException +from ..utils import kerasmodel_io as kerasio +from ..utils import ModelNotTrainedException class VarNNEmbeddedVecClassifier: diff --git a/shorttext/classifiers/__init__.py b/shorttext/classifiers/__init__.py index f437cfe9..f39138fa 100644 --- a/shorttext/classifiers/__init__.py +++ b/shorttext/classifiers/__init__.py @@ -1,2 +1,4 @@ +import AutoencoderEmbedVecClassification, CNNEmbedVecClassification, SumWord2VecClassification, VarNNEmbedVecClassification + # allowed algorithms allowed_algos = {'sumword2vec', 'autoencoder', 'cnn', 'vnn'} \ No newline at end of file