Skip to content

Commit

Permalink
Update demonstrator
Browse files Browse the repository at this point in the history
  • Loading branch information
Severin Simmler committed Feb 7, 2017
1 parent f24e100 commit 449c4f8
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 6 deletions.
16 changes: 13 additions & 3 deletions demonstrator/demo.py
Expand Up @@ -79,7 +79,7 @@ def upload_file():
type2id = {value : key for key, value in id_types.items()}

models = []
for x in range(10): # todo: consider user input
for x in range(5): # todo: consider user input
model = LdaModel(corpus=mm, id2word=type2id, iterations=200, num_topics=x+1, random_state=x)
topics = model.show_topics(num_topics = x+1)
segmented_topics = evaluation.topic_segmenter(model, type2id, x+1, permutation=True)
Expand All @@ -89,11 +89,21 @@ def upload_file():

best_score, best_model = max(models)
worst_score, worst_model = min(models)


with open("./templates/result.html", 'r', encoding='utf-8') as f:
html = f.readlines()

html[89] = str(best_model.show_topics())

with open("./templates/result.html", 'w', encoding='utf-8') as f:
f.writelines(html)

"""
vis = visualization.Visualization(best_model, mm, type2id, labels, interactive=False) # todo: consider user input
heatmap = vis.make_heatmap()
vis.save_heatmap("./visualizations/heatmap")
return render_template('success.html')
"""
return render_template('result.html')

if __name__ == '__main__':
threading.Timer(
Expand Down
Binary file added demonstrator/static/pie.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 27 additions & 2 deletions demonstrator/templates/index.html
Expand Up @@ -14,12 +14,34 @@
<link rel="stylesheet" href="{{url_for('static', filename='css/bootstrap-customization.css')}}" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="{{url_for('static', filename='css/bootstrap-modal.css')}}" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="{{url_for('static', filename='css/font-awesome.css')}}">
<style>div#loading {
width: 120px;
height: 120px;
position: absolute;
margin: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: none;
margin: auto;
background: url(/static/pie.gif) no-repeat;
cursor: wait;
}
</style>


<!-- JavaScript files at the end for faster loading of documents -->

<script type="text/javascript" src="{{url_for('static', filename='js/jquery-1.8.2.js')}}"></script>
<script type="text/javascript" src="{{url_for('static', filename='js/bootstrap.js')}}"></script>
<script type="text/javascript" src="{{url_for('static', filename='js/globalmenu.js')}}"></script>
<script type="text/javascript">
function loading(){
$("#loading").show();
$("#content").hide();
}
</script>

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
Expand All @@ -29,6 +51,8 @@
</head>

<body>
<div id="loading"></div>
<div id="content">
<div class="navbar navbar-inverse navbar-static-top navbar-dariah" id="top">
<div class="navbar-inner">
<div class="container-fluid">
Expand Down Expand Up @@ -108,7 +132,7 @@ <h4>Tokenization, Stopwords and Hapax Legomena</h4>
<input type="text" name="stopword_treshold">
<p>Or upload your own words-to-remove list here:</p>
<input type="file" name="stoplist">
<h3>3. Training the Model</h3>
<h3>3. Modeling</h3>
<p><a href="http://mallet.cs.umass.edu/index.php">MALLET</a>, as well as <a href="https://radimrehurek.com/gensim/">Gensim</a>, are two popular software packages to analyze text corpora. MALLET, whose development started in 2002 at University of Massachusets Amherst, delivers very reliable results. Since 2008, Gensim was used and cited in over 400 commercial and academic applications. It is up to you to which LDA implementation you choose. Basically both of them do the same thing, but there are always some minor differences, and so are user preferences.</p>
<select>
<option value="mallet">MALLET</option>
Expand All @@ -131,7 +155,7 @@ <h3>5. Visualization</h3>
</div>
<h3>6. Submitting the Data</h3>
<p>Finally, submit your data and explore the model.</p>
<input type="submit" value="Send">
<input type="submit" value="Send" onclick="loading();">
</form>
<hr>
<h2>Contact</h2>
Expand All @@ -155,6 +179,7 @@ <h2>Contact</h2>
<noscript>
<div>Enable JavaScript!</div>
</noscript>
</div>
</body>

</html>
120 changes: 120 additions & 0 deletions demonstrator/templates/result.html
@@ -0,0 +1,120 @@
<!DOCTYPE html>
<html lang="de">

<head>
<meta charset="utf-8">
<title>DARIAH-DE :: Demonstrator</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="DARIAH-DE">
<meta name="description" content="DARIAH-DE :: Demonstrator">
<!-- CSS Imports -->
<link rel="stylesheet" href="{{url_for('static', filename='css/bootstrap.css')}}" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="{{url_for('static', filename='css/bootstrap-responsive.css')}}" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="{{url_for('static', filename='css/application.css')}}" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="{{url_for('static', filename='css/bootstrap-customization.css')}}" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="{{url_for('static', filename='css/bootstrap-modal.css')}}" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="{{url_for('static', filename='css/font-awesome.css')}}">

<!-- JavaScript files at the end for faster loading of documents -->

<script type="text/javascript" src="{{url_for('static', filename='js/jquery-1.8.2.js')}}"></script>
<script type="text/javascript" src="{{url_for('static', filename='js/bootstrap.js')}}"></script>
<script type="text/javascript" src="{{url_for('static', filename='js/globalmenu.js')}}"></script>

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="shortcut icon" type="image/png" href="{{url_for('static', filename='img/page_icon.png')}}" />
</head>

<body>
<div class="navbar navbar-inverse navbar-static-top navbar-dariah" id="top">
<div class="navbar-inner">
<div class="container-fluid">
<div class="row-fluid">
<div class="span1"></div>
<div class="span10">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="nav-collapse collapse">
<ul class="nav pull-right">
</ul>
<ul class="nav">
<!--
Don't change this section!
-->
<li id="home_button" class="dropdown">
<a class="brand dropdown-toggle" data-toggle="dropdown" href="#">
<span class="caret"></span> DARIAH-DE
</a>
<ul id="home_dropdown_menu" class="dropdown-menu">
<li class="dropdown-submenu">
<a tabindex="-1" href="#">DARIAH-DE</a>
<ul class="dropdown-menu">
<li><a href="http://de.dariah.eu">DARIAH-DE Home</a>
</li>
<li class="divider"></li>
<li><a href="http://textgrid.de/ ">TextGrid</a>
</li>
</ul>
</li>
<li class="divider"></li>
<li class="dropdown-submenu">
<a tabindex="-1" href="#">DARIAH-EU</a>
<ul class="dropdown-menu">
<li><a href="http://www.dariah.eu/">DARIAH-EU Home</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="content_layout" class="container-fluid">
<div style="height: 70px;"></div>
<div class="row-fluid">
<div class="span10 offset1 main-content-wrapper no-margin">
<div id="content" class="primary-area">
<h1>Demonstrator: Topic Modeling</h1>
<div id="contentInner" style="text-align:justify">








<hr><h2>Contact</h2>
<p><a href="mailto:pielstroem@biozentrum.uni-wuerzburg.de">Dr. Steffen Pielström</a>, University of Würzburg</p>
</div>
</div>
</div>
</div>
<div class="row-fluid">
<div id="footer" class="span10 offset1 no-margin footer">
<span>&copy; 2017 DARIAH-DE</span>
<ul class="pull-right inline">
<li><a href="https://de.dariah.eu/impressum">Impressum</a>
</li>
<li><a href="https://wiki.de.dariah.eu/display/publicde/Cluster+5%3A+Quantitative+Datenanalyse">Contact</a>
</li>
</ul>
</div>
</div>
</div>
<noscript>
<div>Enable JavaScript!</div>
</noscript>
</body>

</html>
1 change: 0 additions & 1 deletion demonstrator/templates/success.html

This file was deleted.

0 comments on commit 449c4f8

Please sign in to comment.