def __init__(self, params):
     self.dbPath = params["dbPath"]
     self.graphdb = neo4j.GraphDatabase(self.dbPath)         
     self.dataFiles = []
     dfs = params["dataFiles"]
     for df in dfs: self.dataFiles.append(dataUtils.getDataFileNameOnly(df))        
     self.cleanRegex = re.compile('[\!\*\?]+')
     self.pprintr = pprint.PrettyPrinter(indent=4) 
示例#2
0
 
  if (agrvDic.__contains__('-store')):
      if not os.path.exists(const.data_dir) or os.listdir(const.data_dir) == []:
          print 'Please download data first. Use "-download" argument'
          sys.exit()  
                  
      du.storeData(const.data_dir, dataProvider)         
 
            
  if (agrvDic.__contains__('-query')):        
      dummy = True  
      print '\n'
      while dummy == True:          
          i = 0
          for df in dataProvider.dataFiles:        
              print str(i)+') '+dataUtils.getDataFileNameOnly(df)
              i = i + 1
          q = raw_input("Please choose one of the above indexes (enter 0-"+str((len(dataProvider.dataFiles)-1))+"): ")
          try: num = int(q) 
          except: continue
          if (num >=0 and num < len(dataProvider.dataFiles)):
              dataFile = dataProvider.dataFiles[num]
              print "Index '"+dataFile+"' was chosen.\n"
              break  
      pprintr = pprint.PrettyPrinter(indent=4)       
      while dummy == True:
          q = raw_input("\nPlease enter your query (or type 'quit;' to quit):")            
          if (q == 'quit;') : break
          q = q.strip()
          if (q == None or len(q)==0) : continue
                  
 def getIndex(self, dataFile):
     return self.graphdb.index(dataUtils.getDataFileNameOnly(dataFile), create=True, full_text='full_text')