Example #1
0
 def get(topic_id='main'):
     # Parse input
     try:
         start_date, end_date = RequestParameterValidator.check_date_window_params(
             request.args)
     except WrongParametersError as wpe:
         return ResponseBuilder.build_exception(wpe.message, 400)
     # Do function
     try:
         graph = TopicService.find_topic(topic_id, start_date, end_date)
         return ResponseBuilder.build(graph, 200)
     except NoCooccurrenceGraphError as nhge:
         return ResponseBuilder.build_exception(nhge.message, 400)
Example #2
0
 def get(hashtag_name):
     # Parse input
     try:
         start_date, end_date = RequestParameterValidator.check_date_window_params(
             request.args)
     except WrongParametersError as wpe:
         return ResponseBuilder.build_exception(wpe.message, 400)
     # Do function
     try:
         graph = HashtagUsageService().find_hashtag(hashtag_name,
                                                    start_date, end_date)
         return ResponseBuilder.build(graph, 200)
     except NoDocumentsFoundError:
         return ResponseBuilder.build_exception('Requested data not found.',
                                                404)
Example #3
0
 def get():
     try:
         start_date, end_date = RequestParameterValidator.check_date_window_params(request.args)
     except WrongParametersError as wpe:
         return ResponseBuilder.build_exception(wpe.message, 400)
     # Do function
     try:
         similarities = SimilarityService.getSimilarities(start_date, end_date)
         return ResponseBuilder.build(similarities, 200)
     except Exception as e:
         return ResponseBuilder.build(e, 500)