marcderbauer / humanitarianKG

0 stars 0 forks source link

Watch Neo4j Cypher introduction course #21

Open marcderbauer opened 8 months ago

marcderbauer commented 8 months ago

https://graphacademy.neo4j.com/courses/cypher-fundamentals/

Unblocks #7

marcderbauer commented 8 months ago

Wanted to watch this to check if my cypher output is correct. Postponing this for now. I'll just try to load the cypher query and if it works then good, if not I'll watch this course.

marcderbauer commented 8 months ago

Better: figure out how to load the cypher query into Neo4j in python. (See #23)

marcderbauer commented 7 months ago

UPDATE: Managed to load cypher query into Neo4j. However, relations aren't created correctly. Will need to watch course to debug.

marcderbauer commented 7 months ago

Problem

WHAT IT LOOKS LIKE

! THIS IS WRONG!!!

CREATE (:Event {name: "Civil_War"})
MATCH (start:South_Sudan), (end:Civil_War) CREATE (start)-[:has_conflict{levels: 'high'}]->(end)

WHAT IT SHOULD LOOK LIKE

CREATE (:Event {name: "Civil War"})
MATCH (start:Country{name: "South Sudan"}), (end:Event{name:"Civil War"}) CREATE (start)-[:has_conflict{levels: 'high'}]->(end)

Not sure if it will exactly work like that, but in general the problem is:

Solution

Manually adjust development set of utterances to fit new schema and develop with that. Shouldn't be too hard to fix this. Once we know the "final" schema that works we can adjust the conversion function to output that schema.

I also considered changing the ChatGPT output, but we want to keep it as simple as possible for now to avoid errors.

marcderbauer commented 7 months ago

Digging Deeper

NODE: ENTITY, TYPE, PROPERTY ["South Sudan", "Country", {}]

RELATION: [ENTITY1, RELATIONSHIP, ENTITY2, PROPERTIES] ["South Sudan", "has_conflict", "Civil War", {"levels": "high"}],

Looking at it a bit more the entity labels seem correct here.

Solution

The actual issue seem to be the CREATE Statements. They're creating nodes with the label country and the property "name=xyz". They instead should be creating nodes with the label=name and category=Country/City/...

How it is

    "CREATE (:Country {name: \"South_Sudan\"})",
    "CREATE (:City {name: \"Juba\"})",
    "CREATE (:Organization {name: \"Government\"})",

How it should be

        "CREATE (:South_Sudan {category: \"Country\"})",
        "CREATE (:Juba {category: \"City\"})",
        "CREATE (:Government {category: \"Organization\"})",
marcderbauer commented 7 months ago

So the CREATE statements work now, but I have the MATCH CREATE statements don't...

image

Seems like all entities need to be created before you can match them. Might have to create a set of entities from the match statement to create first and then can create the matches

marcderbauer commented 6 months ago

Watched course, rest is separate ticket (see #30)