Skip to content

Commit

Permalink
small bugfix/add language to .example
Browse files Browse the repository at this point in the history
  • Loading branch information
interrogator committed Sep 5, 2019
1 parent 43e3f0d commit 8464d87
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 2 additions & 4 deletions buzzword/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

from .parts import start, explore # noqa: F401
from .parts.main import app, server # noqa: F401
from .parts.main import ROOT, CORPORA, CORPUS_META, CORPORA_CONFIGS
from .parts.main import CORPORA, CORPUS_META, CORPORA_CONFIGS
from .parts.tabs import _make_tabs
from .parts.helpers import _get_corpus, _get_initial_table

# where downloadable CSVs/corpora get stored
for path in {"csv", "uploads"}:
if not os.path.isdir(path):
os.makedirs("csv")
os.makedirs(path)


def _get_layout():
Expand Down Expand Up @@ -50,8 +50,6 @@ def _make_explore_layout(slug, conf):
"""
Simulate globals and generate layout for explore page
"""
from buzzword.parts.start import CORPORA, INITIAL_TABLES, CORPORA_CONFIGS

corpus = _get_corpus(slug)
table = _get_initial_table(slug)
conf["len"] = conf.get("len", len(corpus))
Expand Down
2 changes: 1 addition & 1 deletion buzzword/parts/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import flask

from buzzword.parts.main import app, CORPORA, INITIAL_TABLES, CORPORA_CONFIGS
from buzzword.parts.main import app, CORPORA, INITIAL_TABLES

# we can't keep tables in dcc.store, they are too big. so we keep all here with
# a tuple that can identify them (ideally, even dealing with user sessions)
Expand Down
5 changes: 3 additions & 2 deletions buzzword/parts/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ def _make_csv(table, long_name):
df = pd.DataFrame.from_dict(table)
csv_string = df.to_csv(index=False, encoding="utf-8")
with open(fpath, "w") as fo:
fo.write(df.to_csv())
fo.write(csv_string)
return fpath


def _get_corpus(slug):
"""
Get corpus from slug, loading from uploads dir if need be
"""
from buzzword.parts.start import CORPORA, INITIAL_TABLES
from buzzword.parts.start import CORPORA
from buzzword.parts.main import ROOT

if slug in CORPORA:
Expand All @@ -202,6 +202,7 @@ def _get_initial_table(slug):
corpus = _get_corpus(slug)
return corpus.table(show="p", subcorpora="file")


def _cast_query(query, col):
"""
ALlow different query types (e.g. numerical, list, str)
Expand Down
3 changes: 1 addition & 2 deletions buzzword/parts/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def show_uploaded(contents, filenames):
markdown += f"\n* and {rest} more ..."
return dcc.Markdown(markdown)


header = html.H2("buzzword: a tool for analysing annotated linguistic data")

# if no corpora available, do not show this table
Expand Down Expand Up @@ -311,8 +312,6 @@ def show_uploaded(contents, filenames):

upload = _make_upload_parse_space()

hide = {"display": "none"}

content = [header, intro, uphead, upload_text, upload]
if not is_empty:
content.append(demos)
Expand Down
2 changes: 2 additions & 0 deletions corpora.json.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"Do the Right Thing": {
"slug": "do-the-right-thing",
"language": "English",
"path": "dtrt/do-the-right-thing-parsed",
"desc": "Script of Spike Lee's 1989 drama, with various speaker and scene annotations",
"len": 17713,
Expand All @@ -12,6 +13,7 @@
},
"Unabomber Manifesto" : {
"slug": "manifesto",
"language": "English",
"path": "unabomber/manifesto-parsed",
"desc": "Text of the Unabomber's manifesto",
"len": 37347,
Expand Down

0 comments on commit 8464d87

Please sign in to comment.