def init_wsgi_server(langcodes, verbose=False, logformat='[%(asctime)-15s][%(levelname)s][%(module)s][%(pathname)s:%(lineno)d]: %(message)s', use_features=False, debug=False): """ Start a SemanticizerFlaskServer with all processors loaded into the pipeline. @param verbose: Set whether the Flask server should be verbose @param logformat: The logformat used by the Flask server """ # Initialize the pipeline pipeline = procpipeline.build(langcodes, use_features, debug=debug) # Create the FlaskServer logging.getLogger().info("Setting up server") server = Server() server.set_debug(verbose, logformat) # Setup all available routes / namespaces for the HTTP server server.setup_all_routes(pipeline, langcodes) logging.getLogger().info("Done setting up server, now starting...") # And finally, start the thing return server.app
pass try: import simplejson as json except ImportError: import json from flask import Flask, Response, request from semanticizer import procpipeline from semanticizer.config import config_get from semanticizer.wpm import init_datasource wpm_languages = config_get(('wpm', 'languages')) init_datasource(wpm_languages) PIPELINE = procpipeline.build(wpm_languages, feature_config=None) # WSGI application! application = Flask(__name__) application.debug = True APPLICATION_JSON = "application/json" # RegExens for CleanTweet CLEAN_TWEET = \ {'user': re.compile(r"(@\w+)"), 'url': re.compile(r"(http://[a-zA-Z0-9_=\-\.\?&/#]+)"), 'punctuation': re.compile(r"[-!\"#\$%&'\(\)\*\+,\.\/:;<=>\?@\[\\\]\^_`\{\|\}~]+"), 'retweet': re.compile(r"(\bRT\b)") }
except ImportError: pass try: import simplejson as json except ImportError: import json from flask import Flask, Response, request from semanticizer import procpipeline from semanticizer.config import config_get from semanticizer.wpm.data import init_datasource wpm_languages = config_get(('wpm', 'languages')) init_datasource(wpm_languages, settings) PIPELINE = procpipeline.build(wpm_languages) # WSGI application! application = Flask(__name__) application.debug = True APPLICATION_JSON = "application/json" # RegExens for CleanTweet CLEAN_TWEET = \ {'user': re.compile(r"(@\w+)"), 'url': re.compile(r"(http://[a-zA-Z0-9_=\-\.\?&/#]+)"), 'punctuation': re.compile(r"[-!\"#\$%&'\(\)\*\+,\.\/:;<=>\?@\[\\\]\^_`\{\|\}~]+"), 'retweet': re.compile(r"(\bRT\b)") }
pass try: import simplejson as json except ImportError: import json from flask import Flask, Response, request from semanticizer import procpipeline from semanticizer.config import config_get from semanticizer.wpm.data import init_datasource wpm_languages = config_get(('wpm', 'languages')) init_datasource(wpm_languages, settings) PIPELINE = procpipeline.build(wpm_languages) # WSGI application! application = Flask(__name__) application.debug = True APPLICATION_JSON = "application/json" # RegExens for CleanTweet CLEAN_TWEET = \ {'user': re.compile(r"(@\w+)"), 'url': re.compile(r"(http://[a-zA-Z0-9_=\-\.\?&/#]+)"), 'punctuation': re.compile(r"[-!\"#\$%&'\(\)\*\+,\.\/:;<=>\?@\[\\\]\^_`\{\|\}~]+"), 'retweet': re.compile(r"(\bRT\b)") }