forked from uwdata/termite-stm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5edc7dc
Showing
8 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.DS_Store | ||
.gitignore~ | ||
*.py~ | ||
*.pyc | ||
*.sh~ | ||
externals/ | ||
tools/ | ||
apps/ | ||
demo-20newsgroups/ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Copyright (c) 2014, University of Washington | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of the <organization> nor the | ||
names of its contributors may be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY | ||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Termite Web Server for STM models | ||
================================= | ||
|
||
Termite is a visualization tool for inspecting the output of statistical topic models. | ||
|
||
The tool contains two components: | ||
* A web server for accessing the output of a topic model and distributing the content over the internet. | ||
* A client interface for visualizing the topic model in a web browser. | ||
|
||
This repository contains the server-side component for processing the output of an Structural Topic Model (STM) and hosting the content on a web2py server. This middleware is developed by [Jason Chuang](http://jason.chuang.ca), and distributed under the BSD-3 license. Structural Topic Modeling is developed by Margaret Roberts and Brandon Stewart, et al. [The web2py Web Framework](http://web2py.com) is developed by Massimo Di Pierro, et al. | ||
|
||
Using the software | ||
------------------ | ||
|
||
Run the setup script to fetch all required libraries. This script only needs to be run once when Termite Web Server for MALLET is first downloaded onto a new machine. | ||
|
||
``` | ||
bin/setup.sh | ||
``` | ||
|
||
To launch the web server, execute the following command. A dialogue will appear. Click on "start server" to proceed. | ||
|
||
``` | ||
bin/start_server.sh | ||
``` | ||
|
||
License | ||
------- | ||
|
||
Copyright (c) 2014, University of Washington | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of the <organization> nor the | ||
names of its contributors may be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY | ||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
Credits | ||
------- | ||
|
||
Termite requires the use of the following libraries and tools. | ||
We thank their respective authors for developing and distributing these tools. | ||
|
||
Structural Topic Models | ||
Paper website: http://scholar.harvard.edu/mroberts, http://scholar.harvard.edu/bstewart | ||
Developed by Margaret Roberts and Brandon Stewart, et al. | ||
|
||
The web2py Web Framework | ||
Project website: http://web2py.com | ||
Developed by Massimo Di Pierro, et al. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
|
||
EXTERNALS_PATH=externals | ||
TOOLS_PATH=tools | ||
APPS_PATH=apps | ||
|
||
function __create_folder__ { | ||
FOLDER=$1 | ||
TAB=$2 | ||
if [ ! -d $FOLDER ] | ||
then | ||
echo "${TAB}Creating folder: $FOLDER" | ||
mkdir $FOLDER | ||
fi | ||
} | ||
|
||
function __setup_web2py__ { | ||
EXTERNALS_SUBPATH=$EXTERNALS_PATH/web2py | ||
TOOLS_SUBPATH=$TOOLS_PATH/web2py | ||
|
||
if [ ! -f "$EXTERNALS_SUBPATH/web2py_src.zip" ] | ||
then | ||
echo ">> Downloading web2py..." | ||
__create_folder__ $EXTERNALS_SUBPATH " " | ||
curl --insecure --location http://www.web2py.com/examples/static/web2py_src.zip > $EXTERNALS_SUBPATH/web2py_src.zip | ||
else | ||
echo ">> Downloading web2py..." | ||
echo " Already downloaded: $EXTERNALS_SUBPATH/web2py_src.zip" | ||
fi | ||
|
||
if [ ! -d "$TOOLS_SUBPATH" ] | ||
then | ||
echo ">> Uncompressing web2py..." | ||
__create_folder__ $TOOLS_SUBPATH " " | ||
unzip -q $EXTERNALS_SUBPATH/web2py_src.zip web2py/* -d $TOOLS_SUBPATH &&\ | ||
mv $TOOLS_SUBPATH/web2py/* $TOOLS_SUBPATH/ &&\ | ||
rmdir $TOOLS_SUBPATH/web2py | ||
|
||
echo ">> Extracting web2py License..." | ||
unzip -q $EXTERNALS_SUBPATH/web2py_src.zip web2py/LICENSE -d $EXTERNALS_SUBPATH &&\ | ||
mv $EXTERNALS_SUBPATH/web2py/LICENSE $EXTERNALS_SUBPATH/ &&\ | ||
rmdir $EXTERNALS_SUBPATH/web2py | ||
|
||
echo ">> Removing 'no password, no web admin interface' dialogue box..." | ||
echo "sed -i bkp \"s/self.error('no password, no web admin interface')/pass \#self.error('no password, no web admin interface')/g\" $TOOLS_SUBPATH/gluon/widget.py" | ||
sed -i bkp "s/self.error('no password, no web admin interface')/pass #self.error('no password, no web admin interface')/g" $TOOLS_SUBPATH/gluon/widget.py | ||
|
||
echo ">> Setting up 'termite' app..." | ||
__create_folder__ $TOOLS_SUBPATH/applications/termite " " | ||
echo "ln -s ../../../../server_src/termite/controllers $TOOLS_SUBPATH/applications/termite/controllers" | ||
ln -s ../../../../server_src/termite/controllers $TOOLS_SUBPATH/applications/termite/controllers | ||
|
||
echo ">> Using 'termite' as default app..." | ||
echo "sed -i bkp \"s/redirect(URL('welcome', 'default', 'index'))/redirect(URL('termite', 'default', 'index'))/g\" $TOOLS_SUBPATH/gluon/main.py" | ||
sed -i bkp "s/redirect(URL('welcome', 'default', 'index'))/redirect(URL('termite', 'default', 'index'))/g" $TOOLS_SUBPATH/gluon/main.py | ||
|
||
else | ||
echo ">> Setting up web2py..." | ||
echo " Already available: $TOOLS_SUBPATH" | ||
fi | ||
} | ||
|
||
__create_folder__ $EXTERNALS_PATH | ||
__create_folder__ $TOOLS_PATH | ||
__create_folder__ $APPS_PATH | ||
__setup_web2py__ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
echo "python tools/web2py/web2py.py" | ||
python tools/web2py/web2py.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
itm.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import json | ||
|
||
def index(): | ||
identifier = { | ||
'server_type' : 'stm', | ||
'server_version' : '0.1', | ||
'server_handlers' : [ | ||
'TermTopicMatrix', | ||
'TermIndex', | ||
'TopicIndex' | ||
] | ||
} | ||
return json.dumps( identifier, encoding = 'utf-8', indent = 2 ) | ||
|
||
def GetTermTopicMatrix(): | ||
filename = os.path.join( request.folder, 'data', 'term-topic-matrix.txt' ) | ||
with open( filename ) as f: | ||
content = [ [ float(value) for value in line.split('\t') ] for line in f.read().decode( 'utf-8' ).splitlines() ] | ||
return content | ||
|
||
def GerTermIndex(): | ||
filename = os.path.join( request.folder, 'data', 'term-index.txt' ) | ||
with open( filename ) as f: | ||
content = f.read().decode( 'utf-8' ).splitlines() | ||
return content | ||
|
||
def GetTopicIndex(): | ||
filename = os.path.join( request.folder, 'data', 'topic-index.txt' ) | ||
with open( filename ) as f: | ||
content = f.read().decode( 'utf-8' ).splitlines() | ||
return content | ||
|
||
def TermTopicMatrix(): | ||
data = { | ||
'content_type' : 'TermTopicMatrix', | ||
'content_version' : '0.1', | ||
'content' : GetTermTopicMatrix() | ||
} | ||
return json.dumps( data, encoding = 'utf-8' ) | ||
|
||
def TermIndex(): | ||
data = { | ||
'content_type' : 'TermIndex', | ||
'content_version' : '0.1', | ||
'content' : GerTermIndex() | ||
} | ||
return json.dumps( data, encoding = 'utf-8' ) | ||
|
||
def TopicIndex(): | ||
data = { | ||
'content_type' : 'TopicIndex', | ||
'content_version' : '0.1', | ||
'content' : GetTopicIndex() | ||
} | ||
return json.dumps( data, encoding = 'utf-8' ) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def index(): | ||
return "This is a Termite/MALLET server." |