Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ArneBinder/114b9472c2140f3e0ffc85f2b9247a06 to your computer and use it in GitHub Desktop.
Save ArneBinder/114b9472c2140f3e0ffc85f2b9247a06 to your computer and use it in GitHub Desktop.

Descriptions:

  • Relations type: typed dictionary with sources (list of source node ids), targets (list of target node ids), and relation (relation node id)
  • get_relations method that returns all Relations for a certain relation_type (either S, TA, or YA). We use the following constraints (format: REL-NODE-TYPES: SRC-TYPES -> TRG-TYPES):
    • TA: [TA]: [L] -> [L]
    • S: [RA, CA, MA]: [I] -> [I]
    • YA: [YA]: [L, TA] -> [I, L, RA, CA, MA] (Note: relations L -> YA -> L encode (in-)direct speech)
  • get_relation_statistics: collect the following statistics for a given nodeset by using get_relations:
    • "missed_edges": A list of edges not participating in any of the above relations, format: nodeset_id node_src:node_trg src_type:trg_type
    • "covered_edges": The number of covered edges, int.
    • "empty_sources": A list of relations with no source nodes when following above constraints, format: nodeset_id node_id node_type
    • "empty_targets": A list of relations with not targets nodes when following above constraints, format: nodeset_id node_id node_type
    • "more_than_one_target": A list of relations with more than one target, format: nodeset_id node_id node_type
    • "type_combinations": A dictionary containing the number of occurrences for each type combination, format: "relation_type: [source_types] -> [target_types]": count
    • "edges_covered_multi_times": A list of edges that are covered by multiple relations.
    • "covered_relations": A dictionary containing the number of covered relations for each type.
  • main entry method: call get_relation_statistics for a single nodeset or all nodesets in the given directory
CLICK HERE to see result for calling `python src/utils/nodeset_utils.py` on all data
{
  "covered_edges": 141045,
  "covered_relations": {
    "S": 12767,
    "TA": 23038,
    "YA": 34430
  },
  "edges_covered_multi_times": [],
  "empty_sources": [
    "20314 656977 MA",
    "25526 1021390 MA",
    "25526 1021393 RA",
    "25903 1040200 MA",
    "23154 822905 RA",
    "25452 1010043 MA",
    "23595 855175 YA",
    "23595 855176 YA",
    "23595 855177 YA",
    "23595 855178 YA",
    "23595 855179 YA",
    "23595 855180 MA",
    "23595 855181 TA",
    "23595 855182 YA",
    "23595 855183 TA",
    "23595 855184 TA",
    "23595 855185 RA",
    "23595 855186 YA",
    "23595 855187 YA",
    "23595 855188 TA",
    "23595 855189 RA",
    "23595 855190 YA",
    "23595 855191 TA",
    "23595 855192 MA",
    "23595 855193 YA",
    "23595 855194 YA",
    "23595 855195 TA",
    "23595 855196 RA",
    "23595 855197 YA",
    "23595 855198 TA",
    "23595 855199 YA",
    "23595 855200 YA",
    "23595 855201 YA",
    "23595 855202 TA",
    "23595 855203 TA",
    "23595 855204 MA",
    "23595 855205 YA",
    "23595 855206 YA",
    "23595 855207 YA",
    "23595 855208 YA",
    "23595 855209 RA",
    "23595 855210 TA",
    "23595 855211 TA",
    "23595 855212 YA",
    "23595 855213 RA",
    "23595 855214 TA",
    "23595 855215 YA",
    "23595 855216 YA",
    "23595 855217 YA",
    "23595 855218 RA",
    "23595 855219 TA",
    "23595 855220 YA",
    "23595 855221 YA",
    "23595 855222 TA",
    "23595 855223 YA",
    "23595 855224 TA",
    "23595 855225 CA",
    "23595 855226 YA",
    "23595 855227 YA",
    "23595 855228 TA",
    "23595 855229 TA",
    "23595 855230 MA",
    "23595 855231 YA",
    "25463 1014882 MA",
    "25463 1014915 MA",
    "23808 866006 MA",
    "23137 821938 CA",
    "21022 691915 RA",
    "21022 691924 RA",
    "25442 1006850 MA",
    "25461 1014400 MA",
    "25473 1017160 RA",
    "25473 1017163 RA",
    "23597 855344 YA",
    "23597 855345 YA",
    "23597 855346 TA",
    "23597 855347 YA",
    "23597 855348 YA",
    "23597 855349 YA",
    "23597 855350 YA",
    "23597 855351 YA",
    "23597 855352 YA",
    "23597 855353 YA",
    "23597 855354 RA",
    "23597 855355 TA",
    "23597 855356 YA",
    "23597 855357 YA",
    "23597 855358 MA",
    "23597 855359 TA",
    "23597 855360 YA",
    "23597 855361 YA",
    "23597 855362 YA",
    "23597 855363 MA",
    "23597 855364 TA",
    "23597 855365 YA",
    "23597 855366 MA",
    "23597 855367 TA",
    "23597 855368 YA",
    "23597 855369 YA",
    "23597 855370 YA",
    "23597 855371 YA",
    "23597 855372 YA",
    "23597 855373 YA",
    "23597 855374 TA",
    "23597 855375 MA",
    "23597 855376 TA",
    "23597 855377 YA",
    "23597 855378 RA",
    "23597 855379 TA",
    "23597 855380 YA",
    "23597 855381 TA",
    "23597 855382 TA",
    "23597 855383 MA",
    "23597 855384 YA",
    "23597 855385 MA",
    "23597 855386 TA",
    "23597 855387 YA",
    "23597 855388 MA",
    "23597 855389 TA",
    "23597 855390 YA",
    "23597 855391 RA",
    "23597 855392 TA",
    "23597 855393 TA",
    "23597 855394 TA",
    "23597 855395 YA",
    "23597 855396 TA",
    "25522 1021112 RA",
    "25522 1021132 RA",
    "25522 1021135 RA",
    "25443 1007329 MA",
    "25443 1007343 MA",
    "25443 1007346 MA",
    "25443 1007349 MA",
    "25443 1007355 MA",
    "23585 854847 MA",
    "18809 567281 RA",
    "23939 872778 MA",
    "19210 598068 CA",
    "19210 598073 MA",
    "19210 598085 MA",
    "19162 594495 CA",
    "25474 1017711 MA",
    "18497 554222 RA",
    "25445 1008720 RA",
    "25445 1008855 CA",
    "25445 1008858 CA",
    "25445 1008861 MA",
    "25445 1008864 RA",
    "25445 1008868 RA",
    "25445 1008946 CA",
    "25445 1008949 MA",
    "25445 1009126 MA",
    "25445 1009129 RA",
    "25445 1009132 MA",
    "25468 1016265 MA",
    "25468 1016268 MA",
    "25468 1016271 MA",
    "23565 853981 CA",
    "19179 596174 MA",
    "25475 1017469 MA",
    "25475 1017478 MA",
    "19746 631319 RA",
    "21417 715632 MA",
    "24992 977225 RA",
    "25462 1014517 MA",
    "25462 1014521 MA",
    "25462 1014524 MA",
    "25462 1014527 RA",
    "25462 1014530 MA",
    "25462 1014533 MA",
    "17925 511538 MA",
    "17925 511582 MA",
    "19173 595532 RA",
    "23607 856066 MA",
    "25465 1015093 CA",
    "25472 1016830 CA",
    "25472 1017015 MA"
  ],
  "empty_targets": [
    "25902 1040108 YA",
    "20314 656976 TA",
    "25526 1021332 CA",
    "25526 1021390 MA",
    "25526 1021393 RA",
    "25526 1021414 CA",
    "25441 1006717 MA",
    "23602 855795 RA",
    "25452 1010061 YA",
    "23595 855175 YA",
    "23595 855176 YA",
    "23595 855177 YA",
    "23595 855178 YA",
    "23595 855179 YA",
    "23595 855180 MA",
    "23595 855181 TA",
    "23595 855182 YA",
    "23595 855183 TA",
    "23595 855184 TA",
    "23595 855185 RA",
    "23595 855186 YA",
    "23595 855187 YA",
    "23595 855188 TA",
    "23595 855189 RA",
    "23595 855190 YA",
    "23595 855191 TA",
    "23595 855192 MA",
    "23595 855193 YA",
    "23595 855194 YA",
    "23595 855195 TA",
    "23595 855196 RA",
    "23595 855197 YA",
    "23595 855198 TA",
    "23595 855199 YA",
    "23595 855200 YA",
    "23595 855201 YA",
    "23595 855202 TA",
    "23595 855203 TA",
    "23595 855204 MA",
    "23595 855205 YA",
    "23595 855206 YA",
    "23595 855207 YA",
    "23595 855208 YA",
    "23595 855209 RA",
    "23595 855210 TA",
    "23595 855211 TA",
    "23595 855212 YA",
    "23595 855213 RA",
    "23595 855214 TA",
    "23595 855215 YA",
    "23595 855216 YA",
    "23595 855217 YA",
    "23595 855218 RA",
    "23595 855219 TA",
    "23595 855220 YA",
    "23595 855221 YA",
    "23595 855222 TA",
    "23595 855223 YA",
    "23595 855224 TA",
    "23595 855225 CA",
    "23595 855226 YA",
    "23595 855227 YA",
    "23595 855228 TA",
    "23595 855229 TA",
    "23595 855230 MA",
    "23595 855231 YA",
    "19342 606854 MA",
    "21279 704724 CA",
    "25463 1014891 RA",
    "25463 1014897 RA",
    "25463 1014912 MA",
    "23808 866006 MA",
    "21022 691914 TA",
    "21022 691923 TA",
    "21709 732651 MA",
    "25473 1017166 RA",
    "25473 1017169 MA",
    "25473 1017175 RA",
    "25473 1017179 RA",
    "25473 1017200 MA",
    "25473 1017203 RA",
    "25473 1017212 RA",
    "23597 855344 YA",
    "23597 855345 YA",
    "23597 855346 TA",
    "23597 855347 YA",
    "23597 855348 YA",
    "23597 855349 YA",
    "23597 855350 YA",
    "23597 855351 YA",
    "23597 855352 YA",
    "23597 855353 YA",
    "23597 855354 RA",
    "23597 855355 TA",
    "23597 855356 YA",
    "23597 855357 YA",
    "23597 855358 MA",
    "23597 855359 TA",
    "23597 855360 YA",
    "23597 855361 YA",
    "23597 855362 YA",
    "23597 855363 MA",
    "23597 855364 TA",
    "23597 855365 YA",
    "23597 855366 MA",
    "23597 855367 TA",
    "23597 855368 YA",
    "23597 855369 YA",
    "23597 855370 YA",
    "23597 855371 YA",
    "23597 855372 YA",
    "23597 855373 YA",
    "23597 855374 TA",
    "23597 855375 MA",
    "23597 855376 TA",
    "23597 855377 YA",
    "23597 855378 RA",
    "23597 855379 TA",
    "23597 855380 YA",
    "23597 855381 TA",
    "23597 855382 TA",
    "23597 855383 MA",
    "23597 855384 YA",
    "23597 855385 MA",
    "23597 855386 TA",
    "23597 855387 YA",
    "23597 855388 MA",
    "23597 855389 TA",
    "23597 855390 YA",
    "23597 855391 RA",
    "23597 855392 TA",
    "23597 855393 TA",
    "23597 855394 TA",
    "23597 855395 YA",
    "23597 855396 TA",
    "25522 1021115 TA",
    "25522 1021136 TA",
    "25522 1021144 MA",
    "25443 1007352 MA",
    "25443 1007360 MA",
    "23585 854847 MA",
    "23939 872778 MA",
    "19210 598073 MA",
    "19210 598085 MA",
    "25474 1017714 RA",
    "25445 1008693 MA",
    "25445 1008858 CA",
    "25445 1008861 MA",
    "25445 1008871 MA",
    "25445 1008874 CA",
    "25445 1008887 RA",
    "25445 1008966 MA",
    "25445 1009051 MA",
    "25445 1009135 CA",
    "25445 1009138 CA",
    "25445 1009171 RA",
    "25445 1009174 MA",
    "23708 861140 CA",
    "25468 1016262 YA",
    "25468 1016277 MA",
    "25468 1016283 MA",
    "23565 853981 CA",
    "19179 596173 TA",
    "25475 1017475 MA",
    "25475 1017478 MA",
    "25475 1017481 MA",
    "25475 1017487 MA",
    "25444 1007743 MA",
    "25444 1007782 RA",
    "25462 1014551 RA",
    "25462 1014557 RA",
    "25462 1014560 RA",
    "25462 1014563 RA",
    "25462 1014569 MA",
    "17925 511582 MA"
  ],
  "missed_edges": [
    "25526 1021332:601335 CA:L",
    "25526 1021390:601469 MA:L",
    "25526 1021393:601467 RA:L",
    "25526 1021414:601467 CA:L",
    "25526 601471:1021390 L:MA",
    "25526 601471:1021393 L:RA",
    "21579 723274:723273 I:YA",
    "25903 666310:1040200 L:MA",
    "23602 855795:807451 RA:L",
    "23789 820709:820709 L:L",
    "23533 799381:799381 L:L",
    "23154 705693:822905 L:RA",
    "18474 552603:552602 I:YA",
    "21646 727740:727739 RA:L",
    "19140 591787:591786 I:YA",
    "20855 682806:682805 I:YA",
    "23904 834733:871173 I:YA",
    "19342 606854:606775 MA:L",
    "23920 871979:836561 MA:L",
    "21452 718062:718061 MA:L",
    "20318 657413:657412 I:YA",
    "21279 704724:704721 CA:L",
    "23853 828982:828982 L:L",
    "17921 511248:511246 RA:L",
    "23478 794672:849432 I:YA",
    "18463 551673:551672 I:YA",
    "19065 588241:588236 I:YA",
    "20860 682946:682945 RA:L",
    "23808 824506:866006 L:MA",
    "23808 866006:823825 MA:L",
    "23696 817050:817050 L:L",
    "23883 870203:831779 RA:L",
    "23137 684945:821938 L:CA",
    "21285 705153:705152 I:YA",
    "21709 732571:732654 L:RA",
    "21709 732651:732571 MA:L",
    "23491 795572:795678 I:I",
    "23491 795587:795588 I:L",
    "23491 795595:795603 I:L",
    "23491 795676:795570 L:L",
    "23491 795676:795679 L:L",
    "23491 795679:795678 L:I",
    "25524 1021274:599633 RA:L",
    "25524 599563:1021238 I:YA",
    "18479 552979:552978 I:YA",
    "25522 1021144:598417 MA:L",
    "25522 598417:1021132 L:RA",
    "17945 513413:513412 I:YA",
    "23585 854845:854847 TA:MA",
    "23585 854847:854846 MA:MA",
    "18809 567138:567281 L:RA",
    "23939 872777:872778 TA:MA",
    "23939 872778:872774 MA:MA",
    "19210 597996:598068 L:CA",
    "19210 598072:598073 TA:MA",
    "19210 598073:598071 MA:MA",
    "19210 598080:598085 TA:MA",
    "19210 598085:598081 MA:MA",
    "19178 596058:596057 I:YA",
    "17966 515076:515075 I:YA",
    "19145 592290:592287 I:YA",
    "19162 594441:594495 L:CA",
    "21396 713985:713981 MA:L",
    "20752 676334:676333 MA:L",
    "21023 691987:691986 RA:L",
    "25723 816292:816292 L:L",
    "23275 833817:714103 MA:L",
    "17959 514200:514199 I:YA",
    "17959 514233:514232 I:YA",
    "19757 632456:632455 I:YA",
    "18497 554195:554222 L:RA",
    "23625 810028:857111 I:YA",
    "21008 691088:691085 I:YA",
    "25379 800500:1002436 I:YA",
    "23708 861140:811181 CA:L",
    "17938 512651:512647 MA:L",
    "23701 810541:860839 I:YA",
    "23878 831523:831523 L:L",
    "23565 853980:853981 TA:CA",
    "23565 853981:853961 CA:CA",
    "21400 714243:714242 I:YA",
    "21288 705480:705479 I:YA",
    "17964 514730:514727 I:YA",
    "19336 606320:606319 I:YA",
    "22947 630684:805234 I:YA",
    "19155 593584:593583 MA:L",
    "23479 794844:794844 L:L",
    "19746 631318:631319 TA:RA",
    "18453 550792:550791 I:YA",
    "19165 594724:594732 I:L",
    "19165 594732:594716 L:I",
    "19165 594735:594732 I:L",
    "19165 594779:594782 L:L",
    "19165 594782:594775 L:L",
    "19225 599342:599341 I:YA",
    "17925 511524:511538 L:MA",
    "17925 511580:511582 TA:MA",
    "17925 511582:511581 MA:MA",
    "19173 595455:595452 I:YA",
    "19173 595463:595593 L:MA",
    "19173 595530:595532 L:RA",
    "23607 808131:856066 L:MA",
    "23569 854134:854133 YA:TA",
    "23553 801517:853344 I:YA",
    "25509 604747:1020285 I:YA"
  ],
  "more_than_one_target": [
    "25903 1040203 TA",
    "21284 705068 TA",
    "18288 540529 TA",
    "19169 595175 TA",
    "18468 552108 TA",
    "20480 663516 TA",
    "23802 865724 TA",
    "19176 595877 TA",
    "19316 604529 TA",
    "19316 604531 TA",
    "23552 853266 YA",
    "19243 601116 TA",
    "23585 854821 TA",
    "18287 540422 TA",
    "20341 659242 TA",
    "20852 682536 TA",
    "19220 598906 TA",
    "19355 607904 TA",
    "19355 607977 TA",
    "19355 607986 TA",
    "20875 683953 TA",
    "21711 732816 TA",
    "19336 606273 TA",
    "19336 606280 TA",
    "23483 849710 TA",
    "19242 601001 TA",
    "25384 1002757 TA",
    "19758 632536 TA",
    "19890 640600 TA",
    "23554 853434 TA",
    "19225 599327 TA",
    "19225 599363 TA",
    "17940 512940 TA",
    "23895 870681 TA",
    "25506 1019930 TA",
    "25511 1020386 TA"
  ],
  "type_combinations": {
    "S: ['I', 'I', 'I', 'I', 'I', 'I', 'I'] -> ['I']": 3,
    "S: ['I', 'I', 'I', 'I', 'I'] -> ['I']": 7,
    "S: ['I', 'I', 'I', 'I'] -> ['I']": 25,
    "S: ['I', 'I', 'I'] -> ['I']": 97,
    "S: ['I', 'I'] -> ['I']": 542,
    "S: ['I'] -> ['I']": 11961,
    "S: ['I'] -> []": 44,
    "S: [] -> ['I']": 55,
    "S: [] -> []": 33,
    "TA: ['L', 'L', 'L', 'L'] -> ['L']": 1,
    "TA: ['L', 'L', 'L'] -> ['L']": 3,
    "TA: ['L', 'L'] -> ['L', 'L']": 1,
    "TA: ['L', 'L'] -> ['L']": 17,
    "TA: ['L'] -> ['L', 'L', 'L']": 1,
    "TA: ['L'] -> ['L', 'L']": 33,
    "TA: ['L'] -> ['L']": 22943,
    "TA: ['L'] -> []": 6,
    "TA: [] -> []": 33,
    "YA: ['L', 'L'] -> ['I']": 1,
    "YA: ['L', 'TA'] -> ['I']": 1,
    "YA: ['L'] -> ['I', 'L']": 1,
    "YA: ['L'] -> ['I']": 20742,
    "YA: ['L'] -> ['L']": 699,
    "YA: ['L'] -> []": 1,
    "YA: ['TA', 'TA'] -> ['I']": 1,
    "YA: ['TA', 'TA'] -> ['RA']": 3,
    "YA: ['TA'] -> ['CA']": 1224,
    "YA: ['TA'] -> ['I']": 315,
    "YA: ['TA'] -> ['MA']": 5789,
    "YA: ['TA'] -> ['RA']": 5595,
    "YA: ['TA'] -> []": 2,
    "YA: [] -> []": 56
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment