def datasetLookup(self,obj_url): """Method called when going to /api/data/{dataset name}. Returns a serialized version of the dataset.""" try: return Dataset.get(obj_url).serialize() except DoesNotExist: return rc.NOT_FOUND
def datasetLookup(self, obj_url): """Method called when going to /api/data/{dataset name}. Returns a serialized version of the dataset.""" try: return Dataset.get(obj_url).serialize() except DoesNotExist: return rc.NOT_FOUND
def make(dataset, text, reasons=None): needs_save = False if isinstance(dataset, basestring): datasetObj = Dataset.get(dataset) else: datasetObj = dataset dataset = datasetObj.name try: s = Sentence.objects.get(dataset=dataset, text=text) except DoesNotExist: s = Sentence(text=text, dataset=dataset, words=datasetObj.nl.normalize(text).split(), derived_assertions=[]) needs_save = True if reasons is not None: s.add_support(reasons) needs_save = True if needs_save: s.save() return s
def make(dataset, text, reasons=None): needs_save = False if isinstance(dataset, basestring): datasetObj = Dataset.get(dataset) else: datasetObj = dataset dataset = datasetObj.name try: s = Sentence.objects.get(dataset=dataset, text=text) except DoesNotExist: s = Sentence( text=text, dataset=dataset, words=datasetObj.nl.normalize(text).split(), derived_assertions=[] ) needs_save = True if reasons is not None: s.add_support(reasons) needs_save = True if needs_save: s.save() return s