예제 #1
0
def do_text():
    database = request.forms.get('database')
    print(database)
    db.create_database(database)
    db.flush()
    source = request.forms.get('source')
    document = request.forms.get('document')
    node = request.forms.get('node')
    relation = request.forms.get('relation')
    nc.create_network_text(source, document, node, relation, database)
    db.flush()

    current_location = Path(os.getcwd())
    data_location = current_location / 'data'
    graph_location = data_location / 'graph'
    config = ConfigManager({
        "init": {
            "location": graph_location
        },
        "file_format": "graphml"
    })
    print(graph_location)
    nxds = NetworkXDS(config)  # 读取网络用模块
    print(nxds.read_graph())
    network0 = nxds.read_graph(database)[database]
    scale = network0.number_of_nodes()
    size = network0.number_of_edges()
    print(scale)
    print(size)
    data = {
        'database': database + '.graphml',
        'source': source,
        'document': document,
        'node': node,
        'relation': relation,
        'node_number': scale,
        'edge_number': size,
        'nettype': node + ' ' + 'word network',
        'weighttype': 'count'
    }
    print(data)
    return data
예제 #2
0
def do_author():
    database = request.forms.get('database')
    print(database)
    db.flush()
    db.create_database(database)
    source = request.forms.get('source')
    document = request.forms.get('document')
    relation = request.forms.get('relation')
    nc.create_network_author(source, document, relation, database)
    db.flush()
    current_location = Path(os.getcwd())
    data_location = current_location / 'data'
    graph_location = data_location / 'graph'
    config = ConfigManager({
        "init": {
            "location": graph_location
        },
        "file_format": "graphml"
    })
    print(graph_location)
    nxds = NetworkXDS(config)  # 读取网络用模块
    print(nxds.read_graph())
    network0 = nxds.read_graph(database)[database]
    scale = network0.number_of_nodes()
    size = network0.number_of_edges()
    print(scale)
    print(size)
    data = {
        'database': database + '.graphml',
        'source': source,
        'document': document,
        'node': "undefined",
        'relation': relation,
        'node_number': scale,
        'edge_number': size,
        'nettype': 'author citation network',
        'weighttype': 'cite_count'
    }
    #nettype可以为co work network,此时weighttype改为co_count,这个要在后续版本中再进行动态的修改,暂时只使用citation即可。
    print(data)
    return data
예제 #3
0
def do_author():
    database = request.forms.get('database')
    print(database)
    db.flush()
    db.create_database(database)
    source = request.forms.get('source')
    document = request.forms.get('document')
    relation = request.forms.get('relation')
    nc.create_network_author(source, document, relation, database)
    db.flush()
    current_location = Path(os.getcwd())
    data_location = current_location / 'data'
    graph_location = data_location / 'graph'
    config = ConfigManager({
        "init": {
            "location": graph_location
        },
        "file_format": "graphml"
    })
    print(graph_location)
    nxds = NetworkXDS(config)  # 读取网络用模块
    print(nxds.read_graph())
    network = nxds.read_graph(database)[database]
    scale = network.number_of_nodes()
    size = network.number_of_edges()
    print(scale)
    print(size)
    data = {
        'database': database,
        'source': source,
        'document': document,
        'node': "undefined",
        'relation': relation,
        'node_number': scale,
        'edge_number': size
    }
    print(data)
    return data