Commit b67e4c8b authored by Sacha's avatar Sacha Committed by SXibolet@2PITAU
Browse files

more improvements to mturk workflow

parent 1cfcaaa3
......@@ -100,7 +100,7 @@ class Article(object):
self.url = j['web_url']
self.xlarge = 'https://www.nytimes.com/%s' % j['multimedia'][1]['url'] if len(j['multimedia']) > 1 else None
self.published = j['pub_date'][:10]
self.full = self._full_text()
self.full = self._full_text(sentis)
self.comments = article_comments(self.url, sentis=sentis)
def to_dict(self):
......@@ -109,7 +109,7 @@ class Article(object):
def _no_html_ab(self):
return BeautifulSoup(self.abstract or self.lead, 'html.parser').getText()
def _full_text(self):
def _full_text(self, sentis):
"""nyt url --> full article text
"""
if 'Paid Notice:' in self.title or 'video/multimedia' in self.url:
......@@ -120,7 +120,7 @@ class Article(object):
response = opener.open(urllib2.Request(self.url))
soup = BeautifulSoup(response.read(), 'html.parser')
body = soup.findAll('p', {'class' : ['story-body-text', 'story-content']})
res = ' '.join(p.text for p in body)
res = ('\n' if sentis else ' ').join(p.text for p in body)
jar.clear()
return res
......
......@@ -82,7 +82,6 @@ def index():
@mturk.route('/mark_available')
@require_human
def mark_available():
print('\n\n\nhere\n\n\n')
toggle_being_read(get_collection(), session['reading_url'], False)
return success()
......@@ -175,6 +174,9 @@ def get_next_doc():
if poss is None:
return None
to_be_read = poss[:][0]
try:
to_be_read = poss[:][0]
except IndexError:
return None
toggle_being_read(col, to_be_read['url'], True)
return to_be_read
......@@ -32,7 +32,8 @@ if __name__ == '__main__':
if len(sys.argv) > 1:
if sys.argv[1] == 'test':
terms = list(set(terms))[:5]
print('using small subset of training terms')
terms = list(set(terms))[:1]
elif sys.argv[1] in {'--help', 'help'}:
print('''options:\n\t``test`` <== uses small subset of training terms \n\t\t\tfor testing mturk\n\t```` <== (no options) loads all training keywords\n\t``help`` or ``--help`` <== displays this message\n''')
sys.exit(0)
......
......@@ -30,7 +30,7 @@ def is_positive(val):
def sentistrength(s):
"""Score with SentiStength
"""Score with SentiStength.
"""
p = subprocess.Popen(shlex.split('java -jar sentistrength/SentiStrengthCom.jar stdin sentidata sentistrength/data-11/ scale'), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
s = s.encode('utf8')
......
@import url(bootstrap.min.css);*{font-family:'Open Sans', Roboto, Ubuntu, 'Source Sans Pro', 'Helvetica Nueue', Helvetica, sans-serif}h1{font-weight:700}blockquote{font-size:16px}blockquote.good{background-color:#dff0d8;border-left:5px solid #3c763d}blockquote.bad{background-color:#f2dede;border-left:5px solid #a94442}.col-md-3{background-color:#eee}#full_article{font-size:16px}#full_article span{cursor:pointer}#full_article span.controversial{color:#bada55;background-color:#800}#copyright{margin-bottom:14em}.btn{font-weight:700}.top_bar{height:8px;background-color:#d9d9d9;margin-bottom:12px}#full_article{text-align:justify}#bot_bar{position:fixed;z-index:1;bottom:0}#bot_bar .col-md-12{padding:8px;background-color:#eee;margin-top:8px;text-align:right;height:61px}#bot_bar .col-md-12 .pull-left{padding:8px}@media (max-height: 400px){#bot_bar{position:relative}}@media (min-width: 1200px){#bot_bar{width:1170px}}@media (min-width: 992px){#bot_bar{width:970}}@media (min-width: 768px){#bot_bar{width:750}}
@import url(bootstrap.min.css);*{font-family:'Open Sans', Roboto, Ubuntu, 'Source Sans Pro', 'Helvetica Nueue', Helvetica, sans-serif}h1{font-weight:700}blockquote{font-size:16px}blockquote.good{background-color:#dff0d8;border-left:5px solid #3c763d}blockquote.bad{background-color:#f2dede;border-left:5px solid #a94442}.col-md-3{color:#ddd;background-color:rgba(245,245,245,0.3)}#full_article{font-size:16px}#full_article span{cursor:pointer}#full_article span.controversial{color:#bada55;background-color:#800}#copyright{margin-bottom:14em}.btn{font-weight:700}.top_bar{height:8px;background-color:#d9d9d9;margin-bottom:12px}#full_article{text-align:justify}#bot_bar{position:fixed;z-index:1;bottom:0}#bot_bar .col-md-12{padding:8px;background-color:#eee;margin-top:8px;text-align:right;height:61px}#bot_bar .col-md-12 .pull-left{padding:8px}@media (max-height: 400px){#bot_bar{position:relative}}@media (min-width: 1200px){#bot_bar{width:1170px}}@media (min-width: 992px){#bot_bar{width:970}}@media (min-width: 768px){#bot_bar{width:750}}
/*# sourceMappingURL=highlight.css.map */
......@@ -9,7 +9,9 @@ blockquote.good {
blockquote.bad {
background-color: #f2dede;
border-left: 5px solid #a94442; }
.col-md-3 { background-color: #eee; }
.col-md-3 {
color: #ddd;
background-color: rgba(245, 245, 245, .3); }
#full_article {
font-size: 16px;
span { cursor: pointer; }
......
......@@ -7,8 +7,7 @@
<p class="lead">Please click any sentences which you believe are controversial. We define controversial as expressing an opinon which could be debated by many people. When done, click <b><q>Submit</q></b>.</p>
</div>
<div class="col-md-3">
<b>metadata</b>
{{ article.title }} <b>&middot;</b> {{ article.byline }} <b>&middot;</b> {{ article.published }}
<i>{{ article.title }}</i> <b>&middot;</b> {{ article.byline }} <b>&middot;</b> {{ article.published }} <b>&middot;</b> <q>{{ article.keyword }}</q> corpus
</div>
<div class="col-md-12">
<hr>
......@@ -16,7 +15,7 @@
<div class="col-md-12">
<p id="full_article">
{% for sentence in article.full %}
<span title="currently non-controversial" onclick="toggleControversial({{ loop.index-1 }}, this)">{{ sentence }}</span>
<span onclick="toggleControversial({{ loop.index-1 }}, this)">{{ sentence }}</span>
{% endfor %}
</p>
</div>
......
......@@ -2,10 +2,10 @@
{% block content %}
<div class="row">
<div class="col-md-4">
<p class="lead">Tasks completed</p>
<p class="lead">HITS completed</p>
</div>
<div class="col-md-8">
<p>All articles in our training set have been annotated. <a href="https://github.com/gdyer/controversy">Learn more about this project</a>.</p>
<p>All articles in our training set have been annotated. Thank you for your interest. <a href="https://github.com/gdyer/controversy">Learn more about this project</a>.</p>
</div>
</div>
{% endblock %}
......@@ -5,7 +5,7 @@
<p class="lead">You've completed this HIT</p>
</div>
<div class="col-md-8">
<p>Report feedback to us: <b><tt>gdyer</tt>@<tt>seznam</tt>.<tt>cz</tt></b> or <a href="https://github.com/gdyer/controversy">learn more about this project</a>. Thank you.</p>
<p>Report feedback to us at <b><tt>gdyer</tt>@<tt>seznam</tt>.<tt>cz</tt></b> or <a href="https://github.com/gdyer/controversy">learn more about this project</a>. Thank you.</p>
</div>
</div>
{% endblock %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment