Exemplo n.º 1
0
 def setUpClass(cls):
     SyntaxCache().build_cache()
Exemplo n.º 2
0
def syntax_cache():
    SyntaxCache().build_cache()
    return ok()
Exemplo n.º 3
0
 def test_build_cache(self):
     SyntaxCache.build_cache()
     self.assertTrue(self.rs.get_syntax_list() == [
         'compare', 'matches', 'matches_cond', 'most_x', 'partnerships',
         'player_dismissals', 'player_stats', 'scores'
     ])
Exemplo n.º 4
0
from opencricket.chart.syntax_cache import SyntaxCache

sys.path.append(os.path.dirname(__file__))

import json
from opencricket.config import config
from flask import Flask, request, abort, make_response
from opencricket.chart.sentence_parser import SentenceParser
from opencricket.chart.syntax_response import SyntaxResponse
from opencricket.suggestion.productions import Productions
from opencricket.suggestion.suggestions import Suggestions
from opencricket.chart.player_names import PlayerNames
from opencricket.config import es_config

app = Flask(__name__)
SyntaxCache().build_cache()
app.config.from_object('environment.' +
                       (os.environ.get('OPENCRICKET_ENV') or 'Development'))


@app.route("/")
def search():
    user_search = request.args.get('search', '')
    elastic_search = es_connection()

    try:
        player_names = PlayerNames(config.metadata_dir +
                                   'player_names.txt').get_player_names(
                                       user_search)
        parser = SentenceParser(user_search, player_names)
    except Exception as e:
Exemplo n.º 5
0
 def test_build_cache(self):
     SyntaxCache.build_cache()
     self.assertTrue(self.rs.get_syntax_list() == ['compare', 'matches', 'matches_cond', 'most_x', 'partnerships', 'player_dismissals', 'player_stats', 'scores'])