diff --git a/.VSCodeCounter/2022-01-05_11-11-20/details.md b/.VSCodeCounter/2022-01-05_11-11-20/details.md new file mode 100644 index 0000000000000000000000000000000000000000..c6c03fa2963e931cfb54b535cf305844ce510fed --- /dev/null +++ b/.VSCodeCounter/2022-01-05_11-11-20/details.md @@ -0,0 +1,75 @@ +# Details + +Date : 2022-01-05 11:11:20 + +Directory c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung + +Total : 60 files, 4426 codes, 857 comments, 956 blanks, all 6239 lines + +[summary](results.md) + +## Files +| filename | language | code | comment | blank | total | +| :--- | :--- | ---: | ---: | ---: | ---: | +| [assets/cn.js](/assets/cn.js) | JavaScript | 347 | 134 | 68 | 549 | +| [assets/index.html](/assets/index.html) | HTML | 84 | 8 | 15 | 107 | +| [assets/json_text.json](/assets/json_text.json) | JSON | 1 | 0 | 0 | 1 | +| [citation_parser_ui.py](/citation_parser_ui.py) | Python | 198 | 40 | 17 | 255 | +| [count_journal.py](/count_journal.py) | Python | 29 | 4 | 8 | 41 | +| [example_input.py](/example_input.py) | Python | 6 | 4 | 4 | 14 | +| [input/.VSCodeCounter/2021-12-24_13-19-53/details.md](/input/.VSCodeCounter/2021-12-24_13-19-53/details.md) | Markdown | 22 | 0 | 6 | 28 | +| [input/.VSCodeCounter/2021-12-24_13-19-53/results.md](/input/.VSCodeCounter/2021-12-24_13-19-53/results.md) | Markdown | 18 | 0 | 7 | 25 | +| [input/README.md](/input/README.md) | Markdown | 38 | 0 | 12 | 50 | +| [input/__init__.py](/input/__init__.py) | Python | 0 | 0 | 1 | 1 | +| [input/get/__init__.py](/input/get/__init__.py) | Python | 0 | 0 | 1 | 1 | +| [input/get/acs.py](/input/get/acs.py) | Python | 105 | 41 | 47 | 193 | +| [input/get/journal_fetcher.py](/input/get/journal_fetcher.py) | Python | 59 | 25 | 12 | 96 | +| [input/get/nature.py](/input/get/nature.py) | Python | 21 | 23 | 16 | 60 | +| [input/get/template_.py](/input/get/template_.py) | Python | 10 | 31 | 10 | 51 | +| [input/interface.py](/input/interface.py) | Python | 46 | 47 | 21 | 114 | +| [input/publication.py](/input/publication.py) | Python | 80 | 49 | 15 | 144 | +| [input/requirements.txt](/input/requirements.txt) | pip requirements | 2 | 0 | 0 | 2 | +| [input/test/__init__.py](/input/test/__init__.py) | Python | 0 | 0 | 1 | 1 | +| [input/test/test_acs.py](/input/test/test_acs.py) | Python | 285 | 7 | 11 | 303 | +| [input/test/test_input.py](/input/test/test_input.py) | Python | 40 | 28 | 14 | 82 | +| [input_old/README.md](/input_old/README.md) | Markdown | 2 | 0 | 2 | 4 | +| [input_old/input_fj.py](/input_old/input_fj.py) | Python | 118 | 20 | 17 | 155 | +| [input_old/pub.py](/input_old/pub.py) | Python | 24 | 4 | 5 | 33 | +| [input_old/test.py](/input_old/test.py) | Python | 11 | 1 | 4 | 16 | +| [output/README.md](/output/README.md) | Markdown | 40 | 0 | 6 | 46 | +| [output/graph/cn.js](/output/graph/cn.js) | JavaScript | 347 | 134 | 68 | 549 | +| [output/graph/index.html](/output/graph/index.html) | HTML | 84 | 8 | 15 | 107 | +| [output/graph/json_text.json](/output/graph/json_text.json) | JSON | 819 | 0 | 0 | 819 | +| [start_script.py](/start_script.py) | Python | 12 | 4 | 4 | 20 | +| [test.json](/test.json) | JSON | 1 | 0 | 0 | 1 | +| [ui_programm_fragmente/README.md](/ui_programm_fragmente/README.md) | Markdown | 23 | 0 | 16 | 39 | +| [ui_programm_fragmente/input_to_checklist.py](/ui_programm_fragmente/input_to_checklist.py) | Python | 144 | 9 | 8 | 161 | +| [ui_programm_fragmente/upload_to_checklist.py](/ui_programm_fragmente/upload_to_checklist.py) | Python | 52 | 5 | 22 | 79 | +| [verarbeitung/README.md](/verarbeitung/README.md) | Markdown | 39 | 0 | 22 | 61 | +| [verarbeitung/__init__.py](/verarbeitung/__init__.py) | Python | 0 | 0 | 1 | 1 | +| [verarbeitung/construct_new_graph/README.md](/verarbeitung/construct_new_graph/README.md) | Markdown | 18 | 0 | 11 | 29 | +| [verarbeitung/construct_new_graph/__init__.py](/verarbeitung/construct_new_graph/__init__.py) | Python | 0 | 0 | 1 | 1 | +| [verarbeitung/construct_new_graph/add_citations_rec.py](/verarbeitung/construct_new_graph/add_citations_rec.py) | Python | 140 | 15 | 50 | 205 | +| [verarbeitung/construct_new_graph/export_to_json.py](/verarbeitung/construct_new_graph/export_to_json.py) | Python | 66 | 12 | 13 | 91 | +| [verarbeitung/construct_new_graph/initialize_graph.py](/verarbeitung/construct_new_graph/initialize_graph.py) | Python | 127 | 25 | 45 | 197 | +| [verarbeitung/dev_files/README.md](/verarbeitung/dev_files/README.md) | Markdown | 1 | 0 | 0 | 1 | +| [verarbeitung/dev_files/__init__.py](/verarbeitung/dev_files/__init__.py) | Python | 0 | 0 | 1 | 1 | +| [verarbeitung/dev_files/print_graph_test.py](/verarbeitung/dev_files/print_graph_test.py) | Python | 53 | 36 | 19 | 108 | +| [verarbeitung/get_pub_from_input.py](/verarbeitung/get_pub_from_input.py) | Python | 27 | 12 | 9 | 48 | +| [verarbeitung/process_main.py](/verarbeitung/process_main.py) | Python | 29 | 12 | 15 | 56 | +| [verarbeitung/test/README.md](/verarbeitung/test/README.md) | Markdown | 16 | 0 | 9 | 25 | +| [verarbeitung/test/__init__.py](/verarbeitung/test/__init__.py) | Python | 0 | 0 | 1 | 1 | +| [verarbeitung/test/construct_graph_unittest.py](/verarbeitung/test/construct_graph_unittest.py) | Python | 165 | 10 | 56 | 231 | +| [verarbeitung/test/input_test.py](/verarbeitung/test/input_test.py) | Python | 83 | 0 | 22 | 105 | +| [verarbeitung/test/update_graph_unittest.py](/verarbeitung/test/update_graph_unittest.py) | Python | 125 | 4 | 32 | 161 | +| [verarbeitung/update_graph/README.md](/verarbeitung/update_graph/README.md) | Markdown | 24 | 0 | 17 | 41 | +| [verarbeitung/update_graph/__init__.py](/verarbeitung/update_graph/__init__.py) | Python | 0 | 0 | 1 | 1 | +| [verarbeitung/update_graph/compare_old_and_new_node_lists.py](/verarbeitung/update_graph/compare_old_and_new_node_lists.py) | Python | 23 | 7 | 8 | 38 | +| [verarbeitung/update_graph/connect_new_input.py](/verarbeitung/update_graph/connect_new_input.py) | Python | 91 | 23 | 39 | 153 | +| [verarbeitung/update_graph/delete_nodes_edges.py](/verarbeitung/update_graph/delete_nodes_edges.py) | Python | 62 | 13 | 21 | 96 | +| [verarbeitung/update_graph/import_from_json.py](/verarbeitung/update_graph/import_from_json.py) | Python | 46 | 20 | 25 | 91 | +| [verarbeitung/update_graph/update_depth.py](/verarbeitung/update_graph/update_depth.py) | Python | 135 | 14 | 46 | 195 | +| [verarbeitung/update_graph/update_edges.py](/verarbeitung/update_graph/update_edges.py) | Python | 19 | 10 | 9 | 38 | +| [verarbeitung/update_graph/update_graph.py](/verarbeitung/update_graph/update_graph.py) | Python | 69 | 18 | 30 | 117 | + +[summary](results.md) \ No newline at end of file diff --git a/.VSCodeCounter/2022-01-05_11-11-20/results.csv b/.VSCodeCounter/2022-01-05_11-11-20/results.csv new file mode 100644 index 0000000000000000000000000000000000000000..238cb3b6fe549e7e2122b0dfe63b36af70047d46 --- /dev/null +++ b/.VSCodeCounter/2022-01-05_11-11-20/results.csv @@ -0,0 +1,62 @@ +"filename", "language", "Python", "Markdown", "JSON", "HTML", "JavaScript", "pip requirements", "comment", "blank", "total" +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\assets\cn.js", "JavaScript", 0, 0, 0, 0, 347, 0, 134, 68, 549 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\assets\index.html", "HTML", 0, 0, 0, 84, 0, 0, 8, 15, 107 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\assets\json_text.json", "JSON", 0, 0, 1, 0, 0, 0, 0, 0, 1 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\citation_parser_ui.py", "Python", 198, 0, 0, 0, 0, 0, 40, 17, 255 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\count_journal.py", "Python", 29, 0, 0, 0, 0, 0, 4, 8, 41 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\example_input.py", "Python", 6, 0, 0, 0, 0, 0, 4, 4, 14 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\.VSCodeCounter\2021-12-24_13-19-53\details.md", "Markdown", 0, 22, 0, 0, 0, 0, 0, 6, 28 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\.VSCodeCounter\2021-12-24_13-19-53\results.md", "Markdown", 0, 18, 0, 0, 0, 0, 0, 7, 25 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\README.md", "Markdown", 0, 38, 0, 0, 0, 0, 0, 12, 50 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\__init__.py", "Python", 0, 0, 0, 0, 0, 0, 0, 1, 1 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\get\__init__.py", "Python", 0, 0, 0, 0, 0, 0, 0, 1, 1 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\get\acs.py", "Python", 105, 0, 0, 0, 0, 0, 41, 47, 193 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\get\journal_fetcher.py", "Python", 59, 0, 0, 0, 0, 0, 25, 12, 96 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\get\nature.py", "Python", 21, 0, 0, 0, 0, 0, 23, 16, 60 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\get\template_.py", "Python", 10, 0, 0, 0, 0, 0, 31, 10, 51 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\interface.py", "Python", 46, 0, 0, 0, 0, 0, 47, 21, 114 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\publication.py", "Python", 80, 0, 0, 0, 0, 0, 49, 15, 144 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\requirements.txt", "pip requirements", 0, 0, 0, 0, 0, 2, 0, 0, 2 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\test\__init__.py", "Python", 0, 0, 0, 0, 0, 0, 0, 1, 1 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\test\test_acs.py", "Python", 285, 0, 0, 0, 0, 0, 7, 11, 303 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\test\test_input.py", "Python", 40, 0, 0, 0, 0, 0, 28, 14, 82 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input_old\README.md", "Markdown", 0, 2, 0, 0, 0, 0, 0, 2, 4 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input_old\input_fj.py", "Python", 118, 0, 0, 0, 0, 0, 20, 17, 155 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input_old\pub.py", "Python", 24, 0, 0, 0, 0, 0, 4, 5, 33 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input_old\test.py", "Python", 11, 0, 0, 0, 0, 0, 1, 4, 16 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\README.md", "Markdown", 0, 40, 0, 0, 0, 0, 0, 6, 46 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\graph\cn.js", "JavaScript", 0, 0, 0, 0, 347, 0, 134, 68, 549 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\graph\index.html", "HTML", 0, 0, 0, 84, 0, 0, 8, 15, 107 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\graph\json_text.json", "JSON", 0, 0, 819, 0, 0, 0, 0, 0, 819 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\start_script.py", "Python", 12, 0, 0, 0, 0, 0, 4, 4, 20 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\test.json", "JSON", 0, 0, 1, 0, 0, 0, 0, 0, 1 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\ui_programm_fragmente\README.md", "Markdown", 0, 23, 0, 0, 0, 0, 0, 16, 39 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\ui_programm_fragmente\input_to_checklist.py", "Python", 144, 0, 0, 0, 0, 0, 9, 8, 161 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\ui_programm_fragmente\upload_to_checklist.py", "Python", 52, 0, 0, 0, 0, 0, 5, 22, 79 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\README.md", "Markdown", 0, 39, 0, 0, 0, 0, 0, 22, 61 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\__init__.py", "Python", 0, 0, 0, 0, 0, 0, 0, 1, 1 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\construct_new_graph\README.md", "Markdown", 0, 18, 0, 0, 0, 0, 0, 11, 29 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\construct_new_graph\__init__.py", "Python", 0, 0, 0, 0, 0, 0, 0, 1, 1 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\construct_new_graph\add_citations_rec.py", "Python", 140, 0, 0, 0, 0, 0, 15, 50, 205 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\construct_new_graph\export_to_json.py", "Python", 66, 0, 0, 0, 0, 0, 12, 13, 91 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\construct_new_graph\initialize_graph.py", "Python", 127, 0, 0, 0, 0, 0, 25, 45, 197 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\dev_files\README.md", "Markdown", 0, 1, 0, 0, 0, 0, 0, 0, 1 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\dev_files\__init__.py", "Python", 0, 0, 0, 0, 0, 0, 0, 1, 1 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\dev_files\print_graph_test.py", "Python", 53, 0, 0, 0, 0, 0, 36, 19, 108 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\get_pub_from_input.py", "Python", 27, 0, 0, 0, 0, 0, 12, 9, 48 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\process_main.py", "Python", 29, 0, 0, 0, 0, 0, 12, 15, 56 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\test\README.md", "Markdown", 0, 16, 0, 0, 0, 0, 0, 9, 25 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\test\__init__.py", "Python", 0, 0, 0, 0, 0, 0, 0, 1, 1 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\test\construct_graph_unittest.py", "Python", 165, 0, 0, 0, 0, 0, 10, 56, 231 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\test\input_test.py", "Python", 83, 0, 0, 0, 0, 0, 0, 22, 105 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\test\update_graph_unittest.py", "Python", 125, 0, 0, 0, 0, 0, 4, 32, 161 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\README.md", "Markdown", 0, 24, 0, 0, 0, 0, 0, 17, 41 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\__init__.py", "Python", 0, 0, 0, 0, 0, 0, 0, 1, 1 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\compare_old_and_new_node_lists.py", "Python", 23, 0, 0, 0, 0, 0, 7, 8, 38 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\connect_new_input.py", "Python", 91, 0, 0, 0, 0, 0, 23, 39, 153 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\delete_nodes_edges.py", "Python", 62, 0, 0, 0, 0, 0, 13, 21, 96 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\import_from_json.py", "Python", 46, 0, 0, 0, 0, 0, 20, 25, 91 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\update_depth.py", "Python", 135, 0, 0, 0, 0, 0, 14, 46, 195 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\update_edges.py", "Python", 19, 0, 0, 0, 0, 0, 10, 9, 38 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\update_graph.py", "Python", 69, 0, 0, 0, 0, 0, 18, 30, 117 +"Total", "-", 2500, 241, 821, 168, 694, 2, 857, 956, 6239 \ No newline at end of file diff --git a/.VSCodeCounter/2022-01-05_11-11-20/results.md b/.VSCodeCounter/2022-01-05_11-11-20/results.md new file mode 100644 index 0000000000000000000000000000000000000000..c151a7d32c9afd6e29c26c8daac04077b5ba1b8d --- /dev/null +++ b/.VSCodeCounter/2022-01-05_11-11-20/results.md @@ -0,0 +1,41 @@ +# Summary + +Date : 2022-01-05 11:11:20 + +Directory c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung + +Total : 60 files, 4426 codes, 857 comments, 956 blanks, all 6239 lines + +[details](details.md) + +## Languages +| language | files | code | comment | blank | total | +| :--- | ---: | ---: | ---: | ---: | ---: | +| Python | 41 | 2,500 | 573 | 682 | 3,755 | +| JSON | 3 | 821 | 0 | 0 | 821 | +| JavaScript | 2 | 694 | 268 | 136 | 1,098 | +| Markdown | 11 | 241 | 0 | 108 | 349 | +| HTML | 2 | 168 | 16 | 30 | 214 | +| pip requirements | 1 | 2 | 0 | 0 | 2 | + +## Directories +| path | files | code | comment | blank | total | +| :--- | ---: | ---: | ---: | ---: | ---: | +| . | 60 | 4,426 | 857 | 956 | 6,239 | +| assets | 3 | 432 | 142 | 83 | 657 | +| input | 15 | 726 | 251 | 174 | 1,151 | +| input\.VSCodeCounter | 2 | 40 | 0 | 13 | 53 | +| input\.VSCodeCounter\2021-12-24_13-19-53 | 2 | 40 | 0 | 13 | 53 | +| input\get | 5 | 195 | 120 | 86 | 401 | +| input\test | 3 | 325 | 35 | 26 | 386 | +| input_old | 4 | 155 | 25 | 28 | 208 | +| output | 4 | 1,290 | 142 | 89 | 1,521 | +| output\graph | 3 | 1,250 | 142 | 83 | 1,475 | +| ui_programm_fragmente | 3 | 219 | 14 | 46 | 279 | +| verarbeitung | 26 | 1,358 | 231 | 503 | 2,092 | +| verarbeitung\construct_new_graph | 5 | 351 | 52 | 120 | 523 | +| verarbeitung\dev_files | 3 | 54 | 36 | 20 | 110 | +| verarbeitung\test | 5 | 389 | 14 | 120 | 523 | +| verarbeitung\update_graph | 9 | 469 | 105 | 196 | 770 | + +[details](details.md) \ No newline at end of file diff --git a/.VSCodeCounter/2022-01-05_11-11-20/results.txt b/.VSCodeCounter/2022-01-05_11-11-20/results.txt new file mode 100644 index 0000000000000000000000000000000000000000..0327635ea105ae782fcbfaa999a93fb0c86e22b7 --- /dev/null +++ b/.VSCodeCounter/2022-01-05_11-11-20/results.txt @@ -0,0 +1,104 @@ +Date : 2022-01-05 11:11:20 +Directory : c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung +Total : 60 files, 4426 codes, 857 comments, 956 blanks, all 6239 lines + +Languages ++------------------+------------+------------+------------+------------+------------+ +| language | files | code | comment | blank | total | ++------------------+------------+------------+------------+------------+------------+ +| Python | 41 | 2,500 | 573 | 682 | 3,755 | +| JSON | 3 | 821 | 0 | 0 | 821 | +| JavaScript | 2 | 694 | 268 | 136 | 1,098 | +| Markdown | 11 | 241 | 0 | 108 | 349 | +| HTML | 2 | 168 | 16 | 30 | 214 | +| pip requirements | 1 | 2 | 0 | 0 | 2 | ++------------------+------------+------------+------------+------------+------------+ + +Directories ++----------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ +| path | files | code | comment | blank | total | ++----------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ +| . | 60 | 4,426 | 857 | 956 | 6,239 | +| assets | 3 | 432 | 142 | 83 | 657 | +| input | 15 | 726 | 251 | 174 | 1,151 | +| input\.VSCodeCounter | 2 | 40 | 0 | 13 | 53 | +| input\.VSCodeCounter\2021-12-24_13-19-53 | 2 | 40 | 0 | 13 | 53 | +| input\get | 5 | 195 | 120 | 86 | 401 | +| input\test | 3 | 325 | 35 | 26 | 386 | +| input_old | 4 | 155 | 25 | 28 | 208 | +| output | 4 | 1,290 | 142 | 89 | 1,521 | +| output\graph | 3 | 1,250 | 142 | 83 | 1,475 | +| ui_programm_fragmente | 3 | 219 | 14 | 46 | 279 | +| verarbeitung | 26 | 1,358 | 231 | 503 | 2,092 | +| verarbeitung\construct_new_graph | 5 | 351 | 52 | 120 | 523 | +| verarbeitung\dev_files | 3 | 54 | 36 | 20 | 110 | +| verarbeitung\test | 5 | 389 | 14 | 120 | 523 | +| verarbeitung\update_graph | 9 | 469 | 105 | 196 | 770 | ++----------------------------------------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ + +Files ++----------------------------------------------------------------------------------------------------------------------+------------------+------------+------------+------------+------------+ +| filename | language | code | comment | blank | total | ++----------------------------------------------------------------------------------------------------------------------+------------------+------------+------------+------------+------------+ +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\assets\cn.js | JavaScript | 347 | 134 | 68 | 549 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\assets\index.html | HTML | 84 | 8 | 15 | 107 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\assets\json_text.json | JSON | 1 | 0 | 0 | 1 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\citation_parser_ui.py | Python | 198 | 40 | 17 | 255 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\count_journal.py | Python | 29 | 4 | 8 | 41 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\example_input.py | Python | 6 | 4 | 4 | 14 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\.VSCodeCounter\2021-12-24_13-19-53\details.md | Markdown | 22 | 0 | 6 | 28 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\.VSCodeCounter\2021-12-24_13-19-53\results.md | Markdown | 18 | 0 | 7 | 25 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\README.md | Markdown | 38 | 0 | 12 | 50 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\__init__.py | Python | 0 | 0 | 1 | 1 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\get\__init__.py | Python | 0 | 0 | 1 | 1 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\get\acs.py | Python | 105 | 41 | 47 | 193 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\get\journal_fetcher.py | Python | 59 | 25 | 12 | 96 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\get\nature.py | Python | 21 | 23 | 16 | 60 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\get\template_.py | Python | 10 | 31 | 10 | 51 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\interface.py | Python | 46 | 47 | 21 | 114 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\publication.py | Python | 80 | 49 | 15 | 144 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\requirements.txt | pip requirements | 2 | 0 | 0 | 2 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\test\__init__.py | Python | 0 | 0 | 1 | 1 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\test\test_acs.py | Python | 285 | 7 | 11 | 303 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input\test\test_input.py | Python | 40 | 28 | 14 | 82 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input_old\README.md | Markdown | 2 | 0 | 2 | 4 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input_old\input_fj.py | Python | 118 | 20 | 17 | 155 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input_old\pub.py | Python | 24 | 4 | 5 | 33 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input_old\test.py | Python | 11 | 1 | 4 | 16 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\README.md | Markdown | 40 | 0 | 6 | 46 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\graph\cn.js | JavaScript | 347 | 134 | 68 | 549 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\graph\index.html | HTML | 84 | 8 | 15 | 107 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\graph\json_text.json | JSON | 819 | 0 | 0 | 819 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\start_script.py | Python | 12 | 4 | 4 | 20 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\test.json | JSON | 1 | 0 | 0 | 1 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\ui_programm_fragmente\README.md | Markdown | 23 | 0 | 16 | 39 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\ui_programm_fragmente\input_to_checklist.py | Python | 144 | 9 | 8 | 161 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\ui_programm_fragmente\upload_to_checklist.py | Python | 52 | 5 | 22 | 79 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\README.md | Markdown | 39 | 0 | 22 | 61 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\__init__.py | Python | 0 | 0 | 1 | 1 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\construct_new_graph\README.md | Markdown | 18 | 0 | 11 | 29 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\construct_new_graph\__init__.py | Python | 0 | 0 | 1 | 1 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\construct_new_graph\add_citations_rec.py | Python | 140 | 15 | 50 | 205 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\construct_new_graph\export_to_json.py | Python | 66 | 12 | 13 | 91 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\construct_new_graph\initialize_graph.py | Python | 127 | 25 | 45 | 197 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\dev_files\README.md | Markdown | 1 | 0 | 0 | 1 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\dev_files\__init__.py | Python | 0 | 0 | 1 | 1 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\dev_files\print_graph_test.py | Python | 53 | 36 | 19 | 108 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\get_pub_from_input.py | Python | 27 | 12 | 9 | 48 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\process_main.py | Python | 29 | 12 | 15 | 56 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\test\README.md | Markdown | 16 | 0 | 9 | 25 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\test\__init__.py | Python | 0 | 0 | 1 | 1 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\test\construct_graph_unittest.py | Python | 165 | 10 | 56 | 231 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\test\input_test.py | Python | 83 | 0 | 22 | 105 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\test\update_graph_unittest.py | Python | 125 | 4 | 32 | 161 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\README.md | Markdown | 24 | 0 | 17 | 41 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\__init__.py | Python | 0 | 0 | 1 | 1 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\compare_old_and_new_node_lists.py | Python | 23 | 7 | 8 | 38 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\connect_new_input.py | Python | 91 | 23 | 39 | 153 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\delete_nodes_edges.py | Python | 62 | 13 | 21 | 96 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\import_from_json.py | Python | 46 | 20 | 25 | 91 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\update_depth.py | Python | 135 | 14 | 46 | 195 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\update_edges.py | Python | 19 | 10 | 9 | 38 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\verarbeitung\update_graph\update_graph.py | Python | 69 | 18 | 30 | 117 | +| Total | | 4,426 | 857 | 956 | 6,239 | ++----------------------------------------------------------------------------------------------------------------------+------------------+------------+------------+------------+------------+ \ No newline at end of file diff --git a/.VSCodeCounter/2022-01-05_11-23-29/details.md b/.VSCodeCounter/2022-01-05_11-23-29/details.md new file mode 100644 index 0000000000000000000000000000000000000000..0e70130b691ea9a351f0c36230251bd4b9cf16bd --- /dev/null +++ b/.VSCodeCounter/2022-01-05_11-23-29/details.md @@ -0,0 +1,19 @@ +# Details + +Date : 2022-01-05 11:23:29 + +Directory c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output + +Total : 4 files, 1290 codes, 142 comments, 89 blanks, all 1521 lines + +[summary](results.md) + +## Files +| filename | language | code | comment | blank | total | +| :--- | :--- | ---: | ---: | ---: | ---: | +| [output/README.md](/output/README.md) | Markdown | 40 | 0 | 6 | 46 | +| [output/graph/cn.js](/output/graph/cn.js) | JavaScript | 347 | 134 | 68 | 549 | +| [output/graph/index.html](/output/graph/index.html) | HTML | 84 | 8 | 15 | 107 | +| [output/graph/json_text.json](/output/graph/json_text.json) | JSON | 819 | 0 | 0 | 819 | + +[summary](results.md) \ No newline at end of file diff --git a/.VSCodeCounter/2022-01-05_11-23-29/results.csv b/.VSCodeCounter/2022-01-05_11-23-29/results.csv new file mode 100644 index 0000000000000000000000000000000000000000..aa8e5c38deb738d27f159d0d911eadb6abf42e8a --- /dev/null +++ b/.VSCodeCounter/2022-01-05_11-23-29/results.csv @@ -0,0 +1,6 @@ +"filename", "language", "Markdown", "HTML", "JavaScript", "JSON", "comment", "blank", "total" +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\README.md", "Markdown", 40, 0, 0, 0, 0, 6, 46 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\graph\cn.js", "JavaScript", 0, 0, 347, 0, 134, 68, 549 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\graph\index.html", "HTML", 0, 84, 0, 0, 8, 15, 107 +"c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\graph\json_text.json", "JSON", 0, 0, 0, 819, 0, 0, 819 +"Total", "-", 40, 84, 347, 819, 142, 89, 1521 \ No newline at end of file diff --git a/.VSCodeCounter/2022-01-05_11-23-29/results.md b/.VSCodeCounter/2022-01-05_11-23-29/results.md new file mode 100644 index 0000000000000000000000000000000000000000..e3c40ca3387db6b6a8c4a0e026bf732b686fa374 --- /dev/null +++ b/.VSCodeCounter/2022-01-05_11-23-29/results.md @@ -0,0 +1,25 @@ +# Summary + +Date : 2022-01-05 11:23:29 + +Directory c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output + +Total : 4 files, 1290 codes, 142 comments, 89 blanks, all 1521 lines + +[details](details.md) + +## Languages +| language | files | code | comment | blank | total | +| :--- | ---: | ---: | ---: | ---: | ---: | +| JSON | 1 | 819 | 0 | 0 | 819 | +| JavaScript | 1 | 347 | 134 | 68 | 549 | +| HTML | 1 | 84 | 8 | 15 | 107 | +| Markdown | 1 | 40 | 0 | 6 | 46 | + +## Directories +| path | files | code | comment | blank | total | +| :--- | ---: | ---: | ---: | ---: | ---: | +| . | 4 | 1,290 | 142 | 89 | 1,521 | +| graph | 3 | 1,250 | 142 | 83 | 1,475 | + +[details](details.md) \ No newline at end of file diff --git a/.VSCodeCounter/2022-01-05_11-23-29/results.txt b/.VSCodeCounter/2022-01-05_11-23-29/results.txt new file mode 100644 index 0000000000000000000000000000000000000000..a71dc0ce078a7cad90eaf6b08532619188ff2b8e --- /dev/null +++ b/.VSCodeCounter/2022-01-05_11-23-29/results.txt @@ -0,0 +1,32 @@ +Date : 2022-01-05 11:23:29 +Directory : c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output +Total : 4 files, 1290 codes, 142 comments, 89 blanks, all 1521 lines + +Languages ++------------+------------+------------+------------+------------+------------+ +| language | files | code | comment | blank | total | ++------------+------------+------------+------------+------------+------------+ +| JSON | 1 | 819 | 0 | 0 | 819 | +| JavaScript | 1 | 347 | 134 | 68 | 549 | +| HTML | 1 | 84 | 8 | 15 | 107 | +| Markdown | 1 | 40 | 0 | 6 | 46 | ++------------+------------+------------+------------+------------+------------+ + +Directories ++--------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ +| path | files | code | comment | blank | total | ++--------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ +| . | 4 | 1,290 | 142 | 89 | 1,521 | +| graph | 3 | 1,250 | 142 | 83 | 1,475 | ++--------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ + +Files ++--------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ +| filename | language | code | comment | blank | total | ++--------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\README.md | Markdown | 40 | 0 | 6 | 46 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\graph\cn.js | JavaScript | 347 | 134 | 68 | 549 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\graph\index.html | HTML | 84 | 8 | 15 | 107 | +| c:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\output\graph\json_text.json | JSON | 819 | 0 | 0 | 819 | +| Total | | 1,290 | 142 | 89 | 1,521 | ++--------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 61f2dc9f84d472c32fa57194620d6b1e5fa14649..df2eaf4579d8730d30a9b69b2e0568794c12e27f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,129 @@ -**/__pycache__/ +# Editors +.vscode/ +.VSCodeCounter/ +.idea/ + +# Vagrant +.vagrant/ + +# Mac/OSX +.DS_Store + +# Windows +Thumbs.db + +# Source for the following rules: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# json +*.json \ No newline at end of file diff --git a/assets/cn.js b/assets/cn.js index 309678b42520cec11d77cf6a3b4be2925cb8bede..389935df5f1469ec2f152f0adc6995a72302fde7 100644 --- a/assets/cn.js +++ b/assets/cn.js @@ -17,10 +17,10 @@ perc; * scale functions that return y coordinate/color of node depending on group */ var color = d3.scaleOrdinal() - .domain(["height", "input", "depth"]) + .domain(["Citedby", "Input", "Reference"]) .range([' #01d7c0', ' #8b90fe ', ' #a15eb2 ']), y_scale = d3.scaleOrdinal() - .domain(["height", "input", "depth"]) + .domain(["Citedby", "Input", "Reference"]) .range([0, 200, 400]), to_remove; @@ -48,6 +48,7 @@ var rect = svg.append("rect") /** * creates svg object (legend) and associated attributes +* transform */ var svg_legend = d3.select("svg.legendsvg"), legend_position = [65,95,125], @@ -111,20 +112,20 @@ legend_arrow.append("text") */ var simulation = d3.forceSimulation() .force("link", d3.forceLink().id(function(d) {return d.doi;}).distance(50).strength(function(d) { - if (d.group == "input") {return 0;} + if (d.group == "Input") {return 0;} else {return 5;} })) .force("collide", d3.forceCollide(function(d) { - if (d.group == "input") {return 100;} - else {return 65;} + if (d.group == "Input") {return 70;} + else {return 70;} }).strength(0.5)) .force("charge", d3.forceManyBody().strength(0.001)) .force("center", d3.forceCenter(width/2, height/2+20)) .force("yscale", d3.forceY().strength(function(d) { - if (d.group == "input") {return 1000;} - else {return 50;} + if (d.group == "Input") {return 300;} + else {return 200;} }).y(function(d) {return y_scale(d.group)})) - .alpha(0.005) + .alpha(0.004) .on("end", zoom_to); /** @@ -140,6 +141,18 @@ d3.json("json_text.json").then(function(graph) { update(graph.links, graph.nodes); }) +var intervalId=window.setInterval(function(){ + d3.json("json_text.json").then(function(graph) { + newjson_string=JSON.stringify(graph) + var newjson = CryptoJS.MD5(newjson_string).toString(); + oldjson=localStorage.getItem("oldjson") + if(newjson !== oldjson){ + localStorage.setItem("oldjson", newjson); + window.location.reload() + } + }) +},5000); + /** * calls update functions for links and nodes * adds the nodes, links and tick functionality to the simulation @@ -161,7 +174,7 @@ function update(links, nodes) { } /** -* initializes and shows links +* initializes and shows links (edges) * @param {object} links - links */ function update_links(links) { @@ -280,9 +293,9 @@ function self_citation(source,target) { function mark_link(node) { d3.selectAll(".link") .style("stroke", function(o) { - return is_link_for_node(node, o) ? "black" : "#999";}) + return is_link_for_node(node, o) ? "black" : "#DEDEDE";}) .attr('marker-end', function(o) { - return is_link_for_node(node, o) ? update_marker('#000000', o.target) : update_marker('#999', o.target);}) + return is_link_for_node(node, o) ? update_marker('#000000', o.target) : update_marker('#DEDEDE', o.target);}) } /** diff --git a/assets/cn2.js b/assets/cn2.js new file mode 100644 index 0000000000000000000000000000000000000000..dce918d24e11ba191318915544fd9c8179eb9414 --- /dev/null +++ b/assets/cn2.js @@ -0,0 +1,600 @@ +/** +* creates a new zoom behavior +*/ +var zoom = d3.zoom().on("zoom", handle_zoom); + +/** +* creates svg object and associated attributes +* applies the zoom behavior to svg +*/ +var svg = d3.select("svg.graph") + .call(zoom), +width = svg.attr("width"), +height = svg.attr("height"), +perc; + +/** +* scale functions that return y coordinate/color of node depending on group +*/ +var color = d3.scaleOrdinal() + .domain(["Citedby", "Input", "Reference"]) + .range([' #01d7c0', ' #8b90fe ', ' #a15eb2 ']), +y_scale = d3.scaleOrdinal() + .domain(["Citedby", "Input", "Reference"]) + .range([0, 200, 400]), +to_remove; + +/** +* creates node object and (default) radius +*/ +var node, +r = 10; + +/** +* creates link object +*/ +var link; + +/** +* creates a background with a click functionality +*/ +var rect = svg.append("rect") + .attr("x", 0) + .attr("y", 0) + .attr("height", height) + .attr("width", width) + .style("fill", 'white') + .on('click', click_rect); + +/** +* creates svg object (legend) and associated attributes +* transform +* mehr kommentare +*/ +var svg_legend = d3.select("svg.legendsvg"), +legend_position = [65,95,125], +arrow_legend_position = [0,25], +arrow_group_names = ["citation","self-citation"], +group_names = ["cited by","input","reference"], +line_type = d3.scaleOrdinal() + .domain(["line","dotted"]) + .range([("8,0"),("8,8")]), +text_info = '', +text_abstract = ''; + +var legend = svg_legend.selectAll(".legend") + .data(legend_position) + .enter() + .append("g") + .attr("class","legend") + .attr("transform", function(d,i) {return "translate(0," + d + ")"; }); + +legend.append("text") + .attr("x", 80) + .attr("y", 0) + .attr("dy", ".35em") + .style("text-anchor", "start") + .text(function(d,i) {return group_names[i]}); + +legend.append("circle") + .attr("r", r) + .attr("cx",30-r) + .style("fill", color); + +var legend_arrow = svg_legend.selectAll(".legendarr") + .data(arrow_legend_position) + .enter() + .append("g") + .attr("class","legendarr") + .attr("transform", function(d) { return "translate(0," + d + ")"; }); + +legend_arrow.append("line") + .attr("x1", 10) + .attr("x2", 50) + .attr("y1", 10) + .attr("y2", 10) + .style("stroke-dasharray",line_type) + .style("stroke", '#999') + .style("stroke-width", "1px") + .style('pointer-events', 'none') + .attr('marker-end',update_marker('#999',this)); + +legend_arrow.append("text") + .attr("x", 80) + .attr("y", 10) + .attr("dy", ".35em") + .style("text-anchor", "start") + .text(function(d,i){return arrow_group_names[i]}); + +/** +* creates a new simulation +* updates the positions of the links and nodes when the + state of the layout has changed (simulation has advanced by a tick) +*/ + +var simulation = d3.forceSimulation() + .force("link", d3.forceLink().id(function(d) {return d.doi;}).distance(50).strength(function(d) { + if (d.group == "Input") {return 0;} + else {return 5;} + })) + .force("collide", d3.forceCollide(function(d) { + if (d.group == "Input") {return 70;} + else {return 75;} + }).strength(1)) + .force("charge", d3.forceManyBody().strength(0.001)) + .force("center", d3.forceCenter(width/2, height/2+20)) + .alpha(0.004) + .on("end", zoom_to); + +/** +* creates group element +*/ +var g = svg.append("g") + .attr("class", "everything") + +/** +* creates xAxis element +*/ +var xAxis = d3.axisBottom() + .tickFormat(function(d) {return d;}) + .ticks(10);; + +/** +* draw xAxis +*/ +var gX = svg.append("g") + .attr("class", "axis axis--x") + .attr("transform", "translate(0,25)") + gX.append("text") + .attr("y", 0) + .attr("x", 80) + .attr("text-anchor", "end") + .attr("stroke", "black") + .text("year"); + +/** +* loads JSON data and calls the update function +*/ +d3.json("json_text.json").then(function(graph) { + update(graph.links, graph.nodes); +}) + +var intervalId=window.setInterval(function(){ + d3.json("json_text.json").then(function(graph) { + newjson_string=JSON.stringify(graph) + var newjson = CryptoJS.MD5(newjson_string).toString(); + oldjson=localStorage.getItem("oldjson") + if(newjson !== oldjson){ + localStorage.setItem("oldjson", newjson); + window.location.reload() + } + }) +},5000); + +/** +* calls update functions for links and nodes +* adds the nodes, links and tick functionality to the simulation +* @param {object} nodes - nodes +* @param {object} links - links +*/ +function update(links, nodes) { + updateXAxis(nodes); + update_links(links); + update_nodes(nodes); + + simulation + .nodes(nodes) + .on("tick", handle_tick); + simulation.force("link") + .links(links); + + link.attr('marker-end', function(d) {return update_marker("#999", d.target);}) + .style("stroke-dasharray",function(d){return self_citation(d.source,d.target)? ("8,8"): ("1,0")}); +} + +/** +* initializes and shows xAxis +* @param {object} nodes - nodes +*/ +function updateXAxis(nodes) { + years = []; + for (i = 0; i < nodes.length; i++) { + years.push(parseInt((nodes[i]["year"]).split(" ")[2])); + } + + xscale = d3.scaleLinear() + .domain([d3.min(years)-1, d3.max(years)+1]) + .range([50, width-50]) + + xAxis.scale(xscale); + gX.call(xAxis); +} + +/** +* initializes and shows links (edges) +* @param {object} links - links +*/ +function update_links(links) { + link = g.append("g") + .selectAll(".link") + .data(links) + .enter() + .append("line") + .style("stroke-width", "1px") + .style("stroke", "#999") + .attr("class", "link"); +} + +/** +* initializes and shows nodes with circles, texts and a click functionality +* creates a new drag behavior and applies it to the circles +* @param {object} nodes - nodes +*/ +function update_nodes(nodes) { + node = g.selectAll(".node") + .data(nodes) + .enter() + .append("g") + .attr("class", "node") + .call(d3.drag() + .on("start", start_drag) + .on("drag", dragged) + ); + + node.append("circle") + .attr("class", "circle") + .attr("r", function(d) {return 1.5*r+d.citations*0.05}) + .style("fill", function(d){ return color(d.group)}) + .on('click', click_node); + + node.append("text") + .attr("class", "text") + .style("font-size", "15px") + .style('pointer-events', 'auto') + .text(function (d) {const first_author=d.author[0].split(" ") + return first_author[first_author.length-1];}) + .on('click', click_node); +} + +/** +* creates arrowhead and returns its url +* @param {string} color - color of arrowhead +* @param {string} target - target node +*/ +function update_marker(color, target) { + var radius = 1.5*r+target.citations*0.05; + svg.append('defs').append('marker') + .attr('id',color.replace("#", "")+radius) + .attr('viewBox','-0 -5 10 10') + .attr('refX',radius+9.5) + .attr('refY',0) + .attr('orient','auto') + .attr('markerWidth',10) + .attr('markerHeight',15) + .attr('xoverflow','visible') + .append('svg:path') + .attr('d', 'M 0,-5 L 10 ,0 L 0,5') + .attr('fill', color) + .style('stroke','none'); + return "url(" + color + radius + ")"; +}; + +/** +* sets color of circle and its links to black and removes the previous highlights +* displays overview info of node in textbox +* @param {object} node - node +*/ +function click_node(node) { + d3.select(this.parentNode).raise(); + fix_nodes(node); + if(to_remove){ + d3.select(to_remove).selectAll(".circle").style("stroke","none") + } + to_remove = this.parentNode; + d3.select(this.parentNode).selectAll(".circle").style("stroke","black") + mark_link(node) + textbox_content(node) + reset_button_highlight() + highlight_button("overview") +} + +/** +* removes the highlights of the circles and their links +*/ +function click_rect() { + fix_nodes(node); + d3.selectAll(".circle").style("stroke", "none") + d3.selectAll(".link") + .style("stroke", "#999") + .attr('marker-end', function(d) {return update_marker('#999', d.target);}) + text_abstract=''; + text_info=''; + reset_button_highlight() + document.getElementById('textbox').innerHTML = "Click node"; +} + +/** +* returns true if journals have a common author (self-citation) +* @param {object} source - node +* @param {object} target - node +*/ +function self_citation(source,target) { + return source.author.some(item=>target.author.includes(item)) +} + +/** +* sets color of link (line and arrowhead) to black if it is directly connected to node +* and to grey otherwise +* @param {object} node - node +*/ +function mark_link(node) { + d3.selectAll(".link") + .style("stroke", function(o) { + return is_link_for_node(node, o) ? "black" : "#DEDEDE";}) + .attr('marker-end', function(o) { + return is_link_for_node(node, o) ? update_marker('#000000', o.target) : update_marker("#DEDEDE", o.target);}) +} + +/** +* returns true if link is directly connected to node and false if it is not +* @param {object} node - node +* @param {object} link - link +*/ +function is_link_for_node(node, link) { + return link.source.index == node.index || link.target.index == node.index; +} + +/** +* saves text for overview and abstract of node +* outputs node info to textbox +* @param {object} node - node +*/ +function textbox_content(node) { + text_info = "Title:" + '</br>' + node.name + + '</br>' +'</br>'+"Author:"+ '</br>' +node.author+'</br>'+'</br>'+"Date:"+'</br>' + +node.year+'</br>'+'</br>'+"Journal:"+'</br>'+node.journal+'</br>'+'</br>'+"doi:" + +'</br>'+'<a href="'+node.doi+ '">'+node.doi+'</a>'+'</br>'+'</br>'+"Citations:" + +'</br>'+node.citations; + text_abstract = node.abstract; + document.getElementById('textbox').innerHTML = text_info; +} + +/** +* sets color of btn to dark gray +* @param {object} btn - button +*/ +function highlight_button(btn) { + reset_button_highlight(); + document.getElementById(btn).style.background = "#CACACA"; +} + +/** +* sets color of all buttons to default light gray +*/ +function reset_button_highlight() { + document.getElementById("overview").style.background = ''; + document.getElementById("abstract").style.background = ''; +} + +/** +* displays abstract in textbox if a is true, overview text otherwise +* @param {bool} a- bool +*/ +function display_abstract(a) { + if (text_abstract == '' && text_info == '') { + document.getElementById('textbox').innerHTML="Click node"; + } + else { + if (a == true) { + document.getElementById('textbox').innerHTML = text_abstract; + } + else { + document.getElementById('textbox').innerHTML = text_info; + } + } +} + +/** +* updates the positions of the links and nodes +*/ +function handle_tick() { + link.attr("x1", function (d) {return xscale(parseInt((d.source.year).split(" ")[2]));}) + .attr("y1", function (d) {return d.source.y;}) + .attr("x2", function (d) {return xscale(parseInt((d.target.year).split(" ")[2]));}) + .attr("y2", function (d) {return d.target.y;}); + node.attr("transform", function (d) {return "translate(" + xscale(parseInt((d.year).split(" ")[2])) + ", " + d.y + ")";}); +} + +/** +* initializes the dragging of the node +* @param {object} node - node +*/ +function start_drag(node) { + d3.select(this).raise(); + if (!d3.event.active) + simulation.alphaTarget(0.3).restart() + //node.fx = node.x; + node.fy = node.y; + fix_nodes(node); +} + +/** +* applies the dragging to the node +* @param {object} node - node +*/ +function dragged(node) { + //node.fx = d3.event.x; + node.fy = d3.event.y; + fix_nodes(node); +} + +/** +* fix positions of all nodes except for the current node +* @param {object} this_node - node +*/ +function fix_nodes(this_node) { + node.each(function(d) { + if (this_node != d) { + d.fx = d.x; + d.fy = d.y; + } + }); +} + +/** +* applies the transformation (zooming or dragging) to the g element +*/ +function handle_zoom() { + d3.select('g').attr("transform", d3.event.transform); + var new_xScale = d3.event.transform.rescaleX(xscale) + gX.call(xAxis.scale(new_xScale)); +} + +/** +* transforms svg so that the zoom is adapted to the size of the graph +*/ +function zoom_to() { + node_bounds = d3.selectAll("svg.graph").node().getBBox(); + svg_bounds = d3.select("rect").node().getBBox(); + + perc_x = width/(node_bounds.width+100); + perc_y = height/(node_bounds.height+100); + perc = d3.min([perc_x, perc_y]) + + d3.select('svg') + .call(zoom.scaleBy, perc); +} + +/** +* transforms svg so that the zoom and drag is reset +*/ +function reset_view() { + d3.select('svg') + .call(zoom.scaleTo, 1) + d3.select('svg') + .call(zoom.translateTo, 0.5 * width, 0.5 * height); + d3.select('svg') + .call(zoom.scaleBy, perc); +} + +/** +* save svg as png +*/ +function save_svg(){ + var svgString = get_svg_string(svg.node()); + svg_string_to_image(svgString, 2*width, 2*height, 'png', save); // passes Blob and filesize String to the callback + + function save( dataBlob, filesize ){ + saveAs(dataBlob, 'D3 vis exported to PNG.png'); // FileSaver.js function + } +}; + +/** +* generate svgString +* @param {object} svgNode - node +*/ +function get_svg_string(svgNode) { + svgNode.setAttribute('xlink', 'http://www.w3.org/1999/xlink'); + var cssStyleText = get_css_styles(svgNode); + append_css(cssStyleText, svgNode); + + var serializer = new XMLSerializer(); + var svgString = serializer.serializeToString(svgNode); + svgString = svgString.replace(/(\w+)?:?xlink=/g, 'xmlns:xlink='); // Fix root xlink without namespace + svgString = svgString.replace(/NS\d+:href/g, 'xlink:href'); // Safari NS namespace fix + + return svgString; + + function get_css_styles(parentElement) { + var selectorTextArr = []; + + // Add Parent element Id and Classes to the list + selectorTextArr.push('#' + parentElement.id); + for (var c = 0; c < parentElement.classList.length; c++) + if (!contains('.'+parentElement.classList[c], selectorTextArr)) + selectorTextArr.push('.'+parentElement.classList[c]); + + // Add Children element Ids and Classes to the list + var nodes = parentElement.getElementsByTagName("*"); + for (var i = 0; i < nodes.length; i++) { + var id = nodes[i].id; + if (!contains('#'+id, selectorTextArr)) + selectorTextArr.push('#' + id); + + var classes = nodes[i].classList; + for (var c = 0; c < classes.length; c++) + if (!contains('.'+classes[c], selectorTextArr)) + selectorTextArr.push('.'+classes[c]); + } + + // Extract CSS Rules + var extractedCSSText = ""; + for (var i = 0; i < document.styleSheets.length; i++) { + var s = document.styleSheets[i]; + + try { + if(!s.cssRules) continue; + } catch(e) { + if(e.name !== 'SecurityError') throw e; // for Firefox + continue; + } + + var cssRules = s.cssRules; + for (var r = 0; r < cssRules.length; r++) { + if (contains(cssRules[r].selectorText, selectorTextArr)) + extractedCSSText += cssRules[r].cssText; + } + } + + + return extractedCSSText; + + function contains(str,arr) { + return arr.indexOf(str) === -1 ? false : true; + } + + } + + function append_css(cssText, element) { + var styleElement = document.createElement("style"); + styleElement.setAttribute("type","text/css"); + styleElement.innerHTML = cssText; + var refNode = element.hasChildNodes() ? element.children[0] : null; + element.insertBefore(styleElement, refNode); + } +} + +/** +* convert svgString to image and export it +* @param {object} svgString - svgString +* @param {object} width - width of image +* @param {object} height - height of image +* @param {object} format - format to save image in +* @param {object} callback - callback function +*/ +function svg_string_to_image( svgString, width, height, format, callback ) { + var format = format ? format : 'png'; + + var imgsrc = 'data:image/svg+xml;base64,'+ btoa(unescape(encodeURIComponent(svgString))); // Convert SVG string to data URL + + var canvas = document.createElement("canvas"); + var context = canvas.getContext("2d"); + + canvas.width = width; + canvas.height = height; + + var image = new Image(); + image.onload = function() { + context.clearRect(0, 0, width, height); + context.drawImage(image, 0, 0, width, height); + + canvas.toBlob(function(blob) { + var filesize = Math.round(blob.length/1024) + ' KB'; + if (callback) callback(blob, filesize); + }); + + }; + + image.src = imgsrc; +} + diff --git a/assets/index.html b/assets/index.html index 78560da48c01f39debc7a810b58a60672c0995dc..374abe283271574e67bd8d73e3691ef35b9e782d 100644 --- a/assets/index.html +++ b/assets/index.html @@ -18,6 +18,12 @@ border:1px solid #909090; } + button.display{ + width: 120px; + top: 0px; + margin-left: 100px; + } + .button:hover { background-color: #CACACA; } @@ -78,14 +84,17 @@ </head> <body> + <button id="change_graph" class="display" onclick="display()">display timeline</button> + <!-- graph --> <svg class="graph" width="960" height="560"></svg> + <p id="oldjson"></p> <!-- legend --> - <div class="legendbox"> <svg class="legendsvg"></svg></div> + <div class="legendbox"><svg class="legendsvg"></svg></div> <!-- textbox --> - <div class="textbox" id = "textbox">Click node</div> + <div class="textbox" id="textbox">Click node</div> <button id="overview" class="overview" onclick='display_abstract(false), highlight_button("overview")'>Overview</button> <button id="abstract" class="abstract" onclick='display_abstract(true), highlight_button("abstract")'>Abstract</button> @@ -100,8 +109,64 @@ <!-- scripts to save svg element as png --> <script src="https://cdn.rawgit.com/eligrey/canvas-toBlob.js/f1a01896135ab378aa5c0118eadd81da55e698d8/canvas-toBlob.js"></script> <script src="https://cdn.rawgit.com/eligrey/FileSaver.js/e9d941381475b5df8b7d7691013401e171014e89/FileSaver.min.js"></script> + + <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/core.min.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/md5.js"></script> - <!-- javascript for force-directed graph --> - <script type="text/javascript" id="cn" src="cn.js"></script> + <script type="text/javascript" > + if(window.location.hash=='#default'){ + document.getElementById("change_graph").innerHTML = 'display timeline'; + load_default(); + + } + else if(window.location.hash=='#time'){ + document.getElementById("change_graph").innerHTML = 'display default'; + load_time(); + + } + else if(window.location.hash==''){ + window.location.hash = 'default'; + document.getElementById("change_graph").innerHTML = 'display timeline'; + load_default(); + } + function display(){ + if(window.location.hash=='#time'){ + display_default(); + } + else if(window.location.hash=='#default'){ + display_time(); + } + } + function display_default(){ + window.location.hash = 'default'; + window.location.reload(); + } + function display_time(){ + window.location.hash = 'time'; + window.location.reload(); + + } + function load_default(){ + var htmlHeader = document.getElementsByTagName("head")[0]; + var myScript = document.createElement('script'); + myScript.type = 'text/javascript'; + myScript.src = 'cn.js'; + myScript.id='abc'; + htmlHeader.appendChild(myScript); + } + function load_time(){ + var htmlHeader = document.getElementsByTagName("head")[0]; + var myScript = document.createElement('script'); + myScript.type = 'text/javascript'; + myScript.src = 'cn2.js'; + myScript.id='abc'; + htmlHeader.appendChild(myScript); + + } + </script> + + <!-- javascript for force-directed graph + <script type="text/javascript" id="cn" src="cn.js"></script> --> + </body> </html> \ No newline at end of file diff --git a/output/graph/cn.js b/output/graph/cn.js index 309678b42520cec11d77cf6a3b4be2925cb8bede..389935df5f1469ec2f152f0adc6995a72302fde7 100644 --- a/output/graph/cn.js +++ b/output/graph/cn.js @@ -17,10 +17,10 @@ perc; * scale functions that return y coordinate/color of node depending on group */ var color = d3.scaleOrdinal() - .domain(["height", "input", "depth"]) + .domain(["Citedby", "Input", "Reference"]) .range([' #01d7c0', ' #8b90fe ', ' #a15eb2 ']), y_scale = d3.scaleOrdinal() - .domain(["height", "input", "depth"]) + .domain(["Citedby", "Input", "Reference"]) .range([0, 200, 400]), to_remove; @@ -48,6 +48,7 @@ var rect = svg.append("rect") /** * creates svg object (legend) and associated attributes +* transform */ var svg_legend = d3.select("svg.legendsvg"), legend_position = [65,95,125], @@ -111,20 +112,20 @@ legend_arrow.append("text") */ var simulation = d3.forceSimulation() .force("link", d3.forceLink().id(function(d) {return d.doi;}).distance(50).strength(function(d) { - if (d.group == "input") {return 0;} + if (d.group == "Input") {return 0;} else {return 5;} })) .force("collide", d3.forceCollide(function(d) { - if (d.group == "input") {return 100;} - else {return 65;} + if (d.group == "Input") {return 70;} + else {return 70;} }).strength(0.5)) .force("charge", d3.forceManyBody().strength(0.001)) .force("center", d3.forceCenter(width/2, height/2+20)) .force("yscale", d3.forceY().strength(function(d) { - if (d.group == "input") {return 1000;} - else {return 50;} + if (d.group == "Input") {return 300;} + else {return 200;} }).y(function(d) {return y_scale(d.group)})) - .alpha(0.005) + .alpha(0.004) .on("end", zoom_to); /** @@ -140,6 +141,18 @@ d3.json("json_text.json").then(function(graph) { update(graph.links, graph.nodes); }) +var intervalId=window.setInterval(function(){ + d3.json("json_text.json").then(function(graph) { + newjson_string=JSON.stringify(graph) + var newjson = CryptoJS.MD5(newjson_string).toString(); + oldjson=localStorage.getItem("oldjson") + if(newjson !== oldjson){ + localStorage.setItem("oldjson", newjson); + window.location.reload() + } + }) +},5000); + /** * calls update functions for links and nodes * adds the nodes, links and tick functionality to the simulation @@ -161,7 +174,7 @@ function update(links, nodes) { } /** -* initializes and shows links +* initializes and shows links (edges) * @param {object} links - links */ function update_links(links) { @@ -280,9 +293,9 @@ function self_citation(source,target) { function mark_link(node) { d3.selectAll(".link") .style("stroke", function(o) { - return is_link_for_node(node, o) ? "black" : "#999";}) + return is_link_for_node(node, o) ? "black" : "#DEDEDE";}) .attr('marker-end', function(o) { - return is_link_for_node(node, o) ? update_marker('#000000', o.target) : update_marker('#999', o.target);}) + return is_link_for_node(node, o) ? update_marker('#000000', o.target) : update_marker('#DEDEDE', o.target);}) } /** diff --git a/output/graph/cn2.js b/output/graph/cn2.js new file mode 100644 index 0000000000000000000000000000000000000000..dce918d24e11ba191318915544fd9c8179eb9414 --- /dev/null +++ b/output/graph/cn2.js @@ -0,0 +1,600 @@ +/** +* creates a new zoom behavior +*/ +var zoom = d3.zoom().on("zoom", handle_zoom); + +/** +* creates svg object and associated attributes +* applies the zoom behavior to svg +*/ +var svg = d3.select("svg.graph") + .call(zoom), +width = svg.attr("width"), +height = svg.attr("height"), +perc; + +/** +* scale functions that return y coordinate/color of node depending on group +*/ +var color = d3.scaleOrdinal() + .domain(["Citedby", "Input", "Reference"]) + .range([' #01d7c0', ' #8b90fe ', ' #a15eb2 ']), +y_scale = d3.scaleOrdinal() + .domain(["Citedby", "Input", "Reference"]) + .range([0, 200, 400]), +to_remove; + +/** +* creates node object and (default) radius +*/ +var node, +r = 10; + +/** +* creates link object +*/ +var link; + +/** +* creates a background with a click functionality +*/ +var rect = svg.append("rect") + .attr("x", 0) + .attr("y", 0) + .attr("height", height) + .attr("width", width) + .style("fill", 'white') + .on('click', click_rect); + +/** +* creates svg object (legend) and associated attributes +* transform +* mehr kommentare +*/ +var svg_legend = d3.select("svg.legendsvg"), +legend_position = [65,95,125], +arrow_legend_position = [0,25], +arrow_group_names = ["citation","self-citation"], +group_names = ["cited by","input","reference"], +line_type = d3.scaleOrdinal() + .domain(["line","dotted"]) + .range([("8,0"),("8,8")]), +text_info = '', +text_abstract = ''; + +var legend = svg_legend.selectAll(".legend") + .data(legend_position) + .enter() + .append("g") + .attr("class","legend") + .attr("transform", function(d,i) {return "translate(0," + d + ")"; }); + +legend.append("text") + .attr("x", 80) + .attr("y", 0) + .attr("dy", ".35em") + .style("text-anchor", "start") + .text(function(d,i) {return group_names[i]}); + +legend.append("circle") + .attr("r", r) + .attr("cx",30-r) + .style("fill", color); + +var legend_arrow = svg_legend.selectAll(".legendarr") + .data(arrow_legend_position) + .enter() + .append("g") + .attr("class","legendarr") + .attr("transform", function(d) { return "translate(0," + d + ")"; }); + +legend_arrow.append("line") + .attr("x1", 10) + .attr("x2", 50) + .attr("y1", 10) + .attr("y2", 10) + .style("stroke-dasharray",line_type) + .style("stroke", '#999') + .style("stroke-width", "1px") + .style('pointer-events', 'none') + .attr('marker-end',update_marker('#999',this)); + +legend_arrow.append("text") + .attr("x", 80) + .attr("y", 10) + .attr("dy", ".35em") + .style("text-anchor", "start") + .text(function(d,i){return arrow_group_names[i]}); + +/** +* creates a new simulation +* updates the positions of the links and nodes when the + state of the layout has changed (simulation has advanced by a tick) +*/ + +var simulation = d3.forceSimulation() + .force("link", d3.forceLink().id(function(d) {return d.doi;}).distance(50).strength(function(d) { + if (d.group == "Input") {return 0;} + else {return 5;} + })) + .force("collide", d3.forceCollide(function(d) { + if (d.group == "Input") {return 70;} + else {return 75;} + }).strength(1)) + .force("charge", d3.forceManyBody().strength(0.001)) + .force("center", d3.forceCenter(width/2, height/2+20)) + .alpha(0.004) + .on("end", zoom_to); + +/** +* creates group element +*/ +var g = svg.append("g") + .attr("class", "everything") + +/** +* creates xAxis element +*/ +var xAxis = d3.axisBottom() + .tickFormat(function(d) {return d;}) + .ticks(10);; + +/** +* draw xAxis +*/ +var gX = svg.append("g") + .attr("class", "axis axis--x") + .attr("transform", "translate(0,25)") + gX.append("text") + .attr("y", 0) + .attr("x", 80) + .attr("text-anchor", "end") + .attr("stroke", "black") + .text("year"); + +/** +* loads JSON data and calls the update function +*/ +d3.json("json_text.json").then(function(graph) { + update(graph.links, graph.nodes); +}) + +var intervalId=window.setInterval(function(){ + d3.json("json_text.json").then(function(graph) { + newjson_string=JSON.stringify(graph) + var newjson = CryptoJS.MD5(newjson_string).toString(); + oldjson=localStorage.getItem("oldjson") + if(newjson !== oldjson){ + localStorage.setItem("oldjson", newjson); + window.location.reload() + } + }) +},5000); + +/** +* calls update functions for links and nodes +* adds the nodes, links and tick functionality to the simulation +* @param {object} nodes - nodes +* @param {object} links - links +*/ +function update(links, nodes) { + updateXAxis(nodes); + update_links(links); + update_nodes(nodes); + + simulation + .nodes(nodes) + .on("tick", handle_tick); + simulation.force("link") + .links(links); + + link.attr('marker-end', function(d) {return update_marker("#999", d.target);}) + .style("stroke-dasharray",function(d){return self_citation(d.source,d.target)? ("8,8"): ("1,0")}); +} + +/** +* initializes and shows xAxis +* @param {object} nodes - nodes +*/ +function updateXAxis(nodes) { + years = []; + for (i = 0; i < nodes.length; i++) { + years.push(parseInt((nodes[i]["year"]).split(" ")[2])); + } + + xscale = d3.scaleLinear() + .domain([d3.min(years)-1, d3.max(years)+1]) + .range([50, width-50]) + + xAxis.scale(xscale); + gX.call(xAxis); +} + +/** +* initializes and shows links (edges) +* @param {object} links - links +*/ +function update_links(links) { + link = g.append("g") + .selectAll(".link") + .data(links) + .enter() + .append("line") + .style("stroke-width", "1px") + .style("stroke", "#999") + .attr("class", "link"); +} + +/** +* initializes and shows nodes with circles, texts and a click functionality +* creates a new drag behavior and applies it to the circles +* @param {object} nodes - nodes +*/ +function update_nodes(nodes) { + node = g.selectAll(".node") + .data(nodes) + .enter() + .append("g") + .attr("class", "node") + .call(d3.drag() + .on("start", start_drag) + .on("drag", dragged) + ); + + node.append("circle") + .attr("class", "circle") + .attr("r", function(d) {return 1.5*r+d.citations*0.05}) + .style("fill", function(d){ return color(d.group)}) + .on('click', click_node); + + node.append("text") + .attr("class", "text") + .style("font-size", "15px") + .style('pointer-events', 'auto') + .text(function (d) {const first_author=d.author[0].split(" ") + return first_author[first_author.length-1];}) + .on('click', click_node); +} + +/** +* creates arrowhead and returns its url +* @param {string} color - color of arrowhead +* @param {string} target - target node +*/ +function update_marker(color, target) { + var radius = 1.5*r+target.citations*0.05; + svg.append('defs').append('marker') + .attr('id',color.replace("#", "")+radius) + .attr('viewBox','-0 -5 10 10') + .attr('refX',radius+9.5) + .attr('refY',0) + .attr('orient','auto') + .attr('markerWidth',10) + .attr('markerHeight',15) + .attr('xoverflow','visible') + .append('svg:path') + .attr('d', 'M 0,-5 L 10 ,0 L 0,5') + .attr('fill', color) + .style('stroke','none'); + return "url(" + color + radius + ")"; +}; + +/** +* sets color of circle and its links to black and removes the previous highlights +* displays overview info of node in textbox +* @param {object} node - node +*/ +function click_node(node) { + d3.select(this.parentNode).raise(); + fix_nodes(node); + if(to_remove){ + d3.select(to_remove).selectAll(".circle").style("stroke","none") + } + to_remove = this.parentNode; + d3.select(this.parentNode).selectAll(".circle").style("stroke","black") + mark_link(node) + textbox_content(node) + reset_button_highlight() + highlight_button("overview") +} + +/** +* removes the highlights of the circles and their links +*/ +function click_rect() { + fix_nodes(node); + d3.selectAll(".circle").style("stroke", "none") + d3.selectAll(".link") + .style("stroke", "#999") + .attr('marker-end', function(d) {return update_marker('#999', d.target);}) + text_abstract=''; + text_info=''; + reset_button_highlight() + document.getElementById('textbox').innerHTML = "Click node"; +} + +/** +* returns true if journals have a common author (self-citation) +* @param {object} source - node +* @param {object} target - node +*/ +function self_citation(source,target) { + return source.author.some(item=>target.author.includes(item)) +} + +/** +* sets color of link (line and arrowhead) to black if it is directly connected to node +* and to grey otherwise +* @param {object} node - node +*/ +function mark_link(node) { + d3.selectAll(".link") + .style("stroke", function(o) { + return is_link_for_node(node, o) ? "black" : "#DEDEDE";}) + .attr('marker-end', function(o) { + return is_link_for_node(node, o) ? update_marker('#000000', o.target) : update_marker("#DEDEDE", o.target);}) +} + +/** +* returns true if link is directly connected to node and false if it is not +* @param {object} node - node +* @param {object} link - link +*/ +function is_link_for_node(node, link) { + return link.source.index == node.index || link.target.index == node.index; +} + +/** +* saves text for overview and abstract of node +* outputs node info to textbox +* @param {object} node - node +*/ +function textbox_content(node) { + text_info = "Title:" + '</br>' + node.name + + '</br>' +'</br>'+"Author:"+ '</br>' +node.author+'</br>'+'</br>'+"Date:"+'</br>' + +node.year+'</br>'+'</br>'+"Journal:"+'</br>'+node.journal+'</br>'+'</br>'+"doi:" + +'</br>'+'<a href="'+node.doi+ '">'+node.doi+'</a>'+'</br>'+'</br>'+"Citations:" + +'</br>'+node.citations; + text_abstract = node.abstract; + document.getElementById('textbox').innerHTML = text_info; +} + +/** +* sets color of btn to dark gray +* @param {object} btn - button +*/ +function highlight_button(btn) { + reset_button_highlight(); + document.getElementById(btn).style.background = "#CACACA"; +} + +/** +* sets color of all buttons to default light gray +*/ +function reset_button_highlight() { + document.getElementById("overview").style.background = ''; + document.getElementById("abstract").style.background = ''; +} + +/** +* displays abstract in textbox if a is true, overview text otherwise +* @param {bool} a- bool +*/ +function display_abstract(a) { + if (text_abstract == '' && text_info == '') { + document.getElementById('textbox').innerHTML="Click node"; + } + else { + if (a == true) { + document.getElementById('textbox').innerHTML = text_abstract; + } + else { + document.getElementById('textbox').innerHTML = text_info; + } + } +} + +/** +* updates the positions of the links and nodes +*/ +function handle_tick() { + link.attr("x1", function (d) {return xscale(parseInt((d.source.year).split(" ")[2]));}) + .attr("y1", function (d) {return d.source.y;}) + .attr("x2", function (d) {return xscale(parseInt((d.target.year).split(" ")[2]));}) + .attr("y2", function (d) {return d.target.y;}); + node.attr("transform", function (d) {return "translate(" + xscale(parseInt((d.year).split(" ")[2])) + ", " + d.y + ")";}); +} + +/** +* initializes the dragging of the node +* @param {object} node - node +*/ +function start_drag(node) { + d3.select(this).raise(); + if (!d3.event.active) + simulation.alphaTarget(0.3).restart() + //node.fx = node.x; + node.fy = node.y; + fix_nodes(node); +} + +/** +* applies the dragging to the node +* @param {object} node - node +*/ +function dragged(node) { + //node.fx = d3.event.x; + node.fy = d3.event.y; + fix_nodes(node); +} + +/** +* fix positions of all nodes except for the current node +* @param {object} this_node - node +*/ +function fix_nodes(this_node) { + node.each(function(d) { + if (this_node != d) { + d.fx = d.x; + d.fy = d.y; + } + }); +} + +/** +* applies the transformation (zooming or dragging) to the g element +*/ +function handle_zoom() { + d3.select('g').attr("transform", d3.event.transform); + var new_xScale = d3.event.transform.rescaleX(xscale) + gX.call(xAxis.scale(new_xScale)); +} + +/** +* transforms svg so that the zoom is adapted to the size of the graph +*/ +function zoom_to() { + node_bounds = d3.selectAll("svg.graph").node().getBBox(); + svg_bounds = d3.select("rect").node().getBBox(); + + perc_x = width/(node_bounds.width+100); + perc_y = height/(node_bounds.height+100); + perc = d3.min([perc_x, perc_y]) + + d3.select('svg') + .call(zoom.scaleBy, perc); +} + +/** +* transforms svg so that the zoom and drag is reset +*/ +function reset_view() { + d3.select('svg') + .call(zoom.scaleTo, 1) + d3.select('svg') + .call(zoom.translateTo, 0.5 * width, 0.5 * height); + d3.select('svg') + .call(zoom.scaleBy, perc); +} + +/** +* save svg as png +*/ +function save_svg(){ + var svgString = get_svg_string(svg.node()); + svg_string_to_image(svgString, 2*width, 2*height, 'png', save); // passes Blob and filesize String to the callback + + function save( dataBlob, filesize ){ + saveAs(dataBlob, 'D3 vis exported to PNG.png'); // FileSaver.js function + } +}; + +/** +* generate svgString +* @param {object} svgNode - node +*/ +function get_svg_string(svgNode) { + svgNode.setAttribute('xlink', 'http://www.w3.org/1999/xlink'); + var cssStyleText = get_css_styles(svgNode); + append_css(cssStyleText, svgNode); + + var serializer = new XMLSerializer(); + var svgString = serializer.serializeToString(svgNode); + svgString = svgString.replace(/(\w+)?:?xlink=/g, 'xmlns:xlink='); // Fix root xlink without namespace + svgString = svgString.replace(/NS\d+:href/g, 'xlink:href'); // Safari NS namespace fix + + return svgString; + + function get_css_styles(parentElement) { + var selectorTextArr = []; + + // Add Parent element Id and Classes to the list + selectorTextArr.push('#' + parentElement.id); + for (var c = 0; c < parentElement.classList.length; c++) + if (!contains('.'+parentElement.classList[c], selectorTextArr)) + selectorTextArr.push('.'+parentElement.classList[c]); + + // Add Children element Ids and Classes to the list + var nodes = parentElement.getElementsByTagName("*"); + for (var i = 0; i < nodes.length; i++) { + var id = nodes[i].id; + if (!contains('#'+id, selectorTextArr)) + selectorTextArr.push('#' + id); + + var classes = nodes[i].classList; + for (var c = 0; c < classes.length; c++) + if (!contains('.'+classes[c], selectorTextArr)) + selectorTextArr.push('.'+classes[c]); + } + + // Extract CSS Rules + var extractedCSSText = ""; + for (var i = 0; i < document.styleSheets.length; i++) { + var s = document.styleSheets[i]; + + try { + if(!s.cssRules) continue; + } catch(e) { + if(e.name !== 'SecurityError') throw e; // for Firefox + continue; + } + + var cssRules = s.cssRules; + for (var r = 0; r < cssRules.length; r++) { + if (contains(cssRules[r].selectorText, selectorTextArr)) + extractedCSSText += cssRules[r].cssText; + } + } + + + return extractedCSSText; + + function contains(str,arr) { + return arr.indexOf(str) === -1 ? false : true; + } + + } + + function append_css(cssText, element) { + var styleElement = document.createElement("style"); + styleElement.setAttribute("type","text/css"); + styleElement.innerHTML = cssText; + var refNode = element.hasChildNodes() ? element.children[0] : null; + element.insertBefore(styleElement, refNode); + } +} + +/** +* convert svgString to image and export it +* @param {object} svgString - svgString +* @param {object} width - width of image +* @param {object} height - height of image +* @param {object} format - format to save image in +* @param {object} callback - callback function +*/ +function svg_string_to_image( svgString, width, height, format, callback ) { + var format = format ? format : 'png'; + + var imgsrc = 'data:image/svg+xml;base64,'+ btoa(unescape(encodeURIComponent(svgString))); // Convert SVG string to data URL + + var canvas = document.createElement("canvas"); + var context = canvas.getContext("2d"); + + canvas.width = width; + canvas.height = height; + + var image = new Image(); + image.onload = function() { + context.clearRect(0, 0, width, height); + context.drawImage(image, 0, 0, width, height); + + canvas.toBlob(function(blob) { + var filesize = Math.round(blob.length/1024) + ' KB'; + if (callback) callback(blob, filesize); + }); + + }; + + image.src = imgsrc; +} + diff --git a/output/graph/index.html b/output/graph/index.html index 78560da48c01f39debc7a810b58a60672c0995dc..374abe283271574e67bd8d73e3691ef35b9e782d 100644 --- a/output/graph/index.html +++ b/output/graph/index.html @@ -18,6 +18,12 @@ border:1px solid #909090; } + button.display{ + width: 120px; + top: 0px; + margin-left: 100px; + } + .button:hover { background-color: #CACACA; } @@ -78,14 +84,17 @@ </head> <body> + <button id="change_graph" class="display" onclick="display()">display timeline</button> + <!-- graph --> <svg class="graph" width="960" height="560"></svg> + <p id="oldjson"></p> <!-- legend --> - <div class="legendbox"> <svg class="legendsvg"></svg></div> + <div class="legendbox"><svg class="legendsvg"></svg></div> <!-- textbox --> - <div class="textbox" id = "textbox">Click node</div> + <div class="textbox" id="textbox">Click node</div> <button id="overview" class="overview" onclick='display_abstract(false), highlight_button("overview")'>Overview</button> <button id="abstract" class="abstract" onclick='display_abstract(true), highlight_button("abstract")'>Abstract</button> @@ -100,8 +109,64 @@ <!-- scripts to save svg element as png --> <script src="https://cdn.rawgit.com/eligrey/canvas-toBlob.js/f1a01896135ab378aa5c0118eadd81da55e698d8/canvas-toBlob.js"></script> <script src="https://cdn.rawgit.com/eligrey/FileSaver.js/e9d941381475b5df8b7d7691013401e171014e89/FileSaver.min.js"></script> + + <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/core.min.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/md5.js"></script> - <!-- javascript for force-directed graph --> - <script type="text/javascript" id="cn" src="cn.js"></script> + <script type="text/javascript" > + if(window.location.hash=='#default'){ + document.getElementById("change_graph").innerHTML = 'display timeline'; + load_default(); + + } + else if(window.location.hash=='#time'){ + document.getElementById("change_graph").innerHTML = 'display default'; + load_time(); + + } + else if(window.location.hash==''){ + window.location.hash = 'default'; + document.getElementById("change_graph").innerHTML = 'display timeline'; + load_default(); + } + function display(){ + if(window.location.hash=='#time'){ + display_default(); + } + else if(window.location.hash=='#default'){ + display_time(); + } + } + function display_default(){ + window.location.hash = 'default'; + window.location.reload(); + } + function display_time(){ + window.location.hash = 'time'; + window.location.reload(); + + } + function load_default(){ + var htmlHeader = document.getElementsByTagName("head")[0]; + var myScript = document.createElement('script'); + myScript.type = 'text/javascript'; + myScript.src = 'cn.js'; + myScript.id='abc'; + htmlHeader.appendChild(myScript); + } + function load_time(){ + var htmlHeader = document.getElementsByTagName("head")[0]; + var myScript = document.createElement('script'); + myScript.type = 'text/javascript'; + myScript.src = 'cn2.js'; + myScript.id='abc'; + htmlHeader.appendChild(myScript); + + } + </script> + + <!-- javascript for force-directed graph + <script type="text/javascript" id="cn" src="cn.js"></script> --> + </body> </html> \ No newline at end of file diff --git a/verarbeitung/construct_new_graph/initialize_graph.py b/verarbeitung/construct_new_graph/initialize_graph.py index 3807842cb6d96275194dfa4f715763abc2d7d738..1368f6ea92e4b030b9a37fdbd7fb5ff2573968b2 100644 --- a/verarbeitung/construct_new_graph/initialize_graph.py +++ b/verarbeitung/construct_new_graph/initialize_graph.py @@ -190,7 +190,5 @@ def init_graph_construction(doi_input_list, search_depth, search_height, test_va del edges gc.collect() - if test_var: - return(new_nodes, new_edges) - else: - return(new_nodes, new_edges, error_doi_list) + + return(new_nodes, new_edges, error_doi_list) diff --git a/verarbeitung/test/construct_graph_unittest.py b/verarbeitung/test/construct_graph_unittest.py index 8af37fa13cc31e10a9f2be6fd0b138d9d88d7eb6..b73dc4cabf196068ed2f35a69ecb437512e97da7 100644 --- a/verarbeitung/test/construct_graph_unittest.py +++ b/verarbeitung/test/construct_graph_unittest.py @@ -14,12 +14,12 @@ class ConstructionTest(unittest.TestCase): def testCycle(self): - nodes, edges = init_graph_construction(['doiz1'],1,1,True,False) + nodes, edges, err_list = init_graph_construction(['doiz1'],1,1,True,False) doi_nodes = keep_only_dois(nodes) self.assertCountEqual(doi_nodes, ['doiz1', 'doiz2']) self.assertCountEqual(edges, [['doiz1', 'doiz2'], ['doiz2', 'doiz1']]) - nodes, edges = init_graph_construction(['doiz1'],2,2,True,False) + nodes, edges, err_list = init_graph_construction(['doiz1'],2,2,True,False) doi_nodes = keep_only_dois(nodes) self.assertCountEqual(doi_nodes, ['doiz1', 'doiz2']) self.assertCountEqual(edges, [['doiz2', 'doiz1'], ['doiz1', 'doiz2']]) @@ -31,56 +31,56 @@ class ConstructionTest(unittest.TestCase): #def testEmptyDepth(self): def testEmptyDepthHeight(self): - nodes, edges = init_graph_construction(['doi1'],0,0,True,False) + nodes, edges, err_list = init_graph_construction(['doi1'],0,0,True,False) doi_nodes = keep_only_dois(nodes) self.assertCountEqual(doi_nodes,['doi1']) self.assertCountEqual(edges, []) - nodes, edges = init_graph_construction(['doi1', 'doi2'],0,0,True,False) + nodes, edges, err_list = init_graph_construction(['doi1', 'doi2'],0,0,True,False) doi_nodes = keep_only_dois(nodes) self.assertCountEqual(doi_nodes, ['doi1','doi2']) self.assertCountEqual(edges, [['doi1', 'doi2']]) - nodes, edges = init_graph_construction(['doi1', 'doi2', 'doi3'],0,0,True,False) + nodes, edges, err_list = init_graph_construction(['doi1', 'doi2', 'doi3'],0,0,True,False) doi_nodes = keep_only_dois(nodes) self.assertCountEqual(doi_nodes, ['doi1','doi2', 'doi3']) self.assertCountEqual(edges, [['doi3', 'doi1'], ['doi1', 'doi2']]) def testInnerEdges(self): - nodes, edges = init_graph_construction(['doi_ie1'],1,1,True,False) + nodes, edges, err_list = init_graph_construction(['doi_ie1'],1,1,True,False) doi_nodes = keep_only_dois(nodes) self.assertCountEqual(doi_nodes,['doi_ie1','doi_ie2','doi_ie3']) self.assertCountEqual(edges,[['doi_ie1','doi_ie2'],['doi_ie3','doi_ie1'],['doi_ie3','doi_ie2']]) def testRightHeight(self): - nodes, edges = init_graph_construction(['doi_h01'],0,1,True,False) + nodes, edges, err_list = init_graph_construction(['doi_h01'],0,1,True,False) doi_nodes = keep_only_dois(nodes) self.assertCountEqual(doi_nodes,['doi_h01']) self.assertCountEqual(edges, []) - nodes, edges = init_graph_construction(['doi_h02'],0,1,True,False) + nodes, edges, err_list = init_graph_construction(['doi_h02'],0,1,True,False) doi_nodes = keep_only_dois(nodes) self.assertCountEqual(doi_nodes,['doi_h02','doi_h1']) self.assertCountEqual(edges, [['doi_h1','doi_h02']]) - nodes, edges = init_graph_construction(['doi_h02'],0,2,True,False) + nodes, edges, err_list = init_graph_construction(['doi_h02'],0,2,True,False) doi_nodes = keep_only_dois(nodes) self.assertCountEqual(doi_nodes,['doi_h02','doi_h1','doi_h2']) self.assertCountEqual(edges, [['doi_h1','doi_h02'], ['doi_h2','doi_h1']]) def testRightDepth(self): - nodes, edges = init_graph_construction(['doi_d01'],1,0,True,False) + nodes, edges, err_list = init_graph_construction(['doi_d01'],1,0,True,False) doi_nodes = keep_only_dois(nodes) self.assertCountEqual(doi_nodes,['doi_d01']) self.assertCountEqual(edges, []) - nodes, edges = init_graph_construction(['doi_d02'],1,0,True,False) + nodes, edges, err_list = init_graph_construction(['doi_d02'],1,0,True,False) doi_nodes = keep_only_dois(nodes) self.assertCountEqual(doi_nodes,['doi_d02','doi_d1']) self.assertCountEqual(edges, [['doi_d02','doi_d1']]) - nodes, edges = init_graph_construction(['doi_d02'],2,0,True,False) + nodes, edges, err_list = init_graph_construction(['doi_d02'],2,0,True,False) doi_nodes = keep_only_dois(nodes) self.assertCountEqual(doi_nodes,['doi_d02','doi_d1','doi_d2']) self.assertCountEqual(edges, [['doi_d02','doi_d1'], ['doi_d1','doi_d2']]) diff --git a/verarbeitung/test/input_test.py b/verarbeitung/test/input_test.py index a701f7e294ccbda42f29973078921a3b330b948b..352f983d057d4e42d6cfb79df91358f6ed7ad2d7 100644 --- a/verarbeitung/test/input_test.py +++ b/verarbeitung/test/input_test.py @@ -100,5 +100,5 @@ list_of_arrays = [beispiel1, beispiel2, beispiel3, zyklus1, zyklus2, inner_ed right_height01, right_height02, right_height1, right_height2, right_height3, right_depth01, right_depth02, right_depth1, right_depth2, right_depth3, large_graph_1_h21, large_graph_1_h22, large_graph_1_h23, large_graph_1_h11, large_graph_1_h12, large_graph_1_i, large_graph_1_d11, large_graph_1_d12, large_graph_1_d21, large_graph_1_d22, large_graph_1_d23, large_graph_2_h21, large_graph_2_h22, large_graph_2_h23, large_graph_2_h24, large_graph_2_h11, large_graph_2_h12, - large_graph_2_i, large_graph_2_d11, large_graph_2_d12, large_graph_2_d21, large_graph_2_d22, large_graph_2_d23, crossed_graph_h21, crossed_graph_h22, crossed_graph_h11, + large_graph_2_i, large_graph_2_d11, large_graph_2_d12, large_graph_2_d21, large_graph_2_d22, large_graph_2_d23, large_graph_2_d24, crossed_graph_h21, crossed_graph_h22, crossed_graph_h11, crossed_graph_i, crossed_graph_d11, crossed_graph_d12, crossed_graph_d21, crossed_graph_d22] diff --git a/verarbeitung/test/update_graph_unittest.py b/verarbeitung/test/update_graph_unittest.py index 59de002b8d4efdb87f0d57d80bc1f6f6d7889b49..77746ffeb0ee3aa5375020a4cf8d5aa218520821 100644 --- a/verarbeitung/test/update_graph_unittest.py +++ b/verarbeitung/test/update_graph_unittest.py @@ -3,6 +3,7 @@ import unittest import sys from pathlib import Path + sys.path.append("../") from verarbeitung.construct_new_graph.initialize_graph import init_graph_construction @@ -10,46 +11,77 @@ from verarbeitung.construct_new_graph.export_to_json import output_to_json from verarbeitung.update_graph.import_from_json import input_from_json from verarbeitung.update_graph.update_graph import update_graph, get_old_input_dois, get_new_input_dois from verarbeitung.update_graph.update_depth import reduce_max_height_depth_test, get_old_max_references_citations_test +from verarbeitung.update_graph.update_edges import back_to_valid_edges +from verarbeitung.update_graph.delete_nodes_edges import search_ref_cit_graph_rec_test +from verarbeitung.update_graph.compare_old_and_new_node_lists import compare_old_and_new_node_lists +from verarbeitung.update_graph.connect_new_input import find_furthermost_citations_test, complete_changed_group_nodes_test from verarbeitung.get_pub_from_input import input_test_func class UpdatingTest(unittest.TestCase): maxDiff = None - def test_import_from_json(self): - nodes_old, edges_old = init_graph_construction(['doi_lg_1_i'],2,2,True) - output_to_json(nodes_old, edges_old, test_var = True) - nodes_new, edges_new = input_from_json('test_output.json') - self.assertCountEqual(nodes_old,nodes_new) - self.assertCountEqual(edges_old, edges_new) - def test_deleted_input_dois(self): - nodes_old_single, edges_old_single = init_graph_construction(['doi_lg_1_i'],2,2,True) - nodes_old_both, edges_old_both = init_graph_construction(['doi_lg_1_i','doi_lg_2_i'],2,2,True) + nodes_old_single, edges_old_single, err_list = init_graph_construction(['doi_lg_1_i'],2,2,True) + nodes_old_both, edges_old_both, err_list = init_graph_construction(['doi_lg_1_i','doi_lg_2_i'],2,2,True) output_to_json(nodes_old_both, edges_old_both, test_var=True) - nodes_new_single, edges_new_single = update_graph(['doi_lg_1_i'], 'test_output.json', 2, 2, True) + nodes_new_single, edges_new_single, err_list = update_graph(['doi_lg_1_i'], 'test_output.json', 2, 2, True) self.assertCountEqual(nodes_old_single,nodes_new_single) self.assertCountEqual(edges_old_single, edges_new_single) - nodes_old_single, edges_old_single = init_graph_construction(['doi_cg_i'],3,3,True) - nodes_old_two, edges_old_two = init_graph_construction(['doi_lg_1_i','doi_cg_i'],3,3,True) - nodes_old_three, edges_old_three = init_graph_construction(['doi_lg_1_i','doi_lg_2_i','doi_cg_i'],3,3,True) + nodes_old_single, edges_old_single, err_list = init_graph_construction(['doi_cg_i'],3,3,True) + nodes_old_two, edges_old_two, err_list = init_graph_construction(['doi_lg_1_i','doi_cg_i'],3,3,True) + nodes_old_three, edges_old_three, err_list = init_graph_construction(['doi_lg_1_i','doi_lg_2_i','doi_cg_i'],3,3,True) def test_new_height(self): - nodes_height_0, edges_height_0 = init_graph_construction(['doi_lg_1_i'],2,0,True) - nodes_height_1, edges_height_1 = init_graph_construction(['doi_lg_1_i'],2,1,True) - nodes_height_2, edges_height_2 = init_graph_construction(['doi_lg_1_i'],2,2,True) + nodes_height_0, edges_height_0, err_list = init_graph_construction(['doi_lg_1_i'],2,0,True) + nodes_height_1, edges_height_1, err_list = init_graph_construction(['doi_lg_1_i'],2,1,True) + nodes_height_2, edges_height_2, err_list = init_graph_construction(['doi_lg_1_i'],2,2,True) output_to_json(nodes_height_2, edges_height_2, 'new_height.json', True) - nodes_new_height_1, edges_new_height_1 = update_graph(['doi_lg_1_i'], 'new_height.json', 2, 1, True) + nodes_new_height_1, edges_new_height_1, err_list = update_graph(['doi_lg_1_i'], 'new_height.json', 2, 1, True) self.assertCountEqual(nodes_height_1, nodes_new_height_1) self.assertCountEqual(edges_height_1, edges_new_height_1) - nodes_height_2, edges_height_2 = init_graph_construction(['doi_lg_1_i'],2,2,True) + nodes_height_2, edges_height_2, err_list = init_graph_construction(['doi_lg_1_i'],2,2,True) output_to_json(nodes_height_2, edges_height_2, 'new_height.json', True) - nodes_new_height_0, edges_new_height_0 = update_graph(['doi_lg_1_i'], 'new_height.json', 2, 0, True) + nodes_new_height_0, edges_new_height_0, err_list = update_graph(['doi_lg_1_i'], 'new_height.json', 2, 0, True) self.assertCountEqual(nodes_height_0, nodes_new_height_0) self.assertCountEqual(edges_height_0, edges_new_height_0) + def test_ref_to_input(self): + nodes, edges, err_list = init_graph_construction(['doi_cg_i'], 2, 2, True) + nodes_2, edges_2, err_list_2 = init_graph_construction(['doi_cg_d11'], 2, 2, True) + output_to_json(nodes, edges, 'ref_to_input.json') + new_nodes, new_edges, new_err_list = update_graph(['doi_cg_d11'], 'ref_to_input.json', 2, 2, True) + self.assertCountEqual(new_nodes, nodes_2) + self.assertCountEqual(new_edges, edges_2) + + nodes, edges, err_list = init_graph_construction(['doi_cg_i','doi_lg_2_i'], 2, 2, True) + nodes_2, edges_2, err_list_2 = init_graph_construction(['doi_cg_d11','doi_lg_2_i'], 2, 2, True) + + output_to_json(nodes, edges, 'ref_to_input.json') + new_nodes, new_edges, new_err_list = update_graph(['doi_cg_d11','doi_lg_2_i'], 'ref_to_input.json', 2, 2, True) + self.assertCountEqual(new_nodes, nodes_2) + self.assertCountEqual(new_edges, edges_2) + + output_to_json(nodes_2, edges_2, 'ref_to_input.json') + new_nodes, new_edges, new_err_list = update_graph(['doi_cg_d11','doi_lg_2_i'], 'ref_to_input.json', 2, 2, True) + self.assertCountEqual(new_nodes, nodes_2) + self.assertCountEqual(new_edges, edges_2) + + nodes, edges, err_list = init_graph_construction(['doi_cg_i','doi_lg_2_i'], 2, 2, True) + nodes_2, edges_2, err_list_2 = init_graph_construction(['doi_cg_i','doi_lg_2_h11','doi_lg_1_i'], 3, 3, True) + + output_to_json(nodes_2, edges_2, 'ref_to_input.json') + new_nodes, new_edges, new_err_list = update_graph(['doi_cg_i','doi_lg_2_i'], 'ref_to_input.json', 2, 2, True) + self.assertCountEqual(new_nodes, nodes) + self.assertCountEqual(new_edges, edges) + + + + + + ## Ab hier die Tests für die einzelnen Funktionen ## # update_graph.py: @@ -135,13 +167,215 @@ class UpdatingTest(unittest.TestCase): pub_lg_2_d_21.group = -2 pubs = [pub_lg_2_i, pub_lg_2_h_11, pub_lg_2_h_21, pub_lg_2_h_22,pub_lg_2_d_11, pub_lg_2_d_21] self.assertCountEqual(get_old_max_references_citations_test(pubs, 2, "Height"), [pub_lg_2_h_21,pub_lg_2_h_22]) - + # import_from_json.py: + + def test_input_from_json(self): + nodes_old, edges_old, err_list = init_graph_construction(['doi_lg_1_i'],2,2,True) + output_to_json(nodes_old, edges_old, test_var = True) + nodes_new, edges_new = input_from_json('test_output.json') + self.assertCountEqual(nodes_old,nodes_new) + self.assertCountEqual(edges_old, edges_new) + # update_edges.py: + def test_back_to_valid_edges(self): + pub_lg_2_i = input_test_func('doi_lg_2_i') + pub_lg_2_i.group = 0 + pub_lg_2_h_11 = input_test_func('doi_lg_2_h11') + pub_lg_2_h_11.group = 1 + pub_lg_2_d_11 = input_test_func('doi_lg_2_d11') + pub_lg_2_d_11.group = -1 + pubs = [pub_lg_2_i, pub_lg_2_h_11, pub_lg_2_d_11] + edges = [['doi_lg_2_h11','doi_lg_2_i'],['doi_lg_2_i','doi_lg_2_d11'],['doi_lg_2_h21','doi_lg_2_h11'],['doi_lg_2_i','doi_lg_2_d21']] + back_to_valid_edges(edges, pubs) + self.assertCountEqual([['doi_lg_2_h11','doi_lg_2_i'],['doi_lg_2_i','doi_lg_2_d11']],edges) + # delete_nodes_edges.py: + + def test_search_ref_graph_rec(self): + pub_lg_2_i = input_test_func('doi_lg_2_i') + pub_lg_2_i.group = 0 + pub_lg_2_h11 = input_test_func('doi_lg_2_h11') + pub_lg_2_h11.group = 1 + pub_lg_2_h12 = input_test_func('doi_lg_2_h12') + pub_lg_2_h12.group = 1 + pub_lg_2_d11 = input_test_func('doi_lg_2_d11') + pub_lg_2_d11.group = -1 + pub_lg_2_d12 = input_test_func('doi_lg_2_d12') + pub_lg_2_d12.group = -1 + pub_lg_2_h21 = input_test_func('doi_lg_2_h21') + pub_lg_2_h21.group = 2 + pub_lg_2_h22 = input_test_func('doi_lg_2_h22') + pub_lg_2_h22.group = 2 + pub_lg_2_d21 = input_test_func('doi_lg_2_d21') + pub_lg_2_d21.group = -2 + + pub_cg_i = input_test_func('doi_cg_i') + pub_cg_i.group = 0 + pub_cg_h11 = input_test_func('doi_cg_h11') + pub_cg_h11.group = 1 + pub_cg_d12 = input_test_func('doi_cg_d11') + pub_cg_d12.group = -1 + pub_cg_d11 = input_test_func('doi_cg_d12') + pub_cg_d11.group = -1 + pubs = [pub_lg_2_i, pub_lg_2_h11, pub_lg_2_h12, pub_lg_2_d11, pub_lg_2_d12, pub_lg_2_h21, pub_lg_2_h22, pub_lg_2_d21, pub_cg_i, pub_cg_d11, pub_cg_d12, pub_cg_h11] + usable_nodes = search_ref_cit_graph_rec_test(pubs, [pub_cg_i], "Citation") + self.assertCountEqual(usable_nodes, [pub_cg_h11, pub_lg_2_h11, pub_lg_2_h21, pub_lg_2_h22]) + + # compare_old_and_new_node_lists.py: + + def test_compare_old_and_new_nodes(self): + old_input = ['doi_lg_1_i', 'doi_lg_2_i'] + new_input = ['doi_lg_1_i', 'doi_cg_i'] + common_nodes, inserted_nodes, deleted_nodes = compare_old_and_new_node_lists(old_input, new_input) + self.assertCountEqual(common_nodes, ['doi_lg_1_i']) + self.assertCountEqual(inserted_nodes, ['doi_cg_i']) + self.assertCountEqual(deleted_nodes, ['doi_lg_2_i']) + + + # connect_new_input.py: + + def test_find_furthermost_citations(self): + pub_lg_2_i = input_test_func('doi_lg_2_i') + pub_lg_2_i.group = 0 + pub_lg_2_h11 = input_test_func('doi_lg_2_h11') + pub_lg_2_h11.group = 1 + pub_lg_2_h12 = input_test_func('doi_lg_2_h12') + pub_lg_2_h12.group = 1 + pub_lg_2_d11 = input_test_func('doi_lg_2_d11') + pub_lg_2_d11.group = -1 + pub_lg_2_d12 = input_test_func('doi_lg_2_d12') + pub_lg_2_d12.group = -1 + pub_lg_2_h21 = input_test_func('doi_lg_2_h21') + pub_lg_2_h21.group = 2 + pub_lg_2_h22 = input_test_func('doi_lg_2_h22') + pub_lg_2_h22.group = 2 + pub_lg_2_d21 = input_test_func('doi_lg_2_d21') + pub_lg_2_d21.group = -2 + pub_lg_2_d22 = input_test_func('doi_lg_2_d22') + pub_lg_2_d22.group = -2 + pubs = [pub_lg_2_i, pub_lg_2_h11, pub_lg_2_h12, pub_lg_2_d11, pub_lg_2_d12, pub_lg_2_h21, pub_lg_2_h22, pub_lg_2_d21, pub_lg_2_d22] + self.assertCountEqual(find_furthermost_citations_test(pubs, [], pub_lg_2_h11, 2, "Citation"),[pub_lg_2_h21, pub_lg_2_h22]) + self.assertCountEqual(find_furthermost_citations_test(pubs, [], pub_lg_2_h11, 1, "Citation"),[pub_lg_2_h11]) + + self.assertCountEqual(find_furthermost_citations_test(pubs, [], pub_lg_2_d11, 2, "Reference"),[pub_lg_2_d21, pub_lg_2_i]) + self.assertCountEqual(find_furthermost_citations_test(pubs, [], pub_lg_2_d11, 1, "Reference"),[pub_lg_2_d11]) + + + def test_complete_changed_group_nodes(self): + pub_cg_i = input_test_func('doi_cg_i') + pub_cg_i.group = 0 + pub_cg_h11 = input_test_func('doi_cg_h11') + pub_cg_h11.group = 1 + pub_cg_h21 = input_test_func('doi_cg_h21') + pub_cg_h21.group = 2 + pub_cg_h22 = input_test_func('doi_cg_h22') + pub_cg_h22.group = 2 + pub_cg_d11 = input_test_func('doi_cg_d11') + pub_cg_d11.group = -1 + pub_cg_d12 = input_test_func('doi_cg_d12') + pub_cg_d12.group = -1 + pub_cg_d21 = input_test_func('doi_cg_d21') + pub_cg_d21.group = -2 + pub_cg_d22 = input_test_func('doi_cg_d22') + pub_cg_d22.group = -2 + + pub_lg_1_h23 = input_test_func('doi_lg_1_h23') + pub_lg_1_h23.group = 2 + pub_lg_1_d23 = input_test_func('doi_lg_1_d23') + pub_lg_1_d23.group = -2 + + pub_lg_2_i = input_test_func('doi_lg_2_i') + pub_lg_2_i.group = 0 + pub_lg_2_h11 = input_test_func('doi_lg_2_h11') + pub_lg_2_h11.group = 1 + pub_lg_2_h21 = input_test_func('doi_lg_2_h21') + pub_lg_2_h21.group = 2 + pub_lg_2_h22 = input_test_func('doi_lg_2_h22') + pub_lg_2_h22.group = 2 + pub_lg_2_d11 = input_test_func('doi_lg_2_d11') + pub_lg_2_d11.group = -1 + pub_lg_2_d12 = input_test_func('doi_lg_2_d12') + pub_lg_2_d12.group = -1 + pub_lg_2_d21 = input_test_func('doi_lg_2_d21') + pub_lg_2_d21.group = -2 + pub_lg_2_d22 = input_test_func('doi_lg_2_d22') + pub_lg_2_d22.group = -2 + pub_lg_2_d23 = input_test_func('doi_lg_2_d23') + pub_lg_2_d23.group = -2 + pub_lg_2_d24 = input_test_func('doi_lg_2_d24') + pub_lg_2_d24.group = -2 + + + moved_1_pub_cg_i = input_test_func('doi_cg_i') + moved_1_pub_cg_i.group = 1 + moved_1_pub_cg_h11 = input_test_func('doi_cg_h11') + moved_1_pub_cg_h11.group = 2 + moved_1_pub_cg_h21 = input_test_func('doi_cg_h21') + moved_1_pub_cg_h21.group = 3 + moved_1_pub_cg_h22 = input_test_func('doi_cg_h22') + moved_1_pub_cg_h22.group = 3 + moved_1_pub_cg_d11 = input_test_func('doi_cg_d11') + moved_1_pub_cg_d11.group = 0 + + moved_1_pub_cg_d21 = input_test_func('doi_cg_d21') + moved_1_pub_cg_d21.group = -1 + + moved_1_pub_lg_1_h23 = input_test_func('doi_lg_1_h23') + moved_1_pub_lg_1_h23.group = 2 + moved_1_pub_lg_1_d23 = input_test_func('doi_lg_1_d23') + moved_1_pub_lg_1_d23.group = -1 + + moved_1_pub_lg_2_h11 = input_test_func('doi_lg_2_h11') + moved_1_pub_lg_2_h11.group = 1 + + + moved_2_pub_cg_i = input_test_func('doi_cg_i') + moved_2_pub_cg_i.group = -1 + moved_2_pub_cg_d11 = input_test_func('doi_cg_d11') + moved_2_pub_cg_d11.group = -2 + moved_2_pub_cg_d12 = input_test_func('doi_cg_d12') + moved_2_pub_cg_d12.group = -2 + moved_2_pub_cg_d21 = input_test_func('doi_cg_d21') + moved_2_pub_cg_d21.group = -3 + moved_2_pub_cg_d22 = input_test_func('doi_cg_d22') + moved_2_pub_cg_d22.group = -3 + + moved_2_pub_lg_1_d23 = input_test_func('doi_lg_1_d23') + moved_2_pub_lg_1_d23.group = -3 + + moved_2_pub_lg_2_h21 = input_test_func('doi_lg_2_h21') + moved_2_pub_lg_2_h21.group = 1 + moved_2_pub_lg_2_h22 = input_test_func('doi_lg_2_h22') + moved_2_pub_lg_2_h22.group = 1 + moved_2_pub_lg_2_h11 = input_test_func('doi_lg_2_h11') + moved_2_pub_lg_2_h11.group = 0 + moved_2_pub_lg_2_i = input_test_func('doi_lg_2_i') + moved_2_pub_lg_2_i.group = -2 + moved_2_pub_lg_2_d11 = input_test_func('doi_lg_2_d11') + moved_2_pub_lg_2_d11.group = -2 + moved_2_pub_lg_2_d12 = input_test_func('doi_lg_2_d12') + moved_2_pub_lg_2_d12.group = -2 + moved_2_pub_lg_2_d21 = input_test_func('doi_lg_2_d21') + moved_2_pub_lg_2_d21.group = -3 + moved_2_pub_lg_2_d22 = input_test_func('doi_lg_2_d22') + moved_2_pub_lg_2_d22.group = -3 + moved_2_pub_lg_2_d23 = input_test_func('doi_lg_2_d23') + moved_2_pub_lg_2_d23.group = -3 + moved_2_pub_lg_2_d24 = input_test_func('doi_lg_2_d24') + moved_2_pub_lg_2_d24.group = -3 + + pubs = [pub_cg_i, pub_cg_h11, pub_cg_h21, pub_cg_h22, pub_cg_d11, pub_cg_d12, pub_cg_d21, pub_cg_d22, pub_lg_1_h23, pub_lg_1_d23, pub_lg_2_h21, pub_lg_2_h22, pub_lg_2_h11, pub_lg_2_i, pub_lg_2_d11, pub_lg_2_d12, pub_lg_2_d21, pub_lg_2_d22, pub_lg_2_d23, pub_lg_2_d24] + edges = [] + nodes, edges, handled_nodes = complete_changed_group_nodes_test(pubs, edges, 'doi_cg_d11', 2, 2, 2, 2) + self.assertCountEqual(nodes, [moved_1_pub_cg_d11, moved_1_pub_cg_d21, moved_1_pub_lg_1_d23, moved_1_pub_cg_i, moved_1_pub_lg_1_h23, moved_1_pub_cg_h11, moved_1_pub_lg_2_h11]) + self.assertCountEqual(edges, [['doi_cg_d11','doi_lg_1_d23'],['doi_cg_d11','doi_cg_d21'],['doi_cg_i','doi_cg_d11'],['doi_lg_1_h23','doi_cg_i'],['doi_cg_h11','doi_cg_i'],['doi_lg_2_h11','doi_cg_i']]) + nodes, edges, handled_nodes = complete_changed_group_nodes_test(pubs, edges, 'doi_lg_2_h11', 2, 2, 3, 3) + self.assertCountEqual(nodes, [moved_2_pub_cg_i, moved_2_pub_cg_d11, moved_2_pub_lg_1_d23, moved_2_pub_cg_d21, moved_2_pub_cg_d12, moved_2_pub_cg_d22, moved_2_pub_lg_2_h21, moved_2_pub_lg_2_h22, moved_2_pub_lg_2_h11, moved_2_pub_lg_2_i, moved_2_pub_lg_2_d11, moved_2_pub_lg_2_d21, moved_2_pub_lg_2_d12, moved_2_pub_lg_2_d22, moved_2_pub_lg_2_d23, moved_2_pub_lg_2_d24]) + self.assertCountEqual(edges, [['doi_cg_d11','doi_lg_1_d23'],['doi_cg_d11','doi_cg_d21'],['doi_cg_i','doi_cg_d11'],['doi_cg_i','doi_cg_d12'],['doi_cg_d12','doi_cg_d22'],['doi_lg_2_h11','doi_cg_i'],['doi_cg_i','doi_lg_2_i'],['doi_lg_2_h21','doi_lg_2_h11'],['doi_lg_2_h22','doi_lg_2_h11'],['doi_lg_2_h11','doi_lg_2_i'],['doi_lg_2_i','doi_lg_2_d11'],['doi_lg_2_d11','doi_lg_2_i'],['doi_lg_2_d11','doi_lg_2_d21'],['doi_lg_2_i','doi_lg_2_d12'],['doi_lg_2_d12','doi_lg_2_d22'],['doi_lg_2_d12','doi_lg_2_d23'],['doi_lg_2_d12','doi_lg_2_d24']]) def keep_only_dois(nodes): diff --git a/verarbeitung/update_graph/connect_new_input.py b/verarbeitung/update_graph/connect_new_input.py index 5acb05f81f34277231d8b3447d0b89cc34b2f11e..af7363a29fa1bac6bf2fba3dbf3de0d50e64196d 100644 --- a/verarbeitung/update_graph/connect_new_input.py +++ b/verarbeitung/update_graph/connect_new_input.py @@ -23,8 +23,31 @@ from verarbeitung.construct_new_graph.initialize_graph import init_graph_constru from verarbeitung.construct_new_graph.add_citations_rec import add_citations, get_cit_type_list, create_global_lists_cit -def find_furthermost_citations(node, old_search_depth, cit_type): +def find_furthermost_citations_test(test_nodes, test_edges, changed_node, old_search_depth, cit_type): + global nodes, edges + nodes = test_nodes + edges = test_edges + + return(find_furthermost_citations(nodes, edges, changed_node, old_search_depth, cit_type)) + +def complete_changed_group_nodes_test(test_nodes, test_edges, inserted_test_nodes, old_search_depth, old_search_height, new_search_depth, new_search_height): + global nodes, edges + nodes = test_nodes + edges = test_edges + + handled_nodes, new_nodes, new_edges = complete_changed_group_nodes(inserted_test_nodes, old_search_depth, old_search_height, new_search_depth, new_search_height, True) + return(new_nodes, new_edges, handled_nodes) + + + +def find_furthermost_citations(new_nodes, new_edges, node, old_search_depth, cit_type): ''' + :param new_nodes: list of nodes which are generated seperately from main node list to avoid recursive problems + :type new_nodes List[Publication] + + :param new_edges: list of edges which are generated seperately from main edge list to avoid recursive problems + :type new_edges: List[List[String,String]] + :param node: node which is known but not from input group :type node: Publication @@ -34,9 +57,11 @@ def find_furthermost_citations(node, old_search_depth, cit_type): :param cit_type: determines whether the function call is for a reference or citation :type cit_type: String - function to find the furthermost citation/reference for given node which is from the same group + function to find the furthermost citation/reference for given node which is from the same group and + adds all found nodes between input node and furthermost citations. + It return a list of furthermost citations. ''' - citations_saved = get_cit_type_list(node, cit_type) + citations_saved = [node] # group of node and old search depth/height determines how often the loop needs to be repeated for depth in range(old_search_depth - abs(node.group)): @@ -47,13 +72,48 @@ def find_furthermost_citations(node, old_search_depth, cit_type): for new_cit in get_cit_type_list(cit_node, cit_type): for new_cit_node in nodes: if new_cit.doi_url == new_cit_node.doi_url: - new_cit_node.group -= node.group - new_citations.append(new_cit_node) + + if cit_type == "Citation": + + # to find a cyclus and not change height + not_in_citations = True + for new_cit_node_citation in new_cit_node.citations: + if (cit_node.doi_url == new_cit_node_citation.doi_url): + not_in_citations = False + break + if (not_in_citations): + new_citations.append(new_cit_node) + + # change height accordingly and add link to edge + new_cit_node.group = node.group + depth + 1 + if [cit_node.doi_url,cit_node.doi_url] not in new_edges: + new_edges.append([new_cit_node.doi_url,cit_node.doi_url]) + + elif cit_type == "Reference": + + # to find a cyclus and not change depth + not_in_citations = True + for new_cit_node_reference in new_cit_node.references: + if (new_cit_node.doi_url == new_cit_node_reference.doi_url): + not_in_citations = False + break + if (not_in_citations): + new_citations.append(new_cit_node) + + # change height accordingly and add link to edge + new_cit_node.group = node.group - depth - 1 + if [cit_node.doi_url, new_cit_node.doi_url] not in new_edges: + new_edges.append([cit_node.doi_url, new_cit_node.doi_url]) + citations_saved = new_citations + for new_citation in new_citations: + if new_citation not in new_nodes: + new_nodes.append(new_citation) # returns the references/citations which needs to be processed to complete contruction return(citations_saved) + def complete_changed_group_nodes(inserted_nodes, old_search_depth, old_search_height, new_search_depth, new_search_height, test_var): ''' :param inserted_nodes: list of nodes which are inserted to new input array @@ -81,28 +141,50 @@ def complete_changed_group_nodes(inserted_nodes, old_search_depth, old_search_he # saves which nodes were handled because they were known before handled_inserted_nodes = [] + new_nodes = [] + new_edges = [] for node in nodes: - + # moves known reference node to input and completes citations and references for this node if (node.group < 0) and (node.doi_url in inserted_nodes): - node_citations = create_global_lists_cit(nodes, edges, node, 1, new_search_height, "Citation", test_var) - add_citations(nodes, edges, node_citations, 1, new_search_height, "Citation", test_var) - old_max_references = find_furthermost_citations(node, old_search_depth, "Reference") - add_citations(nodes, edges, old_max_references, old_search_depth, new_search_depth, "Reference", test_var) node.group = 0 + new_max_citations = find_furthermost_citations(new_nodes, new_edges, node, old_search_height + abs(node.group), "Citation") + add_citations(new_nodes, new_edges, new_max_citations, old_search_height, new_search_height, "Citation", test_var) + + new_nodes, new_edges, error_doi_list_ref = init_graph_construction([node.doi_url], new_search_height, 0, test_var, True, new_nodes, new_edges) + + for err_node in error_doi_list_ref: + if err_node not in error_doi_list: + error_doi_list.append(err_node) + + + old_max_references = find_furthermost_citations(new_nodes, new_edges, node, old_search_depth, "Reference") + add_citations(new_nodes, new_edges, old_max_references, old_search_depth, new_search_depth, "Reference", test_var) handled_inserted_nodes.append(node) # moves known citation node to input and completes citations and references for this node elif (node.group > 0) and (node.doi_url in inserted_nodes): - node_references = create_global_lists_cit(nodes, edges, node, 1, new_search_depth, "Reference", test_var) - add_citations(nodes, edges, node_references, 1, new_search_depth, "Reference", test_var) - old_max_citations = find_furthermost_citations(node, old_search_height, "Citation") - add_citations(nodes, edges, old_max_citations, old_search_height, new_search_height, "Citation", test_var) - node.group = 0 + new_max_references = find_furthermost_citations(new_nodes, new_edges, node, old_search_depth + abs(node.group), "Reference") + add_citations(new_nodes, new_edges, new_max_references, old_search_depth, new_search_depth, "Reference", test_var) + #new_nodes.append(new_max_references) + + new_nodes, new_edges, error_doi_list_ref = init_graph_construction([node.doi_url], new_search_depth, 0, test_var, True, new_nodes, new_edges) + for err_node in error_doi_list_ref: + if err_node not in error_doi_list: + error_doi_list.append(err_node) + + + old_max_citations = find_furthermost_citations(new_nodes, new_edges, node, old_search_height, "Citation") + add_citations(new_nodes, new_edges, old_max_citations, old_search_height, new_search_height, "Citation", test_var) handled_inserted_nodes.append(node) - return(handled_inserted_nodes) + for new_node in new_nodes: + for inserted_node in inserted_nodes: + if new_node.doi_url == inserted_node: + new_node.group = 0 + + return(handled_inserted_nodes, new_nodes, new_edges) def connect_old_and_new_input(input_nodes_list, input_edges_list, inserted_nodes, old_search_depth, old_search_height, new_search_depth, new_search_height, test_var = False): @@ -133,20 +215,21 @@ def connect_old_and_new_input(input_nodes_list, input_edges_list, inserted_nodes completes the references and citations for nodes which were known in non input group ''' - global nodes, edges - nodes = input_nodes_list - edges = input_edges_list + global nodes, edges, error_doi_list + nodes = input_nodes_list.copy() + edges = input_edges_list.copy() + error_doi_list = [] - handled_inserted_nodes = complete_changed_group_nodes(inserted_nodes, old_search_depth, old_search_height, new_search_depth, new_search_height, test_var) + handled_inserted_nodes, new_nodes, new_edges = complete_changed_group_nodes(inserted_nodes, old_search_depth, old_search_height, new_search_depth, new_search_height, test_var) # copy all nodes from inserted_nodes to new node, if node is not in handled_inserted_nodes not_handled_inserted_nodes = [node for node in inserted_nodes if node not in handled_inserted_nodes] - # initializes nodes/edges from input and gets a list with publication objects for citations and references returned - #references_obj_list, citations_obj_list = initialize_nodes_list(not_handled_inserted_nodes, new_search_depth, new_search_height, test_var) - # function calls to begin recursive processing up to max depth/height - #add_citations(nodes, edges, citations_obj_list, 1, new_search_height, "Citation", test_var) - #add_citations(nodes, edges, references_obj_list, 1, new_search_depth, "Reference", test_var) + # function call to begin recursive processing up to max depth/height for unhandled nodes + nodes, edges, error_doi_list_new = init_graph_construction(not_handled_inserted_nodes, new_search_depth, new_search_height, test_var = test_var, update_var = True, input_nodes = new_nodes, input_edges = new_edges) + for err_node in error_doi_list_new: + if err_node not in error_doi_list: + error_doi_list.append(err_node) - nodes, edges, error_doi_list = init_graph_construction(not_handled_inserted_nodes, new_search_depth, new_search_height, test_var = test_var, update_var = True, input_nodes = nodes, input_edges = edges) + return(nodes, edges, error_doi_list) \ No newline at end of file diff --git a/verarbeitung/update_graph/delete_nodes_edges.py b/verarbeitung/update_graph/delete_nodes_edges.py index 6960f3e32655142988cddf1e9f76f9549dbc8498..205c82e0c814a0901a47011f3ee9e826ae31a8ab 100644 --- a/verarbeitung/update_graph/delete_nodes_edges.py +++ b/verarbeitung/update_graph/delete_nodes_edges.py @@ -20,6 +20,21 @@ sys.path.append("../../") from .update_edges import back_to_valid_edges +def search_ref_cit_graph_rec_test(pubs, new_test_input, cit_var): + global usable_nodes, input_obj_list + usable_nodes = [] + input_obj_list = pubs + + if cit_var == "Reference": + for pub in new_test_input: + search_ref_graph_rec(pub) + elif cit_var == "Citation": + for pub in new_test_input: + search_cit_graph_rec(pub) + return usable_nodes + + + def search_ref_graph_rec(pub): ''' :param pub: pub go get appended to usable_nodes diff --git a/verarbeitung/update_graph/update_edges.py b/verarbeitung/update_graph/update_edges.py index fbfa63e604680fab11bd7c50f0efed0c1ba4ae50..1b046a185dc1ae627805bb23e265ecc775f5a67e 100644 --- a/verarbeitung/update_graph/update_edges.py +++ b/verarbeitung/update_graph/update_edges.py @@ -3,9 +3,10 @@ def back_to_valid_edges(links_from_json, processed_input_list): ''' :param links_from_json: list of edges from the old graph - :type links_from_json: list + :type links_from_json: List[List[String,String]] + :param processed_input_list: list pubs still in graph - :type processed_input_list: list + :type processed_input_list: List[Publication] function that deletes edges, if one ore two including nodes are deleted nodes ''' @@ -28,10 +29,4 @@ def back_to_valid_edges(links_from_json, processed_input_list): #removes the edge if less than 2 adjacent nodes found if (found_adj_nodes < 2): - links_from_json.remove(edge) - -#Kanten_Menge_Ganz = [["doi_1","doi_2"],["doi_3","doi_4"],["doi_5","doi_6"]] -#Geloeschte = ["doi_2","doi_1","doi_4"] -#print(back_to_valid_edges(Kanten_Menge_Ganz,Geloeschte)) - -#Im Anschluss muss mit den Hinzugefügten Knoten Processing aufgerufen werden + links_from_json.remove(edge) \ No newline at end of file diff --git a/verarbeitung/update_graph/update_graph.py b/verarbeitung/update_graph/update_graph.py index 2aaf2140dcb6daf69a30f47acfdbd079a6e41374..416be51f890443d9bf9bdb58bf3ccf63645ba37b 100644 --- a/verarbeitung/update_graph/update_graph.py +++ b/verarbeitung/update_graph/update_graph.py @@ -101,16 +101,34 @@ def update_graph(new_doi_input_list, json_file, search_depth, search_height, tes # retrieve which publications are already known, removed, inserted common_nodes, inserted_nodes, deleted_nodes = compare_old_and_new_node_lists(old_doi_input_list, new_doi_input_list) + old_search_depth, old_search_height = update_depth(processed_list, valid_edges, search_depth, search_height, test_var) + + processed_list_copy = processed_list.copy() + valid_edges_copy = valid_edges.copy() + # deletes publications and edges from node_list if publications can no longer be reached if (len(deleted_nodes) > 0): processed_list, valid_edges = delete_nodes_and_edges(processed_list, common_nodes, valid_edges) - old_search_depth, old_search_height = update_depth(processed_list, valid_edges, search_depth, search_height, test_var) - - if (len(inserted_nodes) > 0): - connect_old_and_new_input(processed_list, valid_edges, inserted_nodes, old_search_depth, old_search_height, search_depth, search_height, test_var) - - if test_var: - return(processed_list, valid_edges) - else: - return(processed_list, valid_edges, error_doi_list) + if (len(inserted_nodes) > 0): + inserted_pub_nodes, inserted_edges, error_doi_list_new = connect_old_and_new_input(processed_list_copy, valid_edges_copy, inserted_nodes, old_search_depth, old_search_height, search_depth, search_height, test_var) + for err_node in error_doi_list_new: + if err_node not in error_doi_list: + error_doi_list.append(err_node) + + for inserted_node in inserted_pub_nodes: + not_in_nodes = True + for node in processed_list: + if inserted_node.doi_url == node.doi_url: + processed_list.remove(node) + processed_list.append(inserted_node) + not_in_nodes = False + break + if not_in_nodes: + processed_list.append(inserted_node) + + for inserted_edge in inserted_edges: + if inserted_edge not in valid_edges: + valid_edges.append(inserted_edge) + + return(processed_list, valid_edges, error_doi_list)