def get(self):
        import math
        page_size = 100

        page = int(self.request.get("page",1))

        row_count = IngredientRawText.gql("WHERE annotated=:annotated", annotated = True).count()
        page_count = int(math.ceil(row_count / float(page_size)))

        rows  = IngredientRawText.gql("WHERE annotated=:annotated", annotated = True).fetch(page_size, offset = (page-1)*page_size)
        
        self.render("history.html", rows = map(lambda r: r.to_dict(), rows), count = row_count, page_count = page_count, page = page)
 def post(self):
     key = self.request.get("key")
     annotation = self.request.get("annotation")
     newcuts = self.request.get("newcuts")
     
     row = IngredientRawText.get(key)
     row.annotation = annotation
     row.newcuts = newcuts
     row.annotated = True
     row.put()
    def get(self):
        from json import loads
        from collections import Counter
        counter = Counter()
        
        rows = IngredientRawText.gql("WHERE annotated=:annotated", annotated = True)
        ings = []
        for r in rows:
            if r.annotation is not None:
                annotation = loads(r.annotation)

                hasbegan = False
                texts = []
                for word in annotation:
                    if "begin" in word["tags"]:
                        hasbegan = True
                        texts.append(word["text"])
                    elif "continue" in word["tags"] and hasbegan:
                        texts.append(word["text"])
                    elif hasbegan: #not begin nor continue
                        hasbegan = False
                        counter["-".join(texts)] += 1
                        texts = []
        self.render("stat_ing_name.html", freq_list = counter)
 def post(self):
     key = self.request.get("key")
     row = IngredientRawText.get(key)
     row.annotated = True
     row.put()
 def get(self):
     rows = IngredientRawText.gql("WHERE annotated=:annotated", annotated = False).fetch(100)
     self.render("to_do.html", rows = rows, known_ingredients = self._load_known_ingredients())
 def get(self):
     IngredientRawText.bulk_insert()
 def get(self):
     from json import loads, dump
     from codecs import open
     
     rows = IngredientRawText.gql("WHERE annotated=:annotated", annotated = True)
     self.render_json(map(lambda r: loads(r.annotation), rows))
 def get(self):
     for i in IngredientRawText.all():
         i.delete()