<commit_before>#!/usr/bin/python3.4

import time

from py2neo import Graph, Node, Relationship
from py2neo import Path, authenticate

def main():

    host_port = 'localhost:7474'
    user_name = 'neo4j'
    user_password = '<PASSWORD>'

    authenticate(host_port, user_name, user_password)

    graph = Graph()
    transaction = graph.begin()

    string = "Hello World"
    for x in string:
        print(x)

    graph.delete_all()

    # units start
    java = Node("Unit", label="Java")
    python = Node("Unit", label="Python")

    transaction.create(java)
    transaction.create(python)
    # units end

    # categories start
    streams_java = Node("Category", name="Streams in Java")
    primitives_java = Node("Category", name="Primitive types in Java")
    jsf_java = Node("Category", name="JSF")
    spring_framework_java = Node("Category", name="Spring Framework")
    spring_data_jpa_java = Node("Category", name="Spring Data JPA")
    spring_data_mongo_java = Node("Category", name="Spring Data MongoDB")
    spring_data_neo_java = Node("Category", name="Spring Data Neo4J")
    spring_boot_java = Node("Category", name="Spring Boot")

    variables_python = Node("Category", name="Variable types in Python")
    py2neo_python = Node("Category", name="Py2neo Module")

    transaction.create(streams_java)
    transaction.create(primitives_java)
    transaction.create(jsf_java)
    transaction.create(spring_framework_java)
    transaction.create(spring_data_jpa_java)
    transaction.create(spring_data_mongo_java)
    transaction.create(spring_data_neo_java)
    transaction.create(spring_boot_java)

    transaction.create(variables_python)
    transaction.create(py2neo_python)
    # categories end

    # relationships unit<-category start
    java_streams_java = Relationship(streams_java, "HAS_IN", java)
    java_primitives_java = Relationship(primitives_java, "HAS_IN", java)
    java_jsf_java = Relationship(jsf_java, "HAS_IN", java)
    java_spring_framework_java = Relationship(spring_framework_java, "HAS_IN", java)
    java_spring_data_jpa_java = Relationship(spring_data_jpa_java, "HAS_IN", java)
    java_spring_data_mongo_java = Relationship(spring_data_mongo_java, "HAS_IN", java)
    java_spring_data_neo_java = Relationship(spring_data_neo_java, "HAS_IN", java)
    java_spring_boot_java = Relationship(spring_boot_java, "HAS_IN", java)

    python_variables_python = Relationship(variables_python, "HAS_IN", python)
    python_py2neo_python = Relationship(py2neo_python, "HAS_IN", python)

    transaction.create(java_streams_java)
    transaction.create(java_primitives_java)
    transaction.create(java_jsf_java)
    transaction.create(java_spring_framework_java)
    transaction.create(java_spring_data_jpa_java)
    transaction.create(java_spring_data_mongo_java)
    transaction.create(java_spring_data_neo_java)
    transaction.create(java_spring_boot_java)

    transaction.create(python_variables_python)
    transaction.create(python_py2neo_python)
    # relationships unit<-category end

    # task start
    for x in range(0, 15):
        task_java = Node("Task", name="Stream question " + str(x))
        transaction.create(task_java)

        task_streams_java = Relationship(task_java, "HAS_IN", streams_java)
        transaction.create(task_streams_java)

    transaction.commit()

    with open('./import.cypher') as file:
        query = file.read()

    print(graph.run(query).dump())

if __name__ == '__main__':
    start = time.time()
    main()
    end = time.time() - start
    print("Time to complete:", end)<commit_msg>Optimize creation of categories in one unit: - use foreach loop<commit_after>#!/usr/bin/python3.4

import time

from py2neo import Graph, Node, Relationship
from py2neo import Path, authenticate

def main():

    host_port = 'localhost:7474'
    user_name = 'neo4j'
    user_password = '<PASSWORD>'

    authenticate(host_port, user_name, user_password)

    graph = Graph()
    transaction = graph.begin()

    graph.delete_all()

    # units start
    java = Node("Unit", label="Java")
    python = Node("Unit", label="Python")

    transaction.create(java)
    transaction.create(python)
    # units end

    categories = [
        'Streams in Java',
        'Primitive types in Java',
        'JSF',
        'Spring Framework',
        'Spring Data JPA',
        'Spring Data MongoDB',
        'Spring Data Neo4J',
        'Spring Boot'
    ]

    # category
    for category in categories:
        print(category)

        node = Node("Category", name=category)
        transaction.create(node)

        transaction.create(Relationship(node, "HAS_IN", java))

        # task
        for x in range(0, 15):
            task_java = Node("Task", name="Some question " + str(x))
            transaction.create(task_java)

            task_streams_java = Relationship(task_java, "HAS_IN", node)
            transaction.create(task_streams_java)

    transaction.commit()

    with open('./import.cypher') as file:
        query = file.read()

    print("\n")
    print(graph.run(query).dump())

if __name__ == '__main__':
    start = time.time()
    main()
    end = time.time() - start
    print("\n")
    print("Time to complete:", end)
{'fraction_non_alphanumeric': 0.11091954022988505, 'fraction_numerical': 0.006130268199233717, 'mean_word_length': 3.737749546279492, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4091878', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1575, 'n_words': 331}