Beispiel #1
0
def gettemporaldocs(context, cdir):
    resutl = list()
    day = context.attribute['day']
    time = context.attribute['time']
    season = context.attribute['season']
    daydoc = document.document(day, os.path.join(cdir,day))
    timedoc = document.document(time, os.path.join(cdir, time))
    seasondoc = document.document(season, os.path.join(cdir, season))
    return [daydoc, timedoc, seasondoc] 
Beispiel #2
0
def makeexampledocs(exdir):
    result = dict()
   # print exdir
    for fname in os.listdir(exdir):
        doc = document.document(fname, os.path.join(exdir, fname))
        result[doc.fid] = doc
    return result    
Beispiel #3
0
def getyelpsuggestions(contextnum, yelpdir, suggdir , urlfile ,categories):
    handle = open(os.path.join(yelpdir,contextnum))
    result = dict()
    load = json.load(handle)
    reader = open(urlfile)
    csvrd = utfcsv.UnicodeReader(reader)
    idurl = dict()
    for row in csvrd:
        if len(row) > 3:
            idurl[row[1]] = row[3]

    for business in load['businesses']: 
        cats = business.get('categories')
        if cats is None:
            continue
        found = False
        for cat in cats:
            if len(cat) > 1 and cat[1] in categories:
                found = True
                break
        if not found:
            continue
        if supercache.get(business['id']) is not None:
            result[business['id']] = supercache.get(business['id'])
            continue

        fpath = os.path.join(suggdir, business['id'])
        if not os.path.exists(fpath):
            continue
        doc = document.document(business['id'], fpath)
        doc.gmaptime = business.get('gmaptime')
        doc.url = idurl[doc.fid]
        result[doc.fid] = doc
        supercache[doc.fid] = doc

    reader.close()
    return result