當前位置: 首頁>>代碼示例>>Python>>正文


Python Region.filterRegions方法代碼示例

本文整理匯總了Python中region.Region.filterRegions方法的典型用法代碼示例。如果您正苦於以下問題:Python Region.filterRegions方法的具體用法?Python Region.filterRegions怎麽用?Python Region.filterRegions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在region.Region的用法示例。


在下文中一共展示了Region.filterRegions方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: buildAllCorpus

# 需要導入模塊: from region import Region [as 別名]
# 或者: from region.Region import filterRegions [as 別名]
def buildAllCorpus(element_type='photos', time_interval_length=14, debug=False, paras={}):
    # return a dict = {region : its local corpus}
    assert element_type in ['photos', 'tweets']

    all_corpus = {}
    if element_type == 'photos':
        config = InstagramConfig
    else:
        config = TwitterConfig

    coordinates = [config.min_lat, config.min_lng,
                   config.max_lat, config.max_lng]

    nyc = Region(coordinates)
    region_list = nyc.divideRegions(25, 25)
    region_list = nyc.filterRegions(region_list, test=True, n=25, m=25, element_type=element_type)

    # 14 days ago
    now = int(tool.getCurrentStampUTC())

    num = 0
    for region in region_list:
        if debug and num > 0:
            # speed up the debugging
            pass
        else:
            cor = Corpus()
            cor.buildCorpus(region, [now - time_interval_length * 3600 * 24, now], element_type, paras)
        all_corpus[region.getKey()] = cor
        num += 1
        print 'build corpus %d' % (num)
    return all_corpus
開發者ID:juicyJ,項目名稱:citybeat_online,代碼行數:34,代碼來源:corpus.py

示例2: test

# 需要導入模塊: from region import Region [as 別名]
# 或者: from region.Region import filterRegions [as 別名]
def test():
    coordinates = [InstagramConfig.photo_min_lat,
                   InstagramConfig.photo_min_lng,
                   InstagramConfig.photo_max_lat,
                   InstagramConfig.photo_max_lng
    ]
    huge_region = Region(coordinates)
    alarm_region_size = 25
    regions = huge_region.divideRegions(25, 25)
    filtered_regions = huge_region.filterRegions(region_list=regions, test=True, n=alarm_region_size,
                                                 m=alarm_region_size)

    for i in range(1):
        test_region = regions[i]
        test_region._region['min_lat'] = 40.7329
        test_region._region['min_lng'] = -73.9957
        test_region._region['max_lat'] = 40.7383
        test_region._region['max_lng'] = -73.9844
        test_region.display()
        ts = TwitterTimeSeries(test_region, '1364829908', '1365693908')
        ts = ts.buildTimeSeries()
        for d in ts:
            print d
開發者ID:juicyJ,項目名稱:citybeat_online,代碼行數:25,代碼來源:twitter_time_series.py


注:本文中的region.Region.filterRegions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。