1. Learn
  2. /
  3. Courses
  4. /
  5. Graph RAG with LangChain and Neo4j

Connected

Exercise

Creating text chunks

The text from Romeo and Juliet has been loaded into a lexical graph with a structure of Acts and Scenes, but the text is still too large to generate meaningful embeddings. Complete the code to split the text from Act I, Scene I into smaller chunks for each line.

The visualize_graph() function will display the nodes and relationships in the graph document.

Instructions

100 XP
  • Append each line_node to the graph_document object.
  • Create HAS_LINE and SPOKEN_BY relationships between each scene and line_node, and line_node and character, respectively, and add them to graph_document.