本文整理汇总了Python中aleph.model.Entity.all方法的典型用法代码示例。如果您正苦于以下问题:Python Entity.all方法的具体用法?Python Entity.all怎么用?Python Entity.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aleph.model.Entity
的用法示例。
在下文中一共展示了Entity.all方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generate
# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import all [as 别名]
def _generate(self):
latest = Entity.latest()
if self.latest is not None and self.latest >= latest:
return
self.latest = latest
self.matches = defaultdict(set)
q = Entity.all()
q = q.options(joinedload('other_names'))
q = q.filter(Entity.state == Entity.STATE_ACTIVE)
for entity in q:
for term in entity.regex_terms:
self.matches[normalize_strong(term)].add(entity.id)
self.regexes = []
terms = self.matches.keys()
terms = [t for t in terms if len(t) > 2]
for i in count(0):
terms_slice = terms[i * BATCH_SIZE:(i + 1) * BATCH_SIZE]
if not len(terms_slice):
break
body = '|'.join(terms_slice)
rex = re.compile('( |^)(%s)( |$)' % body)
# rex = re.compile('(%s)' % body)
self.regexes.append(rex)
log.info('Generating entity tagger: %r (%s terms)',
latest, len(terms))
示例2: all
# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import all [as 别名]
def all():
q = Entity.all()
q = q.filter(Entity.state == Entity.STATE_ACTIVE)
clause = Collection.id.in_(authz.collections(authz.READ))
q = q.filter(Entity.collections.any(clause))
q = q.order_by(Entity.id.asc())
return jsonify(Pager(q, limit=100))
示例3: load_entities
# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import all [as 别名]
def load_entities():
tx = get_graph().begin()
q = Entity.all()
q = q.filter(Entity.state == Entity.STATE_ACTIVE)
for entity in q:
load_entity(tx, entity)
tx.commit()
示例4: load_entities
# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import all [as 别名]
def load_entities():
graph = get_graph()
tx = graph.begin()
q = Entity.all()
q = q.filter(Entity.state == Entity.STATE_ACTIVE)
for i, entity in enumerate(q):
load_entity(tx, entity)
if i > 0 and i % 10000 == 0:
tx.commit()
tx = graph.begin()
tx.commit()
示例5: _generate
# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import all [as 别名]
def _generate(self):
latest = Entity.latest()
if self.latest is not None and self.latest >= latest:
return
self.latest = latest
matches = defaultdict(set)
q = Entity.all()
q = q.options(joinedload('other_names'))
q = q.filter(Entity.state == Entity.STATE_ACTIVE)
for entity in q:
for term in entity.regex_terms:
matches[term].add(entity.id)
if not len(matches):
self.automaton = None
return
self.automaton = Automaton()
for term, entities in matches.items():
self.automaton.add_word(term.encode('utf-8'), entities)
self.automaton.make_automaton()
log.info('Generated automaton with %s terms', len(matches))
示例6: index
# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import all [as 别名]
def index():
collection_ids = match_ids('collection', authz.collections(authz.READ))
q = Entity.all()
q = q.filter(Entity.collection_id.in_(collection_ids))
return jsonify(Pager(q))