本文整理汇总了Python中dossier.fc.FeatureCollection.from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python FeatureCollection.from_dict方法的具体用法?Python FeatureCollection.from_dict怎么用?Python FeatureCollection.from_dict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dossier.fc.FeatureCollection
的用法示例。
在下文中一共展示了FeatureCollection.from_dict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cbor_iter
# 需要导入模块: from dossier.fc import FeatureCollection [as 别名]
# 或者: from dossier.fc.FeatureCollection import from_dict [as 别名]
def cbor_iter(fh):
while True:
try:
chunk = cbor.load(fh)
except EOFError:
break
yield FeatureCollection.from_dict(chunk)
示例2: v1_fc_put
# 需要导入模块: from dossier.fc import FeatureCollection [as 别名]
# 或者: from dossier.fc.FeatureCollection import from_dict [as 别名]
def v1_fc_put(request, response, store, kvlclient, tfidf, cid):
'''Store a single feature collection.
The route for this endpoint is:
``PUT /dossier/v1/feature-collections/<content_id>``.
``content_id`` is the id to associate with the given feature
collection. The feature collection should be in the request
body serialized as JSON.
Alternatively, if the request's ``Content-type`` is
``text/html``, then a feature collection is generated from the
HTML. The generated feature collection is then returned as a
JSON payload.
This endpoint returns status ``201`` upon successful
storage otherwise. An existing feature collection with id
``content_id`` is overwritten.
'''
tfidf = tfidf or None
if request.headers.get('content-type', '').startswith('text/html'):
url = urllib.unquote(cid.split('|', 1)[1])
fc = etl.create_fc_from_html(url, request.body.read(), tfidf=tfidf)
logger.info('created FC for %r', cid)
store.put([(cid, fc)])
return fc_to_json(fc)
else:
fc = FeatureCollection.from_dict(json.load(request.body))
keywords = set()
for subid in fc:
if subid.startswith('subtopic'):
ty = subtopic_type(subid)
if ty in ('text', 'manual'):
# get the user selected string
data = typed_subtopic_data(fc, subid)
map(keywords.add, cleanse(data).split())
keywords.add(cleanse(data))
folders = Folders(kvlclient)
for fid, sid in folders.parent_subfolders(cid):
if not isinstance(fid, unicode):
fid = fid.decode('utf8')
if not isinstance(sid, unicode):
sid = sid.decode('utf8')
keywords.add(cleanse(fid))
keywords.add(cleanse(sid))
fc[u'keywords'] = StringCounter(keywords)
store.put([(cid, fc)])
response.status = 201
示例3: v1_fc_put
# 需要导入模块: from dossier.fc import FeatureCollection [as 别名]
# 或者: from dossier.fc.FeatureCollection import from_dict [as 别名]
def v1_fc_put(request, response, visid_to_dbid, store, cid):
"""Store a single feature collection.
The route for this endpoint is:
``PUT /dossier/v1/feature-collections/<content_id>``.
``content_id`` is the id to associate with the given feature
collection. The feature collection should be in the request
body serialized as JSON.
This endpoint returns status ``201`` upon successful storage.
An existing feature collection with id ``content_id`` is
overwritten.
"""
fc = FeatureCollection.from_dict(json.load(request.body))
store.put([(visid_to_dbid(cid), fc)])
response.status = 201