Example #1
0
 def GET(self, object_id):
     '''Renders a page with all of the questions and values for a specified
        object_id so that it can be retrained manually.'''
     object = model.get_object_by_id(object_id)
     questions = model.get_questions()
     data = model.get_data_dictionary()
     if object:
         return render.retrain(object, list(questions), data)
     else:
         raise web.seeother('/') # returns to admin page
Example #2
0
 def GET(self, object_id):
     '''Renders a page with all of the questions and values for a specified
        object_id so that it can be retrained manually.'''
     object = model.get_object_by_id(object_id)
     questions = model.get_questions()
     data = model.get_data_dictionary()
     if object:
         return render.retrain(object, list(questions), data)
     else:
         raise web.seeother('/')  # returns to admin page
Example #3
0
def get_nearby_objects_values(objects_values, how_many=10):
    '''Returns how_many (value, object) pairs with the highest values in the local
       knowledge base. Default: how_many=10.'''
       
    sorted_objects_values = sort_objects_values(objects_values)
    
    if how_many > len(sorted_objects_values):
        how_many = len(sorted_objects_values)
    
    if sorted_objects_values:
        nearby_objects_values = [(sorted_objects_values[i][0], model.get_object_by_id(sorted_objects_values[i][1])) for i in range(how_many)]
    else:
        nearby_objects_values = []
        
    return nearby_objects_values