Ejemplo n.º 1
0
    formatter = logging.Formatter(logformat)
    
    file_handler = TimedRotatingFileHandler(log, when='midnight')
    stream_handler = logging.StreamHandler(sys.stdout)

    stream_handler.setFormatter(formatter)
    file_handler.setFormatter(formatter)
    
    if verbose == True:
        root.setLevel(logging.DEBUG)
        
    root.addHandler(stream_handler)  
    root.addHandler(file_handler) 

# Init the logger
init_logging(config_get(('logging', 'path'), 'log.txt'),
             config_get(('logging', 'verbose'), False),
             config_get(('logging', 'format'), None))

# Set the datasource and init it
wpmlangs = config_get(('wpm', 'languages'))
settings = config_get(('settings'), {})
init_datasource(wpmlangs, settings)

# Init the server
application = init_wsgi_server(config_get(('wpm', 'languages')).keys(),
                 config_get(('logging', 'verbose'), False),
                 config_get(('logging', 'format'), None),
                 config_get(('linkprocs', 'includefeatures'), False),
                 config_get(('server', 'debug'), False))
Ejemplo n.º 2
0
    import ujson
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 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"[-!\"#\$%&'\(\)\*\+,\.\/:;<=>\?@\[\\\]\^_`\{\|\}~]+"),
Ejemplo n.º 3
0
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
""" Semanticizer (WSGI version)

A stripped down, WSGI compatible, version of the semanticizer.

Usage:
  gunicorn --bind 0.0.0.0:5001 --workers 4 semanticizer_wsgi:application
or
  uwsgi --http :5001 --master --processes 4 --wsgi-file semanticizer_wsgi.py

"""

import re
from semanticizer.config import config_get
settings = config_get(('settings'), {})

# Can do without ujson and simplejson, but speeds up considerably.
try:
    import ujson
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
Ejemplo n.º 4
0
# along with this program. If not, see <http://www.gnu.org/licenses/>.

""" Semanticizer (WSGI version)

A stripped down, WSGI compatible, version of the semanticizer.

Usage:
  gunicorn --bind 0.0.0.0:5001 --workers 4 semanticizer_wsgi:application
or
  uwsgi --http :5001 --master --processes 4 --wsgi-file semanticizer_wsgi.py

"""

import re
from semanticizer.config import config_get
settings = config_get(('settings'), {})

# Can do without ujson and simplejson, but speeds up considerably.
try:
    import ujson
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