当前位置: 首页>>代码示例>>Python>>正文


Python Entity.all方法代码示例

本文整理汇总了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))
开发者ID:andkamau,项目名称:aleph,代码行数:31,代码来源:regex_entity.py

示例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))
开发者ID:rlugojr,项目名称:aleph,代码行数:9,代码来源:entities_api.py

示例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()
开发者ID:simonwoerpel,项目名称:aleph,代码行数:9,代码来源:entities.py

示例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()
开发者ID:rlugojr,项目名称:aleph,代码行数:13,代码来源:entities.py

示例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))
开发者ID:CodeForAfrica,项目名称:aleph,代码行数:25,代码来源:regex_entity.py

示例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))
开发者ID:stefanw,项目名称:aleph,代码行数:7,代码来源:entities_api.py


注:本文中的aleph.model.Entity.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。