diff --git a/code/.ipynb_checkpoints/Untitled2-checkpoint.ipynb b/code/.ipynb_checkpoints/Untitled2-checkpoint.ipynb
new file mode 100644
index 0000000000000000000000000000000000000000..363fcab7ed6e9634e198cf5555ceb88932c9a245
--- /dev/null
+++ b/code/.ipynb_checkpoints/Untitled2-checkpoint.ipynb
@@ -0,0 +1,6 @@
+{
+ "cells": [],
+ "metadata": {},
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/code/.ipynb_checkpoints/generalized_graph_building-checkpoint.ipynb b/code/.ipynb_checkpoints/generalized_graph_building-checkpoint.ipynb
index e65187f57c44818a6cdef1358f801b5d9cfbabf7..9184fb504ecd26f1ad5615cf3c9a61638043089e 100644
--- a/code/.ipynb_checkpoints/generalized_graph_building-checkpoint.ipynb
+++ b/code/.ipynb_checkpoints/generalized_graph_building-checkpoint.ipynb
@@ -16,7 +16,8 @@
     "import os\n",
     "import json\n",
     "import pickle\n",
-    "import re"
+    "import re\n",
+    "import penman"
    ]
   },
   {
@@ -66,7 +67,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 29,
+   "execution_count": 2,
    "metadata": {},
    "outputs": [
     {
@@ -106,7 +107,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 3,
    "metadata": {},
    "outputs": [
     {
@@ -125,7 +126,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": 4,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -136,7 +137,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [
     {
@@ -555,11 +556,11 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 30,
    "metadata": {},
    "outputs": [],
    "source": [
-    "def get_graph_triples(amr_parse):\n",
+    "def get_graph_triples_old(amr_parse):\n",
     "\n",
     "    lines = []\n",
     "    amr_parse = amr_parse[:-1]\n",
@@ -586,7 +587,17 @@
     "            continue\n",
     "        else:\n",
     "            current_nodes.append(node)\n",
-    "    return(graph_triples)"
+    "    return(graph_triples)\n",
+    "\n",
+    "def get_graph_triples(amr_parse, sent_index):\n",
+    "    \n",
+    "    tree = penman.parse(amr_parse)\n",
+    "    var_name = sent_index + ':{i}'\n",
+    "    tree.reset_variables(var_name)\n",
+    "    graph = penman.interpret(tree)\n",
+    "    #graph_triples = graph.triples\n",
+    "    #return(graph_triples)\n",
+    "    return(graph.triples)"
    ]
   },
   {
@@ -598,11 +609,12 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [],
    "source": [
-    "# EDGE: ('3500_EVENT_4', '3500_2')\n",
+    "# EDGE: \n",
+    "edge = ('3500_EVENT_4', '3500_2')\n",
     "annotation = {'dimension': '1', 'quality': 3, 'worker_id': 223, 'rules': \n",
     "    [['A giraffe comes to the fence', 'Causes/Enables', 'Addie feeds the giraffe'], \n",
     "     ['{A giraffe }_[subject] {comes}_[verb] {to }_[preposition1] {the fence}_[object1]', 'Causes/Enables', '{Addie}_[subject] {feeds}_[verb] {the giraffe }_[object1]'], \n",
@@ -614,12 +626,13 @@
     "            'general_replaced': ['crown (this is an animal ) comes up to throne that Max is standing by', 'Causes/Enables', 'Max feeds crown'], \n",
     "            'general_no_brackets': ['crown comes up to throne that Max is standing by', 'Causes/Enables', 'Max feeds crown']}\n",
     "\n",
+    "edge = ('3500_EVENT_3', '3500_0')\n",
     "annotation = {'dimension': '2', 'quality': 3, 'worker_id': 152, 'rules': [[\"Addie's family want(s) fun\", 'Motivates', \"Addie's family is at the zoo\"], [\"{Addie's family}_[subject] {want(s)}_[verb] {fun}_[object]\", 'Motivates', \"{Addie's family}_[subject] {is}_[verb] {at}_[preposition1] {the zoo}_[object1]\"], ['Some People_A want(s) fun', 'Motivates', 'Some People_A are at Somewhere_A (that is a zoo)'], ['{Some People_A}_[subject] {want(s)}_[verb] {fun}_[object]', 'Motivates', '{Some People_A}_[subject] {are}_[verb] {at}_[preposition1] {Somewhere_A ||that is a zoo||}_[object1]']], '2parse': [[\"Addie's family wants fun\", 'Motivates', \"Addie's family is at the zoo\"], ['Some Germans wants fun', 'Motivates', 'Some Germans are at France']], 'general_0': ['Some people_a wants fun', 'Motivates', 'Some people_a are at somewhere_a (that is a zoo)'], 'general_replaced': ['Some Germans wants fun', 'Motivates', 'Some Germans are at France (that is a zoo)'], 'general_no_brackets': ['Some Germans wants fun', 'Motivates', 'Some Germans are at France']}"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
@@ -636,7 +649,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 10,
+   "execution_count": 9,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -647,7 +660,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": 10,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -666,11 +679,11 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 32,
+   "execution_count": 31,
    "metadata": {},
    "outputs": [],
    "source": [
-    "def map_arguments(annotation):\n",
+    "def map_arguments(annotation, edge):\n",
     "    \n",
     "    argument_mappings = []\n",
     "    left_over = []\n",
@@ -685,9 +698,10 @@
     "    filler = [el for el in filler1 if el in filler2]\n",
     "    left_fillers = [el for el in filler1 if el not in filler]+[el for el in filler2 if el not in filler]\n",
     "    #print(left_fillers,' fillers left')\n",
+    "    \n",
     "    # look up amr parse\n",
     "    parse_part1, parse_part2 = replace_names(amr_dict[part1]),replace_names(amr_dict[part2])\n",
-    "    triples_part1, triples_part2 = get_graph_triples(parse_part1), get_graph_triples(parse_part2)\n",
+    "    triples_part1, triples_part2 = get_graph_triples(parse_part1,edge[0]), get_graph_triples(parse_part2,edge[1])\n",
     "    \n",
     "    for fill in filler:\n",
     "        fill = re.sub('[()]', '', replace_names(amr_dict[fill]).split('/ ')[1].split('\\n')[0])\n",
@@ -727,21 +741,20 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 21,
+   "execution_count": 32,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "['France']  fillers left\n",
-      "[(('w / want-01', ':ARG0', 'p / \"Germany\"'), ('b / be-located-at-91', ':ARG1', 'p / \"Germany\"'))]\n",
+      "[(('3500_EMO_1:1', ':instance', '\"Germany\"'), ('3500_2:1', ':instance', '\"Germany\"'))]\n",
       "[]\n"
      ]
     }
    ],
    "source": [
-    "argument_mapping, left_over = map_arguments(annotation)\n",
+    "argument_mapping, left_over = map_arguments(annotation, ('3500_EMO_1', '3500_2'))\n",
     "print(argument_mapping)\n",
     "print(left_over)"
    ]
@@ -762,6 +775,40 @@
     "annotations = [{'dimension': '1', 'quality': 3, 'worker_id': 152, 'rules': [[\"Addie's family drive to the zoo\", 'Causes/Enables', 'Addie is at the zoo'], [\"{Addie's family}_[subject] {drive}_[verb] {to}_[preposition1] {the zoo}_[object1]\", 'Causes/Enables', '{Addie}_[subject] {is}_[verb] {at}_[preposition1] {the zoo}_[object1]'], ['Some People_A drive to Somewhere_A', 'Causes/Enables', 'Someone_A (who is a member of Some People_A) is at Somewhere_A'], ['{Some People_A}_[subject] {drive}_[verb] {to}_[preposition1] {Somewhere_A}_[object1]', 'Causes/Enables', '{Someone_A ||who is a member of Some People_A||}_[subject] {is}_[verb] {at}_[preposition1] {Somewhere_A}_[object1]']], '2parse': [[\"Addie's family drive to the zoo\", 'Causes/Enables', 'Addie is at the zoo'], ['Some Germans drive to France', 'Causes/Enables', 'Max who is a member of Some Germans is at France']], 'general_0': ['Some people_a drive to somewhere_a', 'Causes/Enables', 'someone_a who is a member of Some people_a is at somewhere_a'], 'general_replaced': ['Some Germans drive to France', 'Causes/Enables', 'Max who is a member of Some Germans is at France'], 'general_no_brackets': ['Some Germans drive to France', 'Causes/Enables', 'Max who is a member of Some Germans is at France']}, {'dimension': '1', 'quality': 2, 'worker_id': 11, 'rules': [['Addie goes to the zoo with her family', 'Causes/Enables', 'Addie is at the zoo with her family'], ['{Addie}_[subject] {goes}_[verb] {to}_[preposition1] {the zoo}_[object1] {with}_[preposition2] {her family}_[object2]', 'Causes/Enables', '{Addie}_[subject] {is}_[verb] {at}_[preposition1] {the zoo}_[object1] {with}_[preposition2] {her family}_[object2]'], ['Someone_A goes to Somewhere_A with Some People_A', 'Causes/Enables', 'Someone_A is at Somewhere_A with Some People_A'], ['{Someone_A}_[subject] {goes}_[verb] {to}_[preposition1] {Somewhere_A}_[object1] {with}_[preposition2] {Some People_A}_[object2]', 'Causes/Enables', '{Someone_A}_[subject] {is}_[verb] {at}_[preposition1] {Somewhere_A}_[object1] {with}_[preposition2] {Some People_A}_[object2]']], '2parse': [['Addie goes to the zoo with her family', 'Causes/Enables', 'Addie is at the zoo with her family'], ['Max goes to France with Some Germans', 'Causes/Enables', 'Max is at France with Some Germans']], 'general_0': ['someone_a goes to somewhere_a with Some people_a', 'Causes/Enables', 'someone_a is at somewhere_a with Some people_a'], 'general_replaced': ['Max goes to France with Some Germans', 'Causes/Enables', 'Max is at France with Some Germans'], 'general_no_brackets': ['Max goes to France with Some Germans', 'Causes/Enables', 'Max is at France with Some Germans']}]"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": 16,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "(('3500_EVENT_3:3', ':instance', '\"France\"'), ('3500_0:6', ':instance', '\"France\"'))\n",
+      "(('3500_EVENT_3:2', ':instance', '\"France\"'), ('3500_0:2', ':instance', '\"France\"'))\n",
+      "(('3500_EVENT_3:3', ':instance', '\"Germany\"'), ('3500_0:3', ':instance', '\"Germany\"'))\n",
+      "(('3500_EVENT_3:1', ':instance', '\"Max\"'), ('3500_0:1', ':instance', '\"Max\"'))\n"
+     ]
+    }
+   ],
+   "source": [
+    "def get_argument_mappings(edge):\n",
+    "    annotations = graph.edges[edge]['annotations']\n",
+    "    argument_mappings = []\n",
+    "    for annotation in annotations:\n",
+    "        argument_mapping, left_over = map_arguments(annotation,edge)\n",
+    "        argument_mappings += argument_mapping\n",
+    "        #print(left_over)\n",
+    "    return(argument_mappings)\n",
+    "\n",
+    "edge = ('3500_EMO_0', '3500_0')\n",
+    "edge = ('3500_EMO_1', '3500_2')\n",
+    "edge = ('3500_EVENT_3', '3500_0')\n",
+    "argument_mappings = get_argument_mappings(edge)\n",
+    "for map in argument_mappings:\n",
+    "    print(map)"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": 37,
@@ -798,7 +845,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 40,
+   "execution_count": 27,
    "metadata": {},
    "outputs": [
     {
@@ -807,22 +854,43 @@
      "text": [
       "['Some Germans drive to France', 'Causes/Enables', 'Max who is a member of Some Germans is at France']\n",
       "['Max goes to France with Some Germans', 'Causes/Enables', 'Max is at France with Some Germans']\n",
-      "('p / \"Germany\"', ':quant', 's / some')\n",
-      "('g / go-02', ':ARG0', 'p / \"Max\"')\n",
-      "('n2 / name', ':op1', '\"Some\"')\n",
-      "('g / go-02', ':accompanier', 'p2 / \"Germany\"')\n",
-      "('o / organization', ':name', 'n2 / name')\n",
-      "('b / be-located-at-91', ':ARG2', 'c / \"France\"')\n",
-      "('p2 / \"Germany\"', ':quant', 's / some')\n",
-      "('h / have-org-role-91', ':ARG1', 'o / organization')\n",
-      "('b / be-located-at-91', ':ARG1', 'p / \"Max\"')\n",
-      "('h / have-org-role-91', ':ARG2', 'm / member')\n",
-      "('n2 / name', ':op2', '\"Germans\"')\n",
-      "('g / go-02', ':ARG4', 'c / \"France\"')\n",
-      "('b / be-located-at-91', ':accompanier', 'p2 / \"Germany\"')\n",
-      "('p / \"Max\"', ':ARG0-of', 'h / have-org-role-91')\n",
-      "('d / drive-01', ':ARG0', 'p / \"Germany\"')\n",
-      "('d / drive-01', ':ARG4', 'c2 / \"France\"')\n"
+      "36\n",
+      "('3500_EVENT_3:1', ':instance', '\"Max\"')\n",
+      "('3500_EVENT_3:2', ':instance', '\"France\"')\n",
+      "('3500_0:0', ':ARG1', '3500_0:1')\n",
+      "('3500_0:2', ':ARG0', '3500_0:1')\n",
+      "('3500_0:3', ':quant', '3500_0:4')\n",
+      "('3500_0:2', ':ARG1', '3500_0:3')\n",
+      "('3500_0:2', ':ARG2', '3500_0:5')\n",
+      "('3500_EVENT_3:2', ':instance', 'some')\n",
+      "('3500_EVENT_3:1', ':quant', '3500_EVENT_3:2')\n",
+      "('3500_0:0', ':ARG2', '3500_0:2')\n",
+      "('3500_0:0', ':instance', 'be-located-at-91')\n",
+      "('3500_0:4', ':instance', 'some')\n",
+      "('3500_0:4', ':op2', '\"Germans\"')\n",
+      "('3500_EVENT_3:3', ':instance', '\"France\"')\n",
+      "('3500_EVENT_3:0', ':instance', 'go-02')\n",
+      "('3500_EVENT_3:3', ':quant', '3500_EVENT_3:4')\n",
+      "('3500_0:5', ':instance', 'member')\n",
+      "('3500_EVENT_3:1', ':instance', '\"Germany\"')\n",
+      "('3500_EVENT_3:0', ':accompanier', '3500_EVENT_3:3')\n",
+      "('3500_0:4', ':op1', '\"Some\"')\n",
+      "('3500_0:0', ':accompanier', '3500_0:3')\n",
+      "('3500_0:3', ':instance', '\"Germany\"')\n",
+      "('3500_EVENT_3:0', ':ARG0', '3500_EVENT_3:1')\n",
+      "('3500_EVENT_3:3', ':instance', '\"Germany\"')\n",
+      "('3500_EVENT_3:4', ':instance', 'some')\n",
+      "('3500_EVENT_3:0', ':ARG4', '3500_EVENT_3:3')\n",
+      "('3500_0:3', ':name', '3500_0:4')\n",
+      "('3500_EVENT_3:0', ':instance', 'drive-01')\n",
+      "('3500_0:0', ':ARG2', '3500_0:6')\n",
+      "('3500_0:2', ':instance', 'have-org-role-91')\n",
+      "('3500_0:3', ':instance', 'organization')\n",
+      "('3500_EVENT_3:0', ':ARG4', '3500_EVENT_3:2')\n",
+      "('3500_0:4', ':instance', 'name')\n",
+      "('3500_0:2', ':instance', '\"France\"')\n",
+      "('3500_0:1', ':instance', '\"Max\"')\n",
+      "('3500_0:6', ':instance', '\"France\"')\n"
      ]
     }
    ],
@@ -833,21 +901,211 @@
     "        general_rule = annotation['2parse'][1]\n",
     "        print(general_rule)\n",
     "        part1, part2 = general_rule[0], general_rule[2]\n",
-    "        unite_triples += get_graph_triples(replace_names(amr_dict[part1]))+get_graph_triples(replace_names(amr_dict[part2]))\n",
+    "        unite_triples += get_graph_triples(replace_names(amr_dict[part1]), edge[0])+get_graph_triples(replace_names(amr_dict[part2]), edge[1])\n",
     "    unite_triples = list(set(unite_triples))\n",
     "    return(unite_triples)\n",
     "unite_triples = unite_graph_triples(edge)\n",
+    "\n",
+    "print(len(unite_triples))\n",
     "for triple in unite_triples:\n",
-    "    print(triple)\n",
-    "    "
+    "    print(triple)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "    (('3500_EVENT_3:3', ':instance', '\"France\"'), ('3500_0:6', ':instance', '\"France\"'))\n",
+    "    (('3500_EVENT_3:2', ':instance', '\"France\"'), ('3500_0:2', ':instance', '\"France\"'))\n",
+    "    (('3500_EVENT_3:3', ':instance', '\"Germany\"'), ('3500_0:3', ':instance', '\"Germany\"'))\n",
+    "    (('3500_EVENT_3:1', ':instance', '\"Max\"'), ('3500_0:1', ':instance', '\"Max\"'))\n"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 41,
    "metadata": {},
-   "outputs": [],
-   "source": []
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "33\n",
+      "('3500_0:0', ':accompanier', 'EVENT_3:3&0:3')\n",
+      "('EVENT_3:2&0:2', ':instance', 'some')\n",
+      "('EVENT_3:3&0:3', ':instance', '\"Germany\"')\n",
+      "('3500_EVENT_3:3&0:6', ':instance', '\"France\"')\n",
+      "('3500_EVENT_3:3&0:6', ':quant', '3500_EVENT_3:4')\n",
+      "('EVENT_3:1&0:1', ':quant', 'EVENT_3:2&0:2')\n",
+      "('3500_0:0', ':instance', 'be-located-at-91')\n",
+      "('3500_0:0', ':ARG1', 'EVENT_3:1&0:1')\n",
+      "('3500_0:4', ':instance', 'some')\n",
+      "('EVENT_3:2&0:2', ':ARG2', '3500_0:5')\n",
+      "('3500_0:4', ':op2', '\"Germans\"')\n",
+      "('3500_EVENT_3:0', ':instance', 'go-02')\n",
+      "('EVENT_3:3&0:3', ':name', '3500_0:4')\n",
+      "('EVENT_3:1&0:1', ':instance', '\"Germany\"')\n",
+      "('3500_0:5', ':instance', 'member')\n",
+      "('3500_EVENT_3:3&0:6', ':instance', '\"Germany\"')\n",
+      "('3500_0:4', ':op1', '\"Some\"')\n",
+      "('3500_EVENT_3:0', ':accompanier', '3500_EVENT_3:3&0:6')\n",
+      "('EVENT_3:2&0:2', ':ARG0', 'EVENT_3:1&0:1')\n",
+      "('EVENT_3:3&0:3', ':instance', 'organization')\n",
+      "('3500_0:0', ':ARG2', '3500_EVENT_3:3&0:6')\n",
+      "('3500_EVENT_3:4', ':instance', 'some')\n",
+      "('3500_EVENT_3:0', ':ARG0', 'EVENT_3:1&0:1')\n",
+      "('3500_EVENT_3:0', ':ARG4', '3500_EVENT_3:3&0:6')\n",
+      "('3500_EVENT_3:0', ':instance', 'drive-01')\n",
+      "('EVENT_3:3&0:3', ':quant', '3500_0:4')\n",
+      "('3500_0:0', ':ARG2', 'EVENT_3:2&0:2')\n",
+      "('EVENT_3:2&0:2', ':instance', 'have-org-role-91')\n",
+      "('3500_EVENT_3:0', ':ARG4', 'EVENT_3:2&0:2')\n",
+      "('3500_0:4', ':instance', 'name')\n",
+      "('EVENT_3:2&0:2', ':instance', '\"France\"')\n",
+      "('EVENT_3:2&0:2', ':ARG1', 'EVENT_3:3&0:3')\n",
+      "('EVENT_3:1&0:1', ':instance', '\"Max\"')\n"
+     ]
+    }
+   ],
+   "source": [
+    "def rename_variables(unite_triples, argument_mappings):\n",
+    "    for mapping in argument_mappings:\n",
+    "        var1 = mapping[0][0]\n",
+    "        var2 = mapping[1][0]\n",
+    "        merged_var_name = '_'.join(mapping[0][0].split('_')[1:])+'&'+ '_'.join(mapping[1][0].split('_')[1:])\n",
+    "        #print(merged_var_name)\n",
+    "        merged_instance = (merged_var_name, mapping[0][1], mapping[0][2])\n",
+    "        #print(merged_instance)\n",
+    "\n",
+    "        for i, triple in enumerate(unite_triples):\n",
+    "            if triple == mapping[0] or triple == mapping[1]:\n",
+    "                unite_triples[i] = merged_instance\n",
+    "            elif var1 in triple or var2 in triple:\n",
+    "                new_triple = eval(str(triple).replace(var1, merged_var_name).replace(var2, merged_var_name))\n",
+    "                #print(new_triple)\n",
+    "                #print(type(new_triple))\n",
+    "                unite_triples[i] = new_triple\n",
+    "        unite_triples = list(set(unite_triples))\n",
+    "    return(unite_triples)\n",
+    "renamed_triples = rename_variables(unite_triples, argument_mappings)\n",
+    "\n",
+    "print(len(renamed_triples))\n",
+    "for triple in renamed_triples:\n",
+    "    print(triple)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 42,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "(3500_0:0 / be-located-at-91\n",
+      "          :accompanier (EVENT_3:3&0:3 / organization\n",
+      "                                      / \"Germany\"\n",
+      "                                      :name (3500_0:4 / some\n",
+      "                                                      / name\n",
+      "                                                      :op1 \"Some\"\n",
+      "                                                      :op2 \"Germans\")\n",
+      "                                      :quant 3500_0:4)\n",
+      "          :ARG1 (EVENT_3:1&0:1 / \"Max\"\n",
+      "                               / \"Germany\"\n",
+      "                               :ARG0-of (EVENT_3:2&0:2 / some\n",
+      "                                                       / \"France\"\n",
+      "                                                       / have-org-role-91\n",
+      "                                                       :ARG4-of 3500_EVENT_3:0\n",
+      "                                                       :ARG1 EVENT_3:3&0:3\n",
+      "                                                       :ARG2 (3500_0:5 / member))\n",
+      "                               :ARG0-of (3500_EVENT_3:0 / go-02\n",
+      "                                                        / drive-01\n",
+      "                                                        :ARG4 3500_EVENT_3:3&0:6)\n",
+      "                               :quant EVENT_3:2&0:2)\n",
+      "          :ARG2 (3500_EVENT_3:3&0:6 / \"Germany\"\n",
+      "                                    / \"France\"\n",
+      "                                    :quant (3500_EVENT_3:4 / some)\n",
+      "                                    :accompanier-of 3500_EVENT_3:0)\n",
+      "          :ARG2 EVENT_3:2&0:2)\n"
+     ]
+    }
+   ],
+   "source": [
+    "from penman.graph import Graph\n",
+    "\n",
+    "g = Graph(renamed_triples)\n",
+    "print(penman.encode(g))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 43,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Instance(source='EVENT_3:2&0:2', role=':instance', target='some'),\n",
+       " Instance(source='EVENT_3:3&0:3', role=':instance', target='\"Germany\"'),\n",
+       " Instance(source='3500_EVENT_3:3&0:6', role=':instance', target='\"France\"'),\n",
+       " Instance(source='3500_0:0', role=':instance', target='be-located-at-91'),\n",
+       " Instance(source='3500_0:4', role=':instance', target='some'),\n",
+       " Instance(source='3500_EVENT_3:0', role=':instance', target='go-02'),\n",
+       " Instance(source='EVENT_3:1&0:1', role=':instance', target='\"Germany\"'),\n",
+       " Instance(source='3500_0:5', role=':instance', target='member'),\n",
+       " Instance(source='3500_EVENT_3:3&0:6', role=':instance', target='\"Germany\"'),\n",
+       " Instance(source='EVENT_3:3&0:3', role=':instance', target='organization'),\n",
+       " Instance(source='3500_EVENT_3:4', role=':instance', target='some'),\n",
+       " Instance(source='3500_EVENT_3:0', role=':instance', target='drive-01'),\n",
+       " Instance(source='EVENT_3:2&0:2', role=':instance', target='have-org-role-91'),\n",
+       " Instance(source='3500_0:4', role=':instance', target='name'),\n",
+       " Instance(source='EVENT_3:2&0:2', role=':instance', target='\"France\"'),\n",
+       " Instance(source='EVENT_3:1&0:1', role=':instance', target='\"Max\"')]"
+      ]
+     },
+     "execution_count": 43,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g.instances()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 44,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Edge(source='3500_0:0', role=':accompanier', target='EVENT_3:3&0:3'),\n",
+       " Edge(source='3500_EVENT_3:3&0:6', role=':quant', target='3500_EVENT_3:4'),\n",
+       " Edge(source='EVENT_3:1&0:1', role=':quant', target='EVENT_3:2&0:2'),\n",
+       " Edge(source='3500_0:0', role=':ARG1', target='EVENT_3:1&0:1'),\n",
+       " Edge(source='EVENT_3:2&0:2', role=':ARG2', target='3500_0:5'),\n",
+       " Edge(source='EVENT_3:3&0:3', role=':name', target='3500_0:4'),\n",
+       " Edge(source='3500_EVENT_3:0', role=':accompanier', target='3500_EVENT_3:3&0:6'),\n",
+       " Edge(source='EVENT_3:2&0:2', role=':ARG0', target='EVENT_3:1&0:1'),\n",
+       " Edge(source='3500_0:0', role=':ARG2', target='3500_EVENT_3:3&0:6'),\n",
+       " Edge(source='3500_EVENT_3:0', role=':ARG0', target='EVENT_3:1&0:1'),\n",
+       " Edge(source='3500_EVENT_3:0', role=':ARG4', target='3500_EVENT_3:3&0:6'),\n",
+       " Edge(source='EVENT_3:3&0:3', role=':quant', target='3500_0:4'),\n",
+       " Edge(source='3500_0:0', role=':ARG2', target='EVENT_3:2&0:2'),\n",
+       " Edge(source='3500_EVENT_3:0', role=':ARG4', target='EVENT_3:2&0:2'),\n",
+       " Edge(source='EVENT_3:2&0:2', role=':ARG1', target='EVENT_3:3&0:3')]"
+      ]
+     },
+     "execution_count": 44,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g.edges()"
+   ]
   },
   {
    "cell_type": "markdown",
diff --git a/code/.ipynb_checkpoints/penman_merge-checkpoint.ipynb b/code/.ipynb_checkpoints/penman_merge-checkpoint.ipynb
new file mode 100644
index 0000000000000000000000000000000000000000..02e8fa865dfdb9441342d2f7feff586decaf8876
--- /dev/null
+++ b/code/.ipynb_checkpoints/penman_merge-checkpoint.ipynb
@@ -0,0 +1,421 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "id": "d6161522",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import os\n",
+    "import json\n",
+    "import pickle\n",
+    "import re\n",
+    "import penman"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 38,
+   "id": "143b82a2",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "parse = '''\n",
+    "  # ::snt Max who is a member of Some Germans is at France\n",
+    "  (b / be-located-at-91\n",
+    "      :ARG1 (p / person\n",
+    "            :name (n / name\n",
+    "                  :op1 \"Max\")\n",
+    "            :ARG0-of (h / have-org-role-91\n",
+    "                  :ARG1 (o / organization\n",
+    "                        :name (n2 / name\n",
+    "                              :op1 \"Some\"\n",
+    "                              :op2 \"Germans\"))\n",
+    "                  :ARG2 (m / member))))'''"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 39,
+   "id": "7cdadcf6",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "def replace_names(parse):\n",
+    "    \n",
+    "    name = re.findall('[a-z]+[\\s\\n\\t]*:name \\(n[0-9]? / name[\\s\\n\\t]*:op1 (\"[A-Za-z]+\")\\)', parse)\n",
+    "    names = re.findall('[a-z]+[\\s\\n\\t]*:name \\(n[0-9]? / name[\\s\\n\\t]*:op1 \"[A-Za-z]+\"\\)', parse)\n",
+    "    for i,el in enumerate(names):\n",
+    "        parse = parse.replace(el,name[i])\n",
+    "    name = re.findall('[a-z]+[\\s\\n\\t]*:mod \\(c[0-9]? / (\"[A-Za-z]+\")\\)', parse)\n",
+    "    names = re.findall('[a-z]+[\\s\\n\\t]*:mod \\(c[0-9]? / \"[A-Za-z]+\"\\)', parse)\n",
+    "    for i,el in enumerate(names):\n",
+    "        parse = parse.replace(el,name[i])\n",
+    "    return(parse)\n",
+    "parse2 = replace_names(parse)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 40,
+   "id": "a5787f87",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "g = penman.decode(parse)\n",
+    "g2 = penman.decode(parse2)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 41,
+   "id": "00e50463",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "#print(penman.encode(g))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 46,
+   "id": "07d25c04",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "#g.variables()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 49,
+   "id": "0ab6b3de",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Instance(source='b', role=':instance', target='be-located-at-91'),\n",
+       " Instance(source='p', role=':instance', target='person'),\n",
+       " Instance(source='n', role=':instance', target='name'),\n",
+       " Instance(source='h', role=':instance', target='have-org-role-91'),\n",
+       " Instance(source='o', role=':instance', target='organization'),\n",
+       " Instance(source='n2', role=':instance', target='name'),\n",
+       " Instance(source='m', role=':instance', target='member')]"
+      ]
+     },
+     "execution_count": 49,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g.instances()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 50,
+   "id": "395da001",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Instance(source='b', role=':instance', target='be-located-at-91'),\n",
+       " Instance(source='p', role=':instance', target='\"Max\"'),\n",
+       " Instance(source='h', role=':instance', target='have-org-role-91'),\n",
+       " Instance(source='o', role=':instance', target='organization'),\n",
+       " Instance(source='n2', role=':instance', target='name'),\n",
+       " Instance(source='m', role=':instance', target='member')]"
+      ]
+     },
+     "execution_count": 50,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g2.instances()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 51,
+   "id": "80b46786",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Attribute(source='n', role=':op1', target='\"Max\"'),\n",
+       " Attribute(source='n2', role=':op1', target='\"Some\"'),\n",
+       " Attribute(source='n2', role=':op2', target='\"Germans\"')]"
+      ]
+     },
+     "execution_count": 51,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g.attributes()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 52,
+   "id": "086f7848",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Attribute(source='n2', role=':op1', target='\"Some\"'),\n",
+       " Attribute(source='n2', role=':op2', target='\"Germans\"')]"
+      ]
+     },
+     "execution_count": 52,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g2.attributes()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 53,
+   "id": "928adb43",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Edge(source='b', role=':ARG1', target='p'),\n",
+       " Edge(source='p', role=':name', target='n'),\n",
+       " Edge(source='h', role=':ARG0', target='p'),\n",
+       " Edge(source='h', role=':ARG1', target='o'),\n",
+       " Edge(source='o', role=':name', target='n2'),\n",
+       " Edge(source='h', role=':ARG2', target='m')]"
+      ]
+     },
+     "execution_count": 53,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g.edges()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 54,
+   "id": "9a03c6fa",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Edge(source='b', role=':ARG1', target='p'),\n",
+       " Edge(source='h', role=':ARG0', target='p'),\n",
+       " Edge(source='h', role=':ARG1', target='o'),\n",
+       " Edge(source='o', role=':name', target='n2'),\n",
+       " Edge(source='h', role=':ARG2', target='m')]"
+      ]
+     },
+     "execution_count": 54,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g2.edges()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 33,
+   "id": "a7ff40c1",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[('b', ':instance', 'be-located-at-91'),\n",
+       " ('b', ':ARG1', 'p'),\n",
+       " ('p', ':instance', '\"Max\"'),\n",
+       " ('h', ':ARG0', 'p'),\n",
+       " ('h', ':instance', 'have-org-role-91'),\n",
+       " ('h', ':ARG1', 'o'),\n",
+       " ('o', ':instance', 'organization'),\n",
+       " ('o', ':name', 'n2'),\n",
+       " ('n2', ':instance', 'name'),\n",
+       " ('n2', ':op1', '\"Some\"'),\n",
+       " ('n2', ':op2', '\"Germans\"'),\n",
+       " ('h', ':ARG2', 'm'),\n",
+       " ('m', ':instance', 'member')]"
+      ]
+     },
+     "execution_count": 33,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g.triples"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 62,
+   "id": "9e97520c",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "Tree(('b', [('/', 'be-located-at-91'), (':ARG1', ('p', [('/', '\"Max\"'), (':ARG0-of', ('h', [('/', 'have-org-role-91'), (':ARG1', ('o', [('/', 'organization'), (':name', ('n2', [('/', 'name'), (':op1', '\"Some\"'), (':op2', '\"Germans\"')]))])), (':ARG2', ('m', [('/', 'member')]))]))]))]))"
+      ]
+     },
+     "execution_count": 62,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "t2 = penman.configure(g2)\n",
+    "t2"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 55,
+   "id": "529c85ea",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "#t.node"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 56,
+   "id": "8e5c7fbb",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "#t.nodes()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 63,
+   "id": "30f40ee1",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "Tree(('s1_0', [('/', 'be-located-at-91'), (':ARG1', ('s1_1', [('/', '\"Max\"'), (':ARG0-of', ('s1_2', [('/', 'have-org-role-91'), (':ARG1', ('s1_3', [('/', 'organization'), (':name', ('s1_4', [('/', 'name'), (':op1', '\"Some\"'), (':op2', '\"Germans\"')]))])), (':ARG2', ('s1_5', [('/', 'member')]))]))]))]))"
+      ]
+     },
+     "execution_count": 63,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "t2.reset_variables('s1_{i}')\n",
+    "t2"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 66,
+   "id": "a6463c45",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "<Graph object (top=s1_0) at 140534018533456>"
+      ]
+     },
+     "execution_count": 66,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g3 = penman.interpret(t2)\n",
+    "g3"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 67,
+   "id": "43a437d4",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[('s1_0', ':instance', 'be-located-at-91'),\n",
+       " ('s1_0', ':ARG1', 's1_1'),\n",
+       " ('s1_1', ':instance', '\"Max\"'),\n",
+       " ('s1_2', ':ARG0', 's1_1'),\n",
+       " ('s1_2', ':instance', 'have-org-role-91'),\n",
+       " ('s1_2', ':ARG1', 's1_3'),\n",
+       " ('s1_3', ':instance', 'organization'),\n",
+       " ('s1_3', ':name', 's1_4'),\n",
+       " ('s1_4', ':instance', 'name'),\n",
+       " ('s1_4', ':op1', '\"Some\"'),\n",
+       " ('s1_4', ':op2', '\"Germans\"'),\n",
+       " ('s1_2', ':ARG2', 's1_5'),\n",
+       " ('s1_5', ':instance', 'member')]"
+      ]
+     },
+     "execution_count": 67,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g3.triples"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "76921925",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.8"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/code/Untitled2.ipynb b/code/Untitled2.ipynb
new file mode 100644
index 0000000000000000000000000000000000000000..363fcab7ed6e9634e198cf5555ceb88932c9a245
--- /dev/null
+++ b/code/Untitled2.ipynb
@@ -0,0 +1,6 @@
+{
+ "cells": [],
+ "metadata": {},
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/code/generalized_graph_building.ipynb b/code/generalized_graph_building.ipynb
index e65187f57c44818a6cdef1358f801b5d9cfbabf7..9184fb504ecd26f1ad5615cf3c9a61638043089e 100644
--- a/code/generalized_graph_building.ipynb
+++ b/code/generalized_graph_building.ipynb
@@ -16,7 +16,8 @@
     "import os\n",
     "import json\n",
     "import pickle\n",
-    "import re"
+    "import re\n",
+    "import penman"
    ]
   },
   {
@@ -66,7 +67,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 29,
+   "execution_count": 2,
    "metadata": {},
    "outputs": [
     {
@@ -106,7 +107,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 3,
    "metadata": {},
    "outputs": [
     {
@@ -125,7 +126,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": 4,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -136,7 +137,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [
     {
@@ -555,11 +556,11 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 30,
    "metadata": {},
    "outputs": [],
    "source": [
-    "def get_graph_triples(amr_parse):\n",
+    "def get_graph_triples_old(amr_parse):\n",
     "\n",
     "    lines = []\n",
     "    amr_parse = amr_parse[:-1]\n",
@@ -586,7 +587,17 @@
     "            continue\n",
     "        else:\n",
     "            current_nodes.append(node)\n",
-    "    return(graph_triples)"
+    "    return(graph_triples)\n",
+    "\n",
+    "def get_graph_triples(amr_parse, sent_index):\n",
+    "    \n",
+    "    tree = penman.parse(amr_parse)\n",
+    "    var_name = sent_index + ':{i}'\n",
+    "    tree.reset_variables(var_name)\n",
+    "    graph = penman.interpret(tree)\n",
+    "    #graph_triples = graph.triples\n",
+    "    #return(graph_triples)\n",
+    "    return(graph.triples)"
    ]
   },
   {
@@ -598,11 +609,12 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [],
    "source": [
-    "# EDGE: ('3500_EVENT_4', '3500_2')\n",
+    "# EDGE: \n",
+    "edge = ('3500_EVENT_4', '3500_2')\n",
     "annotation = {'dimension': '1', 'quality': 3, 'worker_id': 223, 'rules': \n",
     "    [['A giraffe comes to the fence', 'Causes/Enables', 'Addie feeds the giraffe'], \n",
     "     ['{A giraffe }_[subject] {comes}_[verb] {to }_[preposition1] {the fence}_[object1]', 'Causes/Enables', '{Addie}_[subject] {feeds}_[verb] {the giraffe }_[object1]'], \n",
@@ -614,12 +626,13 @@
     "            'general_replaced': ['crown (this is an animal ) comes up to throne that Max is standing by', 'Causes/Enables', 'Max feeds crown'], \n",
     "            'general_no_brackets': ['crown comes up to throne that Max is standing by', 'Causes/Enables', 'Max feeds crown']}\n",
     "\n",
+    "edge = ('3500_EVENT_3', '3500_0')\n",
     "annotation = {'dimension': '2', 'quality': 3, 'worker_id': 152, 'rules': [[\"Addie's family want(s) fun\", 'Motivates', \"Addie's family is at the zoo\"], [\"{Addie's family}_[subject] {want(s)}_[verb] {fun}_[object]\", 'Motivates', \"{Addie's family}_[subject] {is}_[verb] {at}_[preposition1] {the zoo}_[object1]\"], ['Some People_A want(s) fun', 'Motivates', 'Some People_A are at Somewhere_A (that is a zoo)'], ['{Some People_A}_[subject] {want(s)}_[verb] {fun}_[object]', 'Motivates', '{Some People_A}_[subject] {are}_[verb] {at}_[preposition1] {Somewhere_A ||that is a zoo||}_[object1]']], '2parse': [[\"Addie's family wants fun\", 'Motivates', \"Addie's family is at the zoo\"], ['Some Germans wants fun', 'Motivates', 'Some Germans are at France']], 'general_0': ['Some people_a wants fun', 'Motivates', 'Some people_a are at somewhere_a (that is a zoo)'], 'general_replaced': ['Some Germans wants fun', 'Motivates', 'Some Germans are at France (that is a zoo)'], 'general_no_brackets': ['Some Germans wants fun', 'Motivates', 'Some Germans are at France']}"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
@@ -636,7 +649,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 10,
+   "execution_count": 9,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -647,7 +660,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": 10,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -666,11 +679,11 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 32,
+   "execution_count": 31,
    "metadata": {},
    "outputs": [],
    "source": [
-    "def map_arguments(annotation):\n",
+    "def map_arguments(annotation, edge):\n",
     "    \n",
     "    argument_mappings = []\n",
     "    left_over = []\n",
@@ -685,9 +698,10 @@
     "    filler = [el for el in filler1 if el in filler2]\n",
     "    left_fillers = [el for el in filler1 if el not in filler]+[el for el in filler2 if el not in filler]\n",
     "    #print(left_fillers,' fillers left')\n",
+    "    \n",
     "    # look up amr parse\n",
     "    parse_part1, parse_part2 = replace_names(amr_dict[part1]),replace_names(amr_dict[part2])\n",
-    "    triples_part1, triples_part2 = get_graph_triples(parse_part1), get_graph_triples(parse_part2)\n",
+    "    triples_part1, triples_part2 = get_graph_triples(parse_part1,edge[0]), get_graph_triples(parse_part2,edge[1])\n",
     "    \n",
     "    for fill in filler:\n",
     "        fill = re.sub('[()]', '', replace_names(amr_dict[fill]).split('/ ')[1].split('\\n')[0])\n",
@@ -727,21 +741,20 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 21,
+   "execution_count": 32,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "['France']  fillers left\n",
-      "[(('w / want-01', ':ARG0', 'p / \"Germany\"'), ('b / be-located-at-91', ':ARG1', 'p / \"Germany\"'))]\n",
+      "[(('3500_EMO_1:1', ':instance', '\"Germany\"'), ('3500_2:1', ':instance', '\"Germany\"'))]\n",
       "[]\n"
      ]
     }
    ],
    "source": [
-    "argument_mapping, left_over = map_arguments(annotation)\n",
+    "argument_mapping, left_over = map_arguments(annotation, ('3500_EMO_1', '3500_2'))\n",
     "print(argument_mapping)\n",
     "print(left_over)"
    ]
@@ -762,6 +775,40 @@
     "annotations = [{'dimension': '1', 'quality': 3, 'worker_id': 152, 'rules': [[\"Addie's family drive to the zoo\", 'Causes/Enables', 'Addie is at the zoo'], [\"{Addie's family}_[subject] {drive}_[verb] {to}_[preposition1] {the zoo}_[object1]\", 'Causes/Enables', '{Addie}_[subject] {is}_[verb] {at}_[preposition1] {the zoo}_[object1]'], ['Some People_A drive to Somewhere_A', 'Causes/Enables', 'Someone_A (who is a member of Some People_A) is at Somewhere_A'], ['{Some People_A}_[subject] {drive}_[verb] {to}_[preposition1] {Somewhere_A}_[object1]', 'Causes/Enables', '{Someone_A ||who is a member of Some People_A||}_[subject] {is}_[verb] {at}_[preposition1] {Somewhere_A}_[object1]']], '2parse': [[\"Addie's family drive to the zoo\", 'Causes/Enables', 'Addie is at the zoo'], ['Some Germans drive to France', 'Causes/Enables', 'Max who is a member of Some Germans is at France']], 'general_0': ['Some people_a drive to somewhere_a', 'Causes/Enables', 'someone_a who is a member of Some people_a is at somewhere_a'], 'general_replaced': ['Some Germans drive to France', 'Causes/Enables', 'Max who is a member of Some Germans is at France'], 'general_no_brackets': ['Some Germans drive to France', 'Causes/Enables', 'Max who is a member of Some Germans is at France']}, {'dimension': '1', 'quality': 2, 'worker_id': 11, 'rules': [['Addie goes to the zoo with her family', 'Causes/Enables', 'Addie is at the zoo with her family'], ['{Addie}_[subject] {goes}_[verb] {to}_[preposition1] {the zoo}_[object1] {with}_[preposition2] {her family}_[object2]', 'Causes/Enables', '{Addie}_[subject] {is}_[verb] {at}_[preposition1] {the zoo}_[object1] {with}_[preposition2] {her family}_[object2]'], ['Someone_A goes to Somewhere_A with Some People_A', 'Causes/Enables', 'Someone_A is at Somewhere_A with Some People_A'], ['{Someone_A}_[subject] {goes}_[verb] {to}_[preposition1] {Somewhere_A}_[object1] {with}_[preposition2] {Some People_A}_[object2]', 'Causes/Enables', '{Someone_A}_[subject] {is}_[verb] {at}_[preposition1] {Somewhere_A}_[object1] {with}_[preposition2] {Some People_A}_[object2]']], '2parse': [['Addie goes to the zoo with her family', 'Causes/Enables', 'Addie is at the zoo with her family'], ['Max goes to France with Some Germans', 'Causes/Enables', 'Max is at France with Some Germans']], 'general_0': ['someone_a goes to somewhere_a with Some people_a', 'Causes/Enables', 'someone_a is at somewhere_a with Some people_a'], 'general_replaced': ['Max goes to France with Some Germans', 'Causes/Enables', 'Max is at France with Some Germans'], 'general_no_brackets': ['Max goes to France with Some Germans', 'Causes/Enables', 'Max is at France with Some Germans']}]"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": 16,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "(('3500_EVENT_3:3', ':instance', '\"France\"'), ('3500_0:6', ':instance', '\"France\"'))\n",
+      "(('3500_EVENT_3:2', ':instance', '\"France\"'), ('3500_0:2', ':instance', '\"France\"'))\n",
+      "(('3500_EVENT_3:3', ':instance', '\"Germany\"'), ('3500_0:3', ':instance', '\"Germany\"'))\n",
+      "(('3500_EVENT_3:1', ':instance', '\"Max\"'), ('3500_0:1', ':instance', '\"Max\"'))\n"
+     ]
+    }
+   ],
+   "source": [
+    "def get_argument_mappings(edge):\n",
+    "    annotations = graph.edges[edge]['annotations']\n",
+    "    argument_mappings = []\n",
+    "    for annotation in annotations:\n",
+    "        argument_mapping, left_over = map_arguments(annotation,edge)\n",
+    "        argument_mappings += argument_mapping\n",
+    "        #print(left_over)\n",
+    "    return(argument_mappings)\n",
+    "\n",
+    "edge = ('3500_EMO_0', '3500_0')\n",
+    "edge = ('3500_EMO_1', '3500_2')\n",
+    "edge = ('3500_EVENT_3', '3500_0')\n",
+    "argument_mappings = get_argument_mappings(edge)\n",
+    "for map in argument_mappings:\n",
+    "    print(map)"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": 37,
@@ -798,7 +845,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 40,
+   "execution_count": 27,
    "metadata": {},
    "outputs": [
     {
@@ -807,22 +854,43 @@
      "text": [
       "['Some Germans drive to France', 'Causes/Enables', 'Max who is a member of Some Germans is at France']\n",
       "['Max goes to France with Some Germans', 'Causes/Enables', 'Max is at France with Some Germans']\n",
-      "('p / \"Germany\"', ':quant', 's / some')\n",
-      "('g / go-02', ':ARG0', 'p / \"Max\"')\n",
-      "('n2 / name', ':op1', '\"Some\"')\n",
-      "('g / go-02', ':accompanier', 'p2 / \"Germany\"')\n",
-      "('o / organization', ':name', 'n2 / name')\n",
-      "('b / be-located-at-91', ':ARG2', 'c / \"France\"')\n",
-      "('p2 / \"Germany\"', ':quant', 's / some')\n",
-      "('h / have-org-role-91', ':ARG1', 'o / organization')\n",
-      "('b / be-located-at-91', ':ARG1', 'p / \"Max\"')\n",
-      "('h / have-org-role-91', ':ARG2', 'm / member')\n",
-      "('n2 / name', ':op2', '\"Germans\"')\n",
-      "('g / go-02', ':ARG4', 'c / \"France\"')\n",
-      "('b / be-located-at-91', ':accompanier', 'p2 / \"Germany\"')\n",
-      "('p / \"Max\"', ':ARG0-of', 'h / have-org-role-91')\n",
-      "('d / drive-01', ':ARG0', 'p / \"Germany\"')\n",
-      "('d / drive-01', ':ARG4', 'c2 / \"France\"')\n"
+      "36\n",
+      "('3500_EVENT_3:1', ':instance', '\"Max\"')\n",
+      "('3500_EVENT_3:2', ':instance', '\"France\"')\n",
+      "('3500_0:0', ':ARG1', '3500_0:1')\n",
+      "('3500_0:2', ':ARG0', '3500_0:1')\n",
+      "('3500_0:3', ':quant', '3500_0:4')\n",
+      "('3500_0:2', ':ARG1', '3500_0:3')\n",
+      "('3500_0:2', ':ARG2', '3500_0:5')\n",
+      "('3500_EVENT_3:2', ':instance', 'some')\n",
+      "('3500_EVENT_3:1', ':quant', '3500_EVENT_3:2')\n",
+      "('3500_0:0', ':ARG2', '3500_0:2')\n",
+      "('3500_0:0', ':instance', 'be-located-at-91')\n",
+      "('3500_0:4', ':instance', 'some')\n",
+      "('3500_0:4', ':op2', '\"Germans\"')\n",
+      "('3500_EVENT_3:3', ':instance', '\"France\"')\n",
+      "('3500_EVENT_3:0', ':instance', 'go-02')\n",
+      "('3500_EVENT_3:3', ':quant', '3500_EVENT_3:4')\n",
+      "('3500_0:5', ':instance', 'member')\n",
+      "('3500_EVENT_3:1', ':instance', '\"Germany\"')\n",
+      "('3500_EVENT_3:0', ':accompanier', '3500_EVENT_3:3')\n",
+      "('3500_0:4', ':op1', '\"Some\"')\n",
+      "('3500_0:0', ':accompanier', '3500_0:3')\n",
+      "('3500_0:3', ':instance', '\"Germany\"')\n",
+      "('3500_EVENT_3:0', ':ARG0', '3500_EVENT_3:1')\n",
+      "('3500_EVENT_3:3', ':instance', '\"Germany\"')\n",
+      "('3500_EVENT_3:4', ':instance', 'some')\n",
+      "('3500_EVENT_3:0', ':ARG4', '3500_EVENT_3:3')\n",
+      "('3500_0:3', ':name', '3500_0:4')\n",
+      "('3500_EVENT_3:0', ':instance', 'drive-01')\n",
+      "('3500_0:0', ':ARG2', '3500_0:6')\n",
+      "('3500_0:2', ':instance', 'have-org-role-91')\n",
+      "('3500_0:3', ':instance', 'organization')\n",
+      "('3500_EVENT_3:0', ':ARG4', '3500_EVENT_3:2')\n",
+      "('3500_0:4', ':instance', 'name')\n",
+      "('3500_0:2', ':instance', '\"France\"')\n",
+      "('3500_0:1', ':instance', '\"Max\"')\n",
+      "('3500_0:6', ':instance', '\"France\"')\n"
      ]
     }
    ],
@@ -833,21 +901,211 @@
     "        general_rule = annotation['2parse'][1]\n",
     "        print(general_rule)\n",
     "        part1, part2 = general_rule[0], general_rule[2]\n",
-    "        unite_triples += get_graph_triples(replace_names(amr_dict[part1]))+get_graph_triples(replace_names(amr_dict[part2]))\n",
+    "        unite_triples += get_graph_triples(replace_names(amr_dict[part1]), edge[0])+get_graph_triples(replace_names(amr_dict[part2]), edge[1])\n",
     "    unite_triples = list(set(unite_triples))\n",
     "    return(unite_triples)\n",
     "unite_triples = unite_graph_triples(edge)\n",
+    "\n",
+    "print(len(unite_triples))\n",
     "for triple in unite_triples:\n",
-    "    print(triple)\n",
-    "    "
+    "    print(triple)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "    (('3500_EVENT_3:3', ':instance', '\"France\"'), ('3500_0:6', ':instance', '\"France\"'))\n",
+    "    (('3500_EVENT_3:2', ':instance', '\"France\"'), ('3500_0:2', ':instance', '\"France\"'))\n",
+    "    (('3500_EVENT_3:3', ':instance', '\"Germany\"'), ('3500_0:3', ':instance', '\"Germany\"'))\n",
+    "    (('3500_EVENT_3:1', ':instance', '\"Max\"'), ('3500_0:1', ':instance', '\"Max\"'))\n"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 41,
    "metadata": {},
-   "outputs": [],
-   "source": []
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "33\n",
+      "('3500_0:0', ':accompanier', 'EVENT_3:3&0:3')\n",
+      "('EVENT_3:2&0:2', ':instance', 'some')\n",
+      "('EVENT_3:3&0:3', ':instance', '\"Germany\"')\n",
+      "('3500_EVENT_3:3&0:6', ':instance', '\"France\"')\n",
+      "('3500_EVENT_3:3&0:6', ':quant', '3500_EVENT_3:4')\n",
+      "('EVENT_3:1&0:1', ':quant', 'EVENT_3:2&0:2')\n",
+      "('3500_0:0', ':instance', 'be-located-at-91')\n",
+      "('3500_0:0', ':ARG1', 'EVENT_3:1&0:1')\n",
+      "('3500_0:4', ':instance', 'some')\n",
+      "('EVENT_3:2&0:2', ':ARG2', '3500_0:5')\n",
+      "('3500_0:4', ':op2', '\"Germans\"')\n",
+      "('3500_EVENT_3:0', ':instance', 'go-02')\n",
+      "('EVENT_3:3&0:3', ':name', '3500_0:4')\n",
+      "('EVENT_3:1&0:1', ':instance', '\"Germany\"')\n",
+      "('3500_0:5', ':instance', 'member')\n",
+      "('3500_EVENT_3:3&0:6', ':instance', '\"Germany\"')\n",
+      "('3500_0:4', ':op1', '\"Some\"')\n",
+      "('3500_EVENT_3:0', ':accompanier', '3500_EVENT_3:3&0:6')\n",
+      "('EVENT_3:2&0:2', ':ARG0', 'EVENT_3:1&0:1')\n",
+      "('EVENT_3:3&0:3', ':instance', 'organization')\n",
+      "('3500_0:0', ':ARG2', '3500_EVENT_3:3&0:6')\n",
+      "('3500_EVENT_3:4', ':instance', 'some')\n",
+      "('3500_EVENT_3:0', ':ARG0', 'EVENT_3:1&0:1')\n",
+      "('3500_EVENT_3:0', ':ARG4', '3500_EVENT_3:3&0:6')\n",
+      "('3500_EVENT_3:0', ':instance', 'drive-01')\n",
+      "('EVENT_3:3&0:3', ':quant', '3500_0:4')\n",
+      "('3500_0:0', ':ARG2', 'EVENT_3:2&0:2')\n",
+      "('EVENT_3:2&0:2', ':instance', 'have-org-role-91')\n",
+      "('3500_EVENT_3:0', ':ARG4', 'EVENT_3:2&0:2')\n",
+      "('3500_0:4', ':instance', 'name')\n",
+      "('EVENT_3:2&0:2', ':instance', '\"France\"')\n",
+      "('EVENT_3:2&0:2', ':ARG1', 'EVENT_3:3&0:3')\n",
+      "('EVENT_3:1&0:1', ':instance', '\"Max\"')\n"
+     ]
+    }
+   ],
+   "source": [
+    "def rename_variables(unite_triples, argument_mappings):\n",
+    "    for mapping in argument_mappings:\n",
+    "        var1 = mapping[0][0]\n",
+    "        var2 = mapping[1][0]\n",
+    "        merged_var_name = '_'.join(mapping[0][0].split('_')[1:])+'&'+ '_'.join(mapping[1][0].split('_')[1:])\n",
+    "        #print(merged_var_name)\n",
+    "        merged_instance = (merged_var_name, mapping[0][1], mapping[0][2])\n",
+    "        #print(merged_instance)\n",
+    "\n",
+    "        for i, triple in enumerate(unite_triples):\n",
+    "            if triple == mapping[0] or triple == mapping[1]:\n",
+    "                unite_triples[i] = merged_instance\n",
+    "            elif var1 in triple or var2 in triple:\n",
+    "                new_triple = eval(str(triple).replace(var1, merged_var_name).replace(var2, merged_var_name))\n",
+    "                #print(new_triple)\n",
+    "                #print(type(new_triple))\n",
+    "                unite_triples[i] = new_triple\n",
+    "        unite_triples = list(set(unite_triples))\n",
+    "    return(unite_triples)\n",
+    "renamed_triples = rename_variables(unite_triples, argument_mappings)\n",
+    "\n",
+    "print(len(renamed_triples))\n",
+    "for triple in renamed_triples:\n",
+    "    print(triple)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 42,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "(3500_0:0 / be-located-at-91\n",
+      "          :accompanier (EVENT_3:3&0:3 / organization\n",
+      "                                      / \"Germany\"\n",
+      "                                      :name (3500_0:4 / some\n",
+      "                                                      / name\n",
+      "                                                      :op1 \"Some\"\n",
+      "                                                      :op2 \"Germans\")\n",
+      "                                      :quant 3500_0:4)\n",
+      "          :ARG1 (EVENT_3:1&0:1 / \"Max\"\n",
+      "                               / \"Germany\"\n",
+      "                               :ARG0-of (EVENT_3:2&0:2 / some\n",
+      "                                                       / \"France\"\n",
+      "                                                       / have-org-role-91\n",
+      "                                                       :ARG4-of 3500_EVENT_3:0\n",
+      "                                                       :ARG1 EVENT_3:3&0:3\n",
+      "                                                       :ARG2 (3500_0:5 / member))\n",
+      "                               :ARG0-of (3500_EVENT_3:0 / go-02\n",
+      "                                                        / drive-01\n",
+      "                                                        :ARG4 3500_EVENT_3:3&0:6)\n",
+      "                               :quant EVENT_3:2&0:2)\n",
+      "          :ARG2 (3500_EVENT_3:3&0:6 / \"Germany\"\n",
+      "                                    / \"France\"\n",
+      "                                    :quant (3500_EVENT_3:4 / some)\n",
+      "                                    :accompanier-of 3500_EVENT_3:0)\n",
+      "          :ARG2 EVENT_3:2&0:2)\n"
+     ]
+    }
+   ],
+   "source": [
+    "from penman.graph import Graph\n",
+    "\n",
+    "g = Graph(renamed_triples)\n",
+    "print(penman.encode(g))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 43,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Instance(source='EVENT_3:2&0:2', role=':instance', target='some'),\n",
+       " Instance(source='EVENT_3:3&0:3', role=':instance', target='\"Germany\"'),\n",
+       " Instance(source='3500_EVENT_3:3&0:6', role=':instance', target='\"France\"'),\n",
+       " Instance(source='3500_0:0', role=':instance', target='be-located-at-91'),\n",
+       " Instance(source='3500_0:4', role=':instance', target='some'),\n",
+       " Instance(source='3500_EVENT_3:0', role=':instance', target='go-02'),\n",
+       " Instance(source='EVENT_3:1&0:1', role=':instance', target='\"Germany\"'),\n",
+       " Instance(source='3500_0:5', role=':instance', target='member'),\n",
+       " Instance(source='3500_EVENT_3:3&0:6', role=':instance', target='\"Germany\"'),\n",
+       " Instance(source='EVENT_3:3&0:3', role=':instance', target='organization'),\n",
+       " Instance(source='3500_EVENT_3:4', role=':instance', target='some'),\n",
+       " Instance(source='3500_EVENT_3:0', role=':instance', target='drive-01'),\n",
+       " Instance(source='EVENT_3:2&0:2', role=':instance', target='have-org-role-91'),\n",
+       " Instance(source='3500_0:4', role=':instance', target='name'),\n",
+       " Instance(source='EVENT_3:2&0:2', role=':instance', target='\"France\"'),\n",
+       " Instance(source='EVENT_3:1&0:1', role=':instance', target='\"Max\"')]"
+      ]
+     },
+     "execution_count": 43,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g.instances()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 44,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Edge(source='3500_0:0', role=':accompanier', target='EVENT_3:3&0:3'),\n",
+       " Edge(source='3500_EVENT_3:3&0:6', role=':quant', target='3500_EVENT_3:4'),\n",
+       " Edge(source='EVENT_3:1&0:1', role=':quant', target='EVENT_3:2&0:2'),\n",
+       " Edge(source='3500_0:0', role=':ARG1', target='EVENT_3:1&0:1'),\n",
+       " Edge(source='EVENT_3:2&0:2', role=':ARG2', target='3500_0:5'),\n",
+       " Edge(source='EVENT_3:3&0:3', role=':name', target='3500_0:4'),\n",
+       " Edge(source='3500_EVENT_3:0', role=':accompanier', target='3500_EVENT_3:3&0:6'),\n",
+       " Edge(source='EVENT_3:2&0:2', role=':ARG0', target='EVENT_3:1&0:1'),\n",
+       " Edge(source='3500_0:0', role=':ARG2', target='3500_EVENT_3:3&0:6'),\n",
+       " Edge(source='3500_EVENT_3:0', role=':ARG0', target='EVENT_3:1&0:1'),\n",
+       " Edge(source='3500_EVENT_3:0', role=':ARG4', target='3500_EVENT_3:3&0:6'),\n",
+       " Edge(source='EVENT_3:3&0:3', role=':quant', target='3500_0:4'),\n",
+       " Edge(source='3500_0:0', role=':ARG2', target='EVENT_3:2&0:2'),\n",
+       " Edge(source='3500_EVENT_3:0', role=':ARG4', target='EVENT_3:2&0:2'),\n",
+       " Edge(source='EVENT_3:2&0:2', role=':ARG1', target='EVENT_3:3&0:3')]"
+      ]
+     },
+     "execution_count": 44,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g.edges()"
+   ]
   },
   {
    "cell_type": "markdown",
diff --git a/code/penman_merge.ipynb b/code/penman_merge.ipynb
new file mode 100644
index 0000000000000000000000000000000000000000..02e8fa865dfdb9441342d2f7feff586decaf8876
--- /dev/null
+++ b/code/penman_merge.ipynb
@@ -0,0 +1,421 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "id": "d6161522",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import os\n",
+    "import json\n",
+    "import pickle\n",
+    "import re\n",
+    "import penman"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 38,
+   "id": "143b82a2",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "parse = '''\n",
+    "  # ::snt Max who is a member of Some Germans is at France\n",
+    "  (b / be-located-at-91\n",
+    "      :ARG1 (p / person\n",
+    "            :name (n / name\n",
+    "                  :op1 \"Max\")\n",
+    "            :ARG0-of (h / have-org-role-91\n",
+    "                  :ARG1 (o / organization\n",
+    "                        :name (n2 / name\n",
+    "                              :op1 \"Some\"\n",
+    "                              :op2 \"Germans\"))\n",
+    "                  :ARG2 (m / member))))'''"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 39,
+   "id": "7cdadcf6",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "def replace_names(parse):\n",
+    "    \n",
+    "    name = re.findall('[a-z]+[\\s\\n\\t]*:name \\(n[0-9]? / name[\\s\\n\\t]*:op1 (\"[A-Za-z]+\")\\)', parse)\n",
+    "    names = re.findall('[a-z]+[\\s\\n\\t]*:name \\(n[0-9]? / name[\\s\\n\\t]*:op1 \"[A-Za-z]+\"\\)', parse)\n",
+    "    for i,el in enumerate(names):\n",
+    "        parse = parse.replace(el,name[i])\n",
+    "    name = re.findall('[a-z]+[\\s\\n\\t]*:mod \\(c[0-9]? / (\"[A-Za-z]+\")\\)', parse)\n",
+    "    names = re.findall('[a-z]+[\\s\\n\\t]*:mod \\(c[0-9]? / \"[A-Za-z]+\"\\)', parse)\n",
+    "    for i,el in enumerate(names):\n",
+    "        parse = parse.replace(el,name[i])\n",
+    "    return(parse)\n",
+    "parse2 = replace_names(parse)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 40,
+   "id": "a5787f87",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "g = penman.decode(parse)\n",
+    "g2 = penman.decode(parse2)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 41,
+   "id": "00e50463",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "#print(penman.encode(g))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 46,
+   "id": "07d25c04",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "#g.variables()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 49,
+   "id": "0ab6b3de",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Instance(source='b', role=':instance', target='be-located-at-91'),\n",
+       " Instance(source='p', role=':instance', target='person'),\n",
+       " Instance(source='n', role=':instance', target='name'),\n",
+       " Instance(source='h', role=':instance', target='have-org-role-91'),\n",
+       " Instance(source='o', role=':instance', target='organization'),\n",
+       " Instance(source='n2', role=':instance', target='name'),\n",
+       " Instance(source='m', role=':instance', target='member')]"
+      ]
+     },
+     "execution_count": 49,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g.instances()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 50,
+   "id": "395da001",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Instance(source='b', role=':instance', target='be-located-at-91'),\n",
+       " Instance(source='p', role=':instance', target='\"Max\"'),\n",
+       " Instance(source='h', role=':instance', target='have-org-role-91'),\n",
+       " Instance(source='o', role=':instance', target='organization'),\n",
+       " Instance(source='n2', role=':instance', target='name'),\n",
+       " Instance(source='m', role=':instance', target='member')]"
+      ]
+     },
+     "execution_count": 50,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g2.instances()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 51,
+   "id": "80b46786",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Attribute(source='n', role=':op1', target='\"Max\"'),\n",
+       " Attribute(source='n2', role=':op1', target='\"Some\"'),\n",
+       " Attribute(source='n2', role=':op2', target='\"Germans\"')]"
+      ]
+     },
+     "execution_count": 51,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g.attributes()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 52,
+   "id": "086f7848",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Attribute(source='n2', role=':op1', target='\"Some\"'),\n",
+       " Attribute(source='n2', role=':op2', target='\"Germans\"')]"
+      ]
+     },
+     "execution_count": 52,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g2.attributes()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 53,
+   "id": "928adb43",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Edge(source='b', role=':ARG1', target='p'),\n",
+       " Edge(source='p', role=':name', target='n'),\n",
+       " Edge(source='h', role=':ARG0', target='p'),\n",
+       " Edge(source='h', role=':ARG1', target='o'),\n",
+       " Edge(source='o', role=':name', target='n2'),\n",
+       " Edge(source='h', role=':ARG2', target='m')]"
+      ]
+     },
+     "execution_count": 53,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g.edges()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 54,
+   "id": "9a03c6fa",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[Edge(source='b', role=':ARG1', target='p'),\n",
+       " Edge(source='h', role=':ARG0', target='p'),\n",
+       " Edge(source='h', role=':ARG1', target='o'),\n",
+       " Edge(source='o', role=':name', target='n2'),\n",
+       " Edge(source='h', role=':ARG2', target='m')]"
+      ]
+     },
+     "execution_count": 54,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g2.edges()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 33,
+   "id": "a7ff40c1",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[('b', ':instance', 'be-located-at-91'),\n",
+       " ('b', ':ARG1', 'p'),\n",
+       " ('p', ':instance', '\"Max\"'),\n",
+       " ('h', ':ARG0', 'p'),\n",
+       " ('h', ':instance', 'have-org-role-91'),\n",
+       " ('h', ':ARG1', 'o'),\n",
+       " ('o', ':instance', 'organization'),\n",
+       " ('o', ':name', 'n2'),\n",
+       " ('n2', ':instance', 'name'),\n",
+       " ('n2', ':op1', '\"Some\"'),\n",
+       " ('n2', ':op2', '\"Germans\"'),\n",
+       " ('h', ':ARG2', 'm'),\n",
+       " ('m', ':instance', 'member')]"
+      ]
+     },
+     "execution_count": 33,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g.triples"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 62,
+   "id": "9e97520c",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "Tree(('b', [('/', 'be-located-at-91'), (':ARG1', ('p', [('/', '\"Max\"'), (':ARG0-of', ('h', [('/', 'have-org-role-91'), (':ARG1', ('o', [('/', 'organization'), (':name', ('n2', [('/', 'name'), (':op1', '\"Some\"'), (':op2', '\"Germans\"')]))])), (':ARG2', ('m', [('/', 'member')]))]))]))]))"
+      ]
+     },
+     "execution_count": 62,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "t2 = penman.configure(g2)\n",
+    "t2"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 55,
+   "id": "529c85ea",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "#t.node"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 56,
+   "id": "8e5c7fbb",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "#t.nodes()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 63,
+   "id": "30f40ee1",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "Tree(('s1_0', [('/', 'be-located-at-91'), (':ARG1', ('s1_1', [('/', '\"Max\"'), (':ARG0-of', ('s1_2', [('/', 'have-org-role-91'), (':ARG1', ('s1_3', [('/', 'organization'), (':name', ('s1_4', [('/', 'name'), (':op1', '\"Some\"'), (':op2', '\"Germans\"')]))])), (':ARG2', ('s1_5', [('/', 'member')]))]))]))]))"
+      ]
+     },
+     "execution_count": 63,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "t2.reset_variables('s1_{i}')\n",
+    "t2"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 66,
+   "id": "a6463c45",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "<Graph object (top=s1_0) at 140534018533456>"
+      ]
+     },
+     "execution_count": 66,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g3 = penman.interpret(t2)\n",
+    "g3"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 67,
+   "id": "43a437d4",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[('s1_0', ':instance', 'be-located-at-91'),\n",
+       " ('s1_0', ':ARG1', 's1_1'),\n",
+       " ('s1_1', ':instance', '\"Max\"'),\n",
+       " ('s1_2', ':ARG0', 's1_1'),\n",
+       " ('s1_2', ':instance', 'have-org-role-91'),\n",
+       " ('s1_2', ':ARG1', 's1_3'),\n",
+       " ('s1_3', ':instance', 'organization'),\n",
+       " ('s1_3', ':name', 's1_4'),\n",
+       " ('s1_4', ':instance', 'name'),\n",
+       " ('s1_4', ':op1', '\"Some\"'),\n",
+       " ('s1_4', ':op2', '\"Germans\"'),\n",
+       " ('s1_2', ':ARG2', 's1_5'),\n",
+       " ('s1_5', ':instance', 'member')]"
+      ]
+     },
+     "execution_count": 67,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "g3.triples"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "76921925",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.8"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}