Navigation Menu

Skip to content

Commit

Permalink
added run script and changed setup
Browse files Browse the repository at this point in the history
  • Loading branch information
tmbo committed Feb 14, 2018
1 parent 0b57584 commit 7f08319
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -48,7 +48,8 @@ jobs:
- export ${!TRAVIS*}
- sphinx-versioning push docs gh-pages .
- stage: deploy
install: skip
install:
- pip install pypandoc==1.4
script: skip
deploy:
provider: pypi
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -9,6 +9,8 @@ help:
@echo " Check style with flake8."
@echo " test"
@echo " Run py.test"
@echo " check-readme"
@echo " Check if the readme can be converted from md to rst for pypi"

clean:
find . -name '*.pyc' -exec rm -f {} +
Expand All @@ -27,3 +29,7 @@ test: clean

livedocs:
cd docs && make livehtml

check-readme:
# if this runs through we can be sure the readme is properly shown on pypi
python setup.py check --restructuredtext --strict
2 changes: 2 additions & 0 deletions rasa_nlu/extractors/duckling_extractor.py
Expand Up @@ -82,6 +82,8 @@ def create(cls, config):
# type: (RasaNLUConfig) -> DucklingExtractor

dims = config["duckling_dimensions"]

config.get({})
if dims:
unknown_dimensions = [dim
for dim in dims
Expand Down
55 changes: 55 additions & 0 deletions rasa_nlu/run.py
@@ -0,0 +1,55 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import json
import logging
import os

import six
from builtins import input

from rasa_nlu.config import RasaNLUConfig
from rasa_nlu.model import Interpreter

logger = logging.getLogger(__name__)


def create_argparser(): # pragma: no cover
import argparse
parser = argparse.ArgumentParser(
description='run a Rasa NLU model locally on the command line '
'for manual testing')

parser.add_argument('-c', '--config', required=True,
help="config file")

parser.add_argument('-m', '--model', required=True,
help="path to model")
return parser


def run_cmdline(config, model_path, component_builder=None):
interpreter = Interpreter.load(model_path, config, component_builder)

logger.info("NLU model loaded. Type a message and press enter to parse it.")
while True:
text = input().strip()
if six.PY2:
# in python 2 input doesn't return unicode values
text = text.decode("utf-8")
r = interpreter.parse(text)
print(json.dumps(r, indent=2))


if __name__ == '__main__': # pragma: no cover
parser = create_argparser()
args = parser.parse_args()

nlu_config = RasaNLUConfig(args.config, os.environ, vars(args))
logging.basicConfig(level=nlu_config['log_level'])

run_cmdline(nlu_config, args.model)

logger.info("Finished evaluation")
51 changes: 28 additions & 23 deletions setup.py
@@ -1,7 +1,16 @@
from setuptools import setup
from setuptools import setup, find_packages
import io

__version__ = None # Avoids IDE errors, but actual version is read from version.py
exec(open('rasa_nlu/version.py').read())
# Avoids IDE errors, but actual version is read from version.py
__version__ = None
exec (open('rasa_nlu/version.py').read())

try:
import pypandoc
readme = pypandoc.convert_file('README.md', 'rst')
except (IOError, ImportError):
with io.open('README.md', encoding='utf-8') as f:
readme = f.read()

tests_requires = [
"pytest",
Expand Down Expand Up @@ -41,18 +50,12 @@

setup(
name='rasa_nlu',
packages=[
'rasa_nlu',
'rasa_nlu.utils',
'rasa_nlu.classifiers',
'rasa_nlu.emulators',
'rasa_nlu.extractors',
'rasa_nlu.featurizers',
'rasa_nlu.tokenizers',
'rasa_nlu.training_data',
'rasa_nlu.training_data.formats'
],
packages = find_packages(exclude=['contrib', 'docs', 'tests']),
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
# supported python versions
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
Expand All @@ -64,17 +67,19 @@
extras_require=extras_requires,
include_package_data=True,
description="Rasa NLU a natural language parser for bots",
author='Alan Nichol',
author_email='alan@rasa.ai',
long_description=readme,
author='Rasa Technologies GmbH',
author_email='hi@rasa.ai',
license='Apache 2.0',
url="https://rasa.com",
keywords=["nlp", "machine-learning", "machine-learning-library", "bot",
"bots",
"botkit", "rasa", "conversational-agents",
"conversational-ai",
"chatbot", "chatbot-framework", "bot-framework"],
download_url="https://github.com/RasaHQ/rasa_nlu/archive/{}.tar.gz".format(__version__)
keywords="nlp machine-learning machine-learning-library bot bots "
"botkit rasa conversational-agents conversational-ai chatbot"
"chatbot-framework bot-framework",
download_url="https://github.com/RasaHQ/rasa_nlu/archive/{}.tar.gz"
"".format(__version__)
)

print("\nWelcome to Rasa NLU!")
print("If any questions please visit documentation page https://rasahq.github.io/rasa_nlu")
print("If any questions please visit documentation "
"page https://rasahq.github.io/rasa_nlu")
print("or join community chat on https://gitter.im/RasaHQ/rasa_nlu")

0 comments on commit 7f08319

Please sign in to comment.