Skip to content

Commit 103ec95

Browse files
committed
updated documentation, updated package with relative paths. running well, but sphinx unsuccessful
1 parent 1cc3258 commit 103ec95

13 files changed

+252
-53
lines changed

docs/Makefile

+26-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
1919
# the i18n builder cannot share the environment and doctrees with the others
2020
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
2121

22-
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext
23-
22+
.PHONY: help
2423
help:
2524
@echo "Please use \`make <target>' where <target> is one of"
2625
@echo " html to make standalone HTML files"
@@ -48,40 +47,48 @@ help:
4847
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
4948
@echo " coverage to run coverage check of the documentation (if enabled)"
5049

50+
.PHONY: clean
5151
clean:
5252
rm -rf $(BUILDDIR)/*
5353

54+
.PHONY: html
5455
html:
5556
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
5657
@echo
5758
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
5859

60+
.PHONY: dirhtml
5961
dirhtml:
6062
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
6163
@echo
6264
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
6365

66+
.PHONY: singlehtml
6467
singlehtml:
6568
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
6669
@echo
6770
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
6871

72+
.PHONY: pickle
6973
pickle:
7074
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
7175
@echo
7276
@echo "Build finished; now you can process the pickle files."
7377

78+
.PHONY: json
7479
json:
7580
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
7681
@echo
7782
@echo "Build finished; now you can process the JSON files."
7883

84+
.PHONY: htmlhelp
7985
htmlhelp:
8086
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
8187
@echo
8288
@echo "Build finished; now you can run HTML Help Workshop with the" \
8389
".hhp project file in $(BUILDDIR)/htmlhelp."
8490

91+
.PHONY: qthelp
8592
qthelp:
8693
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
8794
@echo
@@ -91,6 +98,7 @@ qthelp:
9198
@echo "To view the help file:"
9299
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/shorttext.qhc"
93100

101+
.PHONY: applehelp
94102
applehelp:
95103
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
96104
@echo
@@ -99,6 +107,7 @@ applehelp:
99107
"~/Library/Documentation/Help or install it in your application" \
100108
"bundle."
101109

110+
.PHONY: devhelp
102111
devhelp:
103112
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
104113
@echo
@@ -108,84 +117,99 @@ devhelp:
108117
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/shorttext"
109118
@echo "# devhelp"
110119

120+
.PHONY: epub
111121
epub:
112122
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
113123
@echo
114124
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
115125

126+
.PHONY: latex
116127
latex:
117128
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
118129
@echo
119130
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
120131
@echo "Run \`make' in that directory to run these through (pdf)latex" \
121132
"(use \`make latexpdf' here to do that automatically)."
122133

134+
.PHONY: latexpdf
123135
latexpdf:
124136
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
125137
@echo "Running LaTeX files through pdflatex..."
126138
$(MAKE) -C $(BUILDDIR)/latex all-pdf
127139
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
128140

141+
.PHONY: latexpdfja
129142
latexpdfja:
130143
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
131144
@echo "Running LaTeX files through platex and dvipdfmx..."
132145
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
133146
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
134147

148+
.PHONY: text
135149
text:
136150
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
137151
@echo
138152
@echo "Build finished. The text files are in $(BUILDDIR)/text."
139153

154+
.PHONY: man
140155
man:
141156
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
142157
@echo
143158
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
144159

160+
.PHONY: texinfo
145161
texinfo:
146162
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
147163
@echo
148164
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
149165
@echo "Run \`make' in that directory to run these through makeinfo" \
150166
"(use \`make info' here to do that automatically)."
151167

168+
.PHONY: info
152169
info:
153170
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
154171
@echo "Running Texinfo files through makeinfo..."
155172
make -C $(BUILDDIR)/texinfo info
156173
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
157174

175+
.PHONY: gettext
158176
gettext:
159177
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
160178
@echo
161179
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
162180

181+
.PHONY: changes
163182
changes:
164183
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
165184
@echo
166185
@echo "The overview file is in $(BUILDDIR)/changes."
167186

187+
.PHONY: linkcheck
168188
linkcheck:
169189
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
170190
@echo
171191
@echo "Link check complete; look for any errors in the above output " \
172192
"or in $(BUILDDIR)/linkcheck/output.txt."
173193

194+
.PHONY: doctest
174195
doctest:
175196
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
176197
@echo "Testing of doctests in the sources finished, look at the " \
177198
"results in $(BUILDDIR)/doctest/output.txt."
178199

200+
.PHONY: coverage
179201
coverage:
180202
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
181203
@echo "Testing of coverage in the sources finished, look at the " \
182204
"results in $(BUILDDIR)/coverage/python.txt."
183205

206+
.PHONY: xml
184207
xml:
185208
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
186209
@echo
187210
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
188211

212+
.PHONY: pseudoxml
189213
pseudoxml:
190214
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
191215
@echo

docs/conf.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
#
33
# shorttext documentation build configuration file, created by
4-
# sphinx-quickstart on Fri Nov 11 18:11:01 2016.
4+
# sphinx-quickstart on Tue Nov 15 15:25:44 2016.
55
#
66
# This file is execfile()d with the current directory set to its
77
# containing dir.
@@ -14,14 +14,17 @@
1414

1515
import sys
1616
import os
17-
import shlex
1817

1918
# If extensions (or modules to document with autodoc) are in another directory,
2019
# add these directories to sys.path here. If the directory is relative to the
2120
# documentation root, use os.path.abspath to make it absolute, like shown here.
21+
sys.path.insert(0, os.path.abspath('.'))
2222
sys.path.insert(0, os.path.abspath('../shorttext'))
2323
sys.path.insert(0, os.path.abspath('../shorttext/data'))
2424
sys.path.insert(0, os.path.abspath('../shorttext/utils'))
25+
sys.path.insert(0, os.path.abspath('../shorttext/classifiers'))
26+
sys.path.insert(0, os.path.abspath('../shorttext/classifiers/embed'))
27+
sys.path.insert(0, os.path.abspath('../shorttext/classifiers/embed/autoencode'))
2528
sys.path.insert(0, os.path.abspath('../shorttext/classifiers/embed/sumvec'))
2629
sys.path.insert(0, os.path.abspath('../shorttext/classifiers/embed/nnlib'))
2730

@@ -62,9 +65,9 @@
6265
# built documents.
6366
#
6467
# The short X.Y version.
65-
version = '0.0'
68+
version = u'0.0'
6669
# The full version, including alpha/beta/rc tags.
67-
release = '0.0b5'
70+
release = u'0.0b5'
6871

6972
# The language for content autogenerated by Sphinx. Refer to documentation
7073
# for a list of supported languages.
@@ -229,8 +232,8 @@
229232
# (source start file, target name, title,
230233
# author, documentclass [howto, manual, or own class]).
231234
latex_documents = [
232-
(master_doc, 'shorttext.tex', u'shorttext Documentation',
233-
u'Kwan-Yuet Ho', 'manual'),
235+
(master_doc, 'shorttext.tex', u'shorttext Documentation',
236+
u'Kwan-Yuet Ho', 'manual'),
234237
]
235238

236239
# The name of an image file (relative to this directory) to place at the top of
@@ -273,9 +276,9 @@
273276
# (source start file, target name, title, author,
274277
# dir menu entry, description, category)
275278
texinfo_documents = [
276-
(master_doc, 'shorttext', u'shorttext Documentation',
277-
author, 'shorttext', 'One line description of project.',
278-
'Miscellaneous'),
279+
(master_doc, 'shorttext', u'shorttext Documentation',
280+
author, 'shorttext', 'One line description of project.',
281+
'Miscellaneous'),
279282
]
280283

281284
# Documents to append as an appendix to all manuals.

setup.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ def readme():
2121
author_email="stephenhky@yahoo.com.hk",
2222
license='MIT',
2323
packages=['shorttext',
24+
'shorttext.utils',
2425
'shorttext.classifiers',
2526
'shorttext.classifiers.embed',
2627
'shorttext.classifiers.embed.autoencode',
2728
'shorttext.classifiers.embed.nnlib',
2829
'shorttext.classifiers.embed.sumvec',
29-
'shorttext.data',
30-
'shorttext.utils',],
30+
'shorttext.data',],
31+
package_dir={'shorttext': 'shorttext'},
32+
package_data={'shorttext': ['data/*.csv']},
3133
install_requires=[
3234
'numpy', 'scipy', 'keras', 'theano', 'nltk', 'gensim', 'pandas',
3335
],

shorttext/__init__.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
2-
1+
import data
2+
import utils
3+
import classifiers

shorttext/classifiers/__init__.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
from classifiers.embed.autoencode import AutoencoderEmbedVecClassification
2-
from classifiers.embed.nnlib import CNNEmbedVecClassification
3-
from classifiers.embed.sumvec import SumWord2VecClassification
1+
from ..utils import classification_exceptions
2+
from ..utils import kerasmodel_io as kerasmodel_io
3+
4+
from .embed.autoencode import AutoencoderEmbedVecClassification
5+
from .embed.nnlib import CNNEmbedVecClassification
6+
from .embed.sumvec import SumWord2VecClassification
47

58
# allowed algorithms
6-
allowed_algos = {'sumword2vec', 'autoencoder', 'cnn', 'vnn'}
9+
allowed_algos = {'sumword2vec', 'autoencoder', 'cnn', 'vnn'}

shorttext/classifiers/embed/autoencode/AutoencoderEmbedVecClassification.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from nltk import word_tokenize
99
from scipy.spatial.distance import cosine
1010

11-
from utils import kerasmodel_io as kerasio
12-
from utils import ModelNotTrainedException
11+
from ... import kerasmodel_io as kerasio
12+
from ... import classification_exceptions as e
1313

1414

1515
# Reference: Francois Chollet, "Building Autoencoders in Keras"
@@ -76,7 +76,7 @@ def train(self):
7676

7777
def savemodel(self, nameprefix, save_complete_autoencoder=False):
7878
if not self.trained:
79-
raise ModelNotTrainedException()
79+
raise e.ModelNotTrainedException()
8080
kerasio.save_model(nameprefix+'_encoder', self.encoder)
8181
if save_complete_autoencoder:
8282
kerasio.save_model(nameprefix+'_decoder', self.decoder)
@@ -99,7 +99,7 @@ def shorttext_to_embedvec(self, shorttext):
9999

100100
def encode(self, shorttext):
101101
if not self.trained:
102-
raise ModelNotTrainedException()
102+
raise e.ModelNotTrainedException()
103103
embedvec = self.shorttext_to_embedvec(shorttext)
104104
return self.encoder.predict(np.array([embedvec]))
105105

shorttext/classifiers/embed/nnlib/CNNEmbedVecClassification.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import VarNNEmbedVecClassification as vnn
2-
from classifiers.embed.nnlib import frameworks as fr
2+
import frameworks as fr
33

44

55
# wrapper for VarNNEmbedVecClassification for using CNN only
66
# backward compatible with the previous version of this class
77
class CNNEmbeddedVecClassifier:
8+
"""
9+
This class is a wrapper that runs {@link vnn}, but carries backward compatibility.
10+
"""
811
def __init__(self,
912
wvmodel,
1013
classdict=None,

0 commit comments

Comments
 (0)