<commit_before>import argparse
import json
import os
import urlparse
import subprocess
import glob
import warnings
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer

from rasa_nlu.util import update_config


def create_interpreter(config):
    model_dir = config.get("server_model_dir")
    metadata, backend = None

    if (model_dir is not None):
        # download model from S3 if needed
        if (not os.path.isdir(model_dir)):
            try:
                from rasa_nlu.persistor import Persistor
                p = Persistor(config['path'], config['aws_region'], config['bucket_name'])
                p.fetch_and_extract('{0}.tar.gz'.format(os.path.basename(model_dir)))
            except:
                warnings.warn("using default interpreter, couldn't find model dir or fetch it from S3")

        metadata = json.loads(open(os.path.join(model_dir, 'metadata.json'), 'rb').read())
        backend = metadata["backend"]

    if backend is None:
        from interpreters.simple_interpreter import HelloGoodbyeInterpreter
        return HelloGoodbyeInterpreter()
    elif backend.lower() == 'mitie':
        print("using mitie backend")
        from interpreters.mitie_interpreter import MITIEInterpreter
        return MITIEInterpreter(**metadata)
    elif backend.lower() == 'spacy_sklearn':
        print("using spacy + sklearn backend")
        from interpreters.spacy_sklearn_interpreter import SpacySklearnInterpreter
        return SpacySklearnInterpreter(**metadata)<commit_msg>bugfix multiple assignment in server<commit_after>import argparse
import json
import os
import urlparse
import subprocess
import glob
import warnings
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer

from rasa_nlu.util import update_config


def create_interpreter(config):
    model_dir = config.get("server_model_dir")
    metadata, backend = None, None

    if (model_dir is not None):
        # download model from S3 if needed
        if (not os.path.isdir(model_dir)):
            try:
                from rasa_nlu.persistor import Persistor
                p = Persistor(config['path'], config['aws_region'], config['bucket_name'])
                p.fetch_and_extract('{0}.tar.gz'.format(os.path.basename(model_dir)))
            except:
                warnings.warn("using default interpreter, couldn't find model dir or fetch it from S3")

        metadata = json.loads(open(os.path.join(model_dir, 'metadata.json'), 'rb').read())
        backend = metadata["backend"]

    if backend is None:
        from interpreters.simple_interpreter import HelloGoodbyeInterpreter
        return HelloGoodbyeInterpreter()
    elif backend.lower() == 'mitie':
        print("using mitie backend")
        from interpreters.mitie_interpreter import MITIEInterpreter
        return MITIEInterpreter(**metadata)
    elif backend.lower() == 'spacy_sklearn':
        print("using spacy + sklearn backend")
        from interpreters.spacy_sklearn_interpreter import SpacySklearnInterpreter
        return SpacySklearnInterpreter(**metadata)
{'fraction_non_alphanumeric': 0.08782239634345412, 'fraction_numerical': 0.0019588638589618022, 'mean_word_length': 3.315492957746479, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6907935', 'n_tokens_mistral': 848, 'n_tokens_neox': 838, 'n_words': 220}