Exemplo n.º 1
0
def checkOntology(domain):
    Settings.load_root(root)
    Settings.load_config(None)
    Settings.config.add_section("GENERAL")
    Settings.config.set("GENERAL", 'domains', domain)

    Ontology.init_global_ontology()

    gOnt = Ontology.global_ontology
    for dstring in gOnt.possible_domains:
        informable = gOnt.get_informable_slots(dstring)

        for slot in informable:
            valuesJson = gOnt.get_informable_slot_values(dstring, slot)
            results = gOnt.ontologyManagers[dstring].db.customQuery(
                'SELECT DISTINCT {} FROM {} ORDER BY {} ASC'.format(
                    slot, dstring, slot))
            valuesDB = [entry[slot] for entry in results]
            # valuesDB = map(lambda a : a.lower(),valuesDB)
            valuesJson.append("not available")
            difference = list(set(valuesDB) - set(valuesJson))
            if len(difference):
                print dstring + " " + slot + " " + str(difference)
Exemplo n.º 2
0
                    break
            logger.info(str)
            print (str)
        
#         for a in self.prevbelief["beliefs"]:
#             print a, self.prevbelief["beliefs"][a]
#         for slot,value in self.prevbelief["beliefs"].iteritems():
#             print value
#             print slot
#         raw_input("hold and check beliefs in "+self.domainString)

if __name__ == "__main__":
    from belieftracking.baseline import FocusTracker
    from utils import Settings
    Settings.load_root('/Users/su259/pydial-letsgo/')
    Settings.load_config(None)
    Settings.set_seed(123)
    Settings.config.add_section("GENERAL")
    Settings.config.set("GENERAL",'domains', 'CamRestaurants')
    
    Ontology.init_global_ontology()
    tracker = FocusTracker('CamRestaurants')
    print ("hello()")
    tracker.update_belief_state(None, [('hello()',1.0)])
    print ('inform(area="centre")')
    tracker.update_belief_state('request(area)', [('inform(area="centre")',0.3)])
    print ('inform(area="north")')
    tracker.update_belief_state('confirm(area="centre")', [('negate(area="north",pricerange="cheap")',1.0)])
    tracker.update_belief_state('confirm(area="centre")', [('deny(area="centre",area="north",pricerange="cheap")',1.0)])
#     tracker.update_belief_state('confirm(area="centre")', [('negate(area="north")',1.0)])
Exemplo n.º 3
0
                self.sections.append(currentSection)
            elif currentSection is not None:
                line = line.lstrip().rstrip()
                self.section[currentSection].append(line)
            else:
                pass
        logger.info("Sections in page: "+str(self.sections))
        # and return some section:
        if sectionNum is not None:
            if sectionNum > len(self.sections) or sectionNum < 0:
                sectionNum = 0
            return self.section[self.sections[sectionNum]]
        elif sectionName is not None:
            pass 


#----------------------------------------------------
if __name__=="__main__":
    Settings.load_config(config_file="./config/texthub.cfg")
    ContextLogger.createLoggingHandlers(Settings.config)

    w = Wikipedia_API() 
    print w.summary(query=None)
    #print w.page.content
    print w.where()
    print w.get_section(sectionNum=2)   #sectionName="Phases")
    #print w.randomPages(2)


#END OF FILE