Example #1
0
 def __build_graph(self, term, depth=0):
     if depth == self.MAX_DEPTH:
         return
     suggestions = Suggestions(term).get_suggestion()
     for suggestion in suggestions:
         if ' vs ' not in suggestion:
             continue
         if suggestion.count(' vs ') > 1:
             continue
         a, b = suggestion.split(' vs ')
         a = a.lower()
         b = b.lower()
         if b not in self.__nodes:
             self.__nodes.append(b)
             edge = (a, b)
             rev_edge = (b, a)
             if edge not in self.__edges and rev_edge not in self.__edges:
                 self.__edges.append(edge)
             self.__build_graph(b, depth=depth + 1)
Example #2
0
    def __build_graph(self, term, depth=0):
        if depth == self.MAX_DEPTH:
            return

        suggestions = Suggestions(term).get_suggestions()

        for suggestion in suggestions:
            if not suggestion.count(' vs ') == 1:
                continue

            first_word, second_word = suggestion.split(' vs ')
            if second_word not in self.__nodes:
                self.__nodes.append(second_word)
                edge = (first_word, second_word)
                if edge not in self.__edges and tuple(
                        reversed(edge)) not in self.__edges:
                    self.__edges.append(edge)

                self.__build_graph(second_word, depth=depth + 1)
Example #3
0
import suggestions
import json
import create_csv
from flask import Flask, request, jsonify, render_template, url_for
from flask_cors import CORS
from meta_handler import MetaHandler
from suggestions import Suggestions


meta_handler = MetaHandler()
sugg = Suggestions(meta_handler)
app = Flask(__name__)
CORS(app)

# create & load csv
create_csv.aggregate_csv_data(meta_handler, overwrite=False)
results = create_csv.load_csv()


# --- define routes ---

@app.route('/', methods=['GET'])
def index():
    suggs = sugg.get_top_users(results, 20)

    return render_template('index.html', users=json.dumps(suggs))


@app.route('/suggestions', methods=['POST'])
def get_suggestions():
    res = sugg.get_suggestions(results, request.form)