From 7303bf77ace906855661bf6f14909a1b0c20fdaa Mon Sep 17 00:00:00 2001 From: cyfml <236510120@qq.com> Date: Sun, 4 Dec 2022 15:32:43 +0100 Subject: [PATCH 1/6] mainly fixed same root and submission problem and did some enhancements --- core/src/main/java/de/jplag/JPlag.java | 9 +- .../java/de/jplag/PreventSameRootName.java | 141 ++++++++++ .../jsonfactory/ComparisonReportWriter.java | 4 +- .../jsonfactory/DirectoryManager.java | 14 +- .../de/jplag/PreventSameRootNameTest.java | 85 ++++++ .../2016/same/A/GSTiling.java | 247 ++++++++++++++++++ .../2016/same/A/Match.java | 52 ++++ .../2016/same/A/Matches.java | 57 ++++ .../2016/same/A/Structure.java | 118 +++++++++ .../2016/same/A/Submission.java | 218 ++++++++++++++++ .../2016/same/A/Table.java | 61 +++++ .../2016/same/A/Token.java | 47 ++++ .../2016/same/A/TokenConstants.java | 8 + .../2016/same/D/Match.java | 54 ++++ .../2016/same/D/Matches.java | 59 +++++ .../2016/same/D/Structure.java | 120 +++++++++ .../2016/same/D/Submission.java | 206 +++++++++++++++ .../2016/same/D/Table.java | 53 ++++ .../2016/same/D/Token.java | 44 ++++ .../2016/same/D/TokenConstants.java | 12 + .../2017/same/A/GSTiling.java | 247 ++++++++++++++++++ .../2017/same/A/Match.java | 52 ++++ .../2017/same/A/Matches.java | 57 ++++ .../2017/same/A/Structure.java | 118 +++++++++ .../2017/same/A/Submission.java | 218 ++++++++++++++++ .../2017/same/A/Table.java | 61 +++++ .../2017/same/A/Token.java | 47 ++++ .../2017/same/A/TokenConstants.java | 8 + .../2017/same/D/Match.java | 54 ++++ .../2017/same/D/Matches.java | 59 +++++ .../2017/same/D/Structure.java | 120 +++++++++ .../2017/same/D/Submission.java | 206 +++++++++++++++ .../2017/same/D/Table.java | 53 ++++ .../2017/same/D/Token.java | 44 ++++ .../2017/same/D/TokenConstants.java | 12 + .../2018/root/B/Table.java | 61 +++++ .../2018/root/B/Token.java | 47 ++++ .../2018/root/B/TokenConstants.java | 8 + .../2018/same/A/GSTiling.java | 247 ++++++++++++++++++ .../2018/same/A/Match.java | 52 ++++ .../2018/same/A/Matches.java | 57 ++++ .../2018/same/A/Structure.java | 118 +++++++++ .../2018/same/A/Submission.java | 218 ++++++++++++++++ .../2018/same/A/Table.java | 61 +++++ .../2018/same/A/Token.java | 47 ++++ .../2018/same/A/TokenConstants.java | 8 + .../2018/same/D/Match.java | 54 ++++ .../2018/same/D/Matches.java | 59 +++++ .../2018/same/D/Structure.java | 120 +++++++++ .../2018/same/D/Submission.java | 206 +++++++++++++++ .../2018/same/D/Table.java | 53 ++++ .../2018/same/D/Token.java | 44 ++++ .../2018/same/D/TokenConstants.java | 12 + .../2019/root/A/GSTiling.java | 247 ++++++++++++++++++ .../2019/root/A/Match.java | 52 ++++ .../2019/root/A/Matches.java | 57 ++++ .../2019/root/A/Structure.java | 118 +++++++++ .../2019/root/A/Submission.java | 218 ++++++++++++++++ .../2019/root/A/Table.java | 61 +++++ .../2019/root/A/Token.java | 47 ++++ .../2019/root/A/TokenConstants.java | 8 + .../2019/root/D/Match.java | 54 ++++ .../2019/root/D/Matches.java | 59 +++++ .../2019/root/D/Structure.java | 120 +++++++++ .../2019/root/D/Submission.java | 206 +++++++++++++++ .../2019/root/D/Table.java | 53 ++++ .../2019/root/D/Token.java | 44 ++++ .../2019/root/D/TokenConstants.java | 12 + .../2019/same/A/GSTiling.java | 247 ++++++++++++++++++ .../2019/same/A/Match.java | 52 ++++ .../2019/same/A/Matches.java | 57 ++++ .../2019/same/A/Structure.java | 118 +++++++++ .../2019/same/A/Submission.java | 218 ++++++++++++++++ .../2019/same/A/Table.java | 61 +++++ .../2019/same/A/Token.java | 47 ++++ .../2019/same/A/TokenConstants.java | 8 + .../2019/same/D/Match.java | 54 ++++ .../2019/same/D/Matches.java | 59 +++++ .../2019/same/D/Structure.java | 120 +++++++++ .../2019/same/D/Submission.java | 206 +++++++++++++++ .../2019/same/D/Table.java | 53 ++++ .../2019/same/D/Token.java | 44 ++++ .../2019/same/D/TokenConstants.java | 12 + .../2020/root/B/Table.java | 61 +++++ .../2020/root/B/Token.java | 47 ++++ .../2020/root/B/TokenConstants.java | 8 + .../2020/same/A/GSTiling.java | 247 ++++++++++++++++++ .../2020/same/A/Match.java | 52 ++++ .../2020/same/A/Matches.java | 57 ++++ .../2020/same/A/Structure.java | 118 +++++++++ .../2020/same/A/Submission.java | 218 ++++++++++++++++ .../2020/same/A/Table.java | 61 +++++ .../2020/same/A/Token.java | 47 ++++ .../2020/same/A/TokenConstants.java | 8 + .../2020/same/D/Match.java | 54 ++++ .../2020/same/D/Matches.java | 59 +++++ .../2020/same/D/Structure.java | 120 +++++++++ .../2020/same/D/Submission.java | 206 +++++++++++++++ .../2020/same/D/Table.java | 53 ++++ .../2020/same/D/Token.java | 44 ++++ .../2020/same/D/TokenConstants.java | 12 + .../2021/root/A/GSTiling.java | 247 ++++++++++++++++++ .../2021/root/A/Match.java | 52 ++++ .../2021/root/A/Matches.java | 57 ++++ .../2021/root/A/Structure.java | 118 +++++++++ .../2021/root/A/Submission.java | 218 ++++++++++++++++ .../2021/root/A/Table.java | 61 +++++ .../2021/root/A/Token.java | 47 ++++ .../2021/root/A/TokenConstants.java | 8 + .../2021/root/D/Match.java | 54 ++++ .../2021/root/D/Matches.java | 59 +++++ .../2021/root/D/Structure.java | 120 +++++++++ .../2021/root/D/Submission.java | 206 +++++++++++++++ .../2021/root/D/Table.java | 53 ++++ .../2021/root/D/Token.java | 44 ++++ .../2021/root/D/TokenConstants.java | 12 + .../2021/same/A/GSTiling.java | 247 ++++++++++++++++++ .../2021/same/A/Match.java | 52 ++++ .../2021/same/A/Matches.java | 57 ++++ .../2021/same/A/Structure.java | 118 +++++++++ .../2021/same/A/Submission.java | 218 ++++++++++++++++ .../2021/same/A/Table.java | 61 +++++ .../2021/same/A/Token.java | 47 ++++ .../2021/same/A/TokenConstants.java | 8 + .../2021/same/D/Match.java | 54 ++++ .../2021/same/D/Matches.java | 59 +++++ .../2021/same/D/Structure.java | 120 +++++++++ .../2021/same/D/Submission.java | 206 +++++++++++++++ .../2021/same/D/Table.java | 53 ++++ .../2021/same/D/Token.java | 44 ++++ .../2021/same/D/TokenConstants.java | 12 + .../SameRootName/2019/root/A/GSTiling.java | 247 ++++++++++++++++++ .../SameRootName/2019/root/A/Match.java | 52 ++++ .../SameRootName/2019/root/A/Matches.java | 57 ++++ .../SameRootName/2019/root/A/Structure.java | 118 +++++++++ .../SameRootName/2019/root/A/Submission.java | 218 ++++++++++++++++ .../SameRootName/2019/root/A/Table.java | 61 +++++ .../SameRootName/2019/root/A/Token.java | 47 ++++ .../2019/root/A/TokenConstants.java | 8 + .../SameRootName/2019/root/D/Match.java | 54 ++++ .../SameRootName/2019/root/D/Matches.java | 59 +++++ .../SameRootName/2019/root/D/Structure.java | 120 +++++++++ .../SameRootName/2019/root/D/Submission.java | 206 +++++++++++++++ .../SameRootName/2019/root/D/Table.java | 53 ++++ .../SameRootName/2019/root/D/Token.java | 44 ++++ .../2019/root/D/TokenConstants.java | 12 + .../SameRootName/2020/root/B/Table.java | 61 +++++ .../SameRootName/2020/root/B/Token.java | 47 ++++ .../2020/root/B/TokenConstants.java | 8 + .../SameSubmissionName/root1/A/GSTiling.java | 247 ++++++++++++++++++ .../SameSubmissionName/root1/A/Match.java | 52 ++++ .../SameSubmissionName/root1/A/Matches.java | 57 ++++ .../SameSubmissionName/root1/A/Structure.java | 118 +++++++++ .../root1/A/Submission.java | 218 ++++++++++++++++ .../SameSubmissionName/root1/A/Table.java | 61 +++++ .../SameSubmissionName/root1/A/Token.java | 47 ++++ .../root1/A/TokenConstants.java | 8 + .../SameSubmissionName/root1/B/Table.java | 61 +++++ .../SameSubmissionName/root1/B/Token.java | 47 ++++ .../root1/B/TokenConstants.java | 8 + .../SameSubmissionName/root2/B/Match.java | 54 ++++ .../SameSubmissionName/root2/B/Matches.java | 59 +++++ .../SameSubmissionName/root2/B/Structure.java | 120 +++++++++ .../root2/B/Submission.java | 206 +++++++++++++++ .../SameSubmissionName/root2/B/Table.java | 53 ++++ .../SameSubmissionName/root2/B/Token.java | 44 ++++ .../root2/B/TokenConstants.java | 12 + .../root1/A/B/GSTiling.java | 247 ++++++++++++++++++ .../root1/A/B/Match.java | 52 ++++ .../root1/A/B/Matches.java | 57 ++++ .../root1/A/B/Structure.java | 118 +++++++++ .../root1/A/B/Submission.java | 218 ++++++++++++++++ .../root1/A/B/Table.java | 61 +++++ .../root1/A/B/Token.java | 47 ++++ .../root1/A/B/TokenConstants.java | 8 + .../root1/B/Table.java | 61 +++++ .../root1/B/Token.java | 47 ++++ .../root1/B/TokenConstants.java | 8 + .../root2/B/Match.java | 54 ++++ .../root2/B/Matches.java | 59 +++++ .../root2/B/Structure.java | 120 +++++++++ .../root2/B/Submission.java | 206 +++++++++++++++ .../root2/B/Table.java | 53 ++++ .../root2/B/Token.java | 44 ++++ .../root2/B/TokenConstants.java | 12 + .../src/components/FilesContainer.vue | 38 ++- report-viewer/src/components/MatchTable.vue | 20 +- report-viewer/src/views/ComparisonView.vue | 12 +- report-viewer/src/views/FileUploadView.vue | 1 + 189 files changed, 15794 insertions(+), 26 deletions(-) create mode 100644 core/src/main/java/de/jplag/PreventSameRootName.java create mode 100644 core/src/test/java/de/jplag/PreventSameRootNameTest.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/GSTiling.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/GSTiling.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/GSTiling.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/GSTiling.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/GSTiling.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/GSTiling.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/GSTiling.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/GSTiling.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/GSTiling.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/GSTiling.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/GSTiling.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/TokenConstants.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Match.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Matches.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Structure.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Submission.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Table.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Token.java create mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/TokenConstants.java diff --git a/core/src/main/java/de/jplag/JPlag.java b/core/src/main/java/de/jplag/JPlag.java index 137e6b11c..d37b48aae 100644 --- a/core/src/main/java/de/jplag/JPlag.java +++ b/core/src/main/java/de/jplag/JPlag.java @@ -7,6 +7,7 @@ import de.jplag.clustering.ClusteringFactory; import de.jplag.exceptions.ExitException; +import de.jplag.exceptions.RootDirectoryException; import de.jplag.exceptions.SubmissionException; import de.jplag.options.JPlagOptions; import de.jplag.reporting.reportobject.model.Version; @@ -38,7 +39,13 @@ private static Version loadVersion() { * @param options determines the parameterization. */ public JPlag(JPlagOptions options) { - this.options = options; + PreventSameRootName preventSameRootName = null; + try { + preventSameRootName = new PreventSameRootName(options); + } catch (RootDirectoryException e) { + e.printStackTrace(); + } + this.options = preventSameRootName.getOptions(); language = this.options.language(); GreedyStringTiling coreAlgorithm = new GreedyStringTiling(options); comparisonStrategy = new ParallelComparisonStrategy(options, coreAlgorithm); diff --git a/core/src/main/java/de/jplag/PreventSameRootName.java b/core/src/main/java/de/jplag/PreventSameRootName.java new file mode 100644 index 000000000..fe7795aa8 --- /dev/null +++ b/core/src/main/java/de/jplag/PreventSameRootName.java @@ -0,0 +1,141 @@ +package de.jplag; + +import java.io.File; +import java.nio.file.Path; +import java.util.*; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import de.jplag.exceptions.RootDirectoryException; +import de.jplag.options.JPlagOptions; + +/** + * This class prevents the same root name of submissions. + */ +public class PreventSameRootName { + private static final Logger logger = LoggerFactory.getLogger(PreventSameRootName.class); + + private final Map statistic = new HashMap<>(); // uses to store information of same roots (Key: same root name ---> Value: number + // of the same root name) + private final JPlagOptions options; + + /** + * Creates and initializes a PreventSameRootName instance, parameterized by a set of options. If there are same names of + * root directories, they will be re-named before generating zip file and IDs. (e.g. two same root names: root ===> + * root_1 && root_2) + * @param options determines the parameterization + */ + public PreventSameRootName(JPlagOptions options) throws RootDirectoryException { + Set newChangedSubmissionDirectories; + Set oldChangedSubmissionDirectories; + Set newSubmissionDirectories = options.submissionDirectories(); + Set oldSubmissionDirectories = options.oldSubmissionDirectories(); + if (oldSubmissionDirectories == null && newSubmissionDirectories == null) { + throw new RootDirectoryException("No submission"); + } + boolean hasSameRoots = false; + hasSameRoots = hasSameRoots(newSubmissionDirectories, oldSubmissionDirectories); + if (hasSameRoots) { + logger.info("Detected same name of root directories, the name will be re-named..."); + newChangedSubmissionDirectories = renameRoots(newSubmissionDirectories); + oldChangedSubmissionDirectories = renameRoots(oldSubmissionDirectories); + } else { + newChangedSubmissionDirectories = newSubmissionDirectories; + oldChangedSubmissionDirectories = oldSubmissionDirectories; + } + this.options = new JPlagOptions(options.language(), options.minimumTokenMatch(), newChangedSubmissionDirectories, + oldChangedSubmissionDirectories, options.baseCodeSubmissionDirectory(), options.subdirectoryName(), options.fileSuffixes(), + options.exclusionFileName(), options.similarityMetric(), options.similarityThreshold(), options.maximumNumberOfComparisons(), + options.clusteringOptions(), options.debugParser()); + } + + /** + * @return a new options instance + */ + public JPlagOptions getOptions() { + return options; + } + + /** + * @return the statistic map + */ + public Map getStatistic() { + return statistic; + } + + /** + * Counts the root directory names and their number with Map(named statistic). + * @param submissionDirectories SubmissionDirectories that need to be counted + */ + public void rootsClassification(Set submissionDirectories) { + if (submissionDirectories == null) + return; + for (File submissionDirectory : submissionDirectories) { + String rootDirectory = getRootName(submissionDirectory); + statistic.put(rootDirectory, statistic.getOrDefault(rootDirectory, 0) + 1); + } + } + + /** + * Renames the same root directory name. + * @param submissionDirectories SubmissionDirectories that need to be re-named + * @return SubmissionDirectories that have been re-named + */ + public Set renameRoots(Set submissionDirectories) { + if (submissionDirectories == null) + return Set.of(); + Set set = new HashSet<>(); + for (File submissionDirectory : submissionDirectories) { + String rootDirectory = getRootName(submissionDirectory); + int index = statistic.getOrDefault(rootDirectory, -1); + if (index == -1) + continue; + String newRootDirectory = rootDirectory + "_" + index; + statistic.put(rootDirectory, statistic.get(rootDirectory) - 1); + File newFile = new File(Path.of(submissionDirectory.getParent(), newRootDirectory).toString()); + set.add(newFile); + submissionDirectory.renameTo(newFile); + logger.info("Original submission path ===> Current submission path:" + submissionDirectory.getPath() + " ===> " + newFile.getPath()); + } + return Set.copyOf(set); + } + + /** + * Gets root name of a submissionDirectory. + * @param submissionDirectory A single submissionDirectory + * @return Root name of the submission + */ + public String getRootName(File submissionDirectory) { + return submissionDirectory.getPath().substring(submissionDirectory.getParent().length() + 1); + } + + /** + * Determines if there are the same root directories. + * @param newSubmissionDirectories The new submissionDirectories + * @param oldSubmissionDirectories The old submissionDirectories + * @return True, if there are the same root directories. False, otherwise. + */ + public boolean hasSameRoots(Set newSubmissionDirectories, Set oldSubmissionDirectories) throws RootDirectoryException { + checkDirectoryExist(newSubmissionDirectories); + checkDirectoryExist(oldSubmissionDirectories); + rootsClassification(newSubmissionDirectories); + rootsClassification(oldSubmissionDirectories); + Set> entries = statistic.entrySet(); + entries.removeIf(entry -> entry.getValue() == 1); + return !statistic.isEmpty(); + } + + /** + * Checks if directories exist. If not, throws RootDirectoryException. + * @param submissionDirectories The submissionDirectories which needs to be checked + */ + public void checkDirectoryExist(Set submissionDirectories) throws RootDirectoryException { + for (File submissionDirectory : submissionDirectories) { + boolean exists = submissionDirectory.exists(); + if (!exists) { + throw new RootDirectoryException("Submission Directory doesn't exist: " + submissionDirectory.getPath()); + } + } + } +} diff --git a/core/src/main/java/de/jplag/reporting/jsonfactory/ComparisonReportWriter.java b/core/src/main/java/de/jplag/reporting/jsonfactory/ComparisonReportWriter.java index 981662d0a..0157aeca8 100644 --- a/core/src/main/java/de/jplag/reporting/jsonfactory/ComparisonReportWriter.java +++ b/core/src/main/java/de/jplag/reporting/jsonfactory/ComparisonReportWriter.java @@ -106,9 +106,9 @@ private Match convertMatchToReportMatch(JPlagComparison comparison, de.jplag.Mat private String relativizedFilePath(File file, Submission submission) { if (file.toPath().equals(submission.getRoot().toPath())) { - return Path.of(submission.getName(), submission.getName()).toString(); + return Path.of(submissionToIdFunction.apply(submission), submission.getName()).toString(); } - return Path.of(submission.getName(), submission.getRoot().toPath().relativize(file.toPath()).toString()).toString(); + return Path.of(submissionToIdFunction.apply(submission), submission.getRoot().toPath().relativize(file.toPath()).toString()).toString(); } } diff --git a/core/src/main/java/de/jplag/reporting/jsonfactory/DirectoryManager.java b/core/src/main/java/de/jplag/reporting/jsonfactory/DirectoryManager.java index 43d019319..d59bbda82 100644 --- a/core/src/main/java/de/jplag/reporting/jsonfactory/DirectoryManager.java +++ b/core/src/main/java/de/jplag/reporting/jsonfactory/DirectoryManager.java @@ -34,8 +34,7 @@ public static File createDirectory(String path, String name, File file, File sub File directory; String fileName = file.getPath(); String submissionRootPath = submissionRoot.getPath(); - int lastDirectoryIndex = findRootDirIndex(name, submissionRootPath); - fileName = fileName.substring(lastDirectoryIndex).replaceFirst(name, ""); + fileName = fileName.substring(submissionRootPath.length()); String outputRootDirectory = Path.of(path, name).toString(); if ("".equals(fileName)) { directory = new File(Path.of(outputRootDirectory, name).toString()); @@ -119,15 +118,4 @@ public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOExce logger.info("Display the results with the report viewer at https://jplag.github.io/JPlag/"); return true; } - - /** - * finds the start index of root directory according to this name - * @param name The name of the root directory. According to this name we can find the index of this directory. - * @param submissionRootPath The path of the root directory - * @return The start index of the root directory - */ - public static int findRootDirIndex(String name, String submissionRootPath) { - int submissionRootPathLength = submissionRootPath.length(); - return submissionRootPathLength - name.length(); - } } diff --git a/core/src/test/java/de/jplag/PreventSameRootNameTest.java b/core/src/test/java/de/jplag/PreventSameRootNameTest.java new file mode 100644 index 000000000..da91a86f4 --- /dev/null +++ b/core/src/test/java/de/jplag/PreventSameRootNameTest.java @@ -0,0 +1,85 @@ +package de.jplag; + +import static org.junit.jupiter.api.Assertions.fail; + +import java.io.File; +import java.nio.file.Path; +import java.util.Set; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import de.jplag.exceptions.RootDirectoryException; +import de.jplag.options.JPlagOptions; + +/** + * Test for the same root cases that will be re-named. + */ +public class PreventSameRootNameTest extends TestBase { + + private static final JPlagOptions BASEOPTIONS = new JPlagOptions(new de.jplag.java.Language(), Set.of(), Set.of()); + private static final String NOTEXISTDIRECTORY = Path.of(TestBase.BASE_PATH, "basecode", "NotExistDirectory").toString(); + private static final String SAMPLE_SAMEROOTNAME_1 = Path.of(TestBase.BASE_PATH, "SameRootName", "2019", "root").toString(); + private static final String SAMPLE_SAMEROOTNAME_2 = Path.of(TestBase.BASE_PATH, "SameRootName", "2020", "root").toString(); + + @Test + @DisplayName("test same root directory with withSubmissionDirectories options") + void testSameRootWithNew() { + JPlagOptions options = BASEOPTIONS.withSubmissionDirectories(Set.of(new File(SAMPLE_SAMEROOTNAME_1), new File(SAMPLE_SAMEROOTNAME_2))); + try { + PreventSameRootName preventSameRootName = new PreventSameRootName(options); + JPlagOptions newOptions = preventSameRootName.getOptions(); + File submissionDirectory_2 = options.submissionDirectories().stream().toList().get(0); + File submissionDirectory_1 = options.submissionDirectories().stream().toList().get(1); + File newChangedSubmissionDirectory_2 = newOptions.submissionDirectories().stream().toList().get(0); + File newChangedSubmissionDirectory_1 = newOptions.submissionDirectories().stream().toList().get(1); + Assertions.assertEquals(submissionDirectory_2.getPath() + "_2", newChangedSubmissionDirectory_2.getPath()); + Assertions.assertEquals(submissionDirectory_1.getPath() + "_1", newChangedSubmissionDirectory_1.getPath()); + } catch (RootDirectoryException e) { + fail("PreventSameRootName Class threw an exception:", e); + } + } + + @Test + @DisplayName("test same root directory with withSubmissionDirectories and oldSubmissionDirectories options") + void testSameRootWithNewAndOld() { + JPlagOptions options = BASEOPTIONS.withSubmissionDirectories(Set.of(new File(SAMPLE_SAMEROOTNAME_2))) + .withOldSubmissionDirectories(Set.of(new File(SAMPLE_SAMEROOTNAME_1))); + try { + PreventSameRootName preventSameRootName = new PreventSameRootName(options); + JPlagOptions newOptions = preventSameRootName.getOptions(); + File oldSubmissionDirectory = options.oldSubmissionDirectories().stream().toList().get(0); + File submissionDirectory = options.submissionDirectories().stream().toList().get(0); + File newChangedOldSubmissionDirectory = newOptions.oldSubmissionDirectories().stream().toList().get(0); + File newChangedSubmissionDirectory = newOptions.submissionDirectories().stream().toList().get(0); + Assertions.assertEquals(submissionDirectory.getPath() + "_2", newChangedSubmissionDirectory.getPath()); + Assertions.assertEquals(oldSubmissionDirectory.getPath() + "_1", newChangedOldSubmissionDirectory.getPath()); + } catch (RootDirectoryException e) { + fail("PreventSameRootName Class threw an exception:", e); + } + } + + @Test + @DisplayName("test not existed root directory with withSubmissionDirectories option") + void testCheckDirectoryExistWithNewSubmissionDirectories() { + JPlagOptions options = BASEOPTIONS.withSubmissionDirectories(Set.of(new File(NOTEXISTDIRECTORY))); + testRootDirectoryException(options); + } + + @Test + @DisplayName("test not existed root directory with withOldSubmissionDirectories option") + void testCheckDirectoryExistWithOldSubmissionDirectories() { + JPlagOptions options = BASEOPTIONS.withOldSubmissionDirectories(Set.of(new File(NOTEXISTDIRECTORY))); + testRootDirectoryException(options); + } + + /** + * Test RootDirectoryException for a given Jplag-options. + * @param options is the customized Jplag-options. + */ + void testRootDirectoryException(JPlagOptions options) { + RootDirectoryException exception = Assertions.assertThrows(RootDirectoryException.class, () -> new PreventSameRootName(options)); + Assertions.assertEquals("Submission Directory doesn't exist: " + NOTEXISTDIRECTORY, exception.getMessage()); + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/GSTiling.java new file mode 100644 index 000000000..3ca68224e --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/GSTiling.java @@ -0,0 +1,247 @@ +/* + * Diese Klasse implementiert den GSTiling Algorithmus + * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", + * sowie "Matches" und "Match" ausgelegt + */ +public class GSTiling implements TokenConstants { + private Matches matches = new Matches(); + + /* + * creating hashes. + * The hash-code will be written in every Token for the next token. + * (includes the Token itself) + * Das Ganze laeuft in linearer Zeit. + * condition: 1 < hashLength < 26 !!! + */ + + public void create_hashes(Structure s, int hashLength, boolean makeTable) { + // Hier wird die obere Grenze der Hash-Laenge festgelegt. + // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl + // der Token. + if (hashLength<1) hashLength = 1; + hashLength = (hashLength<26 ? hashLength : 25); + + if (s.size()= hashLength) { + s.tokens[i].hash = hash; + s.table.add(hash, i); // add into hashtable + } else + s.tokens[i].hash = -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } else { + for (i=0; i= hashLength) ? hash : -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } + s.hash_length = hashLength; + } + + public final void compare(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + // first parameter should contain the smaller sequence!!! + private final void compare(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + if(true) { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + } else { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; + } + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 + || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j, hx, hy; + for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j > maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // begining of sequence A + int y = matches.matches[i].startB; // begining of sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--) + A[x++].marked = B[y++].marked = true; // mark all Token! + } + + } while (maxmatch != mml); + } + + public final void compareWithBasecode(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + private final void compareWithBasecode(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + // Initialize + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + + + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j,hx,hy; + for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j != maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // beginning in sequence A + int y = matches.matches[i].startB; // beginning in sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--){ + A[x].marked = B[y].marked = true; // mark all Token! + A[x].basecode = B[y].basecode= true; + x++; y++; + } + } + } while (maxmatch != mml); + + } + + public void resetBaseSubmission(Submission sub){ + Structure tmpStruct = sub.struct; + Token[] tok = tmpStruct.tokens; + for (int z = 0; z < tmpStruct.size()-1;z++){ + tok[z].basecode = false; + } + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Match.java new file mode 100644 index 000000000..dc29ebfd4 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Match.java @@ -0,0 +1,52 @@ +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Matches.java new file mode 100644 index 000000000..55cecdfca --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Matches.java @@ -0,0 +1,57 @@ +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Structure.java new file mode 100644 index 000000000..4e0c4ce4c --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Structure.java @@ -0,0 +1,118 @@ +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Submission.java new file mode 100644 index 000000000..bb2190e55 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Submission.java @@ -0,0 +1,218 @@ +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure struct; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void copySubmission() { + File errorDir = null; + try { + URL url = Submission.class.getResource("errors"); + errorDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!errorDir.exists()) + errorDir.mkdir(); + int i = 0; + File destDir; + while ((destDir = new File(errorDir, format.format(i))).exists()) + i++; + destDir.mkdir(); + for (i = 0; i < files.length; i++) + copyFile(new File(dir, files[i]), new File(destDir, files[i])); + } + + /* Physical copy. :-) */ + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream dis = new FileInputStream(in); + FileOutputStream dos = new FileOutputStream(out); + int count; + do { + count = dis.read(buffer); + if (count != -1) + dos.write(buffer, 0, count); + } while (count != -1); + dis.close(); + dos.close(); + } catch (IOException e) { + + } + } + + public int size() { + if (struct != null) + return structSize = struct.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] result = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + help = help.replaceAll("<", "<"); + help = help.replaceAll(">", ">"); + help = help.replaceAll("\"", """); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + result[i] = new String[text.size()]; + text.copyInto(result[i]); + } + return result; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] result = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + result[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + // TODO: Should an ExitException be thrown here? + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + } + return result; + } + + public int compareTo(Submission other) { + return name.compareTo(other.name); + } + + public String toString() { + return name; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character module. + // maybe other modules can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Match.java new file mode 100644 index 000000000..43fe9a6b1 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Match.java @@ -0,0 +1,54 @@ +package samples.PartialPlagiarism.D; + +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Matches.java new file mode 100644 index 000000000..1037e6b56 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Matches.java @@ -0,0 +1,59 @@ +package samples.PartialPlagiarism.D; + +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Structure.java new file mode 100644 index 000000000..64ca0cce3 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Structure.java @@ -0,0 +1,120 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Submission.java new file mode 100644 index 000000000..20b954493 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Submission.java @@ -0,0 +1,206 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure structure; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void doSmth() { + File failureDir = null; + try { + URL url = Submission.class.getResource("errors"); + failureDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!failureDir.exists()) + failureDir.mkdir(); + int i = 0; + } + + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream des = new FileInputStream(in); + FileOutputStream foo = new FileOutputStream(out); + int count; + do { + count = des.read(buffer); + if (count != -1) + foo.write(buffer, 0, count); + } while (count != -1); + des.close(); + foo.close(); + } catch (IOException e) { + System.out.println("Oh no!"); + } + } + + public int size() { + if (structure != null) + return structSize = structure.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] newName = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + System.out.println("Oh no!"); + } + newName[i] = new String[text.size()]; + text.copyInto(newName[i]); + } + return newName; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] variabl = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + variabl[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + System.out.println("Oh no"); + } catch (IOException e) { + + } + } + return variabl; + } + + @Override + public int compareTo(Submission o) { + return 0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Table.java new file mode 100644 index 000000000..a5d49d4fd --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Table.java @@ -0,0 +1,53 @@ +package samples.PartialPlagiarism.D;//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] foo; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + foo = new int[this.size][]; + } + + private final void addTo(int index, int datum) { + if (foo[index]==null) { // new element + foo[index] = new int[4]; + foo[index][0] = 0; + } else + ensureCapacity(index, foo[index][0] + 2); + + foo[index][++foo[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int old = foo[index].length; + if (minCapacity > old) { + int[] oldData = foo[index]; + int newCapacity = (old + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + foo[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, foo[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // This is original work not copied + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/TokenConstants.java new file mode 100644 index 000000000..230cd2612 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/TokenConstants.java @@ -0,0 +1,12 @@ +package samples.PartialPlagiarism.D; + +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; + + final static int ANOTHER_TOKEN = 42; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/GSTiling.java new file mode 100644 index 000000000..3ca68224e --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/GSTiling.java @@ -0,0 +1,247 @@ +/* + * Diese Klasse implementiert den GSTiling Algorithmus + * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", + * sowie "Matches" und "Match" ausgelegt + */ +public class GSTiling implements TokenConstants { + private Matches matches = new Matches(); + + /* + * creating hashes. + * The hash-code will be written in every Token for the next token. + * (includes the Token itself) + * Das Ganze laeuft in linearer Zeit. + * condition: 1 < hashLength < 26 !!! + */ + + public void create_hashes(Structure s, int hashLength, boolean makeTable) { + // Hier wird die obere Grenze der Hash-Laenge festgelegt. + // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl + // der Token. + if (hashLength<1) hashLength = 1; + hashLength = (hashLength<26 ? hashLength : 25); + + if (s.size()= hashLength) { + s.tokens[i].hash = hash; + s.table.add(hash, i); // add into hashtable + } else + s.tokens[i].hash = -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } else { + for (i=0; i= hashLength) ? hash : -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } + s.hash_length = hashLength; + } + + public final void compare(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + // first parameter should contain the smaller sequence!!! + private final void compare(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + if(true) { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + } else { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; + } + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 + || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j, hx, hy; + for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j > maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // begining of sequence A + int y = matches.matches[i].startB; // begining of sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--) + A[x++].marked = B[y++].marked = true; // mark all Token! + } + + } while (maxmatch != mml); + } + + public final void compareWithBasecode(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + private final void compareWithBasecode(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + // Initialize + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + + + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j,hx,hy; + for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j != maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // beginning in sequence A + int y = matches.matches[i].startB; // beginning in sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--){ + A[x].marked = B[y].marked = true; // mark all Token! + A[x].basecode = B[y].basecode= true; + x++; y++; + } + } + } while (maxmatch != mml); + + } + + public void resetBaseSubmission(Submission sub){ + Structure tmpStruct = sub.struct; + Token[] tok = tmpStruct.tokens; + for (int z = 0; z < tmpStruct.size()-1;z++){ + tok[z].basecode = false; + } + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Match.java new file mode 100644 index 000000000..dc29ebfd4 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Match.java @@ -0,0 +1,52 @@ +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Matches.java new file mode 100644 index 000000000..55cecdfca --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Matches.java @@ -0,0 +1,57 @@ +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Structure.java new file mode 100644 index 000000000..4e0c4ce4c --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Structure.java @@ -0,0 +1,118 @@ +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Submission.java new file mode 100644 index 000000000..bb2190e55 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Submission.java @@ -0,0 +1,218 @@ +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure struct; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void copySubmission() { + File errorDir = null; + try { + URL url = Submission.class.getResource("errors"); + errorDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!errorDir.exists()) + errorDir.mkdir(); + int i = 0; + File destDir; + while ((destDir = new File(errorDir, format.format(i))).exists()) + i++; + destDir.mkdir(); + for (i = 0; i < files.length; i++) + copyFile(new File(dir, files[i]), new File(destDir, files[i])); + } + + /* Physical copy. :-) */ + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream dis = new FileInputStream(in); + FileOutputStream dos = new FileOutputStream(out); + int count; + do { + count = dis.read(buffer); + if (count != -1) + dos.write(buffer, 0, count); + } while (count != -1); + dis.close(); + dos.close(); + } catch (IOException e) { + + } + } + + public int size() { + if (struct != null) + return structSize = struct.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] result = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + help = help.replaceAll("<", "<"); + help = help.replaceAll(">", ">"); + help = help.replaceAll("\"", """); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + result[i] = new String[text.size()]; + text.copyInto(result[i]); + } + return result; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] result = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + result[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + // TODO: Should an ExitException be thrown here? + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + } + return result; + } + + public int compareTo(Submission other) { + return name.compareTo(other.name); + } + + public String toString() { + return name; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character module. + // maybe other modules can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Match.java new file mode 100644 index 000000000..43fe9a6b1 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Match.java @@ -0,0 +1,54 @@ +package samples.PartialPlagiarism.D; + +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Matches.java new file mode 100644 index 000000000..1037e6b56 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Matches.java @@ -0,0 +1,59 @@ +package samples.PartialPlagiarism.D; + +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Structure.java new file mode 100644 index 000000000..64ca0cce3 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Structure.java @@ -0,0 +1,120 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Submission.java new file mode 100644 index 000000000..20b954493 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Submission.java @@ -0,0 +1,206 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure structure; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void doSmth() { + File failureDir = null; + try { + URL url = Submission.class.getResource("errors"); + failureDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!failureDir.exists()) + failureDir.mkdir(); + int i = 0; + } + + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream des = new FileInputStream(in); + FileOutputStream foo = new FileOutputStream(out); + int count; + do { + count = des.read(buffer); + if (count != -1) + foo.write(buffer, 0, count); + } while (count != -1); + des.close(); + foo.close(); + } catch (IOException e) { + System.out.println("Oh no!"); + } + } + + public int size() { + if (structure != null) + return structSize = structure.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] newName = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + System.out.println("Oh no!"); + } + newName[i] = new String[text.size()]; + text.copyInto(newName[i]); + } + return newName; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] variabl = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + variabl[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + System.out.println("Oh no"); + } catch (IOException e) { + + } + } + return variabl; + } + + @Override + public int compareTo(Submission o) { + return 0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Table.java new file mode 100644 index 000000000..a5d49d4fd --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Table.java @@ -0,0 +1,53 @@ +package samples.PartialPlagiarism.D;//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] foo; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + foo = new int[this.size][]; + } + + private final void addTo(int index, int datum) { + if (foo[index]==null) { // new element + foo[index] = new int[4]; + foo[index][0] = 0; + } else + ensureCapacity(index, foo[index][0] + 2); + + foo[index][++foo[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int old = foo[index].length; + if (minCapacity > old) { + int[] oldData = foo[index]; + int newCapacity = (old + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + foo[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, foo[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // This is original work not copied + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/TokenConstants.java new file mode 100644 index 000000000..230cd2612 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/TokenConstants.java @@ -0,0 +1,12 @@ +package samples.PartialPlagiarism.D; + +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; + + final static int ANOTHER_TOKEN = 42; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character front end. + // maybe other front ends can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/GSTiling.java new file mode 100644 index 000000000..3ca68224e --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/GSTiling.java @@ -0,0 +1,247 @@ +/* + * Diese Klasse implementiert den GSTiling Algorithmus + * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", + * sowie "Matches" und "Match" ausgelegt + */ +public class GSTiling implements TokenConstants { + private Matches matches = new Matches(); + + /* + * creating hashes. + * The hash-code will be written in every Token for the next token. + * (includes the Token itself) + * Das Ganze laeuft in linearer Zeit. + * condition: 1 < hashLength < 26 !!! + */ + + public void create_hashes(Structure s, int hashLength, boolean makeTable) { + // Hier wird die obere Grenze der Hash-Laenge festgelegt. + // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl + // der Token. + if (hashLength<1) hashLength = 1; + hashLength = (hashLength<26 ? hashLength : 25); + + if (s.size()= hashLength) { + s.tokens[i].hash = hash; + s.table.add(hash, i); // add into hashtable + } else + s.tokens[i].hash = -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } else { + for (i=0; i= hashLength) ? hash : -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } + s.hash_length = hashLength; + } + + public final void compare(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + // first parameter should contain the smaller sequence!!! + private final void compare(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + if(true) { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + } else { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; + } + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 + || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j, hx, hy; + for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j > maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // begining of sequence A + int y = matches.matches[i].startB; // begining of sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--) + A[x++].marked = B[y++].marked = true; // mark all Token! + } + + } while (maxmatch != mml); + } + + public final void compareWithBasecode(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + private final void compareWithBasecode(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + // Initialize + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + + + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j,hx,hy; + for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j != maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // beginning in sequence A + int y = matches.matches[i].startB; // beginning in sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--){ + A[x].marked = B[y].marked = true; // mark all Token! + A[x].basecode = B[y].basecode= true; + x++; y++; + } + } + } while (maxmatch != mml); + + } + + public void resetBaseSubmission(Submission sub){ + Structure tmpStruct = sub.struct; + Token[] tok = tmpStruct.tokens; + for (int z = 0; z < tmpStruct.size()-1;z++){ + tok[z].basecode = false; + } + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Match.java new file mode 100644 index 000000000..dc29ebfd4 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Match.java @@ -0,0 +1,52 @@ +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Matches.java new file mode 100644 index 000000000..55cecdfca --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Matches.java @@ -0,0 +1,57 @@ +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Structure.java new file mode 100644 index 000000000..4e0c4ce4c --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Structure.java @@ -0,0 +1,118 @@ +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Submission.java new file mode 100644 index 000000000..bb2190e55 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Submission.java @@ -0,0 +1,218 @@ +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure struct; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void copySubmission() { + File errorDir = null; + try { + URL url = Submission.class.getResource("errors"); + errorDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!errorDir.exists()) + errorDir.mkdir(); + int i = 0; + File destDir; + while ((destDir = new File(errorDir, format.format(i))).exists()) + i++; + destDir.mkdir(); + for (i = 0; i < files.length; i++) + copyFile(new File(dir, files[i]), new File(destDir, files[i])); + } + + /* Physical copy. :-) */ + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream dis = new FileInputStream(in); + FileOutputStream dos = new FileOutputStream(out); + int count; + do { + count = dis.read(buffer); + if (count != -1) + dos.write(buffer, 0, count); + } while (count != -1); + dis.close(); + dos.close(); + } catch (IOException e) { + + } + } + + public int size() { + if (struct != null) + return structSize = struct.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] result = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + help = help.replaceAll("<", "<"); + help = help.replaceAll(">", ">"); + help = help.replaceAll("\"", """); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + result[i] = new String[text.size()]; + text.copyInto(result[i]); + } + return result; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] result = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + result[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + // TODO: Should an ExitException be thrown here? + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + } + return result; + } + + public int compareTo(Submission other) { + return name.compareTo(other.name); + } + + public String toString() { + return name; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character module. + // maybe other modules can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Match.java new file mode 100644 index 000000000..43fe9a6b1 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Match.java @@ -0,0 +1,54 @@ +package samples.PartialPlagiarism.D; + +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Matches.java new file mode 100644 index 000000000..1037e6b56 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Matches.java @@ -0,0 +1,59 @@ +package samples.PartialPlagiarism.D; + +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Structure.java new file mode 100644 index 000000000..64ca0cce3 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Structure.java @@ -0,0 +1,120 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Submission.java new file mode 100644 index 000000000..20b954493 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Submission.java @@ -0,0 +1,206 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure structure; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void doSmth() { + File failureDir = null; + try { + URL url = Submission.class.getResource("errors"); + failureDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!failureDir.exists()) + failureDir.mkdir(); + int i = 0; + } + + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream des = new FileInputStream(in); + FileOutputStream foo = new FileOutputStream(out); + int count; + do { + count = des.read(buffer); + if (count != -1) + foo.write(buffer, 0, count); + } while (count != -1); + des.close(); + foo.close(); + } catch (IOException e) { + System.out.println("Oh no!"); + } + } + + public int size() { + if (structure != null) + return structSize = structure.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] newName = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + System.out.println("Oh no!"); + } + newName[i] = new String[text.size()]; + text.copyInto(newName[i]); + } + return newName; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] variabl = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + variabl[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + System.out.println("Oh no"); + } catch (IOException e) { + + } + } + return variabl; + } + + @Override + public int compareTo(Submission o) { + return 0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Table.java new file mode 100644 index 000000000..a5d49d4fd --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Table.java @@ -0,0 +1,53 @@ +package samples.PartialPlagiarism.D;//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] foo; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + foo = new int[this.size][]; + } + + private final void addTo(int index, int datum) { + if (foo[index]==null) { // new element + foo[index] = new int[4]; + foo[index][0] = 0; + } else + ensureCapacity(index, foo[index][0] + 2); + + foo[index][++foo[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int old = foo[index].length; + if (minCapacity > old) { + int[] oldData = foo[index]; + int newCapacity = (old + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + foo[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, foo[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // This is original work not copied + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/TokenConstants.java new file mode 100644 index 000000000..230cd2612 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/TokenConstants.java @@ -0,0 +1,12 @@ +package samples.PartialPlagiarism.D; + +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; + + final static int ANOTHER_TOKEN = 42; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/GSTiling.java new file mode 100644 index 000000000..3ca68224e --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/GSTiling.java @@ -0,0 +1,247 @@ +/* + * Diese Klasse implementiert den GSTiling Algorithmus + * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", + * sowie "Matches" und "Match" ausgelegt + */ +public class GSTiling implements TokenConstants { + private Matches matches = new Matches(); + + /* + * creating hashes. + * The hash-code will be written in every Token for the next token. + * (includes the Token itself) + * Das Ganze laeuft in linearer Zeit. + * condition: 1 < hashLength < 26 !!! + */ + + public void create_hashes(Structure s, int hashLength, boolean makeTable) { + // Hier wird die obere Grenze der Hash-Laenge festgelegt. + // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl + // der Token. + if (hashLength<1) hashLength = 1; + hashLength = (hashLength<26 ? hashLength : 25); + + if (s.size()= hashLength) { + s.tokens[i].hash = hash; + s.table.add(hash, i); // add into hashtable + } else + s.tokens[i].hash = -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } else { + for (i=0; i= hashLength) ? hash : -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } + s.hash_length = hashLength; + } + + public final void compare(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + // first parameter should contain the smaller sequence!!! + private final void compare(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + if(true) { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + } else { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; + } + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 + || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j, hx, hy; + for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j > maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // begining of sequence A + int y = matches.matches[i].startB; // begining of sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--) + A[x++].marked = B[y++].marked = true; // mark all Token! + } + + } while (maxmatch != mml); + } + + public final void compareWithBasecode(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + private final void compareWithBasecode(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + // Initialize + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + + + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j,hx,hy; + for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j != maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // beginning in sequence A + int y = matches.matches[i].startB; // beginning in sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--){ + A[x].marked = B[y].marked = true; // mark all Token! + A[x].basecode = B[y].basecode= true; + x++; y++; + } + } + } while (maxmatch != mml); + + } + + public void resetBaseSubmission(Submission sub){ + Structure tmpStruct = sub.struct; + Token[] tok = tmpStruct.tokens; + for (int z = 0; z < tmpStruct.size()-1;z++){ + tok[z].basecode = false; + } + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Match.java new file mode 100644 index 000000000..dc29ebfd4 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Match.java @@ -0,0 +1,52 @@ +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Matches.java new file mode 100644 index 000000000..55cecdfca --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Matches.java @@ -0,0 +1,57 @@ +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Structure.java new file mode 100644 index 000000000..4e0c4ce4c --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Structure.java @@ -0,0 +1,118 @@ +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Submission.java new file mode 100644 index 000000000..bb2190e55 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Submission.java @@ -0,0 +1,218 @@ +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure struct; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void copySubmission() { + File errorDir = null; + try { + URL url = Submission.class.getResource("errors"); + errorDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!errorDir.exists()) + errorDir.mkdir(); + int i = 0; + File destDir; + while ((destDir = new File(errorDir, format.format(i))).exists()) + i++; + destDir.mkdir(); + for (i = 0; i < files.length; i++) + copyFile(new File(dir, files[i]), new File(destDir, files[i])); + } + + /* Physical copy. :-) */ + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream dis = new FileInputStream(in); + FileOutputStream dos = new FileOutputStream(out); + int count; + do { + count = dis.read(buffer); + if (count != -1) + dos.write(buffer, 0, count); + } while (count != -1); + dis.close(); + dos.close(); + } catch (IOException e) { + + } + } + + public int size() { + if (struct != null) + return structSize = struct.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] result = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + help = help.replaceAll("<", "<"); + help = help.replaceAll(">", ">"); + help = help.replaceAll("\"", """); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + result[i] = new String[text.size()]; + text.copyInto(result[i]); + } + return result; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] result = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + result[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + // TODO: Should an ExitException be thrown here? + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + } + return result; + } + + public int compareTo(Submission other) { + return name.compareTo(other.name); + } + + public String toString() { + return name; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character module. + // maybe other modules can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Match.java new file mode 100644 index 000000000..43fe9a6b1 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Match.java @@ -0,0 +1,54 @@ +package samples.PartialPlagiarism.D; + +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Matches.java new file mode 100644 index 000000000..1037e6b56 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Matches.java @@ -0,0 +1,59 @@ +package samples.PartialPlagiarism.D; + +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Structure.java new file mode 100644 index 000000000..64ca0cce3 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Structure.java @@ -0,0 +1,120 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Submission.java new file mode 100644 index 000000000..20b954493 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Submission.java @@ -0,0 +1,206 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure structure; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void doSmth() { + File failureDir = null; + try { + URL url = Submission.class.getResource("errors"); + failureDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!failureDir.exists()) + failureDir.mkdir(); + int i = 0; + } + + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream des = new FileInputStream(in); + FileOutputStream foo = new FileOutputStream(out); + int count; + do { + count = des.read(buffer); + if (count != -1) + foo.write(buffer, 0, count); + } while (count != -1); + des.close(); + foo.close(); + } catch (IOException e) { + System.out.println("Oh no!"); + } + } + + public int size() { + if (structure != null) + return structSize = structure.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] newName = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + System.out.println("Oh no!"); + } + newName[i] = new String[text.size()]; + text.copyInto(newName[i]); + } + return newName; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] variabl = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + variabl[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + System.out.println("Oh no"); + } catch (IOException e) { + + } + } + return variabl; + } + + @Override + public int compareTo(Submission o) { + return 0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Table.java new file mode 100644 index 000000000..a5d49d4fd --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Table.java @@ -0,0 +1,53 @@ +package samples.PartialPlagiarism.D;//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] foo; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + foo = new int[this.size][]; + } + + private final void addTo(int index, int datum) { + if (foo[index]==null) { // new element + foo[index] = new int[4]; + foo[index][0] = 0; + } else + ensureCapacity(index, foo[index][0] + 2); + + foo[index][++foo[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int old = foo[index].length; + if (minCapacity > old) { + int[] oldData = foo[index]; + int newCapacity = (old + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + foo[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, foo[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // This is original work not copied + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/TokenConstants.java new file mode 100644 index 000000000..230cd2612 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/TokenConstants.java @@ -0,0 +1,12 @@ +package samples.PartialPlagiarism.D; + +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; + + final static int ANOTHER_TOKEN = 42; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/GSTiling.java new file mode 100644 index 000000000..3ca68224e --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/GSTiling.java @@ -0,0 +1,247 @@ +/* + * Diese Klasse implementiert den GSTiling Algorithmus + * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", + * sowie "Matches" und "Match" ausgelegt + */ +public class GSTiling implements TokenConstants { + private Matches matches = new Matches(); + + /* + * creating hashes. + * The hash-code will be written in every Token for the next token. + * (includes the Token itself) + * Das Ganze laeuft in linearer Zeit. + * condition: 1 < hashLength < 26 !!! + */ + + public void create_hashes(Structure s, int hashLength, boolean makeTable) { + // Hier wird die obere Grenze der Hash-Laenge festgelegt. + // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl + // der Token. + if (hashLength<1) hashLength = 1; + hashLength = (hashLength<26 ? hashLength : 25); + + if (s.size()= hashLength) { + s.tokens[i].hash = hash; + s.table.add(hash, i); // add into hashtable + } else + s.tokens[i].hash = -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } else { + for (i=0; i= hashLength) ? hash : -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } + s.hash_length = hashLength; + } + + public final void compare(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + // first parameter should contain the smaller sequence!!! + private final void compare(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + if(true) { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + } else { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; + } + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 + || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j, hx, hy; + for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j > maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // begining of sequence A + int y = matches.matches[i].startB; // begining of sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--) + A[x++].marked = B[y++].marked = true; // mark all Token! + } + + } while (maxmatch != mml); + } + + public final void compareWithBasecode(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + private final void compareWithBasecode(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + // Initialize + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + + + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j,hx,hy; + for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j != maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // beginning in sequence A + int y = matches.matches[i].startB; // beginning in sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--){ + A[x].marked = B[y].marked = true; // mark all Token! + A[x].basecode = B[y].basecode= true; + x++; y++; + } + } + } while (maxmatch != mml); + + } + + public void resetBaseSubmission(Submission sub){ + Structure tmpStruct = sub.struct; + Token[] tok = tmpStruct.tokens; + for (int z = 0; z < tmpStruct.size()-1;z++){ + tok[z].basecode = false; + } + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Match.java new file mode 100644 index 000000000..dc29ebfd4 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Match.java @@ -0,0 +1,52 @@ +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Matches.java new file mode 100644 index 000000000..55cecdfca --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Matches.java @@ -0,0 +1,57 @@ +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Structure.java new file mode 100644 index 000000000..4e0c4ce4c --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Structure.java @@ -0,0 +1,118 @@ +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Submission.java new file mode 100644 index 000000000..bb2190e55 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Submission.java @@ -0,0 +1,218 @@ +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure struct; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void copySubmission() { + File errorDir = null; + try { + URL url = Submission.class.getResource("errors"); + errorDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!errorDir.exists()) + errorDir.mkdir(); + int i = 0; + File destDir; + while ((destDir = new File(errorDir, format.format(i))).exists()) + i++; + destDir.mkdir(); + for (i = 0; i < files.length; i++) + copyFile(new File(dir, files[i]), new File(destDir, files[i])); + } + + /* Physical copy. :-) */ + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream dis = new FileInputStream(in); + FileOutputStream dos = new FileOutputStream(out); + int count; + do { + count = dis.read(buffer); + if (count != -1) + dos.write(buffer, 0, count); + } while (count != -1); + dis.close(); + dos.close(); + } catch (IOException e) { + + } + } + + public int size() { + if (struct != null) + return structSize = struct.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] result = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + help = help.replaceAll("<", "<"); + help = help.replaceAll(">", ">"); + help = help.replaceAll("\"", """); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + result[i] = new String[text.size()]; + text.copyInto(result[i]); + } + return result; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] result = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + result[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + // TODO: Should an ExitException be thrown here? + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + } + return result; + } + + public int compareTo(Submission other) { + return name.compareTo(other.name); + } + + public String toString() { + return name; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character module. + // maybe other modules can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Match.java new file mode 100644 index 000000000..43fe9a6b1 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Match.java @@ -0,0 +1,54 @@ +package samples.PartialPlagiarism.D; + +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Matches.java new file mode 100644 index 000000000..1037e6b56 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Matches.java @@ -0,0 +1,59 @@ +package samples.PartialPlagiarism.D; + +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Structure.java new file mode 100644 index 000000000..64ca0cce3 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Structure.java @@ -0,0 +1,120 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Submission.java new file mode 100644 index 000000000..20b954493 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Submission.java @@ -0,0 +1,206 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure structure; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void doSmth() { + File failureDir = null; + try { + URL url = Submission.class.getResource("errors"); + failureDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!failureDir.exists()) + failureDir.mkdir(); + int i = 0; + } + + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream des = new FileInputStream(in); + FileOutputStream foo = new FileOutputStream(out); + int count; + do { + count = des.read(buffer); + if (count != -1) + foo.write(buffer, 0, count); + } while (count != -1); + des.close(); + foo.close(); + } catch (IOException e) { + System.out.println("Oh no!"); + } + } + + public int size() { + if (structure != null) + return structSize = structure.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] newName = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + System.out.println("Oh no!"); + } + newName[i] = new String[text.size()]; + text.copyInto(newName[i]); + } + return newName; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] variabl = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + variabl[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + System.out.println("Oh no"); + } catch (IOException e) { + + } + } + return variabl; + } + + @Override + public int compareTo(Submission o) { + return 0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Table.java new file mode 100644 index 000000000..a5d49d4fd --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Table.java @@ -0,0 +1,53 @@ +package samples.PartialPlagiarism.D;//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] foo; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + foo = new int[this.size][]; + } + + private final void addTo(int index, int datum) { + if (foo[index]==null) { // new element + foo[index] = new int[4]; + foo[index][0] = 0; + } else + ensureCapacity(index, foo[index][0] + 2); + + foo[index][++foo[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int old = foo[index].length; + if (minCapacity > old) { + int[] oldData = foo[index]; + int newCapacity = (old + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + foo[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, foo[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // This is original work not copied + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/TokenConstants.java new file mode 100644 index 000000000..230cd2612 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/TokenConstants.java @@ -0,0 +1,12 @@ +package samples.PartialPlagiarism.D; + +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; + + final static int ANOTHER_TOKEN = 42; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character front end. + // maybe other front ends can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/GSTiling.java new file mode 100644 index 000000000..3ca68224e --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/GSTiling.java @@ -0,0 +1,247 @@ +/* + * Diese Klasse implementiert den GSTiling Algorithmus + * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", + * sowie "Matches" und "Match" ausgelegt + */ +public class GSTiling implements TokenConstants { + private Matches matches = new Matches(); + + /* + * creating hashes. + * The hash-code will be written in every Token for the next token. + * (includes the Token itself) + * Das Ganze laeuft in linearer Zeit. + * condition: 1 < hashLength < 26 !!! + */ + + public void create_hashes(Structure s, int hashLength, boolean makeTable) { + // Hier wird die obere Grenze der Hash-Laenge festgelegt. + // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl + // der Token. + if (hashLength<1) hashLength = 1; + hashLength = (hashLength<26 ? hashLength : 25); + + if (s.size()= hashLength) { + s.tokens[i].hash = hash; + s.table.add(hash, i); // add into hashtable + } else + s.tokens[i].hash = -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } else { + for (i=0; i= hashLength) ? hash : -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } + s.hash_length = hashLength; + } + + public final void compare(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + // first parameter should contain the smaller sequence!!! + private final void compare(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + if(true) { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + } else { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; + } + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 + || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j, hx, hy; + for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j > maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // begining of sequence A + int y = matches.matches[i].startB; // begining of sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--) + A[x++].marked = B[y++].marked = true; // mark all Token! + } + + } while (maxmatch != mml); + } + + public final void compareWithBasecode(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + private final void compareWithBasecode(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + // Initialize + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + + + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j,hx,hy; + for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j != maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // beginning in sequence A + int y = matches.matches[i].startB; // beginning in sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--){ + A[x].marked = B[y].marked = true; // mark all Token! + A[x].basecode = B[y].basecode= true; + x++; y++; + } + } + } while (maxmatch != mml); + + } + + public void resetBaseSubmission(Submission sub){ + Structure tmpStruct = sub.struct; + Token[] tok = tmpStruct.tokens; + for (int z = 0; z < tmpStruct.size()-1;z++){ + tok[z].basecode = false; + } + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Match.java new file mode 100644 index 000000000..dc29ebfd4 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Match.java @@ -0,0 +1,52 @@ +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Matches.java new file mode 100644 index 000000000..55cecdfca --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Matches.java @@ -0,0 +1,57 @@ +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Structure.java new file mode 100644 index 000000000..4e0c4ce4c --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Structure.java @@ -0,0 +1,118 @@ +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Submission.java new file mode 100644 index 000000000..bb2190e55 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Submission.java @@ -0,0 +1,218 @@ +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure struct; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void copySubmission() { + File errorDir = null; + try { + URL url = Submission.class.getResource("errors"); + errorDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!errorDir.exists()) + errorDir.mkdir(); + int i = 0; + File destDir; + while ((destDir = new File(errorDir, format.format(i))).exists()) + i++; + destDir.mkdir(); + for (i = 0; i < files.length; i++) + copyFile(new File(dir, files[i]), new File(destDir, files[i])); + } + + /* Physical copy. :-) */ + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream dis = new FileInputStream(in); + FileOutputStream dos = new FileOutputStream(out); + int count; + do { + count = dis.read(buffer); + if (count != -1) + dos.write(buffer, 0, count); + } while (count != -1); + dis.close(); + dos.close(); + } catch (IOException e) { + + } + } + + public int size() { + if (struct != null) + return structSize = struct.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] result = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + help = help.replaceAll("<", "<"); + help = help.replaceAll(">", ">"); + help = help.replaceAll("\"", """); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + result[i] = new String[text.size()]; + text.copyInto(result[i]); + } + return result; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] result = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + result[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + // TODO: Should an ExitException be thrown here? + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + } + return result; + } + + public int compareTo(Submission other) { + return name.compareTo(other.name); + } + + public String toString() { + return name; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character module. + // maybe other modules can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Match.java new file mode 100644 index 000000000..43fe9a6b1 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Match.java @@ -0,0 +1,54 @@ +package samples.PartialPlagiarism.D; + +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Matches.java new file mode 100644 index 000000000..1037e6b56 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Matches.java @@ -0,0 +1,59 @@ +package samples.PartialPlagiarism.D; + +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Structure.java new file mode 100644 index 000000000..64ca0cce3 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Structure.java @@ -0,0 +1,120 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Submission.java new file mode 100644 index 000000000..20b954493 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Submission.java @@ -0,0 +1,206 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure structure; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void doSmth() { + File failureDir = null; + try { + URL url = Submission.class.getResource("errors"); + failureDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!failureDir.exists()) + failureDir.mkdir(); + int i = 0; + } + + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream des = new FileInputStream(in); + FileOutputStream foo = new FileOutputStream(out); + int count; + do { + count = des.read(buffer); + if (count != -1) + foo.write(buffer, 0, count); + } while (count != -1); + des.close(); + foo.close(); + } catch (IOException e) { + System.out.println("Oh no!"); + } + } + + public int size() { + if (structure != null) + return structSize = structure.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] newName = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + System.out.println("Oh no!"); + } + newName[i] = new String[text.size()]; + text.copyInto(newName[i]); + } + return newName; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] variabl = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + variabl[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + System.out.println("Oh no"); + } catch (IOException e) { + + } + } + return variabl; + } + + @Override + public int compareTo(Submission o) { + return 0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Table.java new file mode 100644 index 000000000..a5d49d4fd --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Table.java @@ -0,0 +1,53 @@ +package samples.PartialPlagiarism.D;//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] foo; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + foo = new int[this.size][]; + } + + private final void addTo(int index, int datum) { + if (foo[index]==null) { // new element + foo[index] = new int[4]; + foo[index][0] = 0; + } else + ensureCapacity(index, foo[index][0] + 2); + + foo[index][++foo[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int old = foo[index].length; + if (minCapacity > old) { + int[] oldData = foo[index]; + int newCapacity = (old + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + foo[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, foo[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // This is original work not copied + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/TokenConstants.java new file mode 100644 index 000000000..230cd2612 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/TokenConstants.java @@ -0,0 +1,12 @@ +package samples.PartialPlagiarism.D; + +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; + + final static int ANOTHER_TOKEN = 42; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/GSTiling.java new file mode 100644 index 000000000..3ca68224e --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/GSTiling.java @@ -0,0 +1,247 @@ +/* + * Diese Klasse implementiert den GSTiling Algorithmus + * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", + * sowie "Matches" und "Match" ausgelegt + */ +public class GSTiling implements TokenConstants { + private Matches matches = new Matches(); + + /* + * creating hashes. + * The hash-code will be written in every Token for the next token. + * (includes the Token itself) + * Das Ganze laeuft in linearer Zeit. + * condition: 1 < hashLength < 26 !!! + */ + + public void create_hashes(Structure s, int hashLength, boolean makeTable) { + // Hier wird die obere Grenze der Hash-Laenge festgelegt. + // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl + // der Token. + if (hashLength<1) hashLength = 1; + hashLength = (hashLength<26 ? hashLength : 25); + + if (s.size()= hashLength) { + s.tokens[i].hash = hash; + s.table.add(hash, i); // add into hashtable + } else + s.tokens[i].hash = -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } else { + for (i=0; i= hashLength) ? hash : -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } + s.hash_length = hashLength; + } + + public final void compare(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + // first parameter should contain the smaller sequence!!! + private final void compare(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + if(true) { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + } else { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; + } + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 + || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j, hx, hy; + for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j > maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // begining of sequence A + int y = matches.matches[i].startB; // begining of sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--) + A[x++].marked = B[y++].marked = true; // mark all Token! + } + + } while (maxmatch != mml); + } + + public final void compareWithBasecode(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + private final void compareWithBasecode(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + // Initialize + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + + + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j,hx,hy; + for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j != maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // beginning in sequence A + int y = matches.matches[i].startB; // beginning in sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--){ + A[x].marked = B[y].marked = true; // mark all Token! + A[x].basecode = B[y].basecode= true; + x++; y++; + } + } + } while (maxmatch != mml); + + } + + public void resetBaseSubmission(Submission sub){ + Structure tmpStruct = sub.struct; + Token[] tok = tmpStruct.tokens; + for (int z = 0; z < tmpStruct.size()-1;z++){ + tok[z].basecode = false; + } + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Match.java new file mode 100644 index 000000000..dc29ebfd4 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Match.java @@ -0,0 +1,52 @@ +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Matches.java new file mode 100644 index 000000000..55cecdfca --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Matches.java @@ -0,0 +1,57 @@ +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Structure.java new file mode 100644 index 000000000..4e0c4ce4c --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Structure.java @@ -0,0 +1,118 @@ +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Submission.java new file mode 100644 index 000000000..bb2190e55 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Submission.java @@ -0,0 +1,218 @@ +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure struct; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void copySubmission() { + File errorDir = null; + try { + URL url = Submission.class.getResource("errors"); + errorDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!errorDir.exists()) + errorDir.mkdir(); + int i = 0; + File destDir; + while ((destDir = new File(errorDir, format.format(i))).exists()) + i++; + destDir.mkdir(); + for (i = 0; i < files.length; i++) + copyFile(new File(dir, files[i]), new File(destDir, files[i])); + } + + /* Physical copy. :-) */ + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream dis = new FileInputStream(in); + FileOutputStream dos = new FileOutputStream(out); + int count; + do { + count = dis.read(buffer); + if (count != -1) + dos.write(buffer, 0, count); + } while (count != -1); + dis.close(); + dos.close(); + } catch (IOException e) { + + } + } + + public int size() { + if (struct != null) + return structSize = struct.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] result = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + help = help.replaceAll("<", "<"); + help = help.replaceAll(">", ">"); + help = help.replaceAll("\"", """); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + result[i] = new String[text.size()]; + text.copyInto(result[i]); + } + return result; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] result = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + result[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + // TODO: Should an ExitException be thrown here? + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + } + return result; + } + + public int compareTo(Submission other) { + return name.compareTo(other.name); + } + + public String toString() { + return name; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character module. + // maybe other modules can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Match.java new file mode 100644 index 000000000..43fe9a6b1 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Match.java @@ -0,0 +1,54 @@ +package samples.PartialPlagiarism.D; + +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Matches.java new file mode 100644 index 000000000..1037e6b56 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Matches.java @@ -0,0 +1,59 @@ +package samples.PartialPlagiarism.D; + +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Structure.java new file mode 100644 index 000000000..64ca0cce3 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Structure.java @@ -0,0 +1,120 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Submission.java new file mode 100644 index 000000000..20b954493 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Submission.java @@ -0,0 +1,206 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure structure; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void doSmth() { + File failureDir = null; + try { + URL url = Submission.class.getResource("errors"); + failureDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!failureDir.exists()) + failureDir.mkdir(); + int i = 0; + } + + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream des = new FileInputStream(in); + FileOutputStream foo = new FileOutputStream(out); + int count; + do { + count = des.read(buffer); + if (count != -1) + foo.write(buffer, 0, count); + } while (count != -1); + des.close(); + foo.close(); + } catch (IOException e) { + System.out.println("Oh no!"); + } + } + + public int size() { + if (structure != null) + return structSize = structure.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] newName = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + System.out.println("Oh no!"); + } + newName[i] = new String[text.size()]; + text.copyInto(newName[i]); + } + return newName; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] variabl = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + variabl[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + System.out.println("Oh no"); + } catch (IOException e) { + + } + } + return variabl; + } + + @Override + public int compareTo(Submission o) { + return 0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Table.java new file mode 100644 index 000000000..a5d49d4fd --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Table.java @@ -0,0 +1,53 @@ +package samples.PartialPlagiarism.D;//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] foo; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + foo = new int[this.size][]; + } + + private final void addTo(int index, int datum) { + if (foo[index]==null) { // new element + foo[index] = new int[4]; + foo[index][0] = 0; + } else + ensureCapacity(index, foo[index][0] + 2); + + foo[index][++foo[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int old = foo[index].length; + if (minCapacity > old) { + int[] oldData = foo[index]; + int newCapacity = (old + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + foo[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, foo[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // This is original work not copied + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/TokenConstants.java new file mode 100644 index 000000000..230cd2612 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/TokenConstants.java @@ -0,0 +1,12 @@ +package samples.PartialPlagiarism.D; + +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; + + final static int ANOTHER_TOKEN = 42; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/GSTiling.java new file mode 100644 index 000000000..3ca68224e --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/GSTiling.java @@ -0,0 +1,247 @@ +/* + * Diese Klasse implementiert den GSTiling Algorithmus + * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", + * sowie "Matches" und "Match" ausgelegt + */ +public class GSTiling implements TokenConstants { + private Matches matches = new Matches(); + + /* + * creating hashes. + * The hash-code will be written in every Token for the next token. + * (includes the Token itself) + * Das Ganze laeuft in linearer Zeit. + * condition: 1 < hashLength < 26 !!! + */ + + public void create_hashes(Structure s, int hashLength, boolean makeTable) { + // Hier wird die obere Grenze der Hash-Laenge festgelegt. + // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl + // der Token. + if (hashLength<1) hashLength = 1; + hashLength = (hashLength<26 ? hashLength : 25); + + if (s.size()= hashLength) { + s.tokens[i].hash = hash; + s.table.add(hash, i); // add into hashtable + } else + s.tokens[i].hash = -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } else { + for (i=0; i= hashLength) ? hash : -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } + s.hash_length = hashLength; + } + + public final void compare(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + // first parameter should contain the smaller sequence!!! + private final void compare(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + if(true) { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + } else { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; + } + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 + || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j, hx, hy; + for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j > maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // begining of sequence A + int y = matches.matches[i].startB; // begining of sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--) + A[x++].marked = B[y++].marked = true; // mark all Token! + } + + } while (maxmatch != mml); + } + + public final void compareWithBasecode(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + private final void compareWithBasecode(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + // Initialize + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + + + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j,hx,hy; + for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j != maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // beginning in sequence A + int y = matches.matches[i].startB; // beginning in sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--){ + A[x].marked = B[y].marked = true; // mark all Token! + A[x].basecode = B[y].basecode= true; + x++; y++; + } + } + } while (maxmatch != mml); + + } + + public void resetBaseSubmission(Submission sub){ + Structure tmpStruct = sub.struct; + Token[] tok = tmpStruct.tokens; + for (int z = 0; z < tmpStruct.size()-1;z++){ + tok[z].basecode = false; + } + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Match.java new file mode 100644 index 000000000..dc29ebfd4 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Match.java @@ -0,0 +1,52 @@ +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Matches.java new file mode 100644 index 000000000..55cecdfca --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Matches.java @@ -0,0 +1,57 @@ +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Structure.java new file mode 100644 index 000000000..4e0c4ce4c --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Structure.java @@ -0,0 +1,118 @@ +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Submission.java new file mode 100644 index 000000000..bb2190e55 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Submission.java @@ -0,0 +1,218 @@ +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure struct; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void copySubmission() { + File errorDir = null; + try { + URL url = Submission.class.getResource("errors"); + errorDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!errorDir.exists()) + errorDir.mkdir(); + int i = 0; + File destDir; + while ((destDir = new File(errorDir, format.format(i))).exists()) + i++; + destDir.mkdir(); + for (i = 0; i < files.length; i++) + copyFile(new File(dir, files[i]), new File(destDir, files[i])); + } + + /* Physical copy. :-) */ + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream dis = new FileInputStream(in); + FileOutputStream dos = new FileOutputStream(out); + int count; + do { + count = dis.read(buffer); + if (count != -1) + dos.write(buffer, 0, count); + } while (count != -1); + dis.close(); + dos.close(); + } catch (IOException e) { + + } + } + + public int size() { + if (struct != null) + return structSize = struct.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] result = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + help = help.replaceAll("<", "<"); + help = help.replaceAll(">", ">"); + help = help.replaceAll("\"", """); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + result[i] = new String[text.size()]; + text.copyInto(result[i]); + } + return result; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] result = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + result[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + // TODO: Should an ExitException be thrown here? + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + } + return result; + } + + public int compareTo(Submission other) { + return name.compareTo(other.name); + } + + public String toString() { + return name; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character module. + // maybe other modules can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Match.java new file mode 100644 index 000000000..43fe9a6b1 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Match.java @@ -0,0 +1,54 @@ +package samples.PartialPlagiarism.D; + +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Matches.java new file mode 100644 index 000000000..1037e6b56 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Matches.java @@ -0,0 +1,59 @@ +package samples.PartialPlagiarism.D; + +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Structure.java new file mode 100644 index 000000000..64ca0cce3 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Structure.java @@ -0,0 +1,120 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Submission.java new file mode 100644 index 000000000..20b954493 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Submission.java @@ -0,0 +1,206 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure structure; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void doSmth() { + File failureDir = null; + try { + URL url = Submission.class.getResource("errors"); + failureDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!failureDir.exists()) + failureDir.mkdir(); + int i = 0; + } + + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream des = new FileInputStream(in); + FileOutputStream foo = new FileOutputStream(out); + int count; + do { + count = des.read(buffer); + if (count != -1) + foo.write(buffer, 0, count); + } while (count != -1); + des.close(); + foo.close(); + } catch (IOException e) { + System.out.println("Oh no!"); + } + } + + public int size() { + if (structure != null) + return structSize = structure.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] newName = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + System.out.println("Oh no!"); + } + newName[i] = new String[text.size()]; + text.copyInto(newName[i]); + } + return newName; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] variabl = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + variabl[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + System.out.println("Oh no"); + } catch (IOException e) { + + } + } + return variabl; + } + + @Override + public int compareTo(Submission o) { + return 0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Table.java new file mode 100644 index 000000000..a5d49d4fd --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Table.java @@ -0,0 +1,53 @@ +package samples.PartialPlagiarism.D;//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] foo; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + foo = new int[this.size][]; + } + + private final void addTo(int index, int datum) { + if (foo[index]==null) { // new element + foo[index] = new int[4]; + foo[index][0] = 0; + } else + ensureCapacity(index, foo[index][0] + 2); + + foo[index][++foo[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int old = foo[index].length; + if (minCapacity > old) { + int[] oldData = foo[index]; + int newCapacity = (old + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + foo[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, foo[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // This is original work not copied + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/TokenConstants.java new file mode 100644 index 000000000..230cd2612 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/TokenConstants.java @@ -0,0 +1,12 @@ +package samples.PartialPlagiarism.D; + +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; + + final static int ANOTHER_TOKEN = 42; +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/GSTiling.java new file mode 100644 index 000000000..3ca68224e --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/GSTiling.java @@ -0,0 +1,247 @@ +/* + * Diese Klasse implementiert den GSTiling Algorithmus + * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", + * sowie "Matches" und "Match" ausgelegt + */ +public class GSTiling implements TokenConstants { + private Matches matches = new Matches(); + + /* + * creating hashes. + * The hash-code will be written in every Token for the next token. + * (includes the Token itself) + * Das Ganze laeuft in linearer Zeit. + * condition: 1 < hashLength < 26 !!! + */ + + public void create_hashes(Structure s, int hashLength, boolean makeTable) { + // Hier wird die obere Grenze der Hash-Laenge festgelegt. + // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl + // der Token. + if (hashLength<1) hashLength = 1; + hashLength = (hashLength<26 ? hashLength : 25); + + if (s.size()= hashLength) { + s.tokens[i].hash = hash; + s.table.add(hash, i); // add into hashtable + } else + s.tokens[i].hash = -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } else { + for (i=0; i= hashLength) ? hash : -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } + s.hash_length = hashLength; + } + + public final void compare(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + // first parameter should contain the smaller sequence!!! + private final void compare(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + if(true) { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + } else { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; + } + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 + || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j, hx, hy; + for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j > maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // begining of sequence A + int y = matches.matches[i].startB; // begining of sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--) + A[x++].marked = B[y++].marked = true; // mark all Token! + } + + } while (maxmatch != mml); + } + + public final void compareWithBasecode(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + private final void compareWithBasecode(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + // Initialize + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + + + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j,hx,hy; + for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j != maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // beginning in sequence A + int y = matches.matches[i].startB; // beginning in sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--){ + A[x].marked = B[y].marked = true; // mark all Token! + A[x].basecode = B[y].basecode= true; + x++; y++; + } + } + } while (maxmatch != mml); + + } + + public void resetBaseSubmission(Submission sub){ + Structure tmpStruct = sub.struct; + Token[] tok = tmpStruct.tokens; + for (int z = 0; z < tmpStruct.size()-1;z++){ + tok[z].basecode = false; + } + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Match.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Match.java new file mode 100644 index 000000000..dc29ebfd4 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Match.java @@ -0,0 +1,52 @@ +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Matches.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Matches.java new file mode 100644 index 000000000..55cecdfca --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Matches.java @@ -0,0 +1,57 @@ +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Structure.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Structure.java new file mode 100644 index 000000000..4e0c4ce4c --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Structure.java @@ -0,0 +1,118 @@ +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Submission.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Submission.java new file mode 100644 index 000000000..bb2190e55 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Submission.java @@ -0,0 +1,218 @@ +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure struct; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void copySubmission() { + File errorDir = null; + try { + URL url = Submission.class.getResource("errors"); + errorDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!errorDir.exists()) + errorDir.mkdir(); + int i = 0; + File destDir; + while ((destDir = new File(errorDir, format.format(i))).exists()) + i++; + destDir.mkdir(); + for (i = 0; i < files.length; i++) + copyFile(new File(dir, files[i]), new File(destDir, files[i])); + } + + /* Physical copy. :-) */ + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream dis = new FileInputStream(in); + FileOutputStream dos = new FileOutputStream(out); + int count; + do { + count = dis.read(buffer); + if (count != -1) + dos.write(buffer, 0, count); + } while (count != -1); + dis.close(); + dos.close(); + } catch (IOException e) { + + } + } + + public int size() { + if (struct != null) + return structSize = struct.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] result = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + help = help.replaceAll("<", "<"); + help = help.replaceAll(">", ">"); + help = help.replaceAll("\"", """); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + result[i] = new String[text.size()]; + text.copyInto(result[i]); + } + return result; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] result = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + result[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + // TODO: Should an ExitException be thrown here? + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + } + return result; + } + + public int compareTo(Submission other) { + return name.compareTo(other.name); + } + + public String toString() { + return name; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Table.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character module. + // maybe other modules can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Match.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Match.java new file mode 100644 index 000000000..43fe9a6b1 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Match.java @@ -0,0 +1,54 @@ +package samples.PartialPlagiarism.D; + +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Matches.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Matches.java new file mode 100644 index 000000000..1037e6b56 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Matches.java @@ -0,0 +1,59 @@ +package samples.PartialPlagiarism.D; + +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Structure.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Structure.java new file mode 100644 index 000000000..64ca0cce3 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Structure.java @@ -0,0 +1,120 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Submission.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Submission.java new file mode 100644 index 000000000..20b954493 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Submission.java @@ -0,0 +1,206 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure structure; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void doSmth() { + File failureDir = null; + try { + URL url = Submission.class.getResource("errors"); + failureDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!failureDir.exists()) + failureDir.mkdir(); + int i = 0; + } + + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream des = new FileInputStream(in); + FileOutputStream foo = new FileOutputStream(out); + int count; + do { + count = des.read(buffer); + if (count != -1) + foo.write(buffer, 0, count); + } while (count != -1); + des.close(); + foo.close(); + } catch (IOException e) { + System.out.println("Oh no!"); + } + } + + public int size() { + if (structure != null) + return structSize = structure.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] newName = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + System.out.println("Oh no!"); + } + newName[i] = new String[text.size()]; + text.copyInto(newName[i]); + } + return newName; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] variabl = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + variabl[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + System.out.println("Oh no"); + } catch (IOException e) { + + } + } + return variabl; + } + + @Override + public int compareTo(Submission o) { + return 0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Table.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Table.java new file mode 100644 index 000000000..a5d49d4fd --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Table.java @@ -0,0 +1,53 @@ +package samples.PartialPlagiarism.D;//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] foo; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + foo = new int[this.size][]; + } + + private final void addTo(int index, int datum) { + if (foo[index]==null) { // new element + foo[index] = new int[4]; + foo[index][0] = 0; + } else + ensureCapacity(index, foo[index][0] + 2); + + foo[index][++foo[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int old = foo[index].length; + if (minCapacity > old) { + int[] oldData = foo[index]; + int newCapacity = (old + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + foo[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, foo[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // This is original work not copied + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/TokenConstants.java new file mode 100644 index 000000000..230cd2612 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/TokenConstants.java @@ -0,0 +1,12 @@ +package samples.PartialPlagiarism.D; + +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; + + final static int ANOTHER_TOKEN = 42; +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/Table.java b/core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character front end. + // maybe other front ends can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/GSTiling.java new file mode 100644 index 000000000..3ca68224e --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/GSTiling.java @@ -0,0 +1,247 @@ +/* + * Diese Klasse implementiert den GSTiling Algorithmus + * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", + * sowie "Matches" und "Match" ausgelegt + */ +public class GSTiling implements TokenConstants { + private Matches matches = new Matches(); + + /* + * creating hashes. + * The hash-code will be written in every Token for the next token. + * (includes the Token itself) + * Das Ganze laeuft in linearer Zeit. + * condition: 1 < hashLength < 26 !!! + */ + + public void create_hashes(Structure s, int hashLength, boolean makeTable) { + // Hier wird die obere Grenze der Hash-Laenge festgelegt. + // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl + // der Token. + if (hashLength<1) hashLength = 1; + hashLength = (hashLength<26 ? hashLength : 25); + + if (s.size()= hashLength) { + s.tokens[i].hash = hash; + s.table.add(hash, i); // add into hashtable + } else + s.tokens[i].hash = -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } else { + for (i=0; i= hashLength) ? hash : -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } + s.hash_length = hashLength; + } + + public final void compare(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + // first parameter should contain the smaller sequence!!! + private final void compare(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + if(true) { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + } else { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; + } + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 + || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j, hx, hy; + for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j > maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // begining of sequence A + int y = matches.matches[i].startB; // begining of sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--) + A[x++].marked = B[y++].marked = true; // mark all Token! + } + + } while (maxmatch != mml); + } + + public final void compareWithBasecode(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + private final void compareWithBasecode(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + // Initialize + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + + + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j,hx,hy; + for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j != maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // beginning in sequence A + int y = matches.matches[i].startB; // beginning in sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--){ + A[x].marked = B[y].marked = true; // mark all Token! + A[x].basecode = B[y].basecode= true; + x++; y++; + } + } + } while (maxmatch != mml); + + } + + public void resetBaseSubmission(Submission sub){ + Structure tmpStruct = sub.struct; + Token[] tok = tmpStruct.tokens; + for (int z = 0; z < tmpStruct.size()-1;z++){ + tok[z].basecode = false; + } + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Match.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Match.java new file mode 100644 index 000000000..dc29ebfd4 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Match.java @@ -0,0 +1,52 @@ +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Matches.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Matches.java new file mode 100644 index 000000000..55cecdfca --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Matches.java @@ -0,0 +1,57 @@ +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Structure.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Structure.java new file mode 100644 index 000000000..4e0c4ce4c --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Structure.java @@ -0,0 +1,118 @@ +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Submission.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Submission.java new file mode 100644 index 000000000..bb2190e55 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Submission.java @@ -0,0 +1,218 @@ +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure struct; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void copySubmission() { + File errorDir = null; + try { + URL url = Submission.class.getResource("errors"); + errorDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!errorDir.exists()) + errorDir.mkdir(); + int i = 0; + File destDir; + while ((destDir = new File(errorDir, format.format(i))).exists()) + i++; + destDir.mkdir(); + for (i = 0; i < files.length; i++) + copyFile(new File(dir, files[i]), new File(destDir, files[i])); + } + + /* Physical copy. :-) */ + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream dis = new FileInputStream(in); + FileOutputStream dos = new FileOutputStream(out); + int count; + do { + count = dis.read(buffer); + if (count != -1) + dos.write(buffer, 0, count); + } while (count != -1); + dis.close(); + dos.close(); + } catch (IOException e) { + + } + } + + public int size() { + if (struct != null) + return structSize = struct.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] result = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + help = help.replaceAll("<", "<"); + help = help.replaceAll(">", ">"); + help = help.replaceAll("\"", """); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + result[i] = new String[text.size()]; + text.copyInto(result[i]); + } + return result; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] result = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + result[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + // TODO: Should an ExitException be thrown here? + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + } + return result; + } + + public int compareTo(Submission other) { + return name.compareTo(other.name); + } + + public String toString() { + return name; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Table.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character module. + // maybe other modules can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/Table.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character front end. + // maybe other front ends can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Match.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Match.java new file mode 100644 index 000000000..43fe9a6b1 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Match.java @@ -0,0 +1,54 @@ +package samples.PartialPlagiarism.D; + +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Matches.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Matches.java new file mode 100644 index 000000000..1037e6b56 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Matches.java @@ -0,0 +1,59 @@ +package samples.PartialPlagiarism.D; + +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Structure.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Structure.java new file mode 100644 index 000000000..64ca0cce3 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Structure.java @@ -0,0 +1,120 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Submission.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Submission.java new file mode 100644 index 000000000..20b954493 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Submission.java @@ -0,0 +1,206 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure structure; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void doSmth() { + File failureDir = null; + try { + URL url = Submission.class.getResource("errors"); + failureDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!failureDir.exists()) + failureDir.mkdir(); + int i = 0; + } + + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream des = new FileInputStream(in); + FileOutputStream foo = new FileOutputStream(out); + int count; + do { + count = des.read(buffer); + if (count != -1) + foo.write(buffer, 0, count); + } while (count != -1); + des.close(); + foo.close(); + } catch (IOException e) { + System.out.println("Oh no!"); + } + } + + public int size() { + if (structure != null) + return structSize = structure.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] newName = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + System.out.println("Oh no!"); + } + newName[i] = new String[text.size()]; + text.copyInto(newName[i]); + } + return newName; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] variabl = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + variabl[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + System.out.println("Oh no"); + } catch (IOException e) { + + } + } + return variabl; + } + + @Override + public int compareTo(Submission o) { + return 0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Table.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Table.java new file mode 100644 index 000000000..a5d49d4fd --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Table.java @@ -0,0 +1,53 @@ +package samples.PartialPlagiarism.D;//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] foo; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + foo = new int[this.size][]; + } + + private final void addTo(int index, int datum) { + if (foo[index]==null) { // new element + foo[index] = new int[4]; + foo[index][0] = 0; + } else + ensureCapacity(index, foo[index][0] + 2); + + foo[index][++foo[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int old = foo[index].length; + if (minCapacity > old) { + int[] oldData = foo[index]; + int newCapacity = (old + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + foo[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, foo[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // This is original work not copied + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/TokenConstants.java new file mode 100644 index 000000000..230cd2612 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/TokenConstants.java @@ -0,0 +1,12 @@ +package samples.PartialPlagiarism.D; + +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; + + final static int ANOTHER_TOKEN = 42; +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/GSTiling.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/GSTiling.java new file mode 100644 index 000000000..3ca68224e --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/GSTiling.java @@ -0,0 +1,247 @@ +/* + * Diese Klasse implementiert den GSTiling Algorithmus + * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", + * sowie "Matches" und "Match" ausgelegt + */ +public class GSTiling implements TokenConstants { + private Matches matches = new Matches(); + + /* + * creating hashes. + * The hash-code will be written in every Token for the next token. + * (includes the Token itself) + * Das Ganze laeuft in linearer Zeit. + * condition: 1 < hashLength < 26 !!! + */ + + public void create_hashes(Structure s, int hashLength, boolean makeTable) { + // Hier wird die obere Grenze der Hash-Laenge festgelegt. + // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl + // der Token. + if (hashLength<1) hashLength = 1; + hashLength = (hashLength<26 ? hashLength : 25); + + if (s.size()= hashLength) { + s.tokens[i].hash = hash; + s.table.add(hash, i); // add into hashtable + } else + s.tokens[i].hash = -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } else { + for (i=0; i= hashLength) ? hash : -1; + hash -= factor * (s.tokens[i].type & modulo); + hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); + if (s.tokens[i+hashLength].marked) + hashedLength = 0; + else + hashedLength++; + } + } + s.hash_length = hashLength; + } + + public final void compare(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + // first parameter should contain the smaller sequence!!! + private final void compare(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + if(true) { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + } else { + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; + } + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 + || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j, hx, hy; + for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j > maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // begining of sequence A + int y = matches.matches[i].startB; // begining of sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--) + A[x++].marked = B[y++].marked = true; // mark all Token! + } + + } while (maxmatch != mml); + } + + public final void compareWithBasecode(Submission subA, Submission subB) { + Submission A, B, tmp; + if (subA.struct.size() > subB.struct.size()) { + A = subB; B = subA; + } else { + A = subB; B = subA; + } + // if hashtable exists in first but not in second structure: flip around! + if (B.struct.table == null && A.struct.table != null) { + tmp = A; + A = B; + B = tmp; + } + } + + private final void compareWithBasecode(Submission subA, Submission subB, int mml) { + Structure structA = subA.struct; + Structure structB = subB.struct; + + // FILE_END used as pivot + + // init + Token[] A = structA.tokens; + Token[] B = structB.tokens; + int lengthA = structA.size()-1; // minus pivots! + int lengthB = structB.size()-1; // minus pivots! + + + // Initialize + for(int i = 0; i <= lengthA; i++) + A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; + + for(int i = 0; i <= lengthB; i++) + B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; + + + + + int maxmatch; + int[] elemsB; + + do { + maxmatch = mml; + matches.clear(); + for (int x = 0; x <= lengthA - maxmatch; x++) { + if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) + continue; +inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array + int y = elemsB[i]; + if (B[y].marked || maxmatch > lengthB - y) continue; + + int j,hx,hy; + for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind + if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) + continue inner; + } + // expand match + j = maxmatch; + while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) + j++; + + if (j != maxmatch) { // new biggest match? -> delete current smaller + matches.clear(); + maxmatch = j; + } + matches.addMatch(x, y, j); // add match + } + } + for (int i = matches.size() - 1; i >= 0; i--) { + int x = matches.matches[i].startA; // beginning in sequence A + int y = matches.matches[i].startB; // beginning in sequence B + + //in order that "Match" will be newly build (because reusing) + for (int j = matches.matches[i].length; j > 0; j--){ + A[x].marked = B[y].marked = true; // mark all Token! + A[x].basecode = B[y].basecode= true; + x++; y++; + } + } + } while (maxmatch != mml); + + } + + public void resetBaseSubmission(Submission sub){ + Structure tmpStruct = sub.struct; + Token[] tok = tmpStruct.tokens; + for (int z = 0; z < tmpStruct.size()-1;z++){ + tok[z].basecode = false; + } + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Match.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Match.java new file mode 100644 index 000000000..dc29ebfd4 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Match.java @@ -0,0 +1,52 @@ +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Matches.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Matches.java new file mode 100644 index 000000000..55cecdfca --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Matches.java @@ -0,0 +1,57 @@ +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Structure.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Structure.java new file mode 100644 index 000000000..4e0c4ce4c --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Structure.java @@ -0,0 +1,118 @@ +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Submission.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Submission.java new file mode 100644 index 000000000..bb2190e55 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Submission.java @@ -0,0 +1,218 @@ +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure struct; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void copySubmission() { + File errorDir = null; + try { + URL url = Submission.class.getResource("errors"); + errorDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!errorDir.exists()) + errorDir.mkdir(); + int i = 0; + File destDir; + while ((destDir = new File(errorDir, format.format(i))).exists()) + i++; + destDir.mkdir(); + for (i = 0; i < files.length; i++) + copyFile(new File(dir, files[i]), new File(destDir, files[i])); + } + + /* Physical copy. :-) */ + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream dis = new FileInputStream(in); + FileOutputStream dos = new FileOutputStream(out); + int count; + do { + count = dis.read(buffer); + if (count != -1) + dos.write(buffer, 0, count); + } while (count != -1); + dis.close(); + dos.close(); + } catch (IOException e) { + + } + } + + public int size() { + if (struct != null) + return structSize = struct.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] result = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + help = help.replaceAll("<", "<"); + help = help.replaceAll(">", ">"); + help = help.replaceAll("\"", """); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + result[i] = new String[text.size()]; + text.copyInto(result[i]); + } + return result; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] result = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + result[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + // TODO: Should an ExitException be thrown here? + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + + } + } + return result; + } + + public int compareTo(Submission other) { + return name.compareTo(other.name); + } + + public String toString() { + return name; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Table.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character module. + // maybe other modules can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/Table.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/Table.java new file mode 100644 index 000000000..c9072d7ba --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/Table.java @@ -0,0 +1,61 @@ +//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] data; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + data = new int[this.size][]; + } + + public final void add(int hash, int datum) { + addTo(hash % size, datum); + } + + public final int[] get(int hash) { + return data[hash % size]; + } + + private final void addTo(int index, int datum) { + if (data[index]==null) { // new element + data[index] = new int[4]; + data[index][0] = 0; + } else + ensureCapacity(index, data[index][0] + 2); + + data[index][++data[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int oldCapacity = data[index].length; + if (minCapacity > oldCapacity) { + int[] oldData = data[index]; + int newCapacity = (oldCapacity + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + data[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, data[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // this is made to distinguish the character front end. + // maybe other front ends can use it too? + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/TokenConstants.java new file mode 100644 index 000000000..bf022a329 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/TokenConstants.java @@ -0,0 +1,8 @@ +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Match.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Match.java new file mode 100644 index 000000000..43fe9a6b1 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Match.java @@ -0,0 +1,54 @@ +package samples.PartialPlagiarism.D; + +public class Match { + public int startA; + public int startB; + public int length; + + public Match(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + public Match() {} + + public void set(int startA, int startB, int length) { + this.startA = startA; + this.startB = startB; + this.length = length; + } + + public final boolean contains(int index, int sub) { + int start = (sub==0 ? startA : startB); + return (start <= index && index < (start+length)); + } + + public final boolean overlap(Match other) { + if (startA < other.startA) { + if ((other.startA - startA) < length) return true; + } else { + if ((startA - other.startA) < other.length) return true; + } + if (startB < other.startB) { + if ((other.startB - startB) < length) return true; + } else { + if ((startB - other.startB) < other.length) return true; + } + return false; + } + + public final boolean overlap(int oStartA, int oStartB, int oLength) { + if (startA < oStartA) { + if ((oStartA - startA) < length) return true; + } else { + if ((startA - oStartA) < oLength) return true; + } + if (startB < oStartB) { + if ((oStartB - startB) < length) return true; + } else { + if ((startB - oStartB) < oLength) return true; + } + return false; + } +} + diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Matches.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Matches.java new file mode 100644 index 000000000..1037e6b56 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Matches.java @@ -0,0 +1,59 @@ +package samples.PartialPlagiarism.D; + +/* Minimal class that stores "Match" objects. + */ +public class Matches { + public Match[] matches; + + private int anzahl; + private final int increment = 20; + + public Matches() { + matches = new Match[10]; + for (int i=0; i<10; i++) matches[i] = new Match(); + anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = matches.length; + if (minCapacity > oldCapacity) { + Match[] oldMatches = matches; + int newCapacity = (oldCapacity + increment); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + matches = new Match[newCapacity]; + System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); + for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) + if (matches[i].overlap(startA,startB,length)) return; + // no overlaps! + } + ensureCapacity(anzahl + 1); + //if (matches[anzahl] != null) // object recycling... + matches[anzahl].set(startA,startB,length); + //else + //matches[anzahl ] = new Match(startA,startB,length); + anzahl++; + } + + public final void clear() { + anzahl=0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Structure.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Structure.java new file mode 100644 index 000000000..64ca0cce3 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Structure.java @@ -0,0 +1,120 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; + +/** The tokenlist */ +public class Structure implements TokenConstants { + public Token[] tokens = new Token[0]; + Table table = null; + int hash_length = -1; + + int files; // number of END_FILE tokens + private int anzahl; + + //private final int increment = 300; + + public Structure() { + tokens = new Token[400]; + files = anzahl = 0; + } + + public final int size() { + return anzahl; + } + + public final void ensureCapacity(int minCapacity) { + int oldCapacity = tokens.length; + if (minCapacity > oldCapacity) { + Token[] oldTokens = tokens; + int newCapacity = (2 * oldCapacity); + if (newCapacity < minCapacity) { + newCapacity = minCapacity; + } + tokens = new Token[newCapacity]; + System.arraycopy(oldTokens, 0, tokens, 0, anzahl); + } + } + + public final void addToken(Token token) { + ensureCapacity(anzahl + 1); + if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) + token.file = tokens[anzahl - 1].file; // To save memory ... + if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) + token.setLine(tokens[anzahl - 1].getLine()); + // just to make sure + + tokens[anzahl++] = token; + if (token.type == FILE_END) + files++; + } + + public final String toString() { + StringBuffer buf = new StringBuffer(); + + try { + for (int i = 0; i < anzahl; i++) { + String s = tokens[i].toString(); + buf.append(i); + buf.append("\t"); + buf.append(s); + if (i < anzahl - 1) { + buf.append("\n"); + } + } + } catch (OutOfMemoryError e) { + return "Tokenlist to large for output: " + (anzahl) + " Tokens"; + } + return buf.toString(); + } + + public void save(File file) { + + try { + ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); + + p.writeInt(anzahl); + p.writeInt(hash_length); + p.writeInt(files); + + for (int i = 0; i < anzahl; i++) + p.writeObject(tokens[i]); + p.flush(); + p.close(); + } catch (IOException e) { + System.out.println("Error writing file: " + file.toString()); + } + } + + /* returns "true" when successful */ + public boolean load(File file) { + try { + ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); + + int newAnzahl = p.readInt(); + hash_length = p.readInt(); + files = p.readInt(); + ensureCapacity(newAnzahl); + anzahl = newAnzahl; + for (int i = 0; i < anzahl; i++) { + tokens[i] = (Token) p.readObject(); + // special case for text tokens: + // if (tokens[i] instanceof de.jplag.text.TextToken) { + // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; + // de.jplag.text.TextToken.put(token.getText(), token.type); + // } + } + p.close(); + table = null; + } catch (FileNotFoundException e) { + System.out.println("File not found: " + file.toString()); + return false; + } catch (IOException e) { + System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); + return false; + } catch (ClassNotFoundException e) { + System.out.println("Class not found in file: " + file.toString()); + return false; + } + return true; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Submission.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Submission.java new file mode 100644 index 000000000..20b954493 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Submission.java @@ -0,0 +1,206 @@ +package samples.PartialPlagiarism.D; + +import java.io.*; +import java.net.URL; +import java.text.DecimalFormat; +import java.util.Vector; + +/* + * Everything about a single submission is stored in this object. (directory, + * files, ...) + */ +public class Submission implements Comparable { + public String name; + + private boolean readSubDirs; + + public File dir; + + public String[] files = null; // = new String[0]; + + public Structure structure; + + public int structSize = 0; + + // public long structMem; + boolean exact_match = false; // used for fallback + + public boolean errors = false; + + public DecimalFormat format = new DecimalFormat("0000"); + + public Submission(String name, File dir, boolean readSubDirs) { + this.dir = dir; + this.name = name; + this.readSubDirs = readSubDirs; + try { + lookupDir(dir, ""); + } catch (Throwable b) { + } + } + + public Submission(String name, File dir) { + this.dir = dir; + this.name = name; + this.readSubDirs = false; + + files = new String[1]; + files[0] = name; + + } + + // recursively read in all the files + private void lookupDir(File dir, String subDir) throws Throwable { + File aktDir = new File(dir, subDir); + if (!aktDir.isDirectory()) + return; + if (readSubDirs) { + String[] dirs = aktDir.list(); + if (!subDir.equals("")) + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, subDir + File.separator + dirs[i]); + else + for (int i = 0; i < dirs.length; i++) + lookupDir(dir, dirs[i]); + } + String[] newFiles = aktDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return false; + } + }); + if (files != null) { + String[] oldFiles = files; + files = new String[oldFiles.length + newFiles.length]; + if (subDir != "") + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + else + System.arraycopy(newFiles, 0, files, 0, newFiles.length); + System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); + } else { + if (subDir != "") { + files = new String[newFiles.length]; + for (int i = 0; i < newFiles.length; i++) + files[i] = subDir + File.separator + newFiles[i]; + } else + files = newFiles; + } + } + + /* parse all the files... */ + public boolean parse(){ + return false; + } + + /* + * This method is used to copy files that can not be parsed to a special + * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) + * /002/(...files...) + */ + private void doSmth() { + File failureDir = null; + try { + URL url = Submission.class.getResource("errors"); + failureDir = new File(url.getFile()); + } catch (NullPointerException e) { + return; + } + + if (!failureDir.exists()) + failureDir.mkdir(); + int i = 0; + } + + private void copyFile(File in, File out) { + byte[] buffer = new byte[10000]; + try { + FileInputStream des = new FileInputStream(in); + FileOutputStream foo = new FileOutputStream(out); + int count; + do { + count = des.read(buffer); + if (count != -1) + foo.write(buffer, 0, count); + } while (count != -1); + des.close(); + foo.close(); + } catch (IOException e) { + System.out.println("Oh no!"); + } + } + + public int size() { + if (structure != null) + return structSize = structure.size(); + return structSize; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of strings. + */ + public String[][] readFiles(String[] files) { + String[][] newName = new String[files.length][]; + String help; + + Vector text = new Vector(); + for (int i = 0; i < files.length; i++) { + text.removeAllElements(); + try { + /* file encoding = "UTF-8" */ + FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + BufferedReader in = new BufferedReader(inputStreamReader); + while ((help = in.readLine()) != null) { + help = help.replaceAll("&", "&"); + text.addElement(help); + } + in.close(); + inputStreamReader.close(); + fileInputStream.close(); + } catch (FileNotFoundException e) { + System.out.println("File not found: " + ((new File(dir, files[i])).toString())); + } catch (IOException e) { + System.out.println("Oh no!"); + } + newName[i] = new String[text.size()]; + text.copyInto(newName[i]); + } + return newName; + } + + /* + * Used by the "Report" class. All source files are returned as an array of + * an array of chars. + */ + public char[][] readFilesChar(String[] files) { + char[][] variabl = new char[files.length][]; + + for (int i = 0; i < files.length; i++) { + try { + File file = new File(dir, files[i]); + int size = (int) file.length(); + char[] buffer = new char[size]; + + FileReader fis = new FileReader(file); + + if (size != fis.read(buffer)) { + System.out.println("Not right size read from the file, " + "but I will still continue..."); + } + + variabl[i] = buffer; + fis.close(); + } catch (FileNotFoundException e) { + System.out.println("Oh no"); + } catch (IOException e) { + + } + } + return variabl; + } + + @Override + public int compareTo(Submission o) { + return 0; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Table.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Table.java new file mode 100644 index 000000000..a5d49d4fd --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Table.java @@ -0,0 +1,53 @@ +package samples.PartialPlagiarism.D;//import java.io.*; + +/* A simplified hashtable: maps one integer to many integers + */ +public class Table { + private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; + private int[][] foo; /* in data[][0] stores the number of used elements + * of every sub-array */ + private int size; + + public Table(int size) { + //Program.print("Length: "+size+"\n", null); + int primzahl = 0; + if (size>=16001) { + this.size=16001; // just to make sure... :-) + } else { + for (int i=0; i size) break; + this.size = primzahl; + } + foo = new int[this.size][]; + } + + private final void addTo(int index, int datum) { + if (foo[index]==null) { // new element + foo[index] = new int[4]; + foo[index][0] = 0; + } else + ensureCapacity(index, foo[index][0] + 2); + + foo[index][++foo[index][0]] = datum; + } + + private final void ensureCapacity(int index, int minCapacity) { + int old = foo[index].length; + if (minCapacity > old) { + int[] oldData = foo[index]; + int newCapacity = (old + 4); + if (newCapacity < minCapacity) newCapacity = minCapacity; + foo[index] = new int[newCapacity]; + System.arraycopy(oldData, 0, foo[index], 0, oldData.length); + } + } + + public final void count_dist(int[] dist) { + for (int i=0; i0 ? line : 1); + setColumn(column); + setLength(length); + } + + // abstract members + public abstract int getLine(); + public abstract int getColumn(); + public abstract int getLength(); + protected void setLine(int line) {} + protected void setColumn(int line) {} + protected void setLength(int line) {} + + // This is original work not copied + protected int getIndex() { return -1; } + + public static String type2string(int type) { + return ""; + } + + public String toString() { + return type2string(type); + } + + public static int numberOfTokens() { + return 1; + } +} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/TokenConstants.java new file mode 100644 index 000000000..230cd2612 --- /dev/null +++ b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/TokenConstants.java @@ -0,0 +1,12 @@ +package samples.PartialPlagiarism.D; + +public interface TokenConstants { + final static int FILE_END = 0; + /** + * Used to optionally separate methods from each other with an always marked + * token + */ + final static int SEPARATOR_TOKEN = 1; + + final static int ANOTHER_TOKEN = 42; +} diff --git a/report-viewer/src/components/FilesContainer.vue b/report-viewer/src/components/FilesContainer.vue index 5a04ecce9..221e107f5 100644 --- a/report-viewer/src/components/FilesContainer.vue +++ b/report-viewer/src/components/FilesContainer.vue @@ -3,7 +3,7 @@ --> - diff --git a/report-viewer/src/views/ComparisonView.vue b/report-viewer/src/views/ComparisonView.vue index c95088fc4..791414e17 100644 --- a/report-viewer/src/views/ComparisonView.vue +++ b/report-viewer/src/views/ComparisonView.vue @@ -41,17 +41,23 @@ @@ -191,7 +197,7 @@ export default defineComponent({ const isAnonymous = (id: string) => store.state.anonymous.has(id); //Left panel - const hideLeftPanel = ref(true); + const hideLeftPanel = ref(false); const togglePanel = () => { hideLeftPanel.value = !hideLeftPanel.value; }; diff --git a/report-viewer/src/views/FileUploadView.vue b/report-viewer/src/views/FileUploadView.vue index 7c35e9532..784cfd587 100644 --- a/report-viewer/src/views/FileUploadView.vue +++ b/report-viewer/src/views/FileUploadView.vue @@ -6,6 +6,7 @@ JPlag

JPlag Report Viewer

Select an overview or comparison file or a zip to display.

+

(No files get uploaded anywhere)

Drop a .json or .zip on this page

From 73c1015afb03d9c755b96a5899b16fafa1b601a9 Mon Sep 17 00:00:00 2001 From: cyfml <236510120@qq.com> Date: Thu, 8 Dec 2022 15:48:08 +0100 Subject: [PATCH 2/6] delete codes related to same root name --- core/src/main/java/de/jplag/JPlag.java | 9 +- .../java/de/jplag/PreventSameRootName.java | 141 ---------- .../de/jplag/PreventSameRootNameTest.java | 85 ------ .../2016/same/A/GSTiling.java | 247 ------------------ .../2016/same/A/Match.java | 52 ---- .../2016/same/A/Matches.java | 57 ---- .../2016/same/A/Structure.java | 118 --------- .../2016/same/A/Submission.java | 218 ---------------- .../2016/same/A/Table.java | 61 ----- .../2016/same/A/Token.java | 47 ---- .../2016/same/A/TokenConstants.java | 8 - .../2016/same/D/Match.java | 54 ---- .../2016/same/D/Matches.java | 59 ----- .../2016/same/D/Structure.java | 120 --------- .../2016/same/D/Submission.java | 206 --------------- .../2016/same/D/Table.java | 53 ---- .../2016/same/D/Token.java | 44 ---- .../2016/same/D/TokenConstants.java | 12 - .../2017/same/A/GSTiling.java | 247 ------------------ .../2017/same/A/Match.java | 52 ---- .../2017/same/A/Matches.java | 57 ---- .../2017/same/A/Structure.java | 118 --------- .../2017/same/A/Submission.java | 218 ---------------- .../2017/same/A/Table.java | 61 ----- .../2017/same/A/Token.java | 47 ---- .../2017/same/A/TokenConstants.java | 8 - .../2017/same/D/Match.java | 54 ---- .../2017/same/D/Matches.java | 59 ----- .../2017/same/D/Structure.java | 120 --------- .../2017/same/D/Submission.java | 206 --------------- .../2017/same/D/Table.java | 53 ---- .../2017/same/D/Token.java | 44 ---- .../2017/same/D/TokenConstants.java | 12 - .../2018/root/B/Table.java | 61 ----- .../2018/root/B/Token.java | 47 ---- .../2018/root/B/TokenConstants.java | 8 - .../2018/same/A/GSTiling.java | 247 ------------------ .../2018/same/A/Match.java | 52 ---- .../2018/same/A/Matches.java | 57 ---- .../2018/same/A/Structure.java | 118 --------- .../2018/same/A/Submission.java | 218 ---------------- .../2018/same/A/Table.java | 61 ----- .../2018/same/A/Token.java | 47 ---- .../2018/same/A/TokenConstants.java | 8 - .../2018/same/D/Match.java | 54 ---- .../2018/same/D/Matches.java | 59 ----- .../2018/same/D/Structure.java | 120 --------- .../2018/same/D/Submission.java | 206 --------------- .../2018/same/D/Table.java | 53 ---- .../2018/same/D/Token.java | 44 ---- .../2018/same/D/TokenConstants.java | 12 - .../2019/root/A/GSTiling.java | 247 ------------------ .../2019/root/A/Match.java | 52 ---- .../2019/root/A/Matches.java | 57 ---- .../2019/root/A/Structure.java | 118 --------- .../2019/root/A/Submission.java | 218 ---------------- .../2019/root/A/Table.java | 61 ----- .../2019/root/A/Token.java | 47 ---- .../2019/root/A/TokenConstants.java | 8 - .../2019/root/D/Match.java | 54 ---- .../2019/root/D/Matches.java | 59 ----- .../2019/root/D/Structure.java | 120 --------- .../2019/root/D/Submission.java | 206 --------------- .../2019/root/D/Table.java | 53 ---- .../2019/root/D/Token.java | 44 ---- .../2019/root/D/TokenConstants.java | 12 - .../2019/same/A/GSTiling.java | 247 ------------------ .../2019/same/A/Match.java | 52 ---- .../2019/same/A/Matches.java | 57 ---- .../2019/same/A/Structure.java | 118 --------- .../2019/same/A/Submission.java | 218 ---------------- .../2019/same/A/Table.java | 61 ----- .../2019/same/A/Token.java | 47 ---- .../2019/same/A/TokenConstants.java | 8 - .../2019/same/D/Match.java | 54 ---- .../2019/same/D/Matches.java | 59 ----- .../2019/same/D/Structure.java | 120 --------- .../2019/same/D/Submission.java | 206 --------------- .../2019/same/D/Table.java | 53 ---- .../2019/same/D/Token.java | 44 ---- .../2019/same/D/TokenConstants.java | 12 - .../2020/root/B/Table.java | 61 ----- .../2020/root/B/Token.java | 47 ---- .../2020/root/B/TokenConstants.java | 8 - .../2020/same/A/GSTiling.java | 247 ------------------ .../2020/same/A/Match.java | 52 ---- .../2020/same/A/Matches.java | 57 ---- .../2020/same/A/Structure.java | 118 --------- .../2020/same/A/Submission.java | 218 ---------------- .../2020/same/A/Table.java | 61 ----- .../2020/same/A/Token.java | 47 ---- .../2020/same/A/TokenConstants.java | 8 - .../2020/same/D/Match.java | 54 ---- .../2020/same/D/Matches.java | 59 ----- .../2020/same/D/Structure.java | 120 --------- .../2020/same/D/Submission.java | 206 --------------- .../2020/same/D/Table.java | 53 ---- .../2020/same/D/Token.java | 44 ---- .../2020/same/D/TokenConstants.java | 12 - .../2021/root/A/GSTiling.java | 247 ------------------ .../2021/root/A/Match.java | 52 ---- .../2021/root/A/Matches.java | 57 ---- .../2021/root/A/Structure.java | 118 --------- .../2021/root/A/Submission.java | 218 ---------------- .../2021/root/A/Table.java | 61 ----- .../2021/root/A/Token.java | 47 ---- .../2021/root/A/TokenConstants.java | 8 - .../2021/root/D/Match.java | 54 ---- .../2021/root/D/Matches.java | 59 ----- .../2021/root/D/Structure.java | 120 --------- .../2021/root/D/Submission.java | 206 --------------- .../2021/root/D/Table.java | 53 ---- .../2021/root/D/Token.java | 44 ---- .../2021/root/D/TokenConstants.java | 12 - .../2021/same/A/GSTiling.java | 247 ------------------ .../2021/same/A/Match.java | 52 ---- .../2021/same/A/Matches.java | 57 ---- .../2021/same/A/Structure.java | 118 --------- .../2021/same/A/Submission.java | 218 ---------------- .../2021/same/A/Table.java | 61 ----- .../2021/same/A/Token.java | 47 ---- .../2021/same/A/TokenConstants.java | 8 - .../2021/same/D/Match.java | 54 ---- .../2021/same/D/Matches.java | 59 ----- .../2021/same/D/Structure.java | 120 --------- .../2021/same/D/Submission.java | 206 --------------- .../2021/same/D/Table.java | 53 ---- .../2021/same/D/Token.java | 44 ---- .../2021/same/D/TokenConstants.java | 12 - .../SameRootName/2019/root/A/GSTiling.java | 247 ------------------ .../SameRootName/2019/root/A/Match.java | 52 ---- .../SameRootName/2019/root/A/Matches.java | 57 ---- .../SameRootName/2019/root/A/Structure.java | 118 --------- .../SameRootName/2019/root/A/Submission.java | 218 ---------------- .../SameRootName/2019/root/A/Table.java | 61 ----- .../SameRootName/2019/root/A/Token.java | 47 ---- .../2019/root/A/TokenConstants.java | 8 - .../SameRootName/2019/root/D/Match.java | 54 ---- .../SameRootName/2019/root/D/Matches.java | 59 ----- .../SameRootName/2019/root/D/Structure.java | 120 --------- .../SameRootName/2019/root/D/Submission.java | 206 --------------- .../SameRootName/2019/root/D/Table.java | 53 ---- .../SameRootName/2019/root/D/Token.java | 44 ---- .../2019/root/D/TokenConstants.java | 12 - .../SameRootName/2020/root/B/Table.java | 61 ----- .../SameRootName/2020/root/B/Token.java | 47 ---- .../2020/root/B/TokenConstants.java | 8 - .../SameSubmissionName/root1/A/GSTiling.java | 247 ------------------ .../SameSubmissionName/root1/A/Match.java | 52 ---- .../SameSubmissionName/root1/A/Matches.java | 57 ---- .../SameSubmissionName/root1/A/Structure.java | 118 --------- .../root1/A/Submission.java | 218 ---------------- .../SameSubmissionName/root1/A/Table.java | 61 ----- .../SameSubmissionName/root1/A/Token.java | 47 ---- .../root1/A/TokenConstants.java | 8 - .../SameSubmissionName/root1/B/Table.java | 61 ----- .../SameSubmissionName/root1/B/Token.java | 47 ---- .../root1/B/TokenConstants.java | 8 - .../SameSubmissionName/root2/B/Match.java | 54 ---- .../SameSubmissionName/root2/B/Matches.java | 59 ----- .../SameSubmissionName/root2/B/Structure.java | 120 --------- .../root2/B/Submission.java | 206 --------------- .../SameSubmissionName/root2/B/Table.java | 53 ---- .../SameSubmissionName/root2/B/Token.java | 44 ---- .../root2/B/TokenConstants.java | 12 - .../root1/A/B/GSTiling.java | 247 ------------------ .../root1/A/B/Match.java | 52 ---- .../root1/A/B/Matches.java | 57 ---- .../root1/A/B/Structure.java | 118 --------- .../root1/A/B/Submission.java | 218 ---------------- .../root1/A/B/Table.java | 61 ----- .../root1/A/B/Token.java | 47 ---- .../root1/A/B/TokenConstants.java | 8 - .../root1/B/Table.java | 61 ----- .../root1/B/Token.java | 47 ---- .../root1/B/TokenConstants.java | 8 - .../root2/B/Match.java | 54 ---- .../root2/B/Matches.java | 59 ----- .../root2/B/Structure.java | 120 --------- .../root2/B/Submission.java | 206 --------------- .../root2/B/Table.java | 53 ---- .../root2/B/Token.java | 44 ---- .../root2/B/TokenConstants.java | 12 - 183 files changed, 1 insertion(+), 15730 deletions(-) delete mode 100644 core/src/main/java/de/jplag/PreventSameRootName.java delete mode 100644 core/src/test/java/de/jplag/PreventSameRootNameTest.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/GSTiling.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/GSTiling.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/GSTiling.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/GSTiling.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/GSTiling.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/GSTiling.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/GSTiling.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/GSTiling.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/GSTiling.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/GSTiling.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/GSTiling.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/TokenConstants.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Match.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Matches.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Structure.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Submission.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Table.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Token.java delete mode 100644 core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/TokenConstants.java diff --git a/core/src/main/java/de/jplag/JPlag.java b/core/src/main/java/de/jplag/JPlag.java index d37b48aae..137e6b11c 100644 --- a/core/src/main/java/de/jplag/JPlag.java +++ b/core/src/main/java/de/jplag/JPlag.java @@ -7,7 +7,6 @@ import de.jplag.clustering.ClusteringFactory; import de.jplag.exceptions.ExitException; -import de.jplag.exceptions.RootDirectoryException; import de.jplag.exceptions.SubmissionException; import de.jplag.options.JPlagOptions; import de.jplag.reporting.reportobject.model.Version; @@ -39,13 +38,7 @@ private static Version loadVersion() { * @param options determines the parameterization. */ public JPlag(JPlagOptions options) { - PreventSameRootName preventSameRootName = null; - try { - preventSameRootName = new PreventSameRootName(options); - } catch (RootDirectoryException e) { - e.printStackTrace(); - } - this.options = preventSameRootName.getOptions(); + this.options = options; language = this.options.language(); GreedyStringTiling coreAlgorithm = new GreedyStringTiling(options); comparisonStrategy = new ParallelComparisonStrategy(options, coreAlgorithm); diff --git a/core/src/main/java/de/jplag/PreventSameRootName.java b/core/src/main/java/de/jplag/PreventSameRootName.java deleted file mode 100644 index fe7795aa8..000000000 --- a/core/src/main/java/de/jplag/PreventSameRootName.java +++ /dev/null @@ -1,141 +0,0 @@ -package de.jplag; - -import java.io.File; -import java.nio.file.Path; -import java.util.*; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import de.jplag.exceptions.RootDirectoryException; -import de.jplag.options.JPlagOptions; - -/** - * This class prevents the same root name of submissions. - */ -public class PreventSameRootName { - private static final Logger logger = LoggerFactory.getLogger(PreventSameRootName.class); - - private final Map statistic = new HashMap<>(); // uses to store information of same roots (Key: same root name ---> Value: number - // of the same root name) - private final JPlagOptions options; - - /** - * Creates and initializes a PreventSameRootName instance, parameterized by a set of options. If there are same names of - * root directories, they will be re-named before generating zip file and IDs. (e.g. two same root names: root ===> - * root_1 && root_2) - * @param options determines the parameterization - */ - public PreventSameRootName(JPlagOptions options) throws RootDirectoryException { - Set newChangedSubmissionDirectories; - Set oldChangedSubmissionDirectories; - Set newSubmissionDirectories = options.submissionDirectories(); - Set oldSubmissionDirectories = options.oldSubmissionDirectories(); - if (oldSubmissionDirectories == null && newSubmissionDirectories == null) { - throw new RootDirectoryException("No submission"); - } - boolean hasSameRoots = false; - hasSameRoots = hasSameRoots(newSubmissionDirectories, oldSubmissionDirectories); - if (hasSameRoots) { - logger.info("Detected same name of root directories, the name will be re-named..."); - newChangedSubmissionDirectories = renameRoots(newSubmissionDirectories); - oldChangedSubmissionDirectories = renameRoots(oldSubmissionDirectories); - } else { - newChangedSubmissionDirectories = newSubmissionDirectories; - oldChangedSubmissionDirectories = oldSubmissionDirectories; - } - this.options = new JPlagOptions(options.language(), options.minimumTokenMatch(), newChangedSubmissionDirectories, - oldChangedSubmissionDirectories, options.baseCodeSubmissionDirectory(), options.subdirectoryName(), options.fileSuffixes(), - options.exclusionFileName(), options.similarityMetric(), options.similarityThreshold(), options.maximumNumberOfComparisons(), - options.clusteringOptions(), options.debugParser()); - } - - /** - * @return a new options instance - */ - public JPlagOptions getOptions() { - return options; - } - - /** - * @return the statistic map - */ - public Map getStatistic() { - return statistic; - } - - /** - * Counts the root directory names and their number with Map(named statistic). - * @param submissionDirectories SubmissionDirectories that need to be counted - */ - public void rootsClassification(Set submissionDirectories) { - if (submissionDirectories == null) - return; - for (File submissionDirectory : submissionDirectories) { - String rootDirectory = getRootName(submissionDirectory); - statistic.put(rootDirectory, statistic.getOrDefault(rootDirectory, 0) + 1); - } - } - - /** - * Renames the same root directory name. - * @param submissionDirectories SubmissionDirectories that need to be re-named - * @return SubmissionDirectories that have been re-named - */ - public Set renameRoots(Set submissionDirectories) { - if (submissionDirectories == null) - return Set.of(); - Set set = new HashSet<>(); - for (File submissionDirectory : submissionDirectories) { - String rootDirectory = getRootName(submissionDirectory); - int index = statistic.getOrDefault(rootDirectory, -1); - if (index == -1) - continue; - String newRootDirectory = rootDirectory + "_" + index; - statistic.put(rootDirectory, statistic.get(rootDirectory) - 1); - File newFile = new File(Path.of(submissionDirectory.getParent(), newRootDirectory).toString()); - set.add(newFile); - submissionDirectory.renameTo(newFile); - logger.info("Original submission path ===> Current submission path:" + submissionDirectory.getPath() + " ===> " + newFile.getPath()); - } - return Set.copyOf(set); - } - - /** - * Gets root name of a submissionDirectory. - * @param submissionDirectory A single submissionDirectory - * @return Root name of the submission - */ - public String getRootName(File submissionDirectory) { - return submissionDirectory.getPath().substring(submissionDirectory.getParent().length() + 1); - } - - /** - * Determines if there are the same root directories. - * @param newSubmissionDirectories The new submissionDirectories - * @param oldSubmissionDirectories The old submissionDirectories - * @return True, if there are the same root directories. False, otherwise. - */ - public boolean hasSameRoots(Set newSubmissionDirectories, Set oldSubmissionDirectories) throws RootDirectoryException { - checkDirectoryExist(newSubmissionDirectories); - checkDirectoryExist(oldSubmissionDirectories); - rootsClassification(newSubmissionDirectories); - rootsClassification(oldSubmissionDirectories); - Set> entries = statistic.entrySet(); - entries.removeIf(entry -> entry.getValue() == 1); - return !statistic.isEmpty(); - } - - /** - * Checks if directories exist. If not, throws RootDirectoryException. - * @param submissionDirectories The submissionDirectories which needs to be checked - */ - public void checkDirectoryExist(Set submissionDirectories) throws RootDirectoryException { - for (File submissionDirectory : submissionDirectories) { - boolean exists = submissionDirectory.exists(); - if (!exists) { - throw new RootDirectoryException("Submission Directory doesn't exist: " + submissionDirectory.getPath()); - } - } - } -} diff --git a/core/src/test/java/de/jplag/PreventSameRootNameTest.java b/core/src/test/java/de/jplag/PreventSameRootNameTest.java deleted file mode 100644 index da91a86f4..000000000 --- a/core/src/test/java/de/jplag/PreventSameRootNameTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package de.jplag; - -import static org.junit.jupiter.api.Assertions.fail; - -import java.io.File; -import java.nio.file.Path; -import java.util.Set; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -import de.jplag.exceptions.RootDirectoryException; -import de.jplag.options.JPlagOptions; - -/** - * Test for the same root cases that will be re-named. - */ -public class PreventSameRootNameTest extends TestBase { - - private static final JPlagOptions BASEOPTIONS = new JPlagOptions(new de.jplag.java.Language(), Set.of(), Set.of()); - private static final String NOTEXISTDIRECTORY = Path.of(TestBase.BASE_PATH, "basecode", "NotExistDirectory").toString(); - private static final String SAMPLE_SAMEROOTNAME_1 = Path.of(TestBase.BASE_PATH, "SameRootName", "2019", "root").toString(); - private static final String SAMPLE_SAMEROOTNAME_2 = Path.of(TestBase.BASE_PATH, "SameRootName", "2020", "root").toString(); - - @Test - @DisplayName("test same root directory with withSubmissionDirectories options") - void testSameRootWithNew() { - JPlagOptions options = BASEOPTIONS.withSubmissionDirectories(Set.of(new File(SAMPLE_SAMEROOTNAME_1), new File(SAMPLE_SAMEROOTNAME_2))); - try { - PreventSameRootName preventSameRootName = new PreventSameRootName(options); - JPlagOptions newOptions = preventSameRootName.getOptions(); - File submissionDirectory_2 = options.submissionDirectories().stream().toList().get(0); - File submissionDirectory_1 = options.submissionDirectories().stream().toList().get(1); - File newChangedSubmissionDirectory_2 = newOptions.submissionDirectories().stream().toList().get(0); - File newChangedSubmissionDirectory_1 = newOptions.submissionDirectories().stream().toList().get(1); - Assertions.assertEquals(submissionDirectory_2.getPath() + "_2", newChangedSubmissionDirectory_2.getPath()); - Assertions.assertEquals(submissionDirectory_1.getPath() + "_1", newChangedSubmissionDirectory_1.getPath()); - } catch (RootDirectoryException e) { - fail("PreventSameRootName Class threw an exception:", e); - } - } - - @Test - @DisplayName("test same root directory with withSubmissionDirectories and oldSubmissionDirectories options") - void testSameRootWithNewAndOld() { - JPlagOptions options = BASEOPTIONS.withSubmissionDirectories(Set.of(new File(SAMPLE_SAMEROOTNAME_2))) - .withOldSubmissionDirectories(Set.of(new File(SAMPLE_SAMEROOTNAME_1))); - try { - PreventSameRootName preventSameRootName = new PreventSameRootName(options); - JPlagOptions newOptions = preventSameRootName.getOptions(); - File oldSubmissionDirectory = options.oldSubmissionDirectories().stream().toList().get(0); - File submissionDirectory = options.submissionDirectories().stream().toList().get(0); - File newChangedOldSubmissionDirectory = newOptions.oldSubmissionDirectories().stream().toList().get(0); - File newChangedSubmissionDirectory = newOptions.submissionDirectories().stream().toList().get(0); - Assertions.assertEquals(submissionDirectory.getPath() + "_2", newChangedSubmissionDirectory.getPath()); - Assertions.assertEquals(oldSubmissionDirectory.getPath() + "_1", newChangedOldSubmissionDirectory.getPath()); - } catch (RootDirectoryException e) { - fail("PreventSameRootName Class threw an exception:", e); - } - } - - @Test - @DisplayName("test not existed root directory with withSubmissionDirectories option") - void testCheckDirectoryExistWithNewSubmissionDirectories() { - JPlagOptions options = BASEOPTIONS.withSubmissionDirectories(Set.of(new File(NOTEXISTDIRECTORY))); - testRootDirectoryException(options); - } - - @Test - @DisplayName("test not existed root directory with withOldSubmissionDirectories option") - void testCheckDirectoryExistWithOldSubmissionDirectories() { - JPlagOptions options = BASEOPTIONS.withOldSubmissionDirectories(Set.of(new File(NOTEXISTDIRECTORY))); - testRootDirectoryException(options); - } - - /** - * Test RootDirectoryException for a given Jplag-options. - * @param options is the customized Jplag-options. - */ - void testRootDirectoryException(JPlagOptions options) { - RootDirectoryException exception = Assertions.assertThrows(RootDirectoryException.class, () -> new PreventSameRootName(options)); - Assertions.assertEquals("Submission Directory doesn't exist: " + NOTEXISTDIRECTORY, exception.getMessage()); - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/GSTiling.java deleted file mode 100644 index 3ca68224e..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/GSTiling.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Diese Klasse implementiert den GSTiling Algorithmus - * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", - * sowie "Matches" und "Match" ausgelegt - */ -public class GSTiling implements TokenConstants { - private Matches matches = new Matches(); - - /* - * creating hashes. - * The hash-code will be written in every Token for the next token. - * (includes the Token itself) - * Das Ganze laeuft in linearer Zeit. - * condition: 1 < hashLength < 26 !!! - */ - - public void create_hashes(Structure s, int hashLength, boolean makeTable) { - // Hier wird die obere Grenze der Hash-Laenge festgelegt. - // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl - // der Token. - if (hashLength<1) hashLength = 1; - hashLength = (hashLength<26 ? hashLength : 25); - - if (s.size()= hashLength) { - s.tokens[i].hash = hash; - s.table.add(hash, i); // add into hashtable - } else - s.tokens[i].hash = -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } else { - for (i=0; i= hashLength) ? hash : -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } - s.hash_length = hashLength; - } - - public final void compare(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - // first parameter should contain the smaller sequence!!! - private final void compare(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - if(true) { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - } else { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; - } - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 - || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j, hx, hy; - for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j > maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // begining of sequence A - int y = matches.matches[i].startB; // begining of sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--) - A[x++].marked = B[y++].marked = true; // mark all Token! - } - - } while (maxmatch != mml); - } - - public final void compareWithBasecode(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - private final void compareWithBasecode(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - // Initialize - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - - - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j,hx,hy; - for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j != maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // beginning in sequence A - int y = matches.matches[i].startB; // beginning in sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--){ - A[x].marked = B[y].marked = true; // mark all Token! - A[x].basecode = B[y].basecode= true; - x++; y++; - } - } - } while (maxmatch != mml); - - } - - public void resetBaseSubmission(Submission sub){ - Structure tmpStruct = sub.struct; - Token[] tok = tmpStruct.tokens; - for (int z = 0; z < tmpStruct.size()-1;z++){ - tok[z].basecode = false; - } - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Match.java deleted file mode 100644 index dc29ebfd4..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Match.java +++ /dev/null @@ -1,52 +0,0 @@ -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Matches.java deleted file mode 100644 index 55cecdfca..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Matches.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Structure.java deleted file mode 100644 index 4e0c4ce4c..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Structure.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Submission.java deleted file mode 100644 index bb2190e55..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Submission.java +++ /dev/null @@ -1,218 +0,0 @@ -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure struct; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void copySubmission() { - File errorDir = null; - try { - URL url = Submission.class.getResource("errors"); - errorDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!errorDir.exists()) - errorDir.mkdir(); - int i = 0; - File destDir; - while ((destDir = new File(errorDir, format.format(i))).exists()) - i++; - destDir.mkdir(); - for (i = 0; i < files.length; i++) - copyFile(new File(dir, files[i]), new File(destDir, files[i])); - } - - /* Physical copy. :-) */ - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream dis = new FileInputStream(in); - FileOutputStream dos = new FileOutputStream(out); - int count; - do { - count = dis.read(buffer); - if (count != -1) - dos.write(buffer, 0, count); - } while (count != -1); - dis.close(); - dos.close(); - } catch (IOException e) { - - } - } - - public int size() { - if (struct != null) - return structSize = struct.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] result = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - help = help.replaceAll("<", "<"); - help = help.replaceAll(">", ">"); - help = help.replaceAll("\"", """); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - result[i] = new String[text.size()]; - text.copyInto(result[i]); - } - return result; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] result = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - result[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - // TODO: Should an ExitException be thrown here? - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - } - return result; - } - - public int compareTo(Submission other) { - return name.compareTo(other.name); - } - - public String toString() { - return name; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character module. - // maybe other modules can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/A/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Match.java deleted file mode 100644 index 43fe9a6b1..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Match.java +++ /dev/null @@ -1,54 +0,0 @@ -package samples.PartialPlagiarism.D; - -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Matches.java deleted file mode 100644 index 1037e6b56..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Matches.java +++ /dev/null @@ -1,59 +0,0 @@ -package samples.PartialPlagiarism.D; - -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Structure.java deleted file mode 100644 index 64ca0cce3..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Structure.java +++ /dev/null @@ -1,120 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Submission.java deleted file mode 100644 index 20b954493..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Submission.java +++ /dev/null @@ -1,206 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure structure; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void doSmth() { - File failureDir = null; - try { - URL url = Submission.class.getResource("errors"); - failureDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!failureDir.exists()) - failureDir.mkdir(); - int i = 0; - } - - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream des = new FileInputStream(in); - FileOutputStream foo = new FileOutputStream(out); - int count; - do { - count = des.read(buffer); - if (count != -1) - foo.write(buffer, 0, count); - } while (count != -1); - des.close(); - foo.close(); - } catch (IOException e) { - System.out.println("Oh no!"); - } - } - - public int size() { - if (structure != null) - return structSize = structure.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] newName = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - System.out.println("Oh no!"); - } - newName[i] = new String[text.size()]; - text.copyInto(newName[i]); - } - return newName; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] variabl = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - variabl[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - System.out.println("Oh no"); - } catch (IOException e) { - - } - } - return variabl; - } - - @Override - public int compareTo(Submission o) { - return 0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Table.java deleted file mode 100644 index a5d49d4fd..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/Table.java +++ /dev/null @@ -1,53 +0,0 @@ -package samples.PartialPlagiarism.D;//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] foo; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - foo = new int[this.size][]; - } - - private final void addTo(int index, int datum) { - if (foo[index]==null) { // new element - foo[index] = new int[4]; - foo[index][0] = 0; - } else - ensureCapacity(index, foo[index][0] + 2); - - foo[index][++foo[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int old = foo[index].length; - if (minCapacity > old) { - int[] oldData = foo[index]; - int newCapacity = (old + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - foo[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, foo[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // This is original work not copied - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/TokenConstants.java deleted file mode 100644 index 230cd2612..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2016/same/D/TokenConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package samples.PartialPlagiarism.D; - -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; - - final static int ANOTHER_TOKEN = 42; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/GSTiling.java deleted file mode 100644 index 3ca68224e..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/GSTiling.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Diese Klasse implementiert den GSTiling Algorithmus - * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", - * sowie "Matches" und "Match" ausgelegt - */ -public class GSTiling implements TokenConstants { - private Matches matches = new Matches(); - - /* - * creating hashes. - * The hash-code will be written in every Token for the next token. - * (includes the Token itself) - * Das Ganze laeuft in linearer Zeit. - * condition: 1 < hashLength < 26 !!! - */ - - public void create_hashes(Structure s, int hashLength, boolean makeTable) { - // Hier wird die obere Grenze der Hash-Laenge festgelegt. - // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl - // der Token. - if (hashLength<1) hashLength = 1; - hashLength = (hashLength<26 ? hashLength : 25); - - if (s.size()= hashLength) { - s.tokens[i].hash = hash; - s.table.add(hash, i); // add into hashtable - } else - s.tokens[i].hash = -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } else { - for (i=0; i= hashLength) ? hash : -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } - s.hash_length = hashLength; - } - - public final void compare(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - // first parameter should contain the smaller sequence!!! - private final void compare(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - if(true) { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - } else { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; - } - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 - || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j, hx, hy; - for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j > maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // begining of sequence A - int y = matches.matches[i].startB; // begining of sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--) - A[x++].marked = B[y++].marked = true; // mark all Token! - } - - } while (maxmatch != mml); - } - - public final void compareWithBasecode(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - private final void compareWithBasecode(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - // Initialize - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - - - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j,hx,hy; - for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j != maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // beginning in sequence A - int y = matches.matches[i].startB; // beginning in sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--){ - A[x].marked = B[y].marked = true; // mark all Token! - A[x].basecode = B[y].basecode= true; - x++; y++; - } - } - } while (maxmatch != mml); - - } - - public void resetBaseSubmission(Submission sub){ - Structure tmpStruct = sub.struct; - Token[] tok = tmpStruct.tokens; - for (int z = 0; z < tmpStruct.size()-1;z++){ - tok[z].basecode = false; - } - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Match.java deleted file mode 100644 index dc29ebfd4..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Match.java +++ /dev/null @@ -1,52 +0,0 @@ -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Matches.java deleted file mode 100644 index 55cecdfca..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Matches.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Structure.java deleted file mode 100644 index 4e0c4ce4c..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Structure.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Submission.java deleted file mode 100644 index bb2190e55..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Submission.java +++ /dev/null @@ -1,218 +0,0 @@ -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure struct; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void copySubmission() { - File errorDir = null; - try { - URL url = Submission.class.getResource("errors"); - errorDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!errorDir.exists()) - errorDir.mkdir(); - int i = 0; - File destDir; - while ((destDir = new File(errorDir, format.format(i))).exists()) - i++; - destDir.mkdir(); - for (i = 0; i < files.length; i++) - copyFile(new File(dir, files[i]), new File(destDir, files[i])); - } - - /* Physical copy. :-) */ - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream dis = new FileInputStream(in); - FileOutputStream dos = new FileOutputStream(out); - int count; - do { - count = dis.read(buffer); - if (count != -1) - dos.write(buffer, 0, count); - } while (count != -1); - dis.close(); - dos.close(); - } catch (IOException e) { - - } - } - - public int size() { - if (struct != null) - return structSize = struct.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] result = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - help = help.replaceAll("<", "<"); - help = help.replaceAll(">", ">"); - help = help.replaceAll("\"", """); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - result[i] = new String[text.size()]; - text.copyInto(result[i]); - } - return result; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] result = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - result[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - // TODO: Should an ExitException be thrown here? - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - } - return result; - } - - public int compareTo(Submission other) { - return name.compareTo(other.name); - } - - public String toString() { - return name; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character module. - // maybe other modules can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/A/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Match.java deleted file mode 100644 index 43fe9a6b1..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Match.java +++ /dev/null @@ -1,54 +0,0 @@ -package samples.PartialPlagiarism.D; - -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Matches.java deleted file mode 100644 index 1037e6b56..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Matches.java +++ /dev/null @@ -1,59 +0,0 @@ -package samples.PartialPlagiarism.D; - -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Structure.java deleted file mode 100644 index 64ca0cce3..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Structure.java +++ /dev/null @@ -1,120 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Submission.java deleted file mode 100644 index 20b954493..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Submission.java +++ /dev/null @@ -1,206 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure structure; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void doSmth() { - File failureDir = null; - try { - URL url = Submission.class.getResource("errors"); - failureDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!failureDir.exists()) - failureDir.mkdir(); - int i = 0; - } - - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream des = new FileInputStream(in); - FileOutputStream foo = new FileOutputStream(out); - int count; - do { - count = des.read(buffer); - if (count != -1) - foo.write(buffer, 0, count); - } while (count != -1); - des.close(); - foo.close(); - } catch (IOException e) { - System.out.println("Oh no!"); - } - } - - public int size() { - if (structure != null) - return structSize = structure.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] newName = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - System.out.println("Oh no!"); - } - newName[i] = new String[text.size()]; - text.copyInto(newName[i]); - } - return newName; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] variabl = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - variabl[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - System.out.println("Oh no"); - } catch (IOException e) { - - } - } - return variabl; - } - - @Override - public int compareTo(Submission o) { - return 0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Table.java deleted file mode 100644 index a5d49d4fd..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/Table.java +++ /dev/null @@ -1,53 +0,0 @@ -package samples.PartialPlagiarism.D;//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] foo; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - foo = new int[this.size][]; - } - - private final void addTo(int index, int datum) { - if (foo[index]==null) { // new element - foo[index] = new int[4]; - foo[index][0] = 0; - } else - ensureCapacity(index, foo[index][0] + 2); - - foo[index][++foo[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int old = foo[index].length; - if (minCapacity > old) { - int[] oldData = foo[index]; - int newCapacity = (old + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - foo[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, foo[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // This is original work not copied - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/TokenConstants.java deleted file mode 100644 index 230cd2612..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2017/same/D/TokenConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package samples.PartialPlagiarism.D; - -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; - - final static int ANOTHER_TOKEN = 42; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character front end. - // maybe other front ends can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/root/B/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/GSTiling.java deleted file mode 100644 index 3ca68224e..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/GSTiling.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Diese Klasse implementiert den GSTiling Algorithmus - * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", - * sowie "Matches" und "Match" ausgelegt - */ -public class GSTiling implements TokenConstants { - private Matches matches = new Matches(); - - /* - * creating hashes. - * The hash-code will be written in every Token for the next token. - * (includes the Token itself) - * Das Ganze laeuft in linearer Zeit. - * condition: 1 < hashLength < 26 !!! - */ - - public void create_hashes(Structure s, int hashLength, boolean makeTable) { - // Hier wird die obere Grenze der Hash-Laenge festgelegt. - // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl - // der Token. - if (hashLength<1) hashLength = 1; - hashLength = (hashLength<26 ? hashLength : 25); - - if (s.size()= hashLength) { - s.tokens[i].hash = hash; - s.table.add(hash, i); // add into hashtable - } else - s.tokens[i].hash = -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } else { - for (i=0; i= hashLength) ? hash : -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } - s.hash_length = hashLength; - } - - public final void compare(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - // first parameter should contain the smaller sequence!!! - private final void compare(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - if(true) { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - } else { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; - } - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 - || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j, hx, hy; - for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j > maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // begining of sequence A - int y = matches.matches[i].startB; // begining of sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--) - A[x++].marked = B[y++].marked = true; // mark all Token! - } - - } while (maxmatch != mml); - } - - public final void compareWithBasecode(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - private final void compareWithBasecode(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - // Initialize - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - - - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j,hx,hy; - for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j != maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // beginning in sequence A - int y = matches.matches[i].startB; // beginning in sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--){ - A[x].marked = B[y].marked = true; // mark all Token! - A[x].basecode = B[y].basecode= true; - x++; y++; - } - } - } while (maxmatch != mml); - - } - - public void resetBaseSubmission(Submission sub){ - Structure tmpStruct = sub.struct; - Token[] tok = tmpStruct.tokens; - for (int z = 0; z < tmpStruct.size()-1;z++){ - tok[z].basecode = false; - } - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Match.java deleted file mode 100644 index dc29ebfd4..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Match.java +++ /dev/null @@ -1,52 +0,0 @@ -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Matches.java deleted file mode 100644 index 55cecdfca..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Matches.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Structure.java deleted file mode 100644 index 4e0c4ce4c..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Structure.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Submission.java deleted file mode 100644 index bb2190e55..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Submission.java +++ /dev/null @@ -1,218 +0,0 @@ -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure struct; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void copySubmission() { - File errorDir = null; - try { - URL url = Submission.class.getResource("errors"); - errorDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!errorDir.exists()) - errorDir.mkdir(); - int i = 0; - File destDir; - while ((destDir = new File(errorDir, format.format(i))).exists()) - i++; - destDir.mkdir(); - for (i = 0; i < files.length; i++) - copyFile(new File(dir, files[i]), new File(destDir, files[i])); - } - - /* Physical copy. :-) */ - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream dis = new FileInputStream(in); - FileOutputStream dos = new FileOutputStream(out); - int count; - do { - count = dis.read(buffer); - if (count != -1) - dos.write(buffer, 0, count); - } while (count != -1); - dis.close(); - dos.close(); - } catch (IOException e) { - - } - } - - public int size() { - if (struct != null) - return structSize = struct.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] result = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - help = help.replaceAll("<", "<"); - help = help.replaceAll(">", ">"); - help = help.replaceAll("\"", """); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - result[i] = new String[text.size()]; - text.copyInto(result[i]); - } - return result; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] result = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - result[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - // TODO: Should an ExitException be thrown here? - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - } - return result; - } - - public int compareTo(Submission other) { - return name.compareTo(other.name); - } - - public String toString() { - return name; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character module. - // maybe other modules can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/A/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Match.java deleted file mode 100644 index 43fe9a6b1..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Match.java +++ /dev/null @@ -1,54 +0,0 @@ -package samples.PartialPlagiarism.D; - -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Matches.java deleted file mode 100644 index 1037e6b56..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Matches.java +++ /dev/null @@ -1,59 +0,0 @@ -package samples.PartialPlagiarism.D; - -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Structure.java deleted file mode 100644 index 64ca0cce3..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Structure.java +++ /dev/null @@ -1,120 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Submission.java deleted file mode 100644 index 20b954493..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Submission.java +++ /dev/null @@ -1,206 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure structure; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void doSmth() { - File failureDir = null; - try { - URL url = Submission.class.getResource("errors"); - failureDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!failureDir.exists()) - failureDir.mkdir(); - int i = 0; - } - - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream des = new FileInputStream(in); - FileOutputStream foo = new FileOutputStream(out); - int count; - do { - count = des.read(buffer); - if (count != -1) - foo.write(buffer, 0, count); - } while (count != -1); - des.close(); - foo.close(); - } catch (IOException e) { - System.out.println("Oh no!"); - } - } - - public int size() { - if (structure != null) - return structSize = structure.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] newName = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - System.out.println("Oh no!"); - } - newName[i] = new String[text.size()]; - text.copyInto(newName[i]); - } - return newName; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] variabl = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - variabl[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - System.out.println("Oh no"); - } catch (IOException e) { - - } - } - return variabl; - } - - @Override - public int compareTo(Submission o) { - return 0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Table.java deleted file mode 100644 index a5d49d4fd..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/Table.java +++ /dev/null @@ -1,53 +0,0 @@ -package samples.PartialPlagiarism.D;//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] foo; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - foo = new int[this.size][]; - } - - private final void addTo(int index, int datum) { - if (foo[index]==null) { // new element - foo[index] = new int[4]; - foo[index][0] = 0; - } else - ensureCapacity(index, foo[index][0] + 2); - - foo[index][++foo[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int old = foo[index].length; - if (minCapacity > old) { - int[] oldData = foo[index]; - int newCapacity = (old + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - foo[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, foo[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // This is original work not copied - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/TokenConstants.java deleted file mode 100644 index 230cd2612..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2018/same/D/TokenConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package samples.PartialPlagiarism.D; - -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; - - final static int ANOTHER_TOKEN = 42; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/GSTiling.java deleted file mode 100644 index 3ca68224e..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/GSTiling.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Diese Klasse implementiert den GSTiling Algorithmus - * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", - * sowie "Matches" und "Match" ausgelegt - */ -public class GSTiling implements TokenConstants { - private Matches matches = new Matches(); - - /* - * creating hashes. - * The hash-code will be written in every Token for the next token. - * (includes the Token itself) - * Das Ganze laeuft in linearer Zeit. - * condition: 1 < hashLength < 26 !!! - */ - - public void create_hashes(Structure s, int hashLength, boolean makeTable) { - // Hier wird die obere Grenze der Hash-Laenge festgelegt. - // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl - // der Token. - if (hashLength<1) hashLength = 1; - hashLength = (hashLength<26 ? hashLength : 25); - - if (s.size()= hashLength) { - s.tokens[i].hash = hash; - s.table.add(hash, i); // add into hashtable - } else - s.tokens[i].hash = -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } else { - for (i=0; i= hashLength) ? hash : -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } - s.hash_length = hashLength; - } - - public final void compare(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - // first parameter should contain the smaller sequence!!! - private final void compare(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - if(true) { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - } else { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; - } - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 - || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j, hx, hy; - for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j > maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // begining of sequence A - int y = matches.matches[i].startB; // begining of sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--) - A[x++].marked = B[y++].marked = true; // mark all Token! - } - - } while (maxmatch != mml); - } - - public final void compareWithBasecode(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - private final void compareWithBasecode(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - // Initialize - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - - - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j,hx,hy; - for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j != maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // beginning in sequence A - int y = matches.matches[i].startB; // beginning in sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--){ - A[x].marked = B[y].marked = true; // mark all Token! - A[x].basecode = B[y].basecode= true; - x++; y++; - } - } - } while (maxmatch != mml); - - } - - public void resetBaseSubmission(Submission sub){ - Structure tmpStruct = sub.struct; - Token[] tok = tmpStruct.tokens; - for (int z = 0; z < tmpStruct.size()-1;z++){ - tok[z].basecode = false; - } - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Match.java deleted file mode 100644 index dc29ebfd4..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Match.java +++ /dev/null @@ -1,52 +0,0 @@ -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Matches.java deleted file mode 100644 index 55cecdfca..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Matches.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Structure.java deleted file mode 100644 index 4e0c4ce4c..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Structure.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Submission.java deleted file mode 100644 index bb2190e55..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Submission.java +++ /dev/null @@ -1,218 +0,0 @@ -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure struct; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void copySubmission() { - File errorDir = null; - try { - URL url = Submission.class.getResource("errors"); - errorDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!errorDir.exists()) - errorDir.mkdir(); - int i = 0; - File destDir; - while ((destDir = new File(errorDir, format.format(i))).exists()) - i++; - destDir.mkdir(); - for (i = 0; i < files.length; i++) - copyFile(new File(dir, files[i]), new File(destDir, files[i])); - } - - /* Physical copy. :-) */ - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream dis = new FileInputStream(in); - FileOutputStream dos = new FileOutputStream(out); - int count; - do { - count = dis.read(buffer); - if (count != -1) - dos.write(buffer, 0, count); - } while (count != -1); - dis.close(); - dos.close(); - } catch (IOException e) { - - } - } - - public int size() { - if (struct != null) - return structSize = struct.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] result = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - help = help.replaceAll("<", "<"); - help = help.replaceAll(">", ">"); - help = help.replaceAll("\"", """); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - result[i] = new String[text.size()]; - text.copyInto(result[i]); - } - return result; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] result = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - result[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - // TODO: Should an ExitException be thrown here? - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - } - return result; - } - - public int compareTo(Submission other) { - return name.compareTo(other.name); - } - - public String toString() { - return name; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character module. - // maybe other modules can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/A/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Match.java deleted file mode 100644 index 43fe9a6b1..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Match.java +++ /dev/null @@ -1,54 +0,0 @@ -package samples.PartialPlagiarism.D; - -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Matches.java deleted file mode 100644 index 1037e6b56..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Matches.java +++ /dev/null @@ -1,59 +0,0 @@ -package samples.PartialPlagiarism.D; - -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Structure.java deleted file mode 100644 index 64ca0cce3..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Structure.java +++ /dev/null @@ -1,120 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Submission.java deleted file mode 100644 index 20b954493..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Submission.java +++ /dev/null @@ -1,206 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure structure; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void doSmth() { - File failureDir = null; - try { - URL url = Submission.class.getResource("errors"); - failureDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!failureDir.exists()) - failureDir.mkdir(); - int i = 0; - } - - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream des = new FileInputStream(in); - FileOutputStream foo = new FileOutputStream(out); - int count; - do { - count = des.read(buffer); - if (count != -1) - foo.write(buffer, 0, count); - } while (count != -1); - des.close(); - foo.close(); - } catch (IOException e) { - System.out.println("Oh no!"); - } - } - - public int size() { - if (structure != null) - return structSize = structure.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] newName = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - System.out.println("Oh no!"); - } - newName[i] = new String[text.size()]; - text.copyInto(newName[i]); - } - return newName; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] variabl = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - variabl[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - System.out.println("Oh no"); - } catch (IOException e) { - - } - } - return variabl; - } - - @Override - public int compareTo(Submission o) { - return 0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Table.java deleted file mode 100644 index a5d49d4fd..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/Table.java +++ /dev/null @@ -1,53 +0,0 @@ -package samples.PartialPlagiarism.D;//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] foo; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - foo = new int[this.size][]; - } - - private final void addTo(int index, int datum) { - if (foo[index]==null) { // new element - foo[index] = new int[4]; - foo[index][0] = 0; - } else - ensureCapacity(index, foo[index][0] + 2); - - foo[index][++foo[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int old = foo[index].length; - if (minCapacity > old) { - int[] oldData = foo[index]; - int newCapacity = (old + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - foo[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, foo[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // This is original work not copied - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/TokenConstants.java deleted file mode 100644 index 230cd2612..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/root/D/TokenConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package samples.PartialPlagiarism.D; - -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; - - final static int ANOTHER_TOKEN = 42; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/GSTiling.java deleted file mode 100644 index 3ca68224e..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/GSTiling.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Diese Klasse implementiert den GSTiling Algorithmus - * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", - * sowie "Matches" und "Match" ausgelegt - */ -public class GSTiling implements TokenConstants { - private Matches matches = new Matches(); - - /* - * creating hashes. - * The hash-code will be written in every Token for the next token. - * (includes the Token itself) - * Das Ganze laeuft in linearer Zeit. - * condition: 1 < hashLength < 26 !!! - */ - - public void create_hashes(Structure s, int hashLength, boolean makeTable) { - // Hier wird die obere Grenze der Hash-Laenge festgelegt. - // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl - // der Token. - if (hashLength<1) hashLength = 1; - hashLength = (hashLength<26 ? hashLength : 25); - - if (s.size()= hashLength) { - s.tokens[i].hash = hash; - s.table.add(hash, i); // add into hashtable - } else - s.tokens[i].hash = -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } else { - for (i=0; i= hashLength) ? hash : -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } - s.hash_length = hashLength; - } - - public final void compare(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - // first parameter should contain the smaller sequence!!! - private final void compare(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - if(true) { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - } else { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; - } - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 - || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j, hx, hy; - for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j > maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // begining of sequence A - int y = matches.matches[i].startB; // begining of sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--) - A[x++].marked = B[y++].marked = true; // mark all Token! - } - - } while (maxmatch != mml); - } - - public final void compareWithBasecode(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - private final void compareWithBasecode(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - // Initialize - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - - - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j,hx,hy; - for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j != maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // beginning in sequence A - int y = matches.matches[i].startB; // beginning in sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--){ - A[x].marked = B[y].marked = true; // mark all Token! - A[x].basecode = B[y].basecode= true; - x++; y++; - } - } - } while (maxmatch != mml); - - } - - public void resetBaseSubmission(Submission sub){ - Structure tmpStruct = sub.struct; - Token[] tok = tmpStruct.tokens; - for (int z = 0; z < tmpStruct.size()-1;z++){ - tok[z].basecode = false; - } - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Match.java deleted file mode 100644 index dc29ebfd4..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Match.java +++ /dev/null @@ -1,52 +0,0 @@ -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Matches.java deleted file mode 100644 index 55cecdfca..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Matches.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Structure.java deleted file mode 100644 index 4e0c4ce4c..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Structure.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Submission.java deleted file mode 100644 index bb2190e55..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Submission.java +++ /dev/null @@ -1,218 +0,0 @@ -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure struct; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void copySubmission() { - File errorDir = null; - try { - URL url = Submission.class.getResource("errors"); - errorDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!errorDir.exists()) - errorDir.mkdir(); - int i = 0; - File destDir; - while ((destDir = new File(errorDir, format.format(i))).exists()) - i++; - destDir.mkdir(); - for (i = 0; i < files.length; i++) - copyFile(new File(dir, files[i]), new File(destDir, files[i])); - } - - /* Physical copy. :-) */ - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream dis = new FileInputStream(in); - FileOutputStream dos = new FileOutputStream(out); - int count; - do { - count = dis.read(buffer); - if (count != -1) - dos.write(buffer, 0, count); - } while (count != -1); - dis.close(); - dos.close(); - } catch (IOException e) { - - } - } - - public int size() { - if (struct != null) - return structSize = struct.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] result = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - help = help.replaceAll("<", "<"); - help = help.replaceAll(">", ">"); - help = help.replaceAll("\"", """); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - result[i] = new String[text.size()]; - text.copyInto(result[i]); - } - return result; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] result = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - result[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - // TODO: Should an ExitException be thrown here? - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - } - return result; - } - - public int compareTo(Submission other) { - return name.compareTo(other.name); - } - - public String toString() { - return name; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character module. - // maybe other modules can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/A/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Match.java deleted file mode 100644 index 43fe9a6b1..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Match.java +++ /dev/null @@ -1,54 +0,0 @@ -package samples.PartialPlagiarism.D; - -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Matches.java deleted file mode 100644 index 1037e6b56..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Matches.java +++ /dev/null @@ -1,59 +0,0 @@ -package samples.PartialPlagiarism.D; - -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Structure.java deleted file mode 100644 index 64ca0cce3..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Structure.java +++ /dev/null @@ -1,120 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Submission.java deleted file mode 100644 index 20b954493..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Submission.java +++ /dev/null @@ -1,206 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure structure; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void doSmth() { - File failureDir = null; - try { - URL url = Submission.class.getResource("errors"); - failureDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!failureDir.exists()) - failureDir.mkdir(); - int i = 0; - } - - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream des = new FileInputStream(in); - FileOutputStream foo = new FileOutputStream(out); - int count; - do { - count = des.read(buffer); - if (count != -1) - foo.write(buffer, 0, count); - } while (count != -1); - des.close(); - foo.close(); - } catch (IOException e) { - System.out.println("Oh no!"); - } - } - - public int size() { - if (structure != null) - return structSize = structure.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] newName = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - System.out.println("Oh no!"); - } - newName[i] = new String[text.size()]; - text.copyInto(newName[i]); - } - return newName; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] variabl = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - variabl[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - System.out.println("Oh no"); - } catch (IOException e) { - - } - } - return variabl; - } - - @Override - public int compareTo(Submission o) { - return 0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Table.java deleted file mode 100644 index a5d49d4fd..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/Table.java +++ /dev/null @@ -1,53 +0,0 @@ -package samples.PartialPlagiarism.D;//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] foo; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - foo = new int[this.size][]; - } - - private final void addTo(int index, int datum) { - if (foo[index]==null) { // new element - foo[index] = new int[4]; - foo[index][0] = 0; - } else - ensureCapacity(index, foo[index][0] + 2); - - foo[index][++foo[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int old = foo[index].length; - if (minCapacity > old) { - int[] oldData = foo[index]; - int newCapacity = (old + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - foo[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, foo[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // This is original work not copied - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/TokenConstants.java deleted file mode 100644 index 230cd2612..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2019/same/D/TokenConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package samples.PartialPlagiarism.D; - -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; - - final static int ANOTHER_TOKEN = 42; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character front end. - // maybe other front ends can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/root/B/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/GSTiling.java deleted file mode 100644 index 3ca68224e..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/GSTiling.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Diese Klasse implementiert den GSTiling Algorithmus - * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", - * sowie "Matches" und "Match" ausgelegt - */ -public class GSTiling implements TokenConstants { - private Matches matches = new Matches(); - - /* - * creating hashes. - * The hash-code will be written in every Token for the next token. - * (includes the Token itself) - * Das Ganze laeuft in linearer Zeit. - * condition: 1 < hashLength < 26 !!! - */ - - public void create_hashes(Structure s, int hashLength, boolean makeTable) { - // Hier wird die obere Grenze der Hash-Laenge festgelegt. - // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl - // der Token. - if (hashLength<1) hashLength = 1; - hashLength = (hashLength<26 ? hashLength : 25); - - if (s.size()= hashLength) { - s.tokens[i].hash = hash; - s.table.add(hash, i); // add into hashtable - } else - s.tokens[i].hash = -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } else { - for (i=0; i= hashLength) ? hash : -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } - s.hash_length = hashLength; - } - - public final void compare(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - // first parameter should contain the smaller sequence!!! - private final void compare(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - if(true) { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - } else { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; - } - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 - || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j, hx, hy; - for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j > maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // begining of sequence A - int y = matches.matches[i].startB; // begining of sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--) - A[x++].marked = B[y++].marked = true; // mark all Token! - } - - } while (maxmatch != mml); - } - - public final void compareWithBasecode(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - private final void compareWithBasecode(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - // Initialize - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - - - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j,hx,hy; - for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j != maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // beginning in sequence A - int y = matches.matches[i].startB; // beginning in sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--){ - A[x].marked = B[y].marked = true; // mark all Token! - A[x].basecode = B[y].basecode= true; - x++; y++; - } - } - } while (maxmatch != mml); - - } - - public void resetBaseSubmission(Submission sub){ - Structure tmpStruct = sub.struct; - Token[] tok = tmpStruct.tokens; - for (int z = 0; z < tmpStruct.size()-1;z++){ - tok[z].basecode = false; - } - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Match.java deleted file mode 100644 index dc29ebfd4..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Match.java +++ /dev/null @@ -1,52 +0,0 @@ -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Matches.java deleted file mode 100644 index 55cecdfca..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Matches.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Structure.java deleted file mode 100644 index 4e0c4ce4c..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Structure.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Submission.java deleted file mode 100644 index bb2190e55..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Submission.java +++ /dev/null @@ -1,218 +0,0 @@ -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure struct; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void copySubmission() { - File errorDir = null; - try { - URL url = Submission.class.getResource("errors"); - errorDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!errorDir.exists()) - errorDir.mkdir(); - int i = 0; - File destDir; - while ((destDir = new File(errorDir, format.format(i))).exists()) - i++; - destDir.mkdir(); - for (i = 0; i < files.length; i++) - copyFile(new File(dir, files[i]), new File(destDir, files[i])); - } - - /* Physical copy. :-) */ - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream dis = new FileInputStream(in); - FileOutputStream dos = new FileOutputStream(out); - int count; - do { - count = dis.read(buffer); - if (count != -1) - dos.write(buffer, 0, count); - } while (count != -1); - dis.close(); - dos.close(); - } catch (IOException e) { - - } - } - - public int size() { - if (struct != null) - return structSize = struct.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] result = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - help = help.replaceAll("<", "<"); - help = help.replaceAll(">", ">"); - help = help.replaceAll("\"", """); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - result[i] = new String[text.size()]; - text.copyInto(result[i]); - } - return result; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] result = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - result[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - // TODO: Should an ExitException be thrown here? - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - } - return result; - } - - public int compareTo(Submission other) { - return name.compareTo(other.name); - } - - public String toString() { - return name; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character module. - // maybe other modules can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/A/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Match.java deleted file mode 100644 index 43fe9a6b1..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Match.java +++ /dev/null @@ -1,54 +0,0 @@ -package samples.PartialPlagiarism.D; - -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Matches.java deleted file mode 100644 index 1037e6b56..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Matches.java +++ /dev/null @@ -1,59 +0,0 @@ -package samples.PartialPlagiarism.D; - -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Structure.java deleted file mode 100644 index 64ca0cce3..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Structure.java +++ /dev/null @@ -1,120 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Submission.java deleted file mode 100644 index 20b954493..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Submission.java +++ /dev/null @@ -1,206 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure structure; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void doSmth() { - File failureDir = null; - try { - URL url = Submission.class.getResource("errors"); - failureDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!failureDir.exists()) - failureDir.mkdir(); - int i = 0; - } - - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream des = new FileInputStream(in); - FileOutputStream foo = new FileOutputStream(out); - int count; - do { - count = des.read(buffer); - if (count != -1) - foo.write(buffer, 0, count); - } while (count != -1); - des.close(); - foo.close(); - } catch (IOException e) { - System.out.println("Oh no!"); - } - } - - public int size() { - if (structure != null) - return structSize = structure.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] newName = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - System.out.println("Oh no!"); - } - newName[i] = new String[text.size()]; - text.copyInto(newName[i]); - } - return newName; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] variabl = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - variabl[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - System.out.println("Oh no"); - } catch (IOException e) { - - } - } - return variabl; - } - - @Override - public int compareTo(Submission o) { - return 0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Table.java deleted file mode 100644 index a5d49d4fd..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/Table.java +++ /dev/null @@ -1,53 +0,0 @@ -package samples.PartialPlagiarism.D;//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] foo; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - foo = new int[this.size][]; - } - - private final void addTo(int index, int datum) { - if (foo[index]==null) { // new element - foo[index] = new int[4]; - foo[index][0] = 0; - } else - ensureCapacity(index, foo[index][0] + 2); - - foo[index][++foo[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int old = foo[index].length; - if (minCapacity > old) { - int[] oldData = foo[index]; - int newCapacity = (old + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - foo[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, foo[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // This is original work not copied - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/TokenConstants.java deleted file mode 100644 index 230cd2612..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2020/same/D/TokenConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package samples.PartialPlagiarism.D; - -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; - - final static int ANOTHER_TOKEN = 42; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/GSTiling.java deleted file mode 100644 index 3ca68224e..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/GSTiling.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Diese Klasse implementiert den GSTiling Algorithmus - * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", - * sowie "Matches" und "Match" ausgelegt - */ -public class GSTiling implements TokenConstants { - private Matches matches = new Matches(); - - /* - * creating hashes. - * The hash-code will be written in every Token for the next token. - * (includes the Token itself) - * Das Ganze laeuft in linearer Zeit. - * condition: 1 < hashLength < 26 !!! - */ - - public void create_hashes(Structure s, int hashLength, boolean makeTable) { - // Hier wird die obere Grenze der Hash-Laenge festgelegt. - // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl - // der Token. - if (hashLength<1) hashLength = 1; - hashLength = (hashLength<26 ? hashLength : 25); - - if (s.size()= hashLength) { - s.tokens[i].hash = hash; - s.table.add(hash, i); // add into hashtable - } else - s.tokens[i].hash = -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } else { - for (i=0; i= hashLength) ? hash : -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } - s.hash_length = hashLength; - } - - public final void compare(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - // first parameter should contain the smaller sequence!!! - private final void compare(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - if(true) { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - } else { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; - } - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 - || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j, hx, hy; - for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j > maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // begining of sequence A - int y = matches.matches[i].startB; // begining of sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--) - A[x++].marked = B[y++].marked = true; // mark all Token! - } - - } while (maxmatch != mml); - } - - public final void compareWithBasecode(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - private final void compareWithBasecode(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - // Initialize - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - - - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j,hx,hy; - for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j != maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // beginning in sequence A - int y = matches.matches[i].startB; // beginning in sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--){ - A[x].marked = B[y].marked = true; // mark all Token! - A[x].basecode = B[y].basecode= true; - x++; y++; - } - } - } while (maxmatch != mml); - - } - - public void resetBaseSubmission(Submission sub){ - Structure tmpStruct = sub.struct; - Token[] tok = tmpStruct.tokens; - for (int z = 0; z < tmpStruct.size()-1;z++){ - tok[z].basecode = false; - } - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Match.java deleted file mode 100644 index dc29ebfd4..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Match.java +++ /dev/null @@ -1,52 +0,0 @@ -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Matches.java deleted file mode 100644 index 55cecdfca..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Matches.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Structure.java deleted file mode 100644 index 4e0c4ce4c..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Structure.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Submission.java deleted file mode 100644 index bb2190e55..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Submission.java +++ /dev/null @@ -1,218 +0,0 @@ -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure struct; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void copySubmission() { - File errorDir = null; - try { - URL url = Submission.class.getResource("errors"); - errorDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!errorDir.exists()) - errorDir.mkdir(); - int i = 0; - File destDir; - while ((destDir = new File(errorDir, format.format(i))).exists()) - i++; - destDir.mkdir(); - for (i = 0; i < files.length; i++) - copyFile(new File(dir, files[i]), new File(destDir, files[i])); - } - - /* Physical copy. :-) */ - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream dis = new FileInputStream(in); - FileOutputStream dos = new FileOutputStream(out); - int count; - do { - count = dis.read(buffer); - if (count != -1) - dos.write(buffer, 0, count); - } while (count != -1); - dis.close(); - dos.close(); - } catch (IOException e) { - - } - } - - public int size() { - if (struct != null) - return structSize = struct.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] result = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - help = help.replaceAll("<", "<"); - help = help.replaceAll(">", ">"); - help = help.replaceAll("\"", """); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - result[i] = new String[text.size()]; - text.copyInto(result[i]); - } - return result; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] result = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - result[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - // TODO: Should an ExitException be thrown here? - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - } - return result; - } - - public int compareTo(Submission other) { - return name.compareTo(other.name); - } - - public String toString() { - return name; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character module. - // maybe other modules can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/A/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Match.java deleted file mode 100644 index 43fe9a6b1..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Match.java +++ /dev/null @@ -1,54 +0,0 @@ -package samples.PartialPlagiarism.D; - -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Matches.java deleted file mode 100644 index 1037e6b56..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Matches.java +++ /dev/null @@ -1,59 +0,0 @@ -package samples.PartialPlagiarism.D; - -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Structure.java deleted file mode 100644 index 64ca0cce3..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Structure.java +++ /dev/null @@ -1,120 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Submission.java deleted file mode 100644 index 20b954493..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Submission.java +++ /dev/null @@ -1,206 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure structure; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void doSmth() { - File failureDir = null; - try { - URL url = Submission.class.getResource("errors"); - failureDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!failureDir.exists()) - failureDir.mkdir(); - int i = 0; - } - - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream des = new FileInputStream(in); - FileOutputStream foo = new FileOutputStream(out); - int count; - do { - count = des.read(buffer); - if (count != -1) - foo.write(buffer, 0, count); - } while (count != -1); - des.close(); - foo.close(); - } catch (IOException e) { - System.out.println("Oh no!"); - } - } - - public int size() { - if (structure != null) - return structSize = structure.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] newName = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - System.out.println("Oh no!"); - } - newName[i] = new String[text.size()]; - text.copyInto(newName[i]); - } - return newName; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] variabl = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - variabl[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - System.out.println("Oh no"); - } catch (IOException e) { - - } - } - return variabl; - } - - @Override - public int compareTo(Submission o) { - return 0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Table.java deleted file mode 100644 index a5d49d4fd..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/Table.java +++ /dev/null @@ -1,53 +0,0 @@ -package samples.PartialPlagiarism.D;//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] foo; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - foo = new int[this.size][]; - } - - private final void addTo(int index, int datum) { - if (foo[index]==null) { // new element - foo[index] = new int[4]; - foo[index][0] = 0; - } else - ensureCapacity(index, foo[index][0] + 2); - - foo[index][++foo[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int old = foo[index].length; - if (minCapacity > old) { - int[] oldData = foo[index]; - int newCapacity = (old + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - foo[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, foo[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // This is original work not copied - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/TokenConstants.java deleted file mode 100644 index 230cd2612..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/root/D/TokenConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package samples.PartialPlagiarism.D; - -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; - - final static int ANOTHER_TOKEN = 42; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/GSTiling.java deleted file mode 100644 index 3ca68224e..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/GSTiling.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Diese Klasse implementiert den GSTiling Algorithmus - * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", - * sowie "Matches" und "Match" ausgelegt - */ -public class GSTiling implements TokenConstants { - private Matches matches = new Matches(); - - /* - * creating hashes. - * The hash-code will be written in every Token for the next token. - * (includes the Token itself) - * Das Ganze laeuft in linearer Zeit. - * condition: 1 < hashLength < 26 !!! - */ - - public void create_hashes(Structure s, int hashLength, boolean makeTable) { - // Hier wird die obere Grenze der Hash-Laenge festgelegt. - // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl - // der Token. - if (hashLength<1) hashLength = 1; - hashLength = (hashLength<26 ? hashLength : 25); - - if (s.size()= hashLength) { - s.tokens[i].hash = hash; - s.table.add(hash, i); // add into hashtable - } else - s.tokens[i].hash = -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } else { - for (i=0; i= hashLength) ? hash : -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } - s.hash_length = hashLength; - } - - public final void compare(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - // first parameter should contain the smaller sequence!!! - private final void compare(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - if(true) { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - } else { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; - } - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 - || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j, hx, hy; - for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j > maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // begining of sequence A - int y = matches.matches[i].startB; // begining of sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--) - A[x++].marked = B[y++].marked = true; // mark all Token! - } - - } while (maxmatch != mml); - } - - public final void compareWithBasecode(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - private final void compareWithBasecode(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - // Initialize - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - - - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j,hx,hy; - for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j != maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // beginning in sequence A - int y = matches.matches[i].startB; // beginning in sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--){ - A[x].marked = B[y].marked = true; // mark all Token! - A[x].basecode = B[y].basecode= true; - x++; y++; - } - } - } while (maxmatch != mml); - - } - - public void resetBaseSubmission(Submission sub){ - Structure tmpStruct = sub.struct; - Token[] tok = tmpStruct.tokens; - for (int z = 0; z < tmpStruct.size()-1;z++){ - tok[z].basecode = false; - } - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Match.java deleted file mode 100644 index dc29ebfd4..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Match.java +++ /dev/null @@ -1,52 +0,0 @@ -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Matches.java deleted file mode 100644 index 55cecdfca..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Matches.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Structure.java deleted file mode 100644 index 4e0c4ce4c..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Structure.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Submission.java deleted file mode 100644 index bb2190e55..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Submission.java +++ /dev/null @@ -1,218 +0,0 @@ -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure struct; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void copySubmission() { - File errorDir = null; - try { - URL url = Submission.class.getResource("errors"); - errorDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!errorDir.exists()) - errorDir.mkdir(); - int i = 0; - File destDir; - while ((destDir = new File(errorDir, format.format(i))).exists()) - i++; - destDir.mkdir(); - for (i = 0; i < files.length; i++) - copyFile(new File(dir, files[i]), new File(destDir, files[i])); - } - - /* Physical copy. :-) */ - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream dis = new FileInputStream(in); - FileOutputStream dos = new FileOutputStream(out); - int count; - do { - count = dis.read(buffer); - if (count != -1) - dos.write(buffer, 0, count); - } while (count != -1); - dis.close(); - dos.close(); - } catch (IOException e) { - - } - } - - public int size() { - if (struct != null) - return structSize = struct.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] result = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - help = help.replaceAll("<", "<"); - help = help.replaceAll(">", ">"); - help = help.replaceAll("\"", """); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - result[i] = new String[text.size()]; - text.copyInto(result[i]); - } - return result; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] result = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - result[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - // TODO: Should an ExitException be thrown here? - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - } - return result; - } - - public int compareTo(Submission other) { - return name.compareTo(other.name); - } - - public String toString() { - return name; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character module. - // maybe other modules can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/A/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Match.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Match.java deleted file mode 100644 index 43fe9a6b1..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Match.java +++ /dev/null @@ -1,54 +0,0 @@ -package samples.PartialPlagiarism.D; - -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Matches.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Matches.java deleted file mode 100644 index 1037e6b56..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Matches.java +++ /dev/null @@ -1,59 +0,0 @@ -package samples.PartialPlagiarism.D; - -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Structure.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Structure.java deleted file mode 100644 index 64ca0cce3..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Structure.java +++ /dev/null @@ -1,120 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Submission.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Submission.java deleted file mode 100644 index 20b954493..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Submission.java +++ /dev/null @@ -1,206 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure structure; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void doSmth() { - File failureDir = null; - try { - URL url = Submission.class.getResource("errors"); - failureDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!failureDir.exists()) - failureDir.mkdir(); - int i = 0; - } - - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream des = new FileInputStream(in); - FileOutputStream foo = new FileOutputStream(out); - int count; - do { - count = des.read(buffer); - if (count != -1) - foo.write(buffer, 0, count); - } while (count != -1); - des.close(); - foo.close(); - } catch (IOException e) { - System.out.println("Oh no!"); - } - } - - public int size() { - if (structure != null) - return structSize = structure.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] newName = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - System.out.println("Oh no!"); - } - newName[i] = new String[text.size()]; - text.copyInto(newName[i]); - } - return newName; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] variabl = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - variabl[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - System.out.println("Oh no"); - } catch (IOException e) { - - } - } - return variabl; - } - - @Override - public int compareTo(Submission o) { - return 0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Table.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Table.java deleted file mode 100644 index a5d49d4fd..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/Table.java +++ /dev/null @@ -1,53 +0,0 @@ -package samples.PartialPlagiarism.D;//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] foo; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - foo = new int[this.size][]; - } - - private final void addTo(int index, int datum) { - if (foo[index]==null) { // new element - foo[index] = new int[4]; - foo[index][0] = 0; - } else - ensureCapacity(index, foo[index][0] + 2); - - foo[index][++foo[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int old = foo[index].length; - if (minCapacity > old) { - int[] oldData = foo[index]; - int newCapacity = (old + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - foo[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, foo[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // This is original work not copied - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/TokenConstants.java deleted file mode 100644 index 230cd2612..000000000 --- a/core/src/test/resources/de/jplag/samples/MultipleSameRootName/2021/same/D/TokenConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package samples.PartialPlagiarism.D; - -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; - - final static int ANOTHER_TOKEN = 42; -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/GSTiling.java deleted file mode 100644 index 3ca68224e..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/GSTiling.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Diese Klasse implementiert den GSTiling Algorithmus - * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", - * sowie "Matches" und "Match" ausgelegt - */ -public class GSTiling implements TokenConstants { - private Matches matches = new Matches(); - - /* - * creating hashes. - * The hash-code will be written in every Token for the next token. - * (includes the Token itself) - * Das Ganze laeuft in linearer Zeit. - * condition: 1 < hashLength < 26 !!! - */ - - public void create_hashes(Structure s, int hashLength, boolean makeTable) { - // Hier wird die obere Grenze der Hash-Laenge festgelegt. - // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl - // der Token. - if (hashLength<1) hashLength = 1; - hashLength = (hashLength<26 ? hashLength : 25); - - if (s.size()= hashLength) { - s.tokens[i].hash = hash; - s.table.add(hash, i); // add into hashtable - } else - s.tokens[i].hash = -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } else { - for (i=0; i= hashLength) ? hash : -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } - s.hash_length = hashLength; - } - - public final void compare(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - // first parameter should contain the smaller sequence!!! - private final void compare(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - if(true) { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - } else { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; - } - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 - || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j, hx, hy; - for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j > maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // begining of sequence A - int y = matches.matches[i].startB; // begining of sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--) - A[x++].marked = B[y++].marked = true; // mark all Token! - } - - } while (maxmatch != mml); - } - - public final void compareWithBasecode(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - private final void compareWithBasecode(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - // Initialize - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - - - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j,hx,hy; - for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j != maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // beginning in sequence A - int y = matches.matches[i].startB; // beginning in sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--){ - A[x].marked = B[y].marked = true; // mark all Token! - A[x].basecode = B[y].basecode= true; - x++; y++; - } - } - } while (maxmatch != mml); - - } - - public void resetBaseSubmission(Submission sub){ - Structure tmpStruct = sub.struct; - Token[] tok = tmpStruct.tokens; - for (int z = 0; z < tmpStruct.size()-1;z++){ - tok[z].basecode = false; - } - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Match.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Match.java deleted file mode 100644 index dc29ebfd4..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Match.java +++ /dev/null @@ -1,52 +0,0 @@ -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Matches.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Matches.java deleted file mode 100644 index 55cecdfca..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Matches.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Structure.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Structure.java deleted file mode 100644 index 4e0c4ce4c..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Structure.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Submission.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Submission.java deleted file mode 100644 index bb2190e55..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Submission.java +++ /dev/null @@ -1,218 +0,0 @@ -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure struct; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void copySubmission() { - File errorDir = null; - try { - URL url = Submission.class.getResource("errors"); - errorDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!errorDir.exists()) - errorDir.mkdir(); - int i = 0; - File destDir; - while ((destDir = new File(errorDir, format.format(i))).exists()) - i++; - destDir.mkdir(); - for (i = 0; i < files.length; i++) - copyFile(new File(dir, files[i]), new File(destDir, files[i])); - } - - /* Physical copy. :-) */ - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream dis = new FileInputStream(in); - FileOutputStream dos = new FileOutputStream(out); - int count; - do { - count = dis.read(buffer); - if (count != -1) - dos.write(buffer, 0, count); - } while (count != -1); - dis.close(); - dos.close(); - } catch (IOException e) { - - } - } - - public int size() { - if (struct != null) - return structSize = struct.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] result = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - help = help.replaceAll("<", "<"); - help = help.replaceAll(">", ">"); - help = help.replaceAll("\"", """); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - result[i] = new String[text.size()]; - text.copyInto(result[i]); - } - return result; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] result = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - result[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - // TODO: Should an ExitException be thrown here? - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - } - return result; - } - - public int compareTo(Submission other) { - return name.compareTo(other.name); - } - - public String toString() { - return name; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Table.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character module. - // maybe other modules can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/A/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Match.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Match.java deleted file mode 100644 index 43fe9a6b1..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Match.java +++ /dev/null @@ -1,54 +0,0 @@ -package samples.PartialPlagiarism.D; - -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Matches.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Matches.java deleted file mode 100644 index 1037e6b56..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Matches.java +++ /dev/null @@ -1,59 +0,0 @@ -package samples.PartialPlagiarism.D; - -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Structure.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Structure.java deleted file mode 100644 index 64ca0cce3..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Structure.java +++ /dev/null @@ -1,120 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Submission.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Submission.java deleted file mode 100644 index 20b954493..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Submission.java +++ /dev/null @@ -1,206 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure structure; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void doSmth() { - File failureDir = null; - try { - URL url = Submission.class.getResource("errors"); - failureDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!failureDir.exists()) - failureDir.mkdir(); - int i = 0; - } - - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream des = new FileInputStream(in); - FileOutputStream foo = new FileOutputStream(out); - int count; - do { - count = des.read(buffer); - if (count != -1) - foo.write(buffer, 0, count); - } while (count != -1); - des.close(); - foo.close(); - } catch (IOException e) { - System.out.println("Oh no!"); - } - } - - public int size() { - if (structure != null) - return structSize = structure.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] newName = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - System.out.println("Oh no!"); - } - newName[i] = new String[text.size()]; - text.copyInto(newName[i]); - } - return newName; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] variabl = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - variabl[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - System.out.println("Oh no"); - } catch (IOException e) { - - } - } - return variabl; - } - - @Override - public int compareTo(Submission o) { - return 0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Table.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Table.java deleted file mode 100644 index a5d49d4fd..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/Table.java +++ /dev/null @@ -1,53 +0,0 @@ -package samples.PartialPlagiarism.D;//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] foo; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - foo = new int[this.size][]; - } - - private final void addTo(int index, int datum) { - if (foo[index]==null) { // new element - foo[index] = new int[4]; - foo[index][0] = 0; - } else - ensureCapacity(index, foo[index][0] + 2); - - foo[index][++foo[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int old = foo[index].length; - if (minCapacity > old) { - int[] oldData = foo[index]; - int newCapacity = (old + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - foo[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, foo[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // This is original work not copied - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/TokenConstants.java deleted file mode 100644 index 230cd2612..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2019/root/D/TokenConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package samples.PartialPlagiarism.D; - -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; - - final static int ANOTHER_TOKEN = 42; -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/Table.java b/core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character front end. - // maybe other front ends can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/SameRootName/2020/root/B/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/GSTiling.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/GSTiling.java deleted file mode 100644 index 3ca68224e..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/GSTiling.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Diese Klasse implementiert den GSTiling Algorithmus - * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", - * sowie "Matches" und "Match" ausgelegt - */ -public class GSTiling implements TokenConstants { - private Matches matches = new Matches(); - - /* - * creating hashes. - * The hash-code will be written in every Token for the next token. - * (includes the Token itself) - * Das Ganze laeuft in linearer Zeit. - * condition: 1 < hashLength < 26 !!! - */ - - public void create_hashes(Structure s, int hashLength, boolean makeTable) { - // Hier wird die obere Grenze der Hash-Laenge festgelegt. - // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl - // der Token. - if (hashLength<1) hashLength = 1; - hashLength = (hashLength<26 ? hashLength : 25); - - if (s.size()= hashLength) { - s.tokens[i].hash = hash; - s.table.add(hash, i); // add into hashtable - } else - s.tokens[i].hash = -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } else { - for (i=0; i= hashLength) ? hash : -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } - s.hash_length = hashLength; - } - - public final void compare(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - // first parameter should contain the smaller sequence!!! - private final void compare(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - if(true) { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - } else { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; - } - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 - || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j, hx, hy; - for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j > maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // begining of sequence A - int y = matches.matches[i].startB; // begining of sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--) - A[x++].marked = B[y++].marked = true; // mark all Token! - } - - } while (maxmatch != mml); - } - - public final void compareWithBasecode(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - private final void compareWithBasecode(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - // Initialize - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - - - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j,hx,hy; - for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j != maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // beginning in sequence A - int y = matches.matches[i].startB; // beginning in sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--){ - A[x].marked = B[y].marked = true; // mark all Token! - A[x].basecode = B[y].basecode= true; - x++; y++; - } - } - } while (maxmatch != mml); - - } - - public void resetBaseSubmission(Submission sub){ - Structure tmpStruct = sub.struct; - Token[] tok = tmpStruct.tokens; - for (int z = 0; z < tmpStruct.size()-1;z++){ - tok[z].basecode = false; - } - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Match.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Match.java deleted file mode 100644 index dc29ebfd4..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Match.java +++ /dev/null @@ -1,52 +0,0 @@ -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Matches.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Matches.java deleted file mode 100644 index 55cecdfca..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Matches.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Structure.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Structure.java deleted file mode 100644 index 4e0c4ce4c..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Structure.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Submission.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Submission.java deleted file mode 100644 index bb2190e55..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Submission.java +++ /dev/null @@ -1,218 +0,0 @@ -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure struct; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void copySubmission() { - File errorDir = null; - try { - URL url = Submission.class.getResource("errors"); - errorDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!errorDir.exists()) - errorDir.mkdir(); - int i = 0; - File destDir; - while ((destDir = new File(errorDir, format.format(i))).exists()) - i++; - destDir.mkdir(); - for (i = 0; i < files.length; i++) - copyFile(new File(dir, files[i]), new File(destDir, files[i])); - } - - /* Physical copy. :-) */ - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream dis = new FileInputStream(in); - FileOutputStream dos = new FileOutputStream(out); - int count; - do { - count = dis.read(buffer); - if (count != -1) - dos.write(buffer, 0, count); - } while (count != -1); - dis.close(); - dos.close(); - } catch (IOException e) { - - } - } - - public int size() { - if (struct != null) - return structSize = struct.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] result = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - help = help.replaceAll("<", "<"); - help = help.replaceAll(">", ">"); - help = help.replaceAll("\"", """); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - result[i] = new String[text.size()]; - text.copyInto(result[i]); - } - return result; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] result = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - result[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - // TODO: Should an ExitException be thrown here? - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - } - return result; - } - - public int compareTo(Submission other) { - return name.compareTo(other.name); - } - - public String toString() { - return name; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Table.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character module. - // maybe other modules can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/A/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/Table.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character front end. - // maybe other front ends can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root1/B/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Match.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Match.java deleted file mode 100644 index 43fe9a6b1..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Match.java +++ /dev/null @@ -1,54 +0,0 @@ -package samples.PartialPlagiarism.D; - -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Matches.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Matches.java deleted file mode 100644 index 1037e6b56..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Matches.java +++ /dev/null @@ -1,59 +0,0 @@ -package samples.PartialPlagiarism.D; - -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Structure.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Structure.java deleted file mode 100644 index 64ca0cce3..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Structure.java +++ /dev/null @@ -1,120 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Submission.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Submission.java deleted file mode 100644 index 20b954493..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Submission.java +++ /dev/null @@ -1,206 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure structure; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void doSmth() { - File failureDir = null; - try { - URL url = Submission.class.getResource("errors"); - failureDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!failureDir.exists()) - failureDir.mkdir(); - int i = 0; - } - - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream des = new FileInputStream(in); - FileOutputStream foo = new FileOutputStream(out); - int count; - do { - count = des.read(buffer); - if (count != -1) - foo.write(buffer, 0, count); - } while (count != -1); - des.close(); - foo.close(); - } catch (IOException e) { - System.out.println("Oh no!"); - } - } - - public int size() { - if (structure != null) - return structSize = structure.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] newName = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - System.out.println("Oh no!"); - } - newName[i] = new String[text.size()]; - text.copyInto(newName[i]); - } - return newName; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] variabl = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - variabl[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - System.out.println("Oh no"); - } catch (IOException e) { - - } - } - return variabl; - } - - @Override - public int compareTo(Submission o) { - return 0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Table.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Table.java deleted file mode 100644 index a5d49d4fd..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/Table.java +++ /dev/null @@ -1,53 +0,0 @@ -package samples.PartialPlagiarism.D;//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] foo; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - foo = new int[this.size][]; - } - - private final void addTo(int index, int datum) { - if (foo[index]==null) { // new element - foo[index] = new int[4]; - foo[index][0] = 0; - } else - ensureCapacity(index, foo[index][0] + 2); - - foo[index][++foo[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int old = foo[index].length; - if (minCapacity > old) { - int[] oldData = foo[index]; - int newCapacity = (old + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - foo[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, foo[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // This is original work not copied - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/TokenConstants.java deleted file mode 100644 index 230cd2612..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionName/root2/B/TokenConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package samples.PartialPlagiarism.D; - -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; - - final static int ANOTHER_TOKEN = 42; -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/GSTiling.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/GSTiling.java deleted file mode 100644 index 3ca68224e..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/GSTiling.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Diese Klasse implementiert den GSTiling Algorithmus - * Allerdings ist sie sehr spezifisch auf die Klassen "Structure", "Token", - * sowie "Matches" und "Match" ausgelegt - */ -public class GSTiling implements TokenConstants { - private Matches matches = new Matches(); - - /* - * creating hashes. - * The hash-code will be written in every Token for the next token. - * (includes the Token itself) - * Das Ganze laeuft in linearer Zeit. - * condition: 1 < hashLength < 26 !!! - */ - - public void create_hashes(Structure s, int hashLength, boolean makeTable) { - // Hier wird die obere Grenze der Hash-Laenge festgelegt. - // Sie ist bestimmt durch die Bitzahl des 'int' Datentyps und der Anzahl - // der Token. - if (hashLength<1) hashLength = 1; - hashLength = (hashLength<26 ? hashLength : 25); - - if (s.size()= hashLength) { - s.tokens[i].hash = hash; - s.table.add(hash, i); // add into hashtable - } else - s.tokens[i].hash = -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } else { - for (i=0; i= hashLength) ? hash : -1; - hash -= factor * (s.tokens[i].type & modulo); - hash = (2*hash) + (s.tokens[i+hashLength].type & modulo); - if (s.tokens[i+hashLength].marked) - hashedLength = 0; - else - hashedLength++; - } - } - s.hash_length = hashLength; - } - - public final void compare(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - // first parameter should contain the smaller sequence!!! - private final void compare(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - if(true) { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - } else { - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN || A[i].basecode; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN || B[i].basecode; - } - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 - || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) { // elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j, hx, hy; - for (j = maxmatch - 1; j >= 0; j--) { //begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j > maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // begining of sequence A - int y = matches.matches[i].startB; // begining of sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--) - A[x++].marked = B[y++].marked = true; // mark all Token! - } - - } while (maxmatch != mml); - } - - public final void compareWithBasecode(Submission subA, Submission subB) { - Submission A, B, tmp; - if (subA.struct.size() > subB.struct.size()) { - A = subB; B = subA; - } else { - A = subB; B = subA; - } - // if hashtable exists in first but not in second structure: flip around! - if (B.struct.table == null && A.struct.table != null) { - tmp = A; - A = B; - B = tmp; - } - } - - private final void compareWithBasecode(Submission subA, Submission subB, int mml) { - Structure structA = subA.struct; - Structure structB = subB.struct; - - // FILE_END used as pivot - - // init - Token[] A = structA.tokens; - Token[] B = structB.tokens; - int lengthA = structA.size()-1; // minus pivots! - int lengthB = structB.size()-1; // minus pivots! - - - // Initialize - for(int i = 0; i <= lengthA; i++) - A[i].marked = A[i].type == FILE_END || A[i].type == SEPARATOR_TOKEN; - - for(int i = 0; i <= lengthB; i++) - B[i].marked = B[i].type == FILE_END || B[i].type == SEPARATOR_TOKEN; - - - - - int maxmatch; - int[] elemsB; - - do { - maxmatch = mml; - matches.clear(); - for (int x = 0; x <= lengthA - maxmatch; x++) { - if (A[x].marked || A[x].hash == -1 || (elemsB = structB.table.get(A[x].hash)) == null) - continue; -inner: for (int i = 1; i <= elemsB[0]; i++) {// elemsB[0] contains the length of the Array - int y = elemsB[i]; - if (B[y].marked || maxmatch > lengthB - y) continue; - - int j,hx,hy; - for (j = maxmatch - 1; j >= 0; j--) { // begins comparison from behind - if (A[hx = x + j].type != B[hy = y + j].type || A[hx].marked || B[hy].marked) - continue inner; - } - // expand match - j = maxmatch; - while(A[hx = x + j].type == B[hy = y + j].type && !A[hx].marked && !B[hy].marked) - j++; - - if (j != maxmatch) { // new biggest match? -> delete current smaller - matches.clear(); - maxmatch = j; - } - matches.addMatch(x, y, j); // add match - } - } - for (int i = matches.size() - 1; i >= 0; i--) { - int x = matches.matches[i].startA; // beginning in sequence A - int y = matches.matches[i].startB; // beginning in sequence B - - //in order that "Match" will be newly build (because reusing) - for (int j = matches.matches[i].length; j > 0; j--){ - A[x].marked = B[y].marked = true; // mark all Token! - A[x].basecode = B[y].basecode= true; - x++; y++; - } - } - } while (maxmatch != mml); - - } - - public void resetBaseSubmission(Submission sub){ - Structure tmpStruct = sub.struct; - Token[] tok = tmpStruct.tokens; - for (int z = 0; z < tmpStruct.size()-1;z++){ - tok[z].basecode = false; - } - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Match.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Match.java deleted file mode 100644 index dc29ebfd4..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Match.java +++ /dev/null @@ -1,52 +0,0 @@ -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Matches.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Matches.java deleted file mode 100644 index 55cecdfca..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Matches.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Structure.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Structure.java deleted file mode 100644 index 4e0c4ce4c..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Structure.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Submission.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Submission.java deleted file mode 100644 index bb2190e55..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Submission.java +++ /dev/null @@ -1,218 +0,0 @@ -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure struct; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void copySubmission() { - File errorDir = null; - try { - URL url = Submission.class.getResource("errors"); - errorDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!errorDir.exists()) - errorDir.mkdir(); - int i = 0; - File destDir; - while ((destDir = new File(errorDir, format.format(i))).exists()) - i++; - destDir.mkdir(); - for (i = 0; i < files.length; i++) - copyFile(new File(dir, files[i]), new File(destDir, files[i])); - } - - /* Physical copy. :-) */ - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream dis = new FileInputStream(in); - FileOutputStream dos = new FileOutputStream(out); - int count; - do { - count = dis.read(buffer); - if (count != -1) - dos.write(buffer, 0, count); - } while (count != -1); - dis.close(); - dos.close(); - } catch (IOException e) { - - } - } - - public int size() { - if (struct != null) - return structSize = struct.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] result = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - help = help.replaceAll("<", "<"); - help = help.replaceAll(">", ">"); - help = help.replaceAll("\"", """); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - result[i] = new String[text.size()]; - text.copyInto(result[i]); - } - return result; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] result = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - result[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - // TODO: Should an ExitException be thrown here? - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - - } - } - return result; - } - - public int compareTo(Submission other) { - return name.compareTo(other.name); - } - - public String toString() { - return name; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Table.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character module. - // maybe other modules can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/A/B/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/Table.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/Table.java deleted file mode 100644 index c9072d7ba..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/Table.java +++ /dev/null @@ -1,61 +0,0 @@ -//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] data; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - data = new int[this.size][]; - } - - public final void add(int hash, int datum) { - addTo(hash % size, datum); - } - - public final int[] get(int hash) { - return data[hash % size]; - } - - private final void addTo(int index, int datum) { - if (data[index]==null) { // new element - data[index] = new int[4]; - data[index][0] = 0; - } else - ensureCapacity(index, data[index][0] + 2); - - data[index][++data[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int oldCapacity = data[index].length; - if (minCapacity > oldCapacity) { - int[] oldData = data[index]; - int newCapacity = (oldCapacity + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - data[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, data[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // this is made to distinguish the character front end. - // maybe other front ends can use it too? - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/TokenConstants.java deleted file mode 100644 index bf022a329..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root1/B/TokenConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Match.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Match.java deleted file mode 100644 index 43fe9a6b1..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Match.java +++ /dev/null @@ -1,54 +0,0 @@ -package samples.PartialPlagiarism.D; - -public class Match { - public int startA; - public int startB; - public int length; - - public Match(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - public Match() {} - - public void set(int startA, int startB, int length) { - this.startA = startA; - this.startB = startB; - this.length = length; - } - - public final boolean contains(int index, int sub) { - int start = (sub==0 ? startA : startB); - return (start <= index && index < (start+length)); - } - - public final boolean overlap(Match other) { - if (startA < other.startA) { - if ((other.startA - startA) < length) return true; - } else { - if ((startA - other.startA) < other.length) return true; - } - if (startB < other.startB) { - if ((other.startB - startB) < length) return true; - } else { - if ((startB - other.startB) < other.length) return true; - } - return false; - } - - public final boolean overlap(int oStartA, int oStartB, int oLength) { - if (startA < oStartA) { - if ((oStartA - startA) < length) return true; - } else { - if ((startA - oStartA) < oLength) return true; - } - if (startB < oStartB) { - if ((oStartB - startB) < length) return true; - } else { - if ((startB - oStartB) < oLength) return true; - } - return false; - } -} - diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Matches.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Matches.java deleted file mode 100644 index 1037e6b56..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Matches.java +++ /dev/null @@ -1,59 +0,0 @@ -package samples.PartialPlagiarism.D; - -/* Minimal class that stores "Match" objects. - */ -public class Matches { - public Match[] matches; - - private int anzahl; - private final int increment = 20; - - public Matches() { - matches = new Match[10]; - for (int i=0; i<10; i++) matches[i] = new Match(); - anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = matches.length; - if (minCapacity > oldCapacity) { - Match[] oldMatches = matches; - int newCapacity = (oldCapacity + increment); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - matches = new Match[newCapacity]; - System.arraycopy(oldMatches, 0, matches, 0, oldCapacity); - for (int i=oldCapacity; i=0; i--) { // starting at the end is better(?) - if (matches[i].overlap(startA,startB,length)) return; - // no overlaps! - } - ensureCapacity(anzahl + 1); - //if (matches[anzahl] != null) // object recycling... - matches[anzahl].set(startA,startB,length); - //else - //matches[anzahl ] = new Match(startA,startB,length); - anzahl++; - } - - public final void clear() { - anzahl=0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Structure.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Structure.java deleted file mode 100644 index 64ca0cce3..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Structure.java +++ /dev/null @@ -1,120 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; - -/** The tokenlist */ -public class Structure implements TokenConstants { - public Token[] tokens = new Token[0]; - Table table = null; - int hash_length = -1; - - int files; // number of END_FILE tokens - private int anzahl; - - //private final int increment = 300; - - public Structure() { - tokens = new Token[400]; - files = anzahl = 0; - } - - public final int size() { - return anzahl; - } - - public final void ensureCapacity(int minCapacity) { - int oldCapacity = tokens.length; - if (minCapacity > oldCapacity) { - Token[] oldTokens = tokens; - int newCapacity = (2 * oldCapacity); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - tokens = new Token[newCapacity]; - System.arraycopy(oldTokens, 0, tokens, 0, anzahl); - } - } - - public final void addToken(Token token) { - ensureCapacity(anzahl + 1); - if (anzahl > 0 && tokens[anzahl - 1].file.equals(token.file)) - token.file = tokens[anzahl - 1].file; // To save memory ... - if ((anzahl > 0) && (token.getLine() < tokens[anzahl - 1].getLine()) && (token.file.equals(tokens[anzahl - 1].file))) - token.setLine(tokens[anzahl - 1].getLine()); - // just to make sure - - tokens[anzahl++] = token; - if (token.type == FILE_END) - files++; - } - - public final String toString() { - StringBuffer buf = new StringBuffer(); - - try { - for (int i = 0; i < anzahl; i++) { - String s = tokens[i].toString(); - buf.append(i); - buf.append("\t"); - buf.append(s); - if (i < anzahl - 1) { - buf.append("\n"); - } - } - } catch (OutOfMemoryError e) { - return "Tokenlist to large for output: " + (anzahl) + " Tokens"; - } - return buf.toString(); - } - - public void save(File file) { - - try { - ObjectOutputStream p = new ObjectOutputStream(/* new GZIPOutputStream */(new FileOutputStream(file))); - - p.writeInt(anzahl); - p.writeInt(hash_length); - p.writeInt(files); - - for (int i = 0; i < anzahl; i++) - p.writeObject(tokens[i]); - p.flush(); - p.close(); - } catch (IOException e) { - System.out.println("Error writing file: " + file.toString()); - } - } - - /* returns "true" when successful */ - public boolean load(File file) { - try { - ObjectInputStream p = new ObjectInputStream(/* new GZIPInputStream */(new FileInputStream(file))); - - int newAnzahl = p.readInt(); - hash_length = p.readInt(); - files = p.readInt(); - ensureCapacity(newAnzahl); - anzahl = newAnzahl; - for (int i = 0; i < anzahl; i++) { - tokens[i] = (Token) p.readObject(); - // special case for text tokens: - // if (tokens[i] instanceof de.jplag.text.TextToken) { - // de.jplag.text.TextToken token = (de.jplag.text.TextToken)tokens[i]; - // de.jplag.text.TextToken.put(token.getText(), token.type); - // } - } - p.close(); - table = null; - } catch (FileNotFoundException e) { - System.out.println("File not found: " + file.toString()); - return false; - } catch (IOException e) { - System.out.println("Error reading file: " + file.toString() + " (" + e + ")"); - return false; - } catch (ClassNotFoundException e) { - System.out.println("Class not found in file: " + file.toString()); - return false; - } - return true; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Submission.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Submission.java deleted file mode 100644 index 20b954493..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Submission.java +++ /dev/null @@ -1,206 +0,0 @@ -package samples.PartialPlagiarism.D; - -import java.io.*; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.Vector; - -/* - * Everything about a single submission is stored in this object. (directory, - * files, ...) - */ -public class Submission implements Comparable { - public String name; - - private boolean readSubDirs; - - public File dir; - - public String[] files = null; // = new String[0]; - - public Structure structure; - - public int structSize = 0; - - // public long structMem; - boolean exact_match = false; // used for fallback - - public boolean errors = false; - - public DecimalFormat format = new DecimalFormat("0000"); - - public Submission(String name, File dir, boolean readSubDirs) { - this.dir = dir; - this.name = name; - this.readSubDirs = readSubDirs; - try { - lookupDir(dir, ""); - } catch (Throwable b) { - } - } - - public Submission(String name, File dir) { - this.dir = dir; - this.name = name; - this.readSubDirs = false; - - files = new String[1]; - files[0] = name; - - } - - // recursively read in all the files - private void lookupDir(File dir, String subDir) throws Throwable { - File aktDir = new File(dir, subDir); - if (!aktDir.isDirectory()) - return; - if (readSubDirs) { - String[] dirs = aktDir.list(); - if (!subDir.equals("")) - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, subDir + File.separator + dirs[i]); - else - for (int i = 0; i < dirs.length; i++) - lookupDir(dir, dirs[i]); - } - String[] newFiles = aktDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return false; - } - }); - if (files != null) { - String[] oldFiles = files; - files = new String[oldFiles.length + newFiles.length]; - if (subDir != "") - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - else - System.arraycopy(newFiles, 0, files, 0, newFiles.length); - System.arraycopy(oldFiles, 0, files, newFiles.length, oldFiles.length); - } else { - if (subDir != "") { - files = new String[newFiles.length]; - for (int i = 0; i < newFiles.length; i++) - files[i] = subDir + File.separator + newFiles[i]; - } else - files = newFiles; - } - } - - /* parse all the files... */ - public boolean parse(){ - return false; - } - - /* - * This method is used to copy files that can not be parsed to a special - * folder: de/jplag/errors/java old_java scheme cpp /001/(...files...) - * /002/(...files...) - */ - private void doSmth() { - File failureDir = null; - try { - URL url = Submission.class.getResource("errors"); - failureDir = new File(url.getFile()); - } catch (NullPointerException e) { - return; - } - - if (!failureDir.exists()) - failureDir.mkdir(); - int i = 0; - } - - private void copyFile(File in, File out) { - byte[] buffer = new byte[10000]; - try { - FileInputStream des = new FileInputStream(in); - FileOutputStream foo = new FileOutputStream(out); - int count; - do { - count = des.read(buffer); - if (count != -1) - foo.write(buffer, 0, count); - } while (count != -1); - des.close(); - foo.close(); - } catch (IOException e) { - System.out.println("Oh no!"); - } - } - - public int size() { - if (structure != null) - return structSize = structure.size(); - return structSize; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of strings. - */ - public String[][] readFiles(String[] files) { - String[][] newName = new String[files.length][]; - String help; - - Vector text = new Vector(); - for (int i = 0; i < files.length; i++) { - text.removeAllElements(); - try { - /* file encoding = "UTF-8" */ - FileInputStream fileInputStream = new FileInputStream(new File(dir, files[i])); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - BufferedReader in = new BufferedReader(inputStreamReader); - while ((help = in.readLine()) != null) { - help = help.replaceAll("&", "&"); - text.addElement(help); - } - in.close(); - inputStreamReader.close(); - fileInputStream.close(); - } catch (FileNotFoundException e) { - System.out.println("File not found: " + ((new File(dir, files[i])).toString())); - } catch (IOException e) { - System.out.println("Oh no!"); - } - newName[i] = new String[text.size()]; - text.copyInto(newName[i]); - } - return newName; - } - - /* - * Used by the "Report" class. All source files are returned as an array of - * an array of chars. - */ - public char[][] readFilesChar(String[] files) { - char[][] variabl = new char[files.length][]; - - for (int i = 0; i < files.length; i++) { - try { - File file = new File(dir, files[i]); - int size = (int) file.length(); - char[] buffer = new char[size]; - - FileReader fis = new FileReader(file); - - if (size != fis.read(buffer)) { - System.out.println("Not right size read from the file, " + "but I will still continue..."); - } - - variabl[i] = buffer; - fis.close(); - } catch (FileNotFoundException e) { - System.out.println("Oh no"); - } catch (IOException e) { - - } - } - return variabl; - } - - @Override - public int compareTo(Submission o) { - return 0; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Table.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Table.java deleted file mode 100644 index a5d49d4fd..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/Table.java +++ /dev/null @@ -1,53 +0,0 @@ -package samples.PartialPlagiarism.D;//import java.io.*; - -/* A simplified hashtable: maps one integer to many integers - */ -public class Table { - private static final int[] prim ={1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001}; - private int[][] foo; /* in data[][0] stores the number of used elements - * of every sub-array */ - private int size; - - public Table(int size) { - //Program.print("Length: "+size+"\n", null); - int primzahl = 0; - if (size>=16001) { - this.size=16001; // just to make sure... :-) - } else { - for (int i=0; i size) break; - this.size = primzahl; - } - foo = new int[this.size][]; - } - - private final void addTo(int index, int datum) { - if (foo[index]==null) { // new element - foo[index] = new int[4]; - foo[index][0] = 0; - } else - ensureCapacity(index, foo[index][0] + 2); - - foo[index][++foo[index][0]] = datum; - } - - private final void ensureCapacity(int index, int minCapacity) { - int old = foo[index].length; - if (minCapacity > old) { - int[] oldData = foo[index]; - int newCapacity = (old + 4); - if (newCapacity < minCapacity) newCapacity = minCapacity; - foo[index] = new int[newCapacity]; - System.arraycopy(oldData, 0, foo[index], 0, oldData.length); - } - } - - public final void count_dist(int[] dist) { - for (int i=0; i0 ? line : 1); - setColumn(column); - setLength(length); - } - - // abstract members - public abstract int getLine(); - public abstract int getColumn(); - public abstract int getLength(); - protected void setLine(int line) {} - protected void setColumn(int line) {} - protected void setLength(int line) {} - - // This is original work not copied - protected int getIndex() { return -1; } - - public static String type2string(int type) { - return ""; - } - - public String toString() { - return type2string(type); - } - - public static int numberOfTokens() { - return 1; - } -} diff --git a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/TokenConstants.java b/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/TokenConstants.java deleted file mode 100644 index 230cd2612..000000000 --- a/core/src/test/resources/de/jplag/samples/SameSubmissionNameWithSubDirectory/root2/B/TokenConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package samples.PartialPlagiarism.D; - -public interface TokenConstants { - final static int FILE_END = 0; - /** - * Used to optionally separate methods from each other with an always marked - * token - */ - final static int SEPARATOR_TOKEN = 1; - - final static int ANOTHER_TOKEN = 42; -} From 2d0b0cfde8479621fcfceeba3ba5871eed8d4cf8 Mon Sep 17 00:00:00 2001 From: cyfml <236510120@qq.com> Date: Thu, 8 Dec 2022 16:50:38 +0100 Subject: [PATCH 3/6] change submissions folder name to files --- .../jplag/reporting/reportobject/ReportObjectFactory.java | 2 +- report-viewer/src/views/FileUploadView.vue | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java b/core/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java index ef21ae12c..f8a8c9364 100644 --- a/core/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java +++ b/core/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java @@ -42,7 +42,7 @@ public class ReportObjectFactory { private static final ToDiskWriter fileWriter = new ToDiskWriter(); public static final String OVERVIEW_FILE_NAME = "overview.json"; - public static final String SUBMISSIONS_FOLDER = "submissions"; + public static final String SUBMISSIONS_FOLDER = "files"; public static final Version REPORT_VIEWER_VERSION = JPlag.JPLAG_VERSION; private Map submissionNameToIdMap; diff --git a/report-viewer/src/views/FileUploadView.vue b/report-viewer/src/views/FileUploadView.vue index 784cfd587..6c1fccc46 100644 --- a/report-viewer/src/views/FileUploadView.vue +++ b/report-viewer/src/views/FileUploadView.vue @@ -58,14 +58,14 @@ export default defineComponent({ const extractSubmissionFileName = (filePath: path.ParsedPath) => { const folders = filePath.dir.split("/"); const submissionFolderIndex = folders.findIndex( - (folder) => folder === "submissions" + (folder) => folder === "files" ); return folders[submissionFolderIndex + 1]; }; const extractFileNameWithFullPath = (filePath: path.ParsedPath, originalFileName: string) => { let fullPath=""; - const unixPathWithoutSubmissions = filePath.dir.split("submissions"); - const originalPathWithoutSubmissions = originalFileName.split("submissions"); + const unixPathWithoutSubmissions = filePath.dir.split("files"); + const originalPathWithoutSubmissions = originalFileName.split("files"); const unixSubfolderPathAfterSubmissions = unixPathWithoutSubmissions[1].substring(1); if(originalPathWithoutSubmissions[1].charAt(0)==='\\'){ fullPath=(unixSubfolderPathAfterSubmissions + path.sep + filePath.base).replaceAll('/','\\'); @@ -83,7 +83,7 @@ export default defineComponent({ for (const originalFileName of Object.keys(zip.files)) { const unixFileName = slash(originalFileName); if ( - /((.+\/)*)submissions\/(.+)\/(.+)/.test(unixFileName) && + /((.+\/)*)files\/(.+)\/(.+)/.test(unixFileName) && !/^__MACOSX\//.test(unixFileName) ) { const filePath = path.parse(unixFileName); From ad45e51d2336dc66eea3a99887bda3ea2a45f831 Mon Sep 17 00:00:00 2001 From: cyfml <236510120@qq.com> Date: Fri, 16 Dec 2022 14:23:51 +0100 Subject: [PATCH 4/6] rename submissions to files in zip file but also support old version of Jplag --- report-viewer/src/views/FileUploadView.vue | 41 +++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/report-viewer/src/views/FileUploadView.vue b/report-viewer/src/views/FileUploadView.vue index 86e070984..a38920b45 100644 --- a/report-viewer/src/views/FileUploadView.vue +++ b/report-viewer/src/views/FileUploadView.vue @@ -55,23 +55,38 @@ export default defineComponent({ }, }); }; + + const extractRootName = (filePath: path.ParsedPath) => { + const folders = filePath.dir.split("/"); + return folders[0]; + }; const extractSubmissionFileName = (filePath: path.ParsedPath) => { const folders = filePath.dir.split("/"); - const submissionFolderIndex = folders.findIndex( - (folder) => folder === "files" - ); + const rootName = folders[0]; + let submissionFolderIndex = -1; + if(rootName === "files") { + submissionFolderIndex = folders.findIndex( + (folder) => folder === "files" + ); + }else { + submissionFolderIndex = folders.findIndex( + (folder) => folder === "submissions" + ); + } return folders[submissionFolderIndex + 1]; }; const extractFileNameWithFullPath = (filePath: path.ParsedPath, originalFileName: string) => { - let fullPath=""; - const unixPathWithoutSubmissions = filePath.dir.split("files"); - const originalPathWithoutSubmissions = originalFileName.split("files"); - const unixSubfolderPathAfterSubmissions = unixPathWithoutSubmissions[1].substring(1); - if(originalPathWithoutSubmissions[1].charAt(0)==='\\'){ - fullPath=(unixSubfolderPathAfterSubmissions + path.sep + filePath.base).replaceAll('/','\\'); - }else { - fullPath=(unixSubfolderPathAfterSubmissions + path.sep + filePath.base); - } + let fullPath = ""; + const rootName = extractRootName(filePath); + const filesOrSubmissionsIndex_filePath = filePath.dir.indexOf(rootName ==="files" ? "files" : "submissions"); + const filesOrSubmissionsIndex_originalFileName = originalFileName.indexOf(rootName === "files" ? "files" : "submissions"); + const unixSubfolderPathAfterSubmissions = filePath.dir.substring(filesOrSubmissionsIndex_filePath + (rootName === "files" ? "files".length : "submissions".length) + 1); + const originalPathWithoutSubmissions = originalFileName.substring(filesOrSubmissionsIndex_originalFileName + (rootName === "files" ? "files".length : "submissions".length)); + if(originalPathWithoutSubmissions.charAt(0)==='\\'){ + fullPath = (unixSubfolderPathAfterSubmissions + path.sep + filePath.base).replaceAll('/','\\'); + }else { + fullPath = (unixSubfolderPathAfterSubmissions + path.sep + filePath.base); + } return fullPath; }; /** @@ -83,7 +98,7 @@ export default defineComponent({ for (const originalFileName of Object.keys(zip.files)) { const unixFileName = slash(originalFileName); if ( - /((.+\/)*)files\/(.+)\/(.+)/.test(unixFileName) && + /((.+\/)*)(files|submissions)\/(.+)\/(.+)/.test(unixFileName) && !/^__MACOSX\//.test(unixFileName) ) { const filePath = path.parse(unixFileName); From d5e2c96eb147a0fa907bf9e496e378c2270c9e5e Mon Sep 17 00:00:00 2001 From: cyfml <236510120@qq.com> Date: Mon, 19 Dec 2022 14:17:03 +0100 Subject: [PATCH 5/6] change bad naming --- .../de/jplag/reporting/jsonfactory/DirectoryManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/de/jplag/reporting/jsonfactory/DirectoryManager.java b/core/src/main/java/de/jplag/reporting/jsonfactory/DirectoryManager.java index d59bbda82..8bbe60593 100644 --- a/core/src/main/java/de/jplag/reporting/jsonfactory/DirectoryManager.java +++ b/core/src/main/java/de/jplag/reporting/jsonfactory/DirectoryManager.java @@ -32,14 +32,14 @@ public class DirectoryManager { */ public static File createDirectory(String path, String name, File file, File submissionRoot) throws IOException { File directory; - String fileName = file.getPath(); + String fileFullPath = file.getPath(); String submissionRootPath = submissionRoot.getPath(); - fileName = fileName.substring(submissionRootPath.length()); + String filePathWithoutRootName = fileFullPath.substring(submissionRootPath.length()); String outputRootDirectory = Path.of(path, name).toString(); - if ("".equals(fileName)) { + if ("".equals(filePathWithoutRootName)) { directory = new File(Path.of(outputRootDirectory, name).toString()); } else { - directory = new File(outputRootDirectory + fileName); + directory = new File(outputRootDirectory + filePathWithoutRootName); } if (!directory.exists() && !directory.mkdirs()) { throw new IOException("Failed to create dir."); From fa24e16520264458ee398de003c2e4af3498cf31 Mon Sep 17 00:00:00 2001 From: cyfml <236510120@qq.com> Date: Mon, 19 Dec 2022 15:25:49 +0100 Subject: [PATCH 6/6] minimum complexity --- report-viewer/src/components/FilesContainer.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/report-viewer/src/components/FilesContainer.vue b/report-viewer/src/components/FilesContainer.vue index 221e107f5..61ad83d9d 100644 --- a/report-viewer/src/components/FilesContainer.vue +++ b/report-viewer/src/components/FilesContainer.vue @@ -13,9 +13,7 @@ :lines="!files.get(file)?.lines ? [] : files.get(file)?.lines" :matches="!matches.get(file) ? [] : matches.get(file)" :panel-id="containerId" - :title="convertSubmissionIdToName(file, submissionId).length > 40? - '..' + convertSubmissionIdToName(file, submissionId).substring(file.length - 40, file.length): - convertSubmissionIdToName(file, submissionId)" + :title="convertSubmissionIdToName(file, submissionId)" @toggle-collapse="$emit('toggle-collapse', file)" @line-selected="lineSelected" /> @@ -99,13 +97,15 @@ export default defineComponent({ emit("lineSelected", e, index, file, line); }; /** - * converts the submissionId to the name in the path of file. + * converts the submissionId to the name in the path of file. If the length of path exceeds 40, then the file path displays the abbreviation. * @param match * @param submissionId * @return new path of file */ const convertSubmissionIdToName=(file: string, submissionId: string):string => { - return file.replace(submissionId, store.getters.submissionDisplayName(submissionId)); + const filePath = file.replace(submissionId, store.getters.submissionDisplayName(submissionId)); + const filePathLength = filePath.length; + return filePathLength > 40 ? ".." + filePath.substring(filePathLength - 40, filePathLength) : filePath; }; return { lineSelected,