#!/usr/bin/env python import sys from the_semantic_db_code import * from the_semantic_db_functions import * from the_semantic_db_processor import * C = context_list("geonames AU id version") #file = "data/ascii-just-adelaide.txt" file = "data/ascii-cities15000.txt" #file = "data/ascii-AU.txt" with open(file,'r') as f: for line in f: # print("line:",line) # fields = len(line.split("\t")) # print("fields:",fields) id,name,asciiname,altname,lat,long,feat_class,feat_code,country,cc2,admin1,admin2,admin3,admin4,population,elevation,dem,tz,mod_date = line.split("\t") # print("id: ",id) # print("name: ",asciiname) # print("lat: ",lat) # print("long: ",long) # print("country: ",country) # print("population:",population) # print("dem: ",dem) # print("tz: ",tz) # print() if int(population) >= 0: x = ket("id: " + id) # x = ket("location: " + asciiname) C.learn("id",x,"geonameid: " + id) C.learn("name",x,asciiname) # how handle if more than one location shares name, but not id? C.learn("lat",x,ket("latitude",lat)) # currently the last one over-writes the previous. C.learn("long",x,ket("longitude",long)) # heh. id is unique, name is not! C.learn("country",x,"country: " + country) # ie, you are doing it wrong using location as x. C.learn("population",x,ket("population",population)) C.learn("tz",x,"time-zone: " + tz) print(C.dump_universe())