def get_turtle(self): if self.turtleName is None: turtlep = monkapi.yaml2json(self.TEST_TURTLE_SCRIPT) _turtle = monkapi.create_turtle(turtlep) self.turtleName = _turtle.name self.leader = _turtle.creator assert self.turtleName is not None return self.turtleName
def init_monk(): config=default_config() ms.initialize(default_config()) is_initialized = True likeTS = ms.yaml2json('travelgene/pymonk-master/examples/turtle_scripts/turtle_like.yml') # print likeTS likeT = ms.create_turtle(likeTS) likeT.save()
def init_database(): ents = ms.convert_entities() stemTS = ms.yaml2json('travelgene/pymonk-master/examples/turtle_scripts/turtle_stem.yml') stemT = ms.create_turtle(stemTS) # print stemT.generic() ents = ms.load_entities() for ent in ents: add_label(ent._id,'likeTravel','N') # print len(ents) # print ents[0].generic() fields=['title', 'comment', 'desc'] print [stemT.predict(ent, fields) for ent in ents]
import monk.core.api as ms from monk.roles.configuration import default_config from pymongo import MongoClient import json client = MongoClient() def printJson(my_json): parsed = json.loads(my_json) print json.dumps(parsed,indent=4,sort_keys=True) if __name__=='__main__': config=default_config() ms.initialize(default_config()) stemTS = ms.yaml2json('turtle_scripts/turtle_stem.yml') stemT = ms.create_turtle(stemTS) # print stemT.generic() ents = ms.load_entities() # print len(ents) # print ents[0].generic() fields=['title', 'comment', 'desc'] print [stemT.predict(ent, fields) for ent in ents] stemT.save() [ent.save() for ent in ents] likeTS = ms.yaml2json('turtle_scripts/turtle_like.yml') # print likeTS likeT = ms.create_turtle(likeTS) likeT.save() ent = ents[0] # print ents[0].generic()