コード例 #1
0
ファイル: db_comm.py プロジェクト: AdirShemesh/LibraryWiki
def authorities_of_record(authorities):
    if not authorities:
        return None, None
    authors_set = extract_authority('author', authorities)
    subjects_set = extract_authority('subject', authorities)
    return authors_set, subjects_set


def create_relationship(authorities, record, relation):
    if not authorities:
        return
    for authority in authorities:
        node = graph.merge_one("Authority", "id", authority)
        graph.create_unique(py2neo.Relationship(node, relation, record))


def extract_authority(relationship, authorities):
    find_id = re.compile(r"INNL\d{11}\$\$").search
    return authorities.get(relationship) and {find_id(authority).group()[6:-2] for authority in
                                              authorities[relationship] if find_id(authority)}

set_entities(get_authorities(from_id=0))
set_entities(Results('NNL_ALEPH'))
print("Done getting records", flush=True)
create_records_authorities_relationships()
set_portraits()
set_photos()
graph.match()
print("done", flush=True)
コード例 #2
0
import py2neo

from app.db_comm import graph
from app.entity_iterators import get_authorities


def to_node(authority):
    return py2neo.Node(*authority.labels, **authority.properties)


for i in range(3000):
    graph.create(
        *[to_node(authority) for authority in get_authorities(from_id=200000 + 1000 * i, to_id=201000 + 1000 * i)])
    print('yo')
コード例 #3
0
import py2neo

from app.db_comm import graph
from app.entity_iterators import get_authorities


def to_node(authority):
    return py2neo.Node(*authority.labels, **authority.properties)


for i in range(3000):
    graph.create(*[
        to_node(authority)
        for authority in get_authorities(from_id=200000 + 1000 * i,
                                         to_id=201000 + 1000 * i)
    ])
    print('yo')
コード例 #4
0
        return None, None
    authors_set = extract_authority('author', authorities)
    subjects_set = extract_authority('subject', authorities)
    return authors_set, subjects_set


def create_relationship(authorities, record, relation):
    if not authorities:
        return
    for authority in authorities:
        node = graph.merge_one("Authority", "id", authority)
        graph.create_unique(py2neo.Relationship(node, relation, record))


def extract_authority(relationship, authorities):
    find_id = re.compile(r"INNL\d{11}\$\$").search
    return authorities.get(relationship) and {
        find_id(authority).group()[6:-2]
        for authority in authorities[relationship] if find_id(authority)
    }


set_entities(get_authorities(from_id=0))
set_entities(Results('NNL_ALEPH'))
print("Done getting records", flush=True)
create_records_authorities_relationships()
set_portraits()
set_photos()
graph.match()
print("done", flush=True)