Skip to content

Commit

Permalink
buzzword create works; update for the buzz constants change
Browse files Browse the repository at this point in the history
  • Loading branch information
interrogator committed May 5, 2020
1 parent c6594ef commit 071caff
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 26 deletions.
5 changes: 5 additions & 0 deletions bin/create
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

# Run the buzzword app

python -m buzzword.create $@
4 changes: 4 additions & 0 deletions buzzword/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@

from django.core.management import execute_from_command_line

CWD = os.getcwd()

manage_dir = pathlib.Path(__file__).parent.parent.absolute()
os.chdir(manage_dir)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "buzzword.settings")
os.environ.setdefault("BUZZWORD_CORPORA_FILE", os.path.join(CWD, "corpora.json"))
os.environ.setdefault("BUZZWORD_ROOT", CWD)

if len(sys.argv) == 1 and "__main__.py" in sys.argv[0]:
argv = ["manage.py", "runserver"]
Expand Down
37 changes: 21 additions & 16 deletions explorer/create.py → buzzword/create.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

"""
buzzword: make a workspace for buzzword in the current directory
Expand All @@ -11,37 +13,41 @@
import os
import sys

from buzz.corpus import Corpus
from buzz import Corpus

NAME = sys.argv[-1]

FULLNAME = os.path.abspath(NAME)

if "create.py" in FULLNAME:
raise ValueError("Please specify a name for your project.")

if os.path.exists(FULLNAME):
raise OSError(f"Path exists: {FULLNAME}")

CORPUS_PATH = os.path.join(NAME, "example")

print("Making a new workspace at {}".format(FULLNAME))

ENV = """
ENV = f"""
# .env example for deploying buzzword
# comment out keys you are not using
BUZZWORD_CORPORA_FILE=corpora.json
BUZZWORD_ROOT={}
BUZZWORD_ROOT={FULLNAME}
BUZZWORD_LOAD=true
BUZZWORD_TITLE=buzzword
BUZZWORD_DEBUG=false
BUZZWORD_MAX_DATASET_ROWS=999999
BUZZWORD_DROP_COLUMNS=parse,text
BUZZWORD_PAGE_SIZE=25
BUZZWORD_TABLE_SIZE=2000,200
BUZZWORD_ADD_GOVERNOR=false
""".format(
FULLNAME
)
"""

CORPORA = """
CORPORA = f"""
{{
"Example corpus: joke": {{
"slug": "jokes",
"path": "{}",
"path": "{os.path.abspath(CORPUS_PATH + "-parsed")}",
"desc": "Sample corpus with speaker names and metadata",
"len": 29,
"drop_columns": ["text"],
Expand All @@ -50,9 +56,7 @@
"url": "https://en.wikipedia.org/wiki/Joke"
}}
}}
""".format(
os.path.abspath(CORPUS_PATH + "-parsed")
)
"""

CORPUS = """
<meta doc-type="joke" rating=6.50 speaker="NARRATOR"/>
Expand All @@ -73,8 +77,9 @@
fo.write(CORPORA.strip() + "\n")
with open(os.path.join(CORPUS_PATH, "001-joke-lion-pun.txt"), "w") as fo:
fo.write(CORPUS.strip() + "\n")
print("Testing parser: {}->{}-parsed ...".format(CORPUS_PATH, CORPUS_PATH))
parsed = Corpus(CORPUS_PATH).parse(cons_parser=None)
print(f"Testing parser: {CORPUS_PATH}->{CORPUS_PATH}-parsed ...")

parsed = Corpus(CORPUS_PATH).parse(constituencies=False)

print("Workspace made in {}".format(FULLNAME))
print("Run 'cd {} && python -m buzzword' to start.".format(NAME))
print(f"Workspace made in {FULLNAME}")
print(f"Run 'cd {NAME} && python -m buzzword' to start.")
4 changes: 2 additions & 2 deletions corpora.json.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Do the Right Thing": {
"slug": "do-the-right-thing",
"language": "English",
"language": "en",
"path": "dtrt/do-the-right-thing-parsed",
"desc": "Script of Spike Lee's 1989 drama, with various speaker and scene annotations",
"length": 17713,
Expand All @@ -15,7 +15,7 @@
},
"Unabomber Manifesto" : {
"slug": "manifesto",
"language": "English",
"language": "en",
"drop_columns": ["text", "parse"],
"path": "unabomber/manifesto-parsed",
"desc": "Text of the Unabomber's manifesto",
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
django==3.0.5
#django-guardian==2.1.0
git+git://github.com/l0rb/django-guardian@devel#egg=django-guardian
django-plotly-dash==1.3.1
git+https://github.com/l0rb/django-guardian@devel#egg=django-guardian
git+https://github.com/GibbsConsulting/django-plotly-dash
dpd-static-support==0.0.4
dash_bootstrap_components==0.7.2
whitenoise==4.1.4
buzz>=3.1.0
flask==1.1.2
dash==1.10.0
dash-core-components==1.9.1
dash-core-components==1.9.0
dash-html-components==1.0.3
dash-daq==0.5.0
dash-renderer==1.4.0
dash-renderer==1.3.0
dash-table==4.6.2
python-dotenv==0.10.3
# Tests and CI
Expand Down
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def read(fname):
author="Danny McDonald",
include_package_data=True,
zip_safe=False,
scripts=["bin/buzzword", "bin/create"],
packages=["buzzword", "docs", "explorer/parts"],
package_dir={"explorer/parts/assets": "explorer/parts/assets", "docs": "docs"},
package_data={"buzzword/parts": assets, "docs": docs},
Expand All @@ -37,14 +38,14 @@ def read(fname):
"buzz>=3.0.12",
"django==3.0.5",
"python-dotenv==0.10.3",
"django-plotly-dash==1.3.1",
"django-plotly-dash @ https://github.com/GibbsConsulting/django-plotly-dash",
"flask==1.1.2",
"dash==1.10.0",
"dash-core-components==1.9.1",
"dash-core-components==1.9.0",
"dash-html-components==1.0.3",
"dash-daq==0.5.0",
"dash-renderer==1.4.0",
"dash-table==4.6.2"`,
"dash-renderer==1.3.0",
"dash-table==4.6.2",
],
classifiers=[
"Programming Language :: Python",
Expand Down

0 comments on commit 071caff

Please sign in to comment.