diff --git a/coverage/compare.txt b/coverage/compare.txt new file mode 100644 index 00000000000..9e3aa8167f9 --- /dev/null +++ b/coverage/compare.txt @@ -0,0 +1,30 @@ +branch 0 was visited. +branch 1 was visited. +branch 2 was not visited. +branch 3 was not visited. +branch 4 was not visited. +branch 5 was visited. +branch 6 was not visited. +branch 7 was not visited. +branch 8 was not visited. +branch 9 was not visited. +branch 10 was not visited. +branch 11 was not visited. +branch 12 was not visited. +branch 13 was not visited. +branch 14 was visited. +branch 15 was not visited. +branch 16 was not visited. +branch 17 was not visited. +branch 18 was visited. +branch 19 was not visited. +branch 20 was visited. +branch 21 was not visited. +branch 22 was not visited. +branch 23 was not visited. +branch 24 was visited. +branch 25 was visited. +branch 26 was not visited. +branch 27 was not visited. +branch 28 was not visited. +0.27586206896551724 diff --git a/coverage/compare_NEW.txt b/coverage/compare_NEW.txt new file mode 100644 index 00000000000..f283f3da9bd --- /dev/null +++ b/coverage/compare_NEW.txt @@ -0,0 +1,30 @@ +branch 0 was visited. +branch 1 was visited. +branch 2 was not visited. +branch 3 was not visited. +branch 4 was not visited. +branch 5 was visited. +branch 6 was visited. +branch 7 was visited. +branch 8 was not visited. +branch 9 was visited. +branch 10 was not visited. +branch 11 was not visited. +branch 12 was not visited. +branch 13 was not visited. +branch 14 was visited. +branch 15 was visited. +branch 16 was not visited. +branch 17 was visited. +branch 18 was visited. +branch 19 was not visited. +branch 20 was visited. +branch 21 was not visited. +branch 22 was not visited. +branch 23 was not visited. +branch 24 was visited. +branch 25 was visited. +branch 26 was not visited. +branch 27 was not visited. +branch 28 was not visited. +0.4482758620689655 \ No newline at end of file diff --git a/coverage/getFieldValue.txt b/coverage/getFieldValue.txt new file mode 100644 index 00000000000..d4d4bc88d12 --- /dev/null +++ b/coverage/getFieldValue.txt @@ -0,0 +1,69 @@ +branch 0 was visited. +branch 1 was visited. +branch 2 was visited. +branch 3 was visited. +branch 4 was visited. +branch 5 was visited. +branch 6 was visited. +branch 7 was not visited. +branch 8 was visited. +branch 9 was visited. +branch 10 was not visited. +branch 11 was not visited. +branch 12 was not visited. +branch 13 was not visited. +branch 14 was not visited. +branch 15 was not visited. +branch 16 was not visited. +branch 17 was visited. +branch 18 was not visited. +branch 19 was not visited. +branch 20 was not visited. +branch 21 was not visited. +branch 22 was visited. +branch 23 was visited. +branch 24 was visited. +branch 25 was visited. +branch 26 was not visited. +branch 27 was not visited. +branch 28 was not visited. +branch 29 was not visited. +branch 30 was not visited. +branch 31 was not visited. +branch 32 was not visited. +branch 33 was not visited. +branch 34 was not visited. +branch 35 was not visited. +branch 36 was not visited. +branch 37 was not visited. +branch 38 was not visited. +branch 39 was visited. +branch 40 was not visited. +branch 41 was not visited. +branch 42 was visited. +branch 43 was visited. +branch 44 was visited. +branch 45 was visited. +branch 46 was visited. +branch 47 was visited. +branch 48 was visited. +branch 49 was not visited. +branch 50 was not visited. +branch 51 was visited. +branch 52 was not visited. +branch 53 was visited. +branch 54 was visited. +branch 55 was visited. +branch 56 was visited. +branch 57 was visited. +branch 58 was visited. +branch 59 was visited. +branch 60 was visited. +branch 61 was visited. +branch 62 was visited. +branch 63 was visited. +branch 64 was not visited. +branch 65 was not visited. +branch 66 was not visited. +branch 67 was not visited. +0.5 \ No newline at end of file diff --git a/coverage/getFieldValue_NEW.txt b/coverage/getFieldValue_NEW.txt new file mode 100644 index 00000000000..b23e505742c --- /dev/null +++ b/coverage/getFieldValue_NEW.txt @@ -0,0 +1,69 @@ +branch 0 was visited. +branch 1 was visited. +branch 2 was visited. +branch 3 was visited. +branch 4 was visited. +branch 5 was visited. +branch 6 was visited. +branch 7 was visited. +branch 8 was visited. +branch 9 was visited. +branch 10 was visited. +branch 11 was visited. +branch 12 was visited. +branch 13 was not visited. +branch 14 was not visited. +branch 15 was not visited. +branch 16 was not visited. +branch 17 was visited. +branch 18 was not visited. +branch 19 was not visited. +branch 20 was not visited. +branch 21 was not visited. +branch 22 was visited. +branch 23 was visited. +branch 24 was visited. +branch 25 was visited. +branch 26 was not visited. +branch 27 was not visited. +branch 28 was not visited. +branch 29 was not visited. +branch 30 was not visited. +branch 31 was not visited. +branch 32 was not visited. +branch 33 was not visited. +branch 34 was not visited. +branch 35 was not visited. +branch 36 was not visited. +branch 37 was not visited. +branch 38 was not visited. +branch 39 was visited. +branch 40 was not visited. +branch 41 was not visited. +branch 42 was visited. +branch 43 was visited. +branch 44 was visited. +branch 45 was visited. +branch 46 was visited. +branch 47 was visited. +branch 48 was visited. +branch 49 was not visited. +branch 50 was not visited. +branch 51 was visited. +branch 52 was not visited. +branch 53 was visited. +branch 54 was visited. +branch 55 was visited. +branch 56 was visited. +branch 57 was visited. +branch 58 was visited. +branch 59 was visited. +branch 60 was visited. +branch 61 was visited. +branch 62 was visited. +branch 63 was visited. +branch 64 was not visited. +branch 65 was not visited. +branch 66 was not visited. +branch 67 was not visited. +0.5588235294117647 \ No newline at end of file diff --git a/coverage/handleArgument.txt b/coverage/handleArgument.txt new file mode 100644 index 00000000000..1cb5c4b6b2b --- /dev/null +++ b/coverage/handleArgument.txt @@ -0,0 +1,43 @@ +branch 0 was visited. +branch 1 was not visited. +branch 2 was visited. +branch 3 was not visited. +branch 4 was not visited. +branch 5 was visited. +branch 6 was visited. +branch 7 was visited. +branch 8 was not visited. +branch 9 was visited. +branch 10 was visited. +branch 11 was not visited. +branch 12 was not visited. +branch 13 was visited. +branch 14 was not visited. +branch 15 was not visited. +branch 16 was not visited. +branch 17 was visited. +branch 18 was not visited. +branch 19 was visited. +branch 20 was visited. +branch 21 was visited. +branch 22 was visited. +branch 23 was visited. +branch 24 was visited. +branch 25 was visited. +branch 26 was not visited. +branch 27 was not visited. +branch 28 was not visited. +branch 29 was visited. +branch 30 was not visited. +branch 31 was visited. +branch 32 was visited. +branch 33 was visited. +branch 34 was not visited. +branch 35 was not visited. +branch 36 was not visited. +branch 37 was visited. +branch 38 was visited. +branch 39 was visited. +branch 40 was visited. +branch 41 was not visited. +0.5714285714285714 \ No newline at end of file diff --git a/coverage/handleArgumentRefactor.txt b/coverage/handleArgumentRefactor.txt new file mode 100644 index 00000000000..e8cf6dd4378 --- /dev/null +++ b/coverage/handleArgumentRefactor.txt @@ -0,0 +1,9 @@ +branch 0 was visited. +branch 1 was visited. +branch 2 was visited. +branch 3 was visited. +branch 4 was visited. +branch 5 was visited. +branch 6 was visited. +branch 7 was not visited. +0.875 \ No newline at end of file diff --git a/coverage/handleArgument_NEW.txt b/coverage/handleArgument_NEW.txt new file mode 100644 index 00000000000..11f5c2ddf36 --- /dev/null +++ b/coverage/handleArgument_NEW.txt @@ -0,0 +1,43 @@ +branch 0 was visited. +branch 1 was visited. +branch 2 was visited. +branch 3 was not visited. +branch 4 was not visited. +branch 5 was visited. +branch 6 was visited. +branch 7 was visited. +branch 8 was visited. +branch 9 was visited. +branch 10 was visited. +branch 11 was not visited. +branch 12 was not visited. +branch 13 was visited. +branch 14 was not visited. +branch 15 was not visited. +branch 16 was not visited. +branch 17 was visited. +branch 18 was not visited. +branch 19 was visited. +branch 20 was visited. +branch 21 was visited. +branch 22 was visited. +branch 23 was visited. +branch 24 was visited. +branch 25 was visited. +branch 26 was visited. +branch 27 was visited. +branch 28 was visited. +branch 29 was visited. +branch 30 was not visited. +branch 31 was visited. +branch 32 was visited. +branch 33 was visited. +branch 34 was not visited. +branch 35 was not visited. +branch 36 was not visited. +branch 37 was visited. +branch 38 was visited. +branch 39 was visited. +branch 40 was visited. +branch 41 was not visited. +0.6904761904761905 \ No newline at end of file diff --git a/coverage/parseEntry.txt b/coverage/parseEntry.txt new file mode 100644 index 00000000000..0bb2be481e1 --- /dev/null +++ b/coverage/parseEntry.txt @@ -0,0 +1,136 @@ +branch 0 was visited. +branch 1 was visited. +branch 2 was not visited. +branch 3 was visited. +branch 4 was visited. +branch 5 was visited. +branch 6 was visited. +branch 7 was visited. +branch 8 was visited. +branch 9 was not visited. +branch 10 was visited. +branch 11 was visited. +branch 12 was not visited. +branch 13 was visited. +branch 14 was visited. +branch 15 was visited. +branch 16 was visited. +branch 17 was visited. +branch 18 was visited. +branch 19 was visited. +branch 20 was visited. +branch 21 was visited. +branch 22 was visited. +branch 23 was visited. +branch 24 was visited. +branch 25 was not visited. +branch 26 was visited. +branch 27 was visited. +branch 28 was visited. +branch 29 was visited. +branch 30 was not visited. +branch 31 was not visited. +branch 32 was visited. +branch 33 was visited. +branch 34 was not visited. +branch 35 was visited. +branch 36 was visited. +branch 37 was visited. +branch 38 was visited. +branch 39 was visited. +branch 40 was visited. +branch 41 was visited. +branch 42 was visited. +branch 43 was visited. +branch 44 was visited. +branch 45 was visited. +branch 46 was visited. +branch 47 was not visited. +branch 48 was not visited. +branch 49 was not visited. +branch 50 was not visited. +branch 51 was not visited. +branch 52 was not visited. +branch 53 was not visited. +branch 54 was visited. +branch 55 was not visited. +branch 56 was visited. +branch 57 was visited. +branch 58 was visited. +branch 59 was not visited. +branch 60 was visited. +branch 61 was not visited. +branch 62 was not visited. +branch 63 was not visited. +branch 64 was visited. +branch 65 was not visited. +branch 66 was visited. +branch 67 was not visited. +branch 68 was visited. +branch 69 was not visited. +branch 70 was visited. +branch 71 was visited. +branch 72 was visited. +branch 73 was not visited. +branch 74 was not visited. +branch 75 was visited. +branch 76 was visited. +branch 77 was visited. +branch 78 was visited. +branch 79 was visited. +branch 80 was visited. +branch 81 was visited. +branch 82 was visited. +branch 83 was visited. +branch 84 was not visited. +branch 85 was not visited. +branch 86 was not visited. +branch 87 was not visited. +branch 88 was not visited. +branch 89 was visited. +branch 90 was visited. +branch 91 was visited. +branch 92 was visited. +branch 93 was visited. +branch 94 was visited. +branch 95 was visited. +branch 96 was visited. +branch 97 was visited. +branch 98 was visited. +branch 99 was visited. +branch 100 was visited. +branch 101 was visited. +branch 102 was visited. +branch 103 was visited. +branch 104 was visited. +branch 105 was visited. +branch 106 was visited. +branch 107 was visited. +branch 108 was visited. +branch 109 was visited. +branch 110 was visited. +branch 111 was visited. +branch 112 was visited. +branch 113 was visited. +branch 114 was not visited. +branch 115 was visited. +branch 116 was visited. +branch 117 was visited. +branch 118 was visited. +branch 119 was visited. +branch 120 was not visited. +branch 121 was visited. +branch 122 was visited. +branch 123 was visited. +branch 124 was not visited. +branch 125 was visited. +branch 126 was visited. +branch 127 was visited. +branch 128 was visited. +branch 129 was visited. +branch 130 was visited. +branch 131 was visited. +branch 132 was not visited. +branch 133 was not visited. +branch 134 was visited. +0.7481481481481481 \ No newline at end of file diff --git a/coverage/parseEntry_NEW.txt b/coverage/parseEntry_NEW.txt new file mode 100644 index 00000000000..e75c56e46ee --- /dev/null +++ b/coverage/parseEntry_NEW.txt @@ -0,0 +1,136 @@ +branch 0 was visited. +branch 1 was visited. +branch 2 was not visited. +branch 3 was visited. +branch 4 was visited. +branch 5 was visited. +branch 6 was visited. +branch 7 was visited. +branch 8 was visited. +branch 9 was visited. +branch 10 was visited. +branch 11 was visited. +branch 12 was not visited. +branch 13 was visited. +branch 14 was visited. +branch 15 was visited. +branch 16 was visited. +branch 17 was visited. +branch 18 was visited. +branch 19 was visited. +branch 20 was visited. +branch 21 was visited. +branch 22 was visited. +branch 23 was visited. +branch 24 was visited. +branch 25 was visited. +branch 26 was visited. +branch 27 was visited. +branch 28 was visited. +branch 29 was visited. +branch 30 was not visited. +branch 31 was not visited. +branch 32 was visited. +branch 33 was visited. +branch 34 was not visited. +branch 35 was visited. +branch 36 was visited. +branch 37 was visited. +branch 38 was visited. +branch 39 was visited. +branch 40 was visited. +branch 41 was visited. +branch 42 was visited. +branch 43 was visited. +branch 44 was visited. +branch 45 was visited. +branch 46 was visited. +branch 47 was visited. +branch 48 was visited. +branch 49 was visited. +branch 50 was not visited. +branch 51 was not visited. +branch 52 was visited. +branch 53 was not visited. +branch 54 was visited. +branch 55 was not visited. +branch 56 was visited. +branch 57 was visited. +branch 58 was visited. +branch 59 was not visited. +branch 60 was visited. +branch 61 was visited. +branch 62 was visited. +branch 63 was not visited. +branch 64 was visited. +branch 65 was visited. +branch 66 was visited. +branch 67 was not visited. +branch 68 was visited. +branch 69 was not visited. +branch 70 was visited. +branch 71 was visited. +branch 72 was visited. +branch 73 was not visited. +branch 74 was not visited. +branch 75 was visited. +branch 76 was visited. +branch 77 was visited. +branch 78 was visited. +branch 79 was visited. +branch 80 was visited. +branch 81 was visited. +branch 82 was visited. +branch 83 was visited. +branch 84 was visited. +branch 85 was not visited. +branch 86 was visited. +branch 87 was not visited. +branch 88 was visited. +branch 89 was visited. +branch 90 was visited. +branch 91 was visited. +branch 92 was visited. +branch 93 was visited. +branch 94 was visited. +branch 95 was visited. +branch 96 was visited. +branch 97 was visited. +branch 98 was visited. +branch 99 was visited. +branch 100 was visited. +branch 101 was visited. +branch 102 was visited. +branch 103 was visited. +branch 104 was visited. +branch 105 was visited. +branch 106 was visited. +branch 107 was visited. +branch 108 was visited. +branch 109 was visited. +branch 110 was visited. +branch 111 was visited. +branch 112 was visited. +branch 113 was visited. +branch 114 was not visited. +branch 115 was visited. +branch 116 was visited. +branch 117 was visited. +branch 118 was visited. +branch 119 was visited. +branch 120 was not visited. +branch 121 was visited. +branch 122 was visited. +branch 123 was visited. +branch 124 was not visited. +branch 125 was visited. +branch 126 was visited. +branch 127 was visited. +branch 128 was visited. +branch 129 was visited. +branch 130 was visited. +branch 131 was visited. +branch 132 was not visited. +branch 133 was not visited. +branch 134 was visited. +0.837037037037037 \ No newline at end of file diff --git a/coverage/transformSpecialCharacter.txt b/coverage/transformSpecialCharacter.txt new file mode 100644 index 00000000000..93c21d309f8 --- /dev/null +++ b/coverage/transformSpecialCharacter.txt @@ -0,0 +1,92 @@ +branch 0 was visited. +branch 1 was visited. +branch 2 was not visited. +branch 3 was visited. +branch 4 was not visited. +branch 5 was not visited. +branch 6 was not visited. +branch 7 was visited. +branch 8 was not visited. +branch 9 was not visited. +branch 10 was not visited. +branch 11 was not visited. +branch 12 was not visited. +branch 13 was visited. +branch 14 was not visited. +branch 15 was not visited. +branch 16 was not visited. +branch 17 was not visited. +branch 18 was not visited. +branch 19 was visited. +branch 20 was not visited. +branch 21 was visited. +branch 22 was visited. +branch 23 was visited. +branch 24 was not visited. +branch 25 was not visited. +branch 26 was not visited. +branch 27 was visited. +branch 28 was not visited. +branch 29 was not visited. +branch 30 was not visited. +branch 31 was visited. +branch 32 was not visited. +branch 33 was not visited. +branch 34 was not visited. +branch 35 was visited. +branch 36 was not visited. +branch 37 was visited. +branch 38 was not visited. +branch 39 was visited. +branch 40 was not visited. +branch 41 was visited. +branch 42 was not visited. +branch 43 was not visited. +branch 44 was not visited. +branch 45 was visited. +branch 46 was visited. +branch 47 was visited. +branch 48 was visited. +branch 49 was visited. +branch 50 was visited. +branch 51 was visited. +branch 52 was visited. +branch 53 was visited. +branch 54 was visited. +branch 55 was visited. +branch 56 was visited. +branch 57 was visited. +branch 58 was visited. +branch 59 was visited. +branch 60 was visited. +branch 61 was visited. +branch 62 was visited. +branch 63 was visited. +branch 64 was visited. +branch 65 was visited. +branch 66 was visited. +branch 67 was visited. +branch 68 was visited. +branch 69 was visited. +branch 70 was visited. +branch 71 was visited. +branch 72 was visited. +branch 73 was visited. +branch 74 was visited. +branch 75 was visited. +branch 76 was visited. +branch 77 was visited. +branch 78 was visited. +branch 79 was visited. +branch 80 was visited. +branch 81 was visited. +branch 82 was visited. +branch 83 was visited. +branch 84 was visited. +branch 85 was visited. +branch 86 was visited. +branch 87 was visited. +branch 88 was visited. +branch 89 was visited. +branch 90 was visited. +0.6703296703296703 \ No newline at end of file diff --git a/coverage/transformSpecialCharacter_NEW.txt b/coverage/transformSpecialCharacter_NEW.txt new file mode 100644 index 00000000000..4b47a36be49 --- /dev/null +++ b/coverage/transformSpecialCharacter_NEW.txt @@ -0,0 +1,92 @@ +branch 0 was visited. +branch 1 was visited. +branch 2 was visited. +branch 3 was visited. +branch 4 was not visited. +branch 5 was not visited. +branch 6 was visited. +branch 7 was visited. +branch 8 was visited. +branch 9 was not visited. +branch 10 was visited. +branch 11 was not visited. +branch 12 was visited. +branch 13 was visited. +branch 14 was not visited. +branch 15 was not visited. +branch 16 was visited. +branch 17 was not visited. +branch 18 was visited. +branch 19 was visited. +branch 20 was visited. +branch 21 was visited. +branch 22 was visited. +branch 23 was visited. +branch 24 was visited. +branch 25 was visited. +branch 26 was visited. +branch 27 was visited. +branch 28 was visited. +branch 29 was visited. +branch 30 was visited. +branch 31 was visited. +branch 32 was visited. +branch 33 was not visited. +branch 34 was visited. +branch 35 was visited. +branch 36 was not visited. +branch 37 was visited. +branch 38 was visited. +branch 39 was visited. +branch 40 was visited. +branch 41 was visited. +branch 42 was visited. +branch 43 was visited. +branch 44 was visited. +branch 45 was visited. +branch 46 was visited. +branch 47 was visited. +branch 48 was visited. +branch 49 was visited. +branch 50 was visited. +branch 51 was visited. +branch 52 was visited. +branch 53 was visited. +branch 54 was visited. +branch 55 was visited. +branch 56 was visited. +branch 57 was visited. +branch 58 was visited. +branch 59 was visited. +branch 60 was visited. +branch 61 was visited. +branch 62 was visited. +branch 63 was visited. +branch 64 was visited. +branch 65 was visited. +branch 66 was visited. +branch 67 was visited. +branch 68 was visited. +branch 69 was visited. +branch 70 was visited. +branch 71 was visited. +branch 72 was visited. +branch 73 was visited. +branch 74 was visited. +branch 75 was visited. +branch 76 was visited. +branch 77 was visited. +branch 78 was visited. +branch 79 was visited. +branch 80 was visited. +branch 81 was visited. +branch 82 was visited. +branch 83 was visited. +branch 84 was visited. +branch 85 was visited. +branch 86 was visited. +branch 87 was visited. +branch 88 was visited. +branch 89 was visited. +branch 90 was visited. +0.9010989010989011 \ No newline at end of file diff --git a/getToken.txt b/getToken.txt new file mode 100644 index 00000000000..daa13ed5e0e --- /dev/null +++ b/getToken.txt @@ -0,0 +1,37 @@ +branch 0 was visited. +branch 1 was visited. +branch 2 was visited. +branch 3 was visited. +branch 4 was visited. +branch 5 was visited. +branch 6 was visited. +branch 7 was visited. +branch 8 was visited. +branch 9 was visited. +branch 10 was visited. +branch 11 was visited. +branch 12 was visited. +branch 13 was visited. +branch 14 was visited. +branch 15 was visited. +branch 16 was visited. +branch 17 was visited. +branch 18 was visited. +branch 19 was visited. +branch 20 was visited. +branch 21 was visited. +branch 22 was visited. +branch 23 was not visited. +branch 24 was visited. +branch 25 was visited. +branch 26 was visited. +branch 27 was visited. +branch 28 was visited. +branch 29 was visited. +branch 30 was visited. +branch 31 was visited. +branch 32 was visited. +branch 33 was visited. +branch 34 was visited. +branch 35 was visited. +0.9722222222222222 \ No newline at end of file diff --git a/src/main/java/org/jabref/logic/bibtex/comparator/EntryComparator.java b/src/main/java/org/jabref/logic/bibtex/comparator/EntryComparator.java index 1b3397ccfef..4ac18bf9152 100644 --- a/src/main/java/org/jabref/logic/bibtex/comparator/EntryComparator.java +++ b/src/main/java/org/jabref/logic/bibtex/comparator/EntryComparator.java @@ -10,6 +10,10 @@ import org.jabref.model.entry.field.FieldProperty; import org.jabref.model.entry.field.InternalField; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; + /** * This implementation of Comparator takes care of most of the details of sorting BibTeX entries in JabRef. It is * structured as a node in a linked list of comparators, where each node can contain a link to a new comparator that @@ -24,6 +28,8 @@ public class EntryComparator implements Comparator { private final boolean binary; private final Comparator next; + private static boolean[] visited = new boolean[29]; + public EntryComparator(boolean binary, boolean descending, Field field, Comparator next) { this.binary = binary; this.sortField = field; @@ -43,36 +49,56 @@ public int compare(BibEntry e1, BibEntry e2) { // default equals // TODO: with the new default equals this does not only return 0 for identical objects, // but for all objects that have the same id and same fields - if (Objects.equals(e1, e2)) { + if (Objects.equals(e1, e2)) { + visited[0] = true; + branchCoverage(); return 0; + } else { + visited[1] = true; } Object f1 = e1.getField(sortField).orElse(null); Object f2 = e2.getField(sortField).orElse(null); if (binary) { + visited[2] = true; // We just separate on set and unset fields: if (f1 == null) { + visited[3] = true; + branchCoverage(); return f2 == null ? (next == null ? idCompare(e1, e2) : next.compare(e1, e2)) : 1; } else { + visited[4] = true; + branchCoverage(); return f2 == null ? -1 : (next == null ? idCompare(e1, e2) : next.compare(e1, e2)); } + } else { + visited[5] = true; } // If the field is author or editor, we rearrange names so they are // sorted according to last name. if (sortField.getProperties().contains(FieldProperty.PERSON_NAMES)) { + visited[6] = true; if (f1 != null) { + visited[7] = true; f1 = AuthorList.fixAuthorForAlphabetization((String) f1).toLowerCase(Locale.ROOT); + } else { + visited[8] = true; } if (f2 != null) { + visited[9] = true; f2 = AuthorList.fixAuthorForAlphabetization((String) f2).toLowerCase(Locale.ROOT); + } else { + visited[10] = true; } } else if (sortField.equals(InternalField.TYPE_HEADER)) { + visited[11] = true; // Sort by type. f1 = e1.getType(); f2 = e2.getType(); } else if (sortField.isNumeric()) { + visited[12] = true; try { Integer i1 = Integer.parseInt((String) f1); Integer i2 = Integer.parseInt((String) f2); @@ -80,49 +106,91 @@ public int compare(BibEntry e1, BibEntry e2) { f1 = i1; f2 = i2; } catch (NumberFormatException ex) { + visited[13] = true; // Parsing failed. Give up treating these as numbers. // TODO: should we check which of them failed, and sort based on that? } + } else { + visited[14] = true; } if (f2 == null) { + visited[15] = true; if (f1 == null) { + visited[16] = true; + branchCoverage(); return next == null ? idCompare(e1, e2) : next.compare(e1, e2); } else { + visited[17] = true; + branchCoverage(); return -1; } + } else { + visited[18] = true; } if (f1 == null) { // f2 != null here automatically + visited[19] = true; + branchCoverage(); return 1; + } else { + visited[20] = true; } int result; if ((f1 instanceof Integer) && (f2 instanceof Integer)) { + visited[21] = true; result = -((Integer) f1).compareTo((Integer) f2); } else if (f2 instanceof Integer) { + visited[22] = true; Integer f1AsInteger = Integer.valueOf(f1.toString()); result = -f1AsInteger.compareTo((Integer) f2); } else if (f1 instanceof Integer) { + visited[23] = true; Integer f2AsInteger = Integer.valueOf(f2.toString()); result = -((Integer) f1).compareTo(f2AsInteger); } else { + visited[24] = true; String ours = ((String) f1).toLowerCase(Locale.ROOT); String theirs = ((String) f2).toLowerCase(Locale.ROOT); int comp = ours.compareTo(theirs); result = -comp; - } + } if (result != 0) { + visited[25] = true; + branchCoverage(); return descending ? result : -result; // Primary sort. - } + } else { + visited[26] = true; + } if (next == null) { + visited[27] = true; + branchCoverage(); return idCompare(e1, e2); // If still equal, we use the unique IDs. } else { + visited[28] = true; + branchCoverage(); return next.compare(e1, e2); // Secondary sort if existent. } } + private void branchCoverage() { + try { + File f = new File("/tmp/compare.txt"); + BufferedWriter bw = new BufferedWriter(new FileWriter(f)); + double frac = 0; + for (int j = 0; j < visited.length; ++j) { + frac += (visited[j] ? 1 : 0); + bw.write("branch " + j + " was" + (visited[j] ? " visited. " : " not visited. ") + "\n"); + } + bw.write("" + frac / visited.length); + bw.close(); + } catch (Exception e) { + System.err.println("File not found!"); + } + } + private static int idCompare(BibEntry b1, BibEntry b2) { return b1.getId().compareTo(b2.getId()); } diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java index 5b2b15eb964..ee7ce9f7c24 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java @@ -1,5 +1,8 @@ package org.jabref.logic.bibtexkeypattern; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -42,6 +45,7 @@ public class BracketedPattern { private static final String STARTING_CAPITAL_PATTERN = "[^A-Z]"; private static final int CHARS_OF_FIRST = 5; private static final Pattern REGEX_PATTERN = Pattern.compile(".*\\(\\{([A-Z]+)\\}\\).*"); + private static boolean[] visited = new boolean[68]; private final String pattern; @@ -160,204 +164,344 @@ public static String expandBrackets(String pattern, Character keywordDelimiter, * @return String containing the evaluation result. Empty string if the pattern cannot be resolved. */ public static String getFieldValue(BibEntry entry, String value, Character keywordDelimiter, BibDatabase database, boolean isEnforceLegalKey) { - String val = value; try { if (val.startsWith("auth") || val.startsWith("pureauth")) { + visited[0] = true; // result the author String authString; if (database != null) { + visited[1] = true; authString = entry.getResolvedFieldOrAlias(StandardField.AUTHOR, database) .map(authorString -> normalize(database.resolveForStrings(authorString))).orElse(""); } else { + visited[2] = true; authString = entry.getResolvedFieldOrAlias(StandardField.AUTHOR, database).orElse(""); } if (val.startsWith("pure")) { + visited[3] = true; // "pure" is used in the context of authors to resolve to authors only and not fallback to editors // The other functionality of the pattern "ForeIni", ... is the same // Thus, remove the "pure" prefix so the remaining code in this section functions correctly // val = val.substring(4); } else { + visited[4] = true; // special feature: A pattern starting with "auth" falls back to the editor if (authString.isEmpty()) { + visited[5] = true; if (database != null) { + visited[6] = true; authString = entry.getResolvedFieldOrAlias(StandardField.EDITOR, database) .map(authorString -> normalize(database.resolveForStrings(authorString))).orElse(""); } else { + visited[7] = true; authString = entry.getResolvedFieldOrAlias(StandardField.EDITOR, database).orElse(""); } + } else { + visited[8] = true; } } // Gather all author-related checks, so we don't // have to check all the time. if ("auth".equals(val)) { + visited[9] = true; + getBranchCoverage(visited); return firstAuthor(authString); } else if ("authForeIni".equals(val)) { + visited[10] = true; + getBranchCoverage(visited); return firstAuthorForenameInitials(authString); } else if ("authFirstFull".equals(val)) { + visited[11] = true; + getBranchCoverage(visited); return firstAuthorVonAndLast(authString); } else if ("authors".equals(val)) { + visited[12] = true; + getBranchCoverage(visited); return allAuthors(authString); } else if ("authorsAlpha".equals(val)) { + visited[13] = true; + getBranchCoverage(visited); return authorsAlpha(authString); } // Last author's last name else if ("authorLast".equals(val)) { + visited[14] = true; + getBranchCoverage(visited); return lastAuthor(authString); } else if ("authorLastForeIni".equals(val)) { + visited[15] = true; + getBranchCoverage(visited); return lastAuthorForenameInitials(authString); } else if ("authorIni".equals(val)) { + visited[16] = true; + getBranchCoverage(visited); return oneAuthorPlusIni(authString); } else if (val.matches("authIni[\\d]+")) { + visited[17] = true; int num = Integer.parseInt(val.substring(7)); + getBranchCoverage(visited); return authIniN(authString, num); } else if ("auth.auth.ea".equals(val)) { + visited[18] = true; + getBranchCoverage(visited); return authAuthEa(authString); } else if ("auth.etal".equals(val)) { + visited[19] = true; + getBranchCoverage(visited); return authEtal(authString, ".", ".etal"); } else if ("authEtAl".equals(val)) { + visited[20] = true; + getBranchCoverage(visited); return authEtal(authString, "", "EtAl"); } else if ("authshort".equals(val)) { + visited[21] = true; + getBranchCoverage(visited); return authshort(authString); } else if (val.matches("auth[\\d]+_[\\d]+")) { + visited[22] = true; String[] nums = val.substring(4).split("_"); + getBranchCoverage(visited); return authNofMth(authString, Integer.parseInt(nums[0]), Integer.parseInt(nums[1])); } else if (val.matches("auth\\d+")) { + visited[23] = true; int num = Integer.parseInt(val.substring(4)); + getBranchCoverage(visited); return authN(authString, num, isEnforceLegalKey); } else if (val.matches("authors\\d+")) { + visited[24] = true; + getBranchCoverage(visited); return nAuthors(authString, Integer.parseInt(val.substring(7))); } else { // This "auth" business was a dead end, so just // use it literally: + visited[25] = true; + getBranchCoverage(visited); return entry.getResolvedFieldOrAlias(FieldFactory.parseField(val), database).orElse(""); } } else if (val.startsWith("ed")) { + visited[26] = true; // Gather all markers starting with "ed" here, so we // don't have to check all the time. if ("edtr".equals(val)) { + visited[27] = true; + getBranchCoverage(visited); return firstAuthor(entry.getResolvedFieldOrAlias(StandardField.EDITOR, database).orElse("")); } else if ("edtrForeIni".equals(val)) { + visited[28] = true; + getBranchCoverage(visited); return firstAuthorForenameInitials(entry.getResolvedFieldOrAlias(StandardField.EDITOR, database).orElse("")); } else if ("editors".equals(val)) { + visited[29] = true; + getBranchCoverage(visited); return allAuthors(entry.getResolvedFieldOrAlias(StandardField.EDITOR, database).orElse("")); // Last author's last name } else if ("editorLast".equals(val)) { + visited[30] = true; + getBranchCoverage(visited); return lastAuthor(entry.getResolvedFieldOrAlias(StandardField.EDITOR, database).orElse("")); } else if ("editorLastForeIni".equals(val)) { + visited[31] = true; + getBranchCoverage(visited); return lastAuthorForenameInitials(entry.getResolvedFieldOrAlias(StandardField.EDITOR, database).orElse("")); } else if ("editorIni".equals(val)) { + visited[32] = true; + getBranchCoverage(visited); return oneAuthorPlusIni(entry.getResolvedFieldOrAlias(StandardField.EDITOR, database).orElse("")); } else if (val.matches("edtrIni[\\d]+")) { + visited[33] = true; int num = Integer.parseInt(val.substring(7)); + getBranchCoverage(visited); return authIniN(entry.getResolvedFieldOrAlias(StandardField.EDITOR, database).orElse(""), num); } else if (val.matches("edtr[\\d]+_[\\d]+")) { + visited[34] = true; String[] nums = val.substring(4).split("_"); + getBranchCoverage(visited); return authNofMth(entry.getResolvedFieldOrAlias(StandardField.EDITOR, database).orElse(""), Integer.parseInt(nums[0]), Integer.parseInt(nums[1]) - 1); } else if ("edtr.edtr.ea".equals(val)) { + visited[35] = true; + getBranchCoverage(visited); return authAuthEa(entry.getResolvedFieldOrAlias(StandardField.EDITOR, database).orElse("")); } else if ("edtrshort".equals(val)) { + visited[36] = true; + getBranchCoverage(visited); return authshort(entry.getResolvedFieldOrAlias(StandardField.EDITOR, database).orElse("")); } // authN. First N chars of the first author's last // name. else if (val.matches("edtr\\d+")) { + visited[37] = true; String fa = firstAuthor(entry.getResolvedFieldOrAlias(StandardField.EDITOR, database).orElse("")); int num = Integer.parseInt(val.substring(4)); if (num > fa.length()) { + visited[66] = true; num = fa.length(); } + visited[65] = true; + getBranchCoverage(visited); return fa.substring(0, num); } else { + visited[38] = true; // This "ed" business was a dead end, so just // use it literally: + getBranchCoverage(visited); return entry.getResolvedFieldOrAlias(FieldFactory.parseField(val), database).orElse(""); } } else if ("firstpage".equals(val)) { + visited[39] = true; + getBranchCoverage(visited); return firstPage(entry.getResolvedFieldOrAlias(StandardField.PAGES, database).orElse("")); } else if ("pageprefix".equals(val)) { + visited[40] = true; + getBranchCoverage(visited); return pagePrefix(entry.getResolvedFieldOrAlias(StandardField.PAGES, database).orElse("")); } else if ("lastpage".equals(val)) { + visited[41] = true; + getBranchCoverage(visited); return lastPage(entry.getResolvedFieldOrAlias(StandardField.PAGES, database).orElse("")); } else if ("title".equals(val)) { + visited[42] = true; + getBranchCoverage(visited); return camelizeSignificantWordsInTitle(entry.getResolvedFieldOrAlias(StandardField.TITLE, database).orElse("")); } else if ("fulltitle".equals(val)) { + visited[43] = true; + getBranchCoverage(visited); return entry.getResolvedFieldOrAlias(StandardField.TITLE, database).orElse(""); } else if ("shorttitle".equals(val)) { + visited[44] = true; + getBranchCoverage(visited); return getTitleWords(3, removeSmallWords(entry.getResolvedFieldOrAlias(StandardField.TITLE, database).orElse(""))); } else if ("shorttitleINI".equals(val)) { + visited[45] = true; + getBranchCoverage(visited); return keepLettersAndDigitsOnly( applyModifiers(getTitleWordsWithSpaces(3, entry.getResolvedFieldOrAlias(StandardField.TITLE, database).orElse("")), Collections.singletonList("abbr"), 0)); } else if ("veryshorttitle".equals(val)) { + visited[46] = true; + getBranchCoverage(visited); return getTitleWords(1, removeSmallWords(entry.getResolvedFieldOrAlias(StandardField.TITLE, database).orElse(""))); } else if ("camel".equals(val)) { + visited[47] = true; + getBranchCoverage(visited); return getCamelizedTitle(entry.getResolvedFieldOrAlias(StandardField.TITLE, database).orElse("")); } else if ("shortyear".equals(val)) { + visited[48] = true; String yearString = entry.getResolvedFieldOrAlias(StandardField.YEAR, database).orElse(""); if (yearString.isEmpty()) { + visited[49] = true; + getBranchCoverage(visited); return yearString; // In press/in preparation/submitted } else if (yearString.startsWith("in") || yearString.startsWith("sub")) { + visited[50] = true; + getBranchCoverage(visited); return "IP"; } else if (yearString.length() > 2) { + visited[51] = true; + getBranchCoverage(visited); return yearString.substring(yearString.length() - 2); } else { + visited[52] = true; + getBranchCoverage(visited); return yearString; } } else if ("entrytype".equals(val)) { + visited[53] = true; + getBranchCoverage(visited); return entry.getResolvedFieldOrAlias(InternalField.TYPE_HEADER, database).orElse(""); } else if (val.matches("keyword\\d+")) { + visited[54] = true; // according to LabelPattern.php, it returns keyword number n int num = Integer.parseInt(val.substring(7)); KeywordList separatedKeywords = entry.getResolvedKeywords(keywordDelimiter, database); if (separatedKeywords.size() < num) { + visited[55] = true; // not enough keywords + getBranchCoverage(visited); return ""; } else { + visited[56] = true; // num counts from 1 to n, but index in arrayList count from 0 to n-1 + getBranchCoverage(visited); return separatedKeywords.get(num - 1).toString(); } } else if (val.matches("keywords\\d*")) { + visited[57] = true; // return all keywords, not separated int num; if (val.length() > 8) { + visited[58] = true; num = Integer.parseInt(val.substring(8)); } else { + visited[59] = true; num = Integer.MAX_VALUE; } KeywordList separatedKeywords = entry.getResolvedKeywords(keywordDelimiter, database); StringBuilder sb = new StringBuilder(); int i = 0; + int sizeOfSeparatedKeywords = separatedKeywords.size(); for (Keyword keyword : separatedKeywords) { + visited[60] = true; // remove all spaces sb.append(keyword.toString().replaceAll("\\s+", "")); i++; if (i >= num) { + visited[61] = true; break; + } else { + visited[62] = true; } } + if (sizeOfSeparatedKeywords == 0) { + visited[67] = true; + } + getBranchCoverage(visited); return sb.toString(); } else { + visited[63] = true; // we haven't seen any special demands + getBranchCoverage(visited); return entry.getResolvedFieldOrAlias(FieldFactory.parseField(val), database).orElse(""); } } catch (NullPointerException ex) { + visited[64] = true; + getBranchCoverage(visited); LOGGER.debug("Problem making expanding bracketed expression", ex); return ""; } } + private static void getBranchCoverage(boolean[] visited) { + try { + File directory = new File("/Temp"); + if (!directory.exists()) { + directory.mkdir(); + } + File f = new File(directory + "/getFieldValue.txt"); + BufferedWriter bw = new BufferedWriter(new FileWriter(f)); + double frac = 0; + for (int i = 0; i < visited.length; ++i) { + frac += (visited[i] ? 1 : 0); + bw.write("branch " + i + " was" + (visited[i] ? " visited." : " not visited.") + "\n"); + } + bw.write("" + frac / visited.length); + bw.close(); + } catch (Exception e) { + System.err.println("ye"); + } + } + /** * Applies modifiers to a label generated based on a field marker. * @param label The generated label. diff --git a/src/main/java/org/jabref/logic/importer/fileformat/GvkParser.java b/src/main/java/org/jabref/logic/importer/fileformat/GvkParser.java index 29c24e20f4d..7263d5a5b7d 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/GvkParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/GvkParser.java @@ -1,5 +1,8 @@ package org.jabref.logic.importer.fileformat; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.util.LinkedList; @@ -27,8 +30,35 @@ import org.xml.sax.SAXException; public class GvkParser implements Parser { + private static boolean[] visited = new boolean[64]; private static final Logger LOGGER = LoggerFactory.getLogger(GvkParser.class); + private String author = null; + private String editor = null; + private String title = null; + private String publisher = null; + private String year = null; + private String address = null; + private String series = null; + private String edition = null; + private String isbn = null; + private String issn = null; + private String number = null; + private String pagetotal = null; + private String volume = null; + private String pages = null; + private String journal = null; + private String ppn = null; + private String booktitle = null; + private String url = null; + private String note = null; + + private String quelle = ""; + private String mak = ""; + private String subtitle = ""; + + private EntryType entryType = StandardEntryType.Book; // Default + @Override public List parseEntries(InputStream inputStream) throws ParseException { try { @@ -70,186 +100,136 @@ private List parseEntries(Document content) { } private BibEntry parseEntry(Element e) { - String author = null; - String editor = null; - String title = null; - String publisher = null; - String year = null; - String address = null; - String series = null; - String edition = null; - String isbn = null; - String issn = null; - String number = null; - String pagetotal = null; - String volume = null; - String pages = null; - String journal = null; - String ppn = null; - String booktitle = null; - String url = null; - String note = null; - - String quelle = ""; - String mak = ""; - String subtitle = ""; - - EntryType entryType = StandardEntryType.Book; // Default - // Alle relevanten Informationen einsammeln List datafields = getChildren("datafield", e); + int SIZEOFDATAFIELDS = datafields.size(); for (Element datafield : datafields) { + visited[0] = true; String tag = datafield.getAttribute("tag"); LOGGER.debug("tag: " + tag); // mak if ("002@".equals(tag)) { - mak = getSubfield("0", datafield); - if (mak == null) { - mak = ""; - } + visited[1] = true; + parseBibliographicTypeAndStatusData(datafield); + } else { + visited[2] = true; } //ppn if ("003@".equals(tag)) { - ppn = getSubfield("0", datafield); + visited[3] = true; + parseRecordControlNumberData(datafield); + } else { + visited[4] = true; } //author if ("028A".equals(tag)) { - String vorname = getSubfield("d", datafield); - String nachname = getSubfield("a", datafield); - - if (author == null) { - author = ""; - } else { - author = author.concat(" and "); - } - author = author.concat(vorname + " " + nachname); + visited[5] = true; + parsePrimaryAuthorData(datafield); + } else { + visited[6] = true; } + //author (weiterer) if ("028B".equals(tag)) { - String vorname = getSubfield("d", datafield); - String nachname = getSubfield("a", datafield); - - if (author == null) { - author = ""; - } else { - author = author.concat(" and "); - } - author = author.concat(vorname + " " + nachname); + visited[7] = true; + parseCoauthorData(datafield); + } else { + visited[8] = true; } //editor if ("028C".equals(tag)) { - String vorname = getSubfield("d", datafield); - String nachname = getSubfield("a", datafield); - - if (editor == null) { - editor = ""; - } else { - editor = editor.concat(" and "); - } - editor = editor.concat(vorname + " " + nachname); + visited[9] = true; + parseSecondaryAuthorData(datafield); + } else { + visited[10] = true; } //title and subtitle if ("021A".equals(tag)) { - title = getSubfield("a", datafield); - subtitle = getSubfield("d", datafield); + visited[11] = true; + parseTitleAndStatementOfResponsibilityAreaData(datafield); + } else { + visited[12] = true; } //publisher and address if ("033A".equals(tag)) { - publisher = getSubfield("n", datafield); - address = getSubfield("p", datafield); + visited[13] = true; + parseFirstPublisherData(datafield); + } else { + visited[14] = true; } //year if ("011@".equals(tag)) { - year = getSubfield("a", datafield); + visited[15] = true; + parseDateOfPublicationData(datafield); + } else { + visited[16] = true; } //year, volume, number, pages (year bei Zeitschriften (evtl. redundant mit 011@)) if ("031A".equals(tag)) { - year = getSubfield("j", datafield); - - volume = getSubfield("e", datafield); - number = getSubfield("a", datafield); - pages = getSubfield("h", datafield); - + visited[17] = true; + parseNumberingAreaData(datafield); + } else { + visited[18] = true; } // 036D seems to contain more information than the other fields // overwrite information using that field // 036D also contains information normally found in 036E if ("036D".equals(tag)) { - // 021 might have been present - if (title != null) { - // convert old title (contained in "a" of 021A) to volume - if (title.startsWith("@")) { - // "@" indicates a number - title = title.substring(1); - } - number = title; - } - //title and subtitle - title = getSubfield("a", datafield); - subtitle = getSubfield("d", datafield); - volume = getSubfield("l", datafield); + visited[19] = true; + parseLinkToMultiVolumePublicationData(datafield); + } else { + visited[20] = true; } //series and number if ("036E".equals(tag)) { - series = getSubfield("a", datafield); - number = getSubfield("l", datafield); - String kor = getSubfield("b", datafield); - - if (kor != null) { - series = series + " / " + kor; - } + visited[21] = true; + parseExtraLinkSerialPublicationData(datafield); + } else { + visited[22] = true; } //note if ("037A".equals(tag)) { - note = getSubfield("a", datafield); + visited[23] = true; + parseGeneralNoteData(datafield); + } else { + visited[24] = true; } //edition if ("032@".equals(tag)) { - edition = getSubfield("a", datafield); + visited[25] = true; + parseEditionAreaData(datafield); + } else { + visited[26] = true; } //isbn if ("004A".equals(tag)) { - final String isbn10 = getSubfield("0", datafield); - final String isbn13 = getSubfield("A", datafield); - - if (isbn10 != null) { - isbn = isbn10; - } - - if (isbn13 != null) { - isbn = isbn13; - } - + visited[27] = true; + parseISBNData(datafield); + } else { + visited[28] = true; } // Hochschulschriftenvermerk // Bei einer Verlagsdissertation ist der Ort schon eingetragen if ("037C".equals(tag)) { - if (address == null) { - address = getSubfield("b", datafield); - if (address != null) { - address = removeSortCharacters(address); - } - } - - String st = getSubfield("a", datafield); - if ((st != null) && st.contains("Diss")) { - entryType = StandardEntryType.PhdThesis; - } + visited[29] = true; + parseDissertationNoteData(datafield); + } else { + visited[30] = true; } //journal oder booktitle @@ -265,36 +245,34 @@ private BibEntry parseEntry(Element e) { * (sonst in Kategorie 033A). */ if ("027D".equals(tag)) { - journal = getSubfield("a", datafield); - booktitle = getSubfield("a", datafield); - address = getSubfield("p", datafield); - publisher = getSubfield("n", datafield); + visited[31] = true; + parseVolumeSetAndEssayData(datafield); + } else { + visited[32] = true; } //pagetotal if ("034D".equals(tag)) { - pagetotal = getSubfield("a", datafield); - - if (pagetotal != null) { - // S, S. etc. entfernen - pagetotal = pagetotal.replaceAll(" S\\.?$", ""); - } + visited[33] = true; + parsePhysicalInformationData(datafield); + } else { + visited[34] = true; } // Behandlung von Konferenzen if ("030F".equals(tag)) { - address = getSubfield("k", datafield); - - if (!"proceedings".equals(entryType)) { - subtitle = getSubfield("a", datafield); - } - - entryType = StandardEntryType.Proceedings; + visited[35] = true; + parseConferenceData(datafield); + } else { + visited[36] = true; } // Wenn eine Verlagsdiss vorliegt if (entryType.equals(StandardEntryType.PhdThesis) && (isbn != null)) { + visited[37] = true; entryType = StandardEntryType.Book; + } else { + visited[38] = true; } //Hilfskategorien zur Entscheidung @article @@ -305,55 +283,99 @@ private BibEntry parseEntry(Element e) { //Quelle unvollständig sind (z.B. nicht Serie //und Nummer angegeben werden) if ("039B".equals(tag)) { - quelle = getSubfield("8", datafield); + visited[38] = true; + parseRelationToParentLiteratureData(datafield); + } else { + visited[40] = true; } + if ("046R".equals(tag) && ((quelle == null) || quelle.isEmpty())) { - quelle = getSubfield("a", datafield); + visited[41] = true; + parseLiteratureSourceData(datafield); + } else { + visited[42] = true; } // URLs behandeln if ("009P".equals(tag) && ("03".equals(datafield.getAttribute("occurrence")) || "05".equals(datafield.getAttribute("occurrence"))) && (url == null)) { - url = getSubfield("a", datafield); + visited[43] = true; + parseOnlineResourceData(datafield); + } else { + visited[44] = true; } } - + // if we skipped the for loop completely + if (SIZEOFDATAFIELDS == 0) { + visited[45] = true; + } // Abfangen von Nulleintraegen if (quelle == null) { + visited[46] = true; quelle = ""; + } else { + visited[47] = true; } // Nichtsortierzeichen entfernen if (author != null) { + visited[48] = true; author = removeSortCharacters(author); + } else { + visited[49] = true; } + if (editor != null) { + visited[50] = true; editor = removeSortCharacters(editor); + } else { + visited[51] = true; } + if (title != null) { + visited[52] = true; title = removeSortCharacters(title); + } else { + visited[53] = true; } + if (subtitle != null) { + visited[54] = true; subtitle = removeSortCharacters(subtitle); + } else { + visited[55] = true; } // Dokumenttyp bestimmen und Eintrag anlegen if (mak.startsWith("As")) { + visited[56] = true; entryType = BibEntry.DEFAULT_TYPE; if (quelle.contains("ISBN")) { + visited[57] = true; entryType = StandardEntryType.InCollection; + } else { + visited[58] = true; } + if (quelle.contains("ZDB-ID")) { + visited[59] = true; entryType = StandardEntryType.Article; + } else { + visited[60] = true; } + } else if (mak.isEmpty()) { + visited[61] = true; entryType = BibEntry.DEFAULT_TYPE; } else if (mak.startsWith("O")) { + visited[62] = true; entryType = BibEntry.DEFAULT_TYPE; // FIXME: online only available in Biblatex //entryType = "online"; + } else { + visited[63] = true; } /* @@ -365,16 +387,80 @@ private BibEntry parseEntry(Element e) { */ BibEntry result = new BibEntry(entryType); + configureBibEntry(result); + + try { + File f = new File("/tmp/parseEntry.txt"); + BufferedWriter bw = new BufferedWriter(new FileWriter(f)); + double frac = 0; + for(int i = 0; i < visited.length; ++i) { + frac += (visited[i] ? 1 : 0); + bw.write("branch " + i + " was " + (visited[i] ? " visited." : " not visited.") + "\n"); + } + bw.write("" + frac/visited.length); + bw.close(); + } catch (Exception exc) { + System.err.println("Could not open/write to file!"); + exc.printStackTrace(); + } + + return result; + } + + /* HELPER FUNCTIONS FOR parseEntry */ + + private void parseVolumeSetAndEssayData(Element datafield) { + journal = getSubfield("a", datafield); + booktitle = getSubfield("a", datafield); + address = getSubfield("p", datafield); + publisher = getSubfield("n", datafield); + } + + private void parsePhysicalInformationData(Element datafield) { + pagetotal = getSubfield("a", datafield); + + if (pagetotal != null) { + // S, S. etc. entfernen + pagetotal = pagetotal.replaceAll(" S\\.?$", ""); + } + } + + private void parseConferenceData(Element datafield) { + address = getSubfield("k", datafield); + + if (!"proceedings".equals(entryType)) { + subtitle = getSubfield("a", datafield); + } + + entryType = StandardEntryType.Proceedings; + } + + private void parseRelationToParentLiteratureData(Element datafield) { + quelle = getSubfield("8", datafield); + } + + private void parseLiteratureSourceData(Element datafield) { + quelle = getSubfield("a", datafield); + } + + private void parseOnlineResourceData(Element datafield) { + url = getSubfield("a", datafield); + } + + private void configureBibEntry(BibEntry result) { // Zuordnung der Felder in Abhängigkeit vom Dokumenttyp if (author != null) { result.setField(StandardField.AUTHOR, author); } + if (editor != null) { result.setField(StandardField.EDITOR, editor); } + if (title != null) { result.setField(StandardField.TITLE, title); } + if (!Strings.isNullOrEmpty(subtitle)) { // ensure that first letter is an upper case letter // there could be the edge case that the string is only one character long, therefore, this special treatment @@ -384,50 +470,66 @@ private BibEntry parseEntry(Element e) { if (subtitle.length() > 1) { newSubtitle.append(subtitle.substring(1)); } + result.setField(StandardField.SUBTITLE, newSubtitle.toString()); } + if (publisher != null) { result.setField(StandardField.PUBLISHER, publisher); - } + } + if (year != null) { result.setField(StandardField.YEAR, year); } + if (address != null) { result.setField(StandardField.ADDRESS, address); } + if (series != null) { result.setField(StandardField.SERIES, series); } + if (edition != null) { result.setField(StandardField.EDITION, edition); - } + } + if (isbn != null) { result.setField(StandardField.ISBN, isbn); } + if (issn != null) { result.setField(StandardField.ISSN, issn); } + if (number != null) { result.setField(StandardField.NUMBER, number); } + if (pagetotal != null) { result.setField(StandardField.PAGETOTAL, pagetotal); } + if (pages != null) { result.setField(StandardField.PAGES, pages); } + if (volume != null) { result.setField(StandardField.VOLUME, volume); } + if (journal != null) { result.setField(StandardField.JOURNAL, journal); } + if (ppn != null) { result.setField(new UnknownField("ppn_GVK"), ppn); - } + } + if (url != null) { result.setField(StandardField.URL, url); } + if (note != null) { result.setField(StandardField.NOTE, note); } @@ -437,8 +539,137 @@ private BibEntry parseEntry(Element e) { } else if ("incollection".equals(entryType) && (booktitle != null)) { result.setField(StandardField.BOOKTITLE, booktitle); } + } - return result; + private void parseBibliographicTypeAndStatusData(Element datafield) { + mak = getSubfield("0", datafield); + if (mak == null) { + mak = ""; + } else { + } + } + + private void parseRecordControlNumberData(Element datafield) { + ppn = getSubfield("0", datafield); + } + + private void parsePrimaryAuthorData(Element datafield) { + String vorname = getSubfield("d", datafield); + String nachname = getSubfield("a", datafield); + + if (author == null) { + author = ""; + } else { + author = author.concat(" and "); + } + author = author.concat(vorname + " " + nachname); + } + + private void parseCoauthorData(Element datafield) { + String vorname = getSubfield("d", datafield); + String nachname = getSubfield("a", datafield); + + if (author == null) { + author = ""; + } else { + author = author.concat(" and "); + } + author = author.concat(vorname + " " + nachname); + } + + private void parseSecondaryAuthorData(Element datafield) { + String vorname = getSubfield("d", datafield); + String nachname = getSubfield("a", datafield); + + if (editor == null) { + editor = ""; + } else { + editor = editor.concat(" and "); + } + editor = editor.concat(vorname + " " + nachname); + } + + private void parseLinkToMultiVolumePublicationData(Element datafield) { + // 021 might have been present + if (title != null) { + // convert old title (contained in "a" of 021A) to volume + if (title.startsWith("@")) { + // "@" indicates a number + title = title.substring(1); + } + + number = title; + } + + //title and subtitle + title = getSubfield("a", datafield); + subtitle = getSubfield("d", datafield); + volume = getSubfield("l", datafield); + } + + private void parseNumberingAreaData(Element datafield) { + year = getSubfield("j", datafield); + volume = getSubfield("e", datafield); + number = getSubfield("a", datafield); + pages = getSubfield("h", datafield); + } + + private void parseDateOfPublicationData(Element datafield) { + year = getSubfield("a", datafield); + } + + private void parseFirstPublisherData(Element datafield) { + publisher = getSubfield("n", datafield); + address = getSubfield("p", datafield); + } + + private void parseTitleAndStatementOfResponsibilityAreaData(Element datafield) { + title = getSubfield("a", datafield); + subtitle = getSubfield("d", datafield); + } + + private void parseExtraLinkSerialPublicationData(Element datafield) { + series = getSubfield("a", datafield); + number = getSubfield("l", datafield); + String kor = getSubfield("b", datafield); + if (kor != null) { + series = series + " / " + kor; + } + } + + private void parseGeneralNoteData(Element datafield) { + note = getSubfield("a", datafield); + } + + private void parseEditionAreaData(Element datafield) { + edition = getSubfield("a", datafield); + } + + private void parseISBNData(Element datafield) { + final String isbn10 = getSubfield("0", datafield); + final String isbn13 = getSubfield("A", datafield); + + if (isbn10 != null) { + isbn = isbn10; + } + + if (isbn13 != null) { + isbn = isbn13; + } + } + + private void parseDissertationNoteData(Element datafield) { + if (address == null) { + address = getSubfield("b", datafield); + if (address != null) { + address = removeSortCharacters(address); + } + } + + String st = getSubfield("a", datafield); + if ((st != null) && st.contains("Diss")) { + entryType = StandardEntryType.PhdThesis; + } } private String getSubfield(String a, Element datafield) { diff --git a/src/main/java/org/jabref/logic/layout/format/Authors.java b/src/main/java/org/jabref/logic/layout/format/Authors.java index b1514623c87..aec772bbc7b 100644 --- a/src/main/java/org/jabref/logic/layout/format/Authors.java +++ b/src/main/java/org/jabref/logic/layout/format/Authors.java @@ -9,6 +9,9 @@ import org.jabref.model.entry.Author; import org.jabref.model.entry.AuthorList; +import java.io.FileWriter; +import java.io.BufferedWriter; +import java.io.File; /** * Versatile author name formatter that takes arguments to control the formatting style. */ @@ -77,6 +80,7 @@ public class Authors extends AbstractParamLayoutFormatter { private static final String SEMICOLON = "; "; private static final String AND = " and "; private static final String OXFORD = ", and "; + private static boolean[] visited = new boolean[42]; private int flMode; @@ -116,100 +120,169 @@ public void setArgument(String arg) { private void handleArgument(String key, String value) { if (Authors.AUTHOR_ORDER.contains(key.trim().toLowerCase(Locale.ROOT))) { + visited[0] = true; if (comp(key, "FirstFirst")) { + visited[1] = true; flMode = Authors.FIRST_FIRST; } else if (comp(key, "LastFirst")) { + visited[2] = true; flMode = Authors.LAST_FIRST; } else if (comp(key, "LastFirstFirstFirst")) { + visited[3] = true; flMode = Authors.LF_FF; + } else { + visited[4] = true; } } else if (Authors.AUTHOR_ABRV.contains(key.trim().toLowerCase(Locale.ROOT))) { + visited[5] = true; if (comp(key, "FullName")) { + visited[6] = true; abbreviate = false; } else if (comp(key, "Initials")) { + visited[7] = true; abbreviate = true; firstInitialOnly = false; } else if (comp(key, "FirstInitial")) { + visited[8] = true; abbreviate = true; firstInitialOnly = true; } else if (comp(key, "MiddleInitial")) { + visited[9] = true; abbreviate = true; middleInitial = true; } else if (comp(key, "LastName")) { + visited[10] = true; lastNameOnly = true; } else if (comp(key, "InitialsNoSpace")) { + visited[11] = true; abbreviate = true; abbrSpaces = false; + } else { + visited[12] = true; } } else if (Authors.AUTHOR_PUNC.contains(key.trim().toLowerCase(Locale.ROOT))) { + visited[13] = true; if (comp(key, "FullPunc")) { + visited[14] = true; abbrDots = true; lastFirstSeparator = ", "; } else if (comp(key, "NoPunc")) { + visited[15] = true; abbrDots = false; lastFirstSeparator = " "; } else if (comp(key, "NoComma")) { + visited[16] = true; abbrDots = true; lastFirstSeparator = " "; } else if (comp(key, "NoPeriod")) { + visited[17] = true; abbrDots = false; lastFirstSeparator = ", "; + } else { + visited[18] = true; } } // AuthorSep = [Comma | And | Colon | Semicolon | sep=] // AuthorLastSep = [And | Comma | Colon | Semicolon | Amp | Oxford | lastsep=] else if (Authors.SEPARATORS.contains(key.trim().toLowerCase(Locale.ROOT)) || Authors.LAST_SEPARATORS.contains(key.trim().toLowerCase(Locale.ROOT))) { + visited[19] = true; if (comp(key, "Comma")) { + visited[20] = true; if (setSep) { + visited[21] = true; lastSeparator = Authors.COMMA; } else { + visited[22] = true; separator = Authors.COMMA; setSep = true; } } else if (comp(key, "And")) { + visited[23] = true; if (setSep) { + visited[24] = true; lastSeparator = Authors.AND; } else { + visited[25] = true; separator = Authors.AND; setSep = true; } } else if (comp(key, "Colon")) { + visited[26] = true; if (setSep) { + visited[27] = true; lastSeparator = Authors.COLON; } else { + visited[28] = true; separator = Authors.COLON; setSep = true; } } else if (comp(key, "Semicolon")) { + visited[29] = true; if (setSep) { + visited[30] = true; lastSeparator = Authors.SEMICOLON; } else { + visited[31] = true; separator = Authors.SEMICOLON; setSep = true; } } else if (comp(key, "Oxford")) { + visited[32] = true; lastSeparator = Authors.OXFORD; } else if (comp(key, "Amp")) { + visited[33] = true; lastSeparator = Authors.AMP; } else if (comp(key, "Sep") && !value.isEmpty()) { + visited[34] = true; separator = value; setSep = true; } else if (comp(key, "LastSep") && !value.isEmpty()) { + visited[35] = true; lastSeparator = value; + } else { + visited[36] = true; } } else if ("etal".equalsIgnoreCase(key.trim())) { + visited[37] = true; etAlString = value; } else if (Authors.NUMBER_PATTERN.matcher(key.trim()).matches()) { + visited[38] = true; // Just a number: int num = Integer.parseInt(key.trim()); if (setMaxAuthors) { + visited[39] = true; authorNumberEtAl = num; } else { + visited[40] = true; maxAuthors = num; setMaxAuthors = true; } + } else { + visited[41] = true; + } + + try { + File directory = new File("/Temp"); + if (!directory.exists()){ + directory.mkdir(); + } + File f = new File(directory + "/handleArgument.txt"); + + BufferedWriter bw = new BufferedWriter(new FileWriter(f)); + double frac = 0; + for(int i = 0; i < visited.length; ++i) { + frac += (visited[i] ? 1 : 0); + bw.write("branch " + i + " was " + (visited[i] ? " visited." : " not visited.") + "\n"); + } + + bw.write("" + frac/visited.length); + bw.close(); + } catch (Exception e) { + System.err.println("Did not find the path"); } + + // SHOULD BE: 58% } /** diff --git a/src/main/java/org/jabref/logic/layout/format/AuthorsRefactor.java b/src/main/java/org/jabref/logic/layout/format/AuthorsRefactor.java new file mode 100644 index 00000000000..e5f2bebf2cb --- /dev/null +++ b/src/main/java/org/jabref/logic/layout/format/AuthorsRefactor.java @@ -0,0 +1,360 @@ +package org.jabref.logic.layout.format; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Pattern; + +import org.jabref.logic.layout.AbstractParamLayoutFormatter; +import org.jabref.model.entry.Author; +import org.jabref.model.entry.AuthorList; + +import java.io.FileWriter; +import java.io.BufferedWriter; +import java.io.File; +/** + * Versatile author name formatter that takes arguments to control the formatting style. + */ +public class AuthorsRefactor extends AbstractParamLayoutFormatter { + + private static boolean[] visited = new boolean[8]; + + /* + AuthorSort = [FirstFirst | LastFirst | LastFirstFirstFirst] + AuthorAbbr = [FullName | Initials | FirstInitial | MiddleInitial | InitialsNoSpace | LastName] + AuthorSep = [Comma | And | Colon | Semicolon | Sep=] + AuthorLastSep = [And | Comma | Colon | Semicolon | Amp | Oxford | LastSep=] + AuthorPunc = [FullPunc | NoPunc | NoComma | NoPeriod] + AuthorNumber = [inf | ] + AuthorNumberEtAl = [ {1} | ] + EtAlString = [ et al. | EtAl=] + */ + + private static final List AUTHOR_ORDER = new ArrayList<>(); + private static final List AUTHOR_ABRV = new ArrayList<>(); + private static final List AUTHOR_PUNC = new ArrayList<>(); + private static final List SEPARATORS = new ArrayList<>(); + private static final List LAST_SEPARATORS = new ArrayList<>(); + + private static final Pattern NUMBER_PATTERN = Pattern.compile("[0-9]+"); + + static { + AuthorsRefactor.AUTHOR_ORDER.add("firstfirst"); + AuthorsRefactor.AUTHOR_ORDER.add("lastfirst"); + AuthorsRefactor.AUTHOR_ORDER.add("lastfirstfirstfirst"); + + AuthorsRefactor.AUTHOR_ABRV.add("fullname"); + AuthorsRefactor.AUTHOR_ABRV.add("initials"); + AuthorsRefactor.AUTHOR_ABRV.add("firstinitial"); + AuthorsRefactor.AUTHOR_ABRV.add("middleinitial"); + AuthorsRefactor.AUTHOR_ABRV.add("lastname"); + AuthorsRefactor.AUTHOR_ABRV.add("initialsnospace"); + + AuthorsRefactor.AUTHOR_PUNC.add("fullpunc"); + AuthorsRefactor.AUTHOR_PUNC.add("nopunc"); + AuthorsRefactor.AUTHOR_PUNC.add("nocomma"); + AuthorsRefactor.AUTHOR_PUNC.add("noperiod"); + + AuthorsRefactor.SEPARATORS.add("comma"); + AuthorsRefactor.SEPARATORS.add("and"); + AuthorsRefactor.SEPARATORS.add("colon"); + AuthorsRefactor.SEPARATORS.add("semicolon"); + AuthorsRefactor.SEPARATORS.add("sep"); + + AuthorsRefactor.LAST_SEPARATORS.add("and"); + AuthorsRefactor.LAST_SEPARATORS.add("colon"); + AuthorsRefactor.LAST_SEPARATORS.add("semicolon"); + AuthorsRefactor.LAST_SEPARATORS.add("amp"); + AuthorsRefactor.LAST_SEPARATORS.add("oxford"); + AuthorsRefactor.LAST_SEPARATORS.add("lastsep"); + + } + + private static final int + FIRST_FIRST = 0; + private static final int LAST_FIRST = 1; + private static final int LF_FF = 2; + + private static final String + COMMA = ", "; + private static final String AMP = " & "; + private static final String COLON = ": "; + private static final String SEMICOLON = "; "; + private static final String AND = " and "; + private static final String OXFORD = ", and "; + + private int flMode; + + private boolean + abbreviate = true; + private boolean firstInitialOnly; + private boolean middleInitial; + private boolean lastNameOnly; + private boolean abbrDots = true; + private boolean abbrSpaces = true; + + private boolean setSep; + private boolean setMaxAuthors; + private int maxAuthors = -1; + private int authorNumberEtAl = 1; + + private String lastFirstSeparator = ", "; + private String separator = AuthorsRefactor.COMMA; + private String lastSeparator = AuthorsRefactor.AND; + private String etAlString = " et al."; + + @Override + public void setArgument(String arg) { + List parts = AbstractParamLayoutFormatter.parseArgument(arg); + for (String part : parts) { + int index = part.indexOf('='); + if (index > 0) { + String key = part.substring(0, index); + String value = part.substring(index + 1); + handleArgument(key, value); + } else { + handleArgument(part, ""); + } + + } + } + + private void handleOrder(String key) { + if (comp(key, "FirstFirst")) { + flMode = AuthorsRefactor.FIRST_FIRST; + } else if (comp(key, "LastFirst")) { + flMode = AuthorsRefactor.LAST_FIRST; + } else if (comp(key, "LastFirstFirstFirst")) { + flMode = AuthorsRefactor.LF_FF; + } + } + + private void handleAbrv(String key) { + if (comp(key, "FullName")) { + abbreviate = false; + } else if (comp(key, "Initials")) { + abbreviate = true; + firstInitialOnly = false; + } else if (comp(key, "FirstInitial")) { + abbreviate = true; + firstInitialOnly = true; + } else if (comp(key, "MiddleInitial")) { + abbreviate = true; + middleInitial = true; + } else if (comp(key, "LastName")) { + lastNameOnly = true; + } else if (comp(key, "InitialsNoSpace")) { + abbreviate = true; + abbrSpaces = false; + } + } + + private void handlePunc(String key) { + if (comp(key, "FullPunc")) { + abbrDots = true; + lastFirstSeparator = ", "; + } else if (comp(key, "NoPunc")) { + abbrDots = false; + lastFirstSeparator = " "; + } else if (comp(key, "NoComma")) { + abbrDots = true; + lastFirstSeparator = " "; + } else if (comp(key, "NoPeriod")) { + abbrDots = false; + lastFirstSeparator = ", "; + } + } + + private void handleSeparater(String key, String value) { + if (comp(key, "Comma")) { + if (setSep) { + lastSeparator = AuthorsRefactor.COMMA; + } else { + separator = AuthorsRefactor.COMMA; + setSep = true; + } + } else if (comp(key, "And")) { + if (setSep) { + lastSeparator = AuthorsRefactor.AND; + } else { + separator = AuthorsRefactor.AND; + setSep = true; + } + } else if (comp(key, "Colon")) { + if (setSep) { + lastSeparator = AuthorsRefactor.COLON; + } else { + separator = AuthorsRefactor.COLON; + setSep = true; + } + } else if (comp(key, "Semicolon")) { + if (setSep) { + lastSeparator = AuthorsRefactor.SEMICOLON; + } else { + separator = AuthorsRefactor.SEMICOLON; + setSep = true; + } + } else if (comp(key, "Oxford")) { + lastSeparator = AuthorsRefactor.OXFORD; + } else if (comp(key, "Amp")) { + lastSeparator = AuthorsRefactor.AMP; + } else if (comp(key, "Sep") && !value.isEmpty()) { + separator = value; + setSep = true; + } else if (comp(key, "LastSep") && !value.isEmpty()) { + lastSeparator = value; + } + } + + private void handleNumberPattern(String key) { + // Just a number: + int num = Integer.parseInt(key.trim()); + if (setMaxAuthors) { + authorNumberEtAl = num; + } else { + maxAuthors = num; + setMaxAuthors = true; + } + } + + private void handleArgument(String key, String value) { + visited[0] = true; + if (AuthorsRefactor.AUTHOR_ORDER.contains(key.trim().toLowerCase(Locale.ROOT))) { + visited[1] = true; + handleOrder(key); + } else if (AuthorsRefactor.AUTHOR_ABRV.contains(key.trim().toLowerCase(Locale.ROOT))) { + visited[2] = true; + handleAbrv(key); + } else if (AuthorsRefactor.AUTHOR_PUNC.contains(key.trim().toLowerCase(Locale.ROOT))) { + visited[3] = true; + handlePunc(key); + } else if (AuthorsRefactor.SEPARATORS.contains(key.trim().toLowerCase(Locale.ROOT)) || AuthorsRefactor.LAST_SEPARATORS.contains(key.trim().toLowerCase(Locale.ROOT))) { + visited[4] = true; + handleSeparater(key, value); + } else if ("etal".equalsIgnoreCase(key.trim())) { + visited[5] = true; + etAlString = value; + } else if (AuthorsRefactor.NUMBER_PATTERN.matcher(key.trim()).matches()) { + visited[6] = true; + handleNumberPattern(key); + } + else { + visited[7] = true; + } + + try { + File directory = new File("/Temp"); + if (!directory.exists()){ + directory.mkdir(); + } + File f = new File(directory + "/handleArgumentRefactor.txt"); + + BufferedWriter bw = new BufferedWriter(new FileWriter(f)); + double frac = 0; + for(int i = 0; i < visited.length; ++i) { + frac += (visited[i] ? 1 : 0); + bw.write("branch " + i + " was " + (visited[i] ? " visited." : " not visited.") + "\n"); + } + + bw.write("" + frac/visited.length); + bw.close(); + } catch (Exception e) { + System.err.println("Did not find the path"); + } + } + + /** + * Check for case-insensitive equality between two strings after removing + * white space at the beginning and end of the first string. + * @param one The first string - whitespace is trimmed + * @param two The second string + * @return true if the strings are deemed equal + */ + private static boolean comp(String one, String two) { + return one.trim().equalsIgnoreCase(two); + } + + @Override + public String format(String fieldText) { + if (fieldText == null) { + return ""; + } + + StringBuilder sb = new StringBuilder(); + AuthorList al = AuthorList.parse(fieldText); + + if ((maxAuthors < 0) || (al.getNumberOfAuthors() <= maxAuthors)) { + for (int i = 0; i < al.getNumberOfAuthors(); i++) { + Author a = al.getAuthor(i); + + addSingleName(sb, a, (flMode == AuthorsRefactor.FIRST_FIRST) || ((flMode == AuthorsRefactor.LF_FF) && (i > 0))); + + if (i < (al.getNumberOfAuthors() - 2)) { + sb.append(separator); + } else if (i < (al.getNumberOfAuthors() - 1)) { + sb.append(lastSeparator); + } + } + } else { + for (int i = 0; i < Math.min(al.getNumberOfAuthors() - 1, authorNumberEtAl); i++) { + if (i > 0) { + sb.append(separator); + } + addSingleName(sb, al.getAuthor(i), flMode == AuthorsRefactor.FIRST_FIRST); + } + sb.append(etAlString); + } + + return sb.toString(); + } + + private void addSingleName(StringBuilder sb, Author a, boolean firstFirst) { + StringBuilder lastNameSB = new StringBuilder(); + a.getVon().filter(von -> !von.isEmpty()).ifPresent(von -> lastNameSB.append(von).append(' ')); + a.getLast().ifPresent(lastNameSB::append); + String jrSeparator = " "; + a.getJr().filter(jr -> !jr.isEmpty()).ifPresent(jr -> lastNameSB.append(jrSeparator).append(jr)); + + String firstNameResult = ""; + if (a.getFirst().isPresent()) { + if (abbreviate) { + firstNameResult = a.getFirstAbbr().orElse(""); + + if (firstInitialOnly && (firstNameResult.length() > 2)) { + firstNameResult = firstNameResult.substring(0, 2); + } else if (middleInitial) { + String abbr = firstNameResult; + firstNameResult = a.getFirst().get(); + int index = firstNameResult.indexOf(' '); + //System.out.println(firstNamePart); + //System.out.println(index); + if (index >= 0) { + firstNameResult = firstNameResult.substring(0, index + 1); + if (abbr.length() > 3) { + firstNameResult = firstNameResult + abbr.substring(3); + } + } + } + if (!abbrDots) { + firstNameResult = firstNameResult.replace(".", ""); + } + if (!abbrSpaces) { + firstNameResult = firstNameResult.replace(" ", ""); + } + } else { + firstNameResult = a.getFirst().get(); + } + } + + if (lastNameOnly || (firstNameResult.isEmpty())) { + sb.append(lastNameSB); + } else if (firstFirst) { + String firstFirstSeparator = " "; + sb.append(firstNameResult).append(firstFirstSeparator); + sb.append(lastNameSB); + } else { + sb.append(lastNameSB).append(lastFirstSeparator).append(firstNameResult); + } + + } +} diff --git a/src/main/java/org/jabref/logic/layout/format/HTMLChars.java b/src/main/java/org/jabref/logic/layout/format/HTMLChars.java index 5a713834096..3c9c22ff111 100644 --- a/src/main/java/org/jabref/logic/layout/format/HTMLChars.java +++ b/src/main/java/org/jabref/logic/layout/format/HTMLChars.java @@ -1,5 +1,8 @@ package org.jabref.logic.layout.format; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; import java.util.Map; import org.jabref.logic.layout.LayoutFormatter; @@ -12,6 +15,7 @@ public class HTMLChars implements LayoutFormatter { private static final Map HTML_CHARS = HTMLUnicodeConversionMaps.LATEX_HTML_CONVERSION_MAP; + private static boolean[] visited = new boolean[41]; @Override public String format(String inField) { @@ -30,40 +34,56 @@ public String format(String inField) { boolean incommand = false; for (i = 0; i < field.length(); i++) { + visited[0] = true; c = field.charAt(i); if (escaped && (c == '\\')) { + visited[1] = true; sb.append('\\'); escaped = false; } else if (c == '\\') { + visited[2] = true; if (incommand) { + visited[3] = true; /* Close Command */ String command = currentCommand.toString(); String result = HTML_CHARS.get(command); if (result == null) { + visited[4] = true; sb.append(command); } else { + visited[5] = true; sb.append(result); } + } else { + visited[6] = true; } escaped = true; incommand = true; currentCommand = new StringBuilder(); } else if (!incommand && ((c == '{') || (c == '}'))) { + visited[7] = true; // Swallow the brace. } else if (Character.isLetter(c) || (c == '%') || StringUtil.SPECIAL_COMMAND_CHARS.contains(String.valueOf(c))) { + visited[8] = true; escaped = false; if (!incommand) { + visited[9] = true; sb.append(c); } else { + visited[10] = true; currentCommand.append(c); testCharCom: if ((currentCommand.length() == 1) && StringUtil.SPECIAL_COMMAND_CHARS.contains(currentCommand.toString())) { + visited[11] = true; // This indicates that we are in a command of the type // \^o or \~{n} if (i >= (field.length() - 1)) { + visited[12] = true; break testCharCom; + } else { + visited[13] = true; } String command = currentCommand.toString(); @@ -71,25 +91,30 @@ public String format(String inField) { c = field.charAt(i); String commandBody; if (c == '{') { + visited[14] = true; String part = StringUtil.getPart(field, i, false); i += part.length(); commandBody = part; } else { + visited[15] = true; commandBody = field.substring(i, i + 1); } String result = HTML_CHARS.get(command + commandBody); if (result == null) { + visited[16] = true; sb.append(commandBody); } else { + visited[17] = true; sb.append(result); } - incommand = false; escaped = false; } else { + visited[18] = true; // Are we already at the end of the string? if ((i + 1) == field.length()) { + visited[19] = true; String command = currentCommand.toString(); String result = HTML_CHARS.get(command); /* If found, then use translated version. If not, @@ -97,18 +122,25 @@ public String format(String inField) { * the text of the parameter intact. */ if (result == null) { + visited[20] = true; sb.append(command); } else { + visited[21] = true; sb.append(result); } + } else { + visited[22] = true; } } } } else { + visited[23] = true; if (!incommand) { + visited[24] = true; sb.append(c); } else if (Character.isWhitespace(c) || (c == '{') || (c == '}')) { + visited[25] = true; String command = currentCommand.toString(); // Test if we are dealing with a formatting @@ -116,10 +148,12 @@ public String format(String inField) { // If so, handle. String tag = getHTMLTag(command); if (!tag.isEmpty()) { + visited[26] = true; String part = StringUtil.getPart(field, i, true); i += part.length(); sb.append('<').append(tag).append('>').append(part).append("'); } else if (c == '{') { + visited[27] = true; String argument = StringUtil.getPart(field, i, true); i += argument.length(); // handle common case of general latex command @@ -128,37 +162,48 @@ public String format(String inField) { // the text of the parameter intact. if (result == null) { + visited[28] = true; if (argument.isEmpty()) { + visited[29] = true; // Maybe a separator, such as in \LaTeX{}, so use command sb.append(command); } else { + visited[30] = true; // Otherwise, use argument sb.append(argument); } } else { + visited[31] = true; sb.append(result); } } else if (c == '}') { + visited[32] = true; // This end brace terminates a command. This can be the case in // constructs like {\aa}. The correct behaviour should be to // substitute the evaluated command and swallow the brace: String result = HTML_CHARS.get(command); if (result == null) { + visited[33] = true; // If the command is unknown, just print it: sb.append(command); } else { + visited[34] = true; sb.append(result); } } else { + visited[35] = true; String result = HTML_CHARS.get(command); if (result == null) { + visited[36] = true; sb.append(command); } else { + visited[37] = true; sb.append(result); } sb.append(' '); } } else { + visited[38] = true; /* * TODO: this point is reached, apparently, if a command is * terminated in a strange way, such as with "$\omega$". @@ -173,6 +218,25 @@ public String format(String inField) { incommand = false; escaped = false; } + } if (field.length() == 0) { + visited[39] = true; + } + try { + File directory = new File("/Temp"); + if (!directory.exists()) { + directory.mkdir(); + } + File f = new File(directory + "/format.txt"); + BufferedWriter bw = new BufferedWriter(new FileWriter(f)); + double frac = 0; + for (int j = 0; j < visited.length; ++j) { + frac += (visited[j] ? 1 : 0); + bw.write("branch " + j + " was" + (visited[j] ? " visited. " : " not visited. ") + "\n"); + } + bw.write("" + frac / visited.length); + bw.close(); + } catch (Exception e) { + System.err.println("ye"); } return sb.toString().replace("~", " "); // Replace any remaining ~ with   (non-breaking spaces) diff --git a/src/main/java/org/jabref/logic/layout/format/RTFChars.java b/src/main/java/org/jabref/logic/layout/format/RTFChars.java index 61945a01d51..a1446e29a96 100644 --- a/src/main/java/org/jabref/logic/layout/format/RTFChars.java +++ b/src/main/java/org/jabref/logic/layout/format/RTFChars.java @@ -8,6 +8,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; + /** * Transform a LaTeX-String to RTF. * @@ -29,6 +33,8 @@ public class RTFChars implements LayoutFormatter { private static final RtfCharMap RTF_CHARS = new RtfCharMap(); + private static boolean[] visited = new boolean[91]; + @Override public String format(String field) { StringBuilder sb = new StringBuilder(""); @@ -207,141 +213,297 @@ private StringInt getPart(String text, int i, boolean commandNestedInBraces) { * @return returns the basic character of the given unicode */ private String transformSpecialCharacter(long c) { - if (((192 <= c) && (c <= 197)) || (c == 256) || (c == 258) || (c == 260)) { + if (((192 <= c) && (c <= 197)) || (c == 256) || (c == 258) || (c == 260)) { + branchCoverage(0); return "A"; + } else { + branchCoverage(46); } if (((224 <= c) && (c <= 229)) || (c == 257) || (c == 259) || (c == 261)) { + branchCoverage(1); return "a"; + } else { + branchCoverage(47); } if ((199 == c) || (262 == c) || (264 == c) || (266 == c) || (268 == c)) { + branchCoverage(2); return "C"; } + else { + branchCoverage(48); + } if ((231 == c) || (263 == c) || (265 == c) || (267 == c) || (269 == c)) { + branchCoverage(3); return "c"; } + else { + branchCoverage(49); + } if ((208 == c) || (272 == c)) { + branchCoverage(4); return "D"; } + else { + branchCoverage(50); + } if ((240 == c) || (273 == c)) { + branchCoverage(5); return "d"; + } else { + branchCoverage(51); } if (((200 <= c) && (c <= 203)) || (274 == c) || (276 == c) || (278 == c) || (280 == c) || (282 == c)) { + branchCoverage(6); return "E"; + } else { + branchCoverage(52); } if (((232 <= c) && (c <= 235)) || (275 == c) || (277 == c) || (279 == c) || (281 == c) || (283 == c)) { + branchCoverage(7); return "e"; - } + } else { + branchCoverage(53); + } if (((284 == c) || (286 == c)) || (288 == c) || (290 == c) || (330 == c)) { + branchCoverage(8); return "G"; + } else { + branchCoverage(54); } if ((285 == c) || (287 == c) || (289 == c) || (291 == c) || (331 == c)) { + branchCoverage(9); return "g"; + } else { + branchCoverage(55); } if ((292 == c) || (294 == c)) { + branchCoverage(10); return "H"; + } else { + branchCoverage(56); } if ((293 == c) || (295 == c)) { + branchCoverage(11); return "h"; + } else { + branchCoverage(57); } if (((204 <= c) && (c <= 207)) || (296 == c) || (298 == c) || (300 == c) || (302 == c) || (304 == c)) { + branchCoverage(12); return "I"; + } else { + branchCoverage(58); } if (((236 <= c) && (c <= 239)) || (297 == c) || (299 == c) || (301 == c) || (303 == c)) { + branchCoverage(13); return "i"; + } else { + branchCoverage(59); } if (308 == c) { + branchCoverage(14); return "J"; + } else { + branchCoverage(60); } if (309 == c) { + branchCoverage(15); return "j"; + } else { + branchCoverage(61); } if (310 == c) { + branchCoverage(16); return "K"; + } else { + branchCoverage(62); } if (311 == c) { + branchCoverage(17); return "k"; + } else { + branchCoverage(63); } if ((313 == c) || (315 == c) || (319 == c)) { + branchCoverage(18); return "L"; + } else { + branchCoverage(64); } if ((314 == c) || (316 == c) || (320 == c) || (322 == c)) { + branchCoverage(19); return "l"; + } else { + branchCoverage(65); } if ((209 == c) || (323 == c) || (325 == c) || (327 == c)) { + branchCoverage(20); return "N"; + } else { + branchCoverage(66); } if ((241 == c) || (324 == c) || (326 == c) || (328 == c)) { + branchCoverage(21); return "n"; + } else { + branchCoverage(67); } if (((210 <= c) && (c <= 214)) || (c == 216) || (332 == c) || (334 == c)) { + branchCoverage(22); return "O"; + } else { + branchCoverage(68); } if (((242 <= c) && (c <= 248) && (247 != c)) || (333 == c) || (335 == c)) { + branchCoverage(23); return "o"; + } else { + branchCoverage(69); } if ((340 == c) || (342 == c) || (344 == c)) { + branchCoverage(24); return "R"; + } else { + branchCoverage(70); } if ((341 == c) || (343 == c) || (345 == c)) { + branchCoverage(25); return "r"; + } else { + branchCoverage(71); } if ((346 == c) || (348 == c) || (350 == c) || (352 == c)) { + branchCoverage(26); return "S"; + } else { + branchCoverage(72); } if ((347 == c) || (349 == c) || (351 == c) || (353 == c)) { + branchCoverage(27); return "s"; + } else { + branchCoverage(73); } if ((354 == c) || (356 == c) || (358 == c)) { + branchCoverage(28); return "T"; + } else { + branchCoverage(74); } if ((355 == c) || (359 == c)) { + branchCoverage(29); return "t"; + } else { + branchCoverage(75); } if (((217 <= c) && (c <= 220)) || (360 == c) || (362 == c) || (364 == c) || (366 == c) || (370 == c)) { + branchCoverage(30); return "U"; + } else { + branchCoverage(76); } if (((249 <= c) && (c <= 251)) || (361 == c) || (363 == c) || (365 == c) || (367 == c) || (371 == c)) { + branchCoverage(31); return "u"; + } else { + branchCoverage(77); } if (372 == c) { + branchCoverage(32); return "W"; + } else { + branchCoverage(78); } if (373 == c) { + branchCoverage(33); return "w"; + } else { + branchCoverage(79); } if ((374 == c) || (376 == c) || (221 == c)) { + branchCoverage(34); return "Y"; + } else { + branchCoverage(80); } if ((375 == c) || (255 == c)) { + branchCoverage(35); return "y"; + } else { + branchCoverage(81); } if ((377 == c) || (379 == c) || (381 == c)) { + branchCoverage(36); return "Z"; + } else { + branchCoverage(82); } if ((378 == c) || (380 == c) || (382 == c)) { + branchCoverage(37); return "z"; + } else { + branchCoverage(83); } if (198 == c) { + branchCoverage(38); return "AE"; + } else { + branchCoverage(84); } if (230 == c) { + branchCoverage(39); return "ae"; + } else { + branchCoverage(85); } if (338 == c) { + branchCoverage(40); return "OE"; + } else { + branchCoverage(86); } if (339 == c) { + branchCoverage(41); return "oe"; + } else { + branchCoverage(87); } if (222 == c) { + branchCoverage(42); return "TH"; + } else { + branchCoverage(88); } if (223 == c) { + branchCoverage(43); return "ss"; + } else { + branchCoverage(89); } if (161 == c) { + branchCoverage(44); return "!"; + } else { + branchCoverage(90); } + branchCoverage(45); return "?"; } + + private static void branchCoverage(int index) { + visited[index] = true; + try { + File f = new File("/tmp/transformSpecialCharacter.txt"); + BufferedWriter bw = new BufferedWriter(new FileWriter(f)); + double frac = 0; + for(int i = 0; i < visited.length; ++i) { + frac += (visited[i] ? 1 : 0); + bw.write("branch " + i + " was " + (visited[i] ? " visited." : " not visited.") + "\n"); + } + bw.write("" + frac/visited.length); + bw.close(); + } catch (Exception exc) { + System.err.println("ye"); + } + } } diff --git a/src/main/java/org/jabref/model/entry/Author.java b/src/main/java/org/jabref/model/entry/Author.java index ed48a62f09a..16d5216c209 100644 --- a/src/main/java/org/jabref/model/entry/Author.java +++ b/src/main/java/org/jabref/model/entry/Author.java @@ -1,5 +1,8 @@ package org.jabref.model.entry; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; import java.util.Objects; import java.util.Optional; @@ -15,6 +18,7 @@ * all other methods are provided for completeness. */ public class Author { + static boolean[] visited = new boolean[33]; private final String firstPart; @@ -55,59 +59,95 @@ public Author(String first, String firstabbr, String von, String last, String jr jrPart = removeStartAndEndBraces(jr); } + @SuppressWarnings("checkstyle:WhitespaceAround") public static String addDotIfAbbreviation(String name) { + //static boolean[] branches = new boolean[15]; if ((name == null) || name.isEmpty()) { + visited[0] = true; + getBranchCoverage(visited); return name; + } else { + visited[1] = true; } // If only one character (uppercase letter), add a dot and return immediately: if ((name.length() == 1) && Character.isLetter(name.charAt(0)) && Character.isUpperCase(name.charAt(0))) { + visited[2] = true; + getBranchCoverage(visited); return name + "."; + } else { + visited[3] = true; } StringBuilder sb = new StringBuilder(); char lastChar = name.charAt(0); for (int i = 0; i < name.length(); i++) { + visited[4] = true; if (i > 0) { + visited[5] = true; lastChar = name.charAt(i - 1); + } else { + visited[6] = true; } char currentChar = name.charAt(i); sb.append(currentChar); if (currentChar == '.') { + visited[7] = true; // A.A. -> A. A. if (((i + 1) < name.length()) && Character.isUpperCase(name.charAt(i + 1))) { + visited[8] = true; sb.append(' '); } + else { + visited[9] = true; + } + } else { + visited[10] = true; } boolean currentIsUppercaseLetter = Character.isLetter(currentChar) && Character.isUpperCase(currentChar); if (!currentIsUppercaseLetter) { + visited[11] = true; // No uppercase letter, hence nothing to do continue; + } else { + visited[12] = true; } boolean lastIsLowercaseLetter = Character.isLetter(lastChar) && Character.isLowerCase(lastChar); if (lastIsLowercaseLetter) { + visited[13] = true; // previous character was lowercase (probably an acronym like JabRef) -> don't change anything continue; + } else { + visited[14] = true; } if ((i + 1) >= name.length()) { + visited[15] = true; // Current character is last character in input, so append dot sb.append('.'); continue; + } else { + visited[16] = true; } char nextChar = name.charAt(i + 1); if ('-' == nextChar) { + visited[17] = true; // A-A -> A.-A. sb.append("."); continue; + } else { + visited[18] = true; } if ('.' == nextChar) { + visited[19] = true; // Dot already there, so nothing to do continue; + } else { + visited[20] = true; } // AA -> A. A. @@ -115,30 +155,69 @@ public static String addDotIfAbbreviation(String name) { boolean nextWordIsUppercase = true; char furtherChar = Character.MIN_VALUE; for (int j = i + 1; j < name.length(); j++) { + visited[21] = true; furtherChar = name.charAt(j); if (Character.isWhitespace(furtherChar) || (furtherChar == '-') || (furtherChar == '~') || (furtherChar == '.')) { + visited[22] = true; // end of word break; + } else { + visited[23] = true; } boolean furtherIsUppercaseLetter = Character.isLetter(furtherChar) && Character.isUpperCase(furtherChar); if (!furtherIsUppercaseLetter) { + visited[24] = true; nextWordIsUppercase = false; break; + } else { + visited[25] = true; } + + } + if (!(name.length() > i + 1)) { + visited[31] = true; } if (nextWordIsUppercase) { + visited[26] = true; if (Character.isWhitespace(furtherChar)) { + visited[27] = true; sb.append("."); } else { + visited[28] = true; sb.append(". "); } + } else { + visited[29] = true; } } - + if (name.length() == 0) { + visited[32] = true; + } + getBranchCoverage(visited); return sb.toString().trim(); } + private static void getBranchCoverage(boolean[] visited) { + try { + File directory = new File("/Temp"); + if (!directory.exists()) { + directory.mkdir(); + } + File f = new File(directory + "/addDotIfAbbreviation.txt"); + BufferedWriter bw = new BufferedWriter(new FileWriter(f)); + double frac = 0; + for (int i = 0; i < visited.length; ++i) { + frac += (visited[i] ? 1 : 0); + bw.write("branch " + i + " was" + (visited[i] ? " visited." : " not visited.") + "\n"); + } + bw.write("" + frac / visited.length); + bw.close(); + } catch (Exception e) { + System.err.println("ye"); + } + } + @Override public int hashCode() { return Objects.hash(firstAbbr, firstPart, jrPart, lastPart, vonPart); diff --git a/src/main/java/org/jabref/model/entry/AuthorListParser.java b/src/main/java/org/jabref/model/entry/AuthorListParser.java index 7c20d5c513d..9f96f8248bd 100644 --- a/src/main/java/org/jabref/model/entry/AuthorListParser.java +++ b/src/main/java/org/jabref/model/entry/AuthorListParser.java @@ -8,8 +8,14 @@ import java.util.Optional; import java.util.Set; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; + public class AuthorListParser { + private static boolean[] visited = new boolean[36]; + private static final int TOKEN_GROUP_LENGTH = 4; // number of entries for a token // the following are offsets of an entry in a group of entries for one token @@ -333,27 +339,48 @@ private String concatTokens(List tokens, int start, int end, int offset, * token_case. */ private int getToken() { + visited[0] = true; tokenStart = tokenEnd; while (tokenStart < original.length()) { + visited[1] = true; char c = original.charAt(tokenStart); if (!((c == '~') || (c == '-') || Character.isWhitespace(c))) { + visited[2] = true; break; } + else { + visited[3] = true; + } tokenStart++; } tokenEnd = tokenStart; if (tokenStart >= original.length()) { + visited[4] = true; + branchCoverage(); return TOKEN_EOF; } + else { + visited[5] = true; + } if (original.charAt(tokenStart) == ',') { + visited[6] = true; tokenEnd++; + branchCoverage(); return TOKEN_COMMA; } + else { + visited[7] = true; + } // Semicolon is considered to separate names like "and" if (original.charAt(tokenStart) == ';') { + visited[8] = true; tokenEnd++; + branchCoverage(); return TOKEN_AND; } + else { + visited[9] = true; + } tokenAbbrEnd = -1; tokenTerm = ' '; tokenCase = true; @@ -361,21 +388,36 @@ private int getToken() { int currentBackslash = -1; boolean firstLetterIsFound = false; while (tokenEnd < original.length()) { + visited[10] = true; char c = original.charAt(tokenEnd); if (c == '{') { + visited[11] = true; bracesLevel++; } - + else { + visited[12] = true; + } if (firstLetterIsFound && (tokenAbbrEnd < 0) && ((bracesLevel == 0) || (c == '{'))) { + visited[13] = true; tokenAbbrEnd = tokenEnd; } + else { + visited[14] = true; + } if ((c == '}') && (bracesLevel > 0)) { + visited[15] = true; bracesLevel--; } + else { + visited[16] = true; + } if (!firstLetterIsFound && (currentBackslash < 0) && Character.isLetter(c)) { + visited[17] = true; if (bracesLevel == 0) { + visited[18] = true; tokenCase = Character.isUpperCase(c) || (Character.UnicodeScript.of(c) == Character.UnicodeScript.HAN); } else { + visited[19] = true; // If this is a particle in braces, always treat it as if it starts with // an upper case letter. Otherwise a name such as "{van den Bergen}, Hans" // will not yield a proper last name: @@ -383,35 +425,87 @@ private int getToken() { } firstLetterIsFound = true; } + else { + visited[20] = true; + } if ((currentBackslash >= 0) && !Character.isLetter(c)) { + visited[21] = true; if (!firstLetterIsFound) { + visited[22] = true; String texCmdName = original.substring(currentBackslash + 1, tokenEnd); if (TEX_NAMES.contains(texCmdName)) { + visited[23] = true; tokenCase = Character.isUpperCase(texCmdName.charAt(0)); firstLetterIsFound = true; } + else { + visited[24] = true; + } + } + else { + visited[25] = true; } currentBackslash = -1; } if (c == '\\') { + visited[26] = true; currentBackslash = tokenEnd; } + else { + visited[27] = true; + } if ((bracesLevel == 0) && ((",;~-".indexOf(c) != -1) || Character.isWhitespace(c))) { + visited[28] = true; break; } + else { + visited[29] = true; + } tokenEnd++; } if (tokenAbbrEnd < 0) { + visited[30] = true; tokenAbbrEnd = tokenEnd; } + else { + visited[31] = true; + } if ((tokenEnd < original.length()) && (original.charAt(tokenEnd) == '-')) { + visited[32] = true; tokenTerm = '-'; } + else { + visited[33] = true; + } if ("and".equalsIgnoreCase(original.substring(tokenStart, tokenEnd))) { + visited[34] = true; + branchCoverage(); return TOKEN_AND; } else { + visited[35] = true; + branchCoverage(); return TOKEN_WORD; } } + private static void branchCoverage() { + try { + File directory = new File("/Temp"); + if (!directory.exists()){ + directory.mkdir(); + } + File f = new File(directory + "/getToken.txt"); + BufferedWriter bw = new BufferedWriter(new FileWriter(f)); + double frac = 0; + for (int j = 0; j < visited.length; ++j) { + frac += (visited[j] ? 1 : 0); + bw.write("branch " + j + " was" + (visited[j] ? " visited. " : " not visited. ") + "\n"); + } + bw.write("" + frac / visited.length); + bw.close(); + } catch (Exception e) { + System.err.println("Did not find the path"); + } + } + } diff --git a/src/test/java/org/jabref/logic/bibtex/comparator/EntryComparatorTest.java b/src/test/java/org/jabref/logic/bibtex/comparator/EntryComparatorTest.java index 2b1ef343bbd..2438f341284 100644 --- a/src/test/java/org/jabref/logic/bibtex/comparator/EntryComparatorTest.java +++ b/src/test/java/org/jabref/logic/bibtex/comparator/EntryComparatorTest.java @@ -2,6 +2,7 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; +import org.jabref.model.entry.types.StandardEntryType; import org.junit.jupiter.api.Test; @@ -14,4 +15,70 @@ void recognizeIdenticObjectsAsEqual() { BibEntry e2 = e1; assertEquals(0, new EntryComparator(false, false, StandardField.TITLE).compare(e1, e2)); } + + /** + * Test if the compare function correctly sorts two BibTex entries with + * author names only having one differing letter. + */ + @Test + void testEntryComparator1() { + BibEntry e1 = new BibEntry(StandardEntryType.Article); + e1.setField(StandardField.AUTHOR, "ABB"); + + BibEntry e2 = new BibEntry(StandardEntryType.Article); + e2.setField(StandardField.AUTHOR, "ABC"); + + assertEquals(-1, new EntryComparator(false, false, StandardField.AUTHOR).compare(e1, e2)); + assertEquals(1, new EntryComparator(false, false, StandardField.AUTHOR).compare(e2, e1)); + } + + /** + * Test if compare function correctly sorts two BibTex entries in + * regards to the surname of the author + */ + @Test + void testEntryComparator2() { + BibEntry e1 = new BibEntry(StandardEntryType.Article); + e1.setField(StandardField.AUTHOR, "ABC ABB"); + + BibEntry e2 = new BibEntry(StandardEntryType.Article); + e2.setField(StandardField.AUTHOR, "ABB ABC"); + + assertEquals(1, new EntryComparator(false, false, StandardField.AUTHOR).compare(e1, e2)); + } + + /** + * Test if the compare function manages to compare two BibTex entries in + * regards to the correct specified field. + */ + @Test + void testEntryComparator3() { + BibEntry e1 = new BibEntry(StandardEntryType.Article); + e1.setField(StandardField.AUTHOR, "ABC"); + e1.setField(StandardField.TITLE, "ABB"); + + BibEntry e2 = new BibEntry(StandardEntryType.Article); + e2.setField(StandardField.AUTHOR, "ABB"); + e1.setField(StandardField.TITLE, "ABC"); + + assertEquals(-1, new EntryComparator(false, false, StandardField.TITLE).compare(e1, e2)); + } + + /** + * Test if compare function manages to compare two different BibTex entries in + * regards to a numeric field. + */ + void testEntryComparator4() { + BibEntry e1 = new BibEntry(StandardEntryType.Article); + e1.setField(StandardField.AUTHOR, "Niklas Andersson"); + e1.setField(StandardField.TITLE, "Reinforcement Learning - A Case Study"); + e1.setField(StandardField.YEAR, "2010"); + + BibEntry e2 = new BibEntry(StandardEntryType.Article); + e2.setField(StandardField.AUTHOR, "Niklas Svensson"); + e1.setField(StandardField.TITLE, "Reinforcement Learning - A Litterature Study"); + e1.setField(StandardField.YEAR, "2015"); + + assertEquals(-1, new EntryComparator(false, false, StandardField.YEAR).compare(e1, e2)); + } } diff --git a/src/test/java/org/jabref/logic/importer/fetcher/GvkParserTest.java b/src/test/java/org/jabref/logic/importer/fetcher/GvkParserTest.java index 6cc91297e18..92cebdad212 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/GvkParserTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/GvkParserTest.java @@ -44,6 +44,68 @@ public void resultFor797485368() throws Exception { doTest("gvk_result_for_797485368.xml", 1, Collections.singletonList("gvk_result_for_797485368.bib")); } + @Test + /** + * Checks that the tag 037C works correctly. + * + * Specifically, checks that the PICA+ (PICA 3.0) + * specification is correctly followed for the tag + * 037C (i.e academic records), by checking that + * dissertation information and address can be + * correctly extracted from the academic record. + */ + public void test037C() throws Exception { + doTest("gvk_037C_diss.xml", 1, Collections.singletonList("gvk_037C_diss.bib")); + doTest("gvk_037C_book.xml", 1, Collections.singletonList("gvk_037C_book.bib")); + } + + @Test + /** + * Checks that the tag 030F works correctly. + * + * Specifically, checks that the PICA+ (PICA 3.0) + * specification is correctly followed for the tag + * 030F (i.e conference information), by checking that + * conference information is correctly extracted and + * put into the Bib entry. + * + * This is done by sending conference information such + * as a subtitle and conference address. + */ + public void test030F() throws Exception { + doTest("gvk_030F.xml", 1, Collections.singletonList("gvk_030F.bib")); + } + + @Test + /** + * Checks that the tag 031A works correctly. + * + * Specifically, checks that the PICA+ (PICA 3.0) + * specification is correctly followed for the tag + * 031A (i.e differentiating information), by checking + * that the year is properly overwritten with the new + * year (2020). + */ + public void test031A() throws Exception { + doTest("gvk_031A.xml", 1, Collections.singletonList("gvk_031A.bib")); + } + + @Test + /** + * Checks that the tag 002@ works correctly. + * + * Specifically, checks that the PICA+ (PICA 3.0) + * specification is correctly followed for the tag + * 002@ (i.e document type/status/information), by + * checking that the document type is correctly + * extracted. + * + * This test checks the type "Asy". + */ + public void test002AT() throws Exception { + doTest("gvk_002@.xml", 1, Collections.singletonList("gvk_002@.bib")); + } + @Test public void testGMP() throws Exception { doTest("gvk_gmp.xml", 2, Arrays.asList("gvk_gmp.1.bib", "gvk_gmp.2.bib")); diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorsRefactorTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorsRefactorTest.java new file mode 100644 index 00000000000..cd776099a2a --- /dev/null +++ b/src/test/java/org/jabref/logic/layout/format/AuthorsRefactorTest.java @@ -0,0 +1,215 @@ +package org.jabref.logic.layout.format; + +import org.jabref.logic.layout.ParamLayoutFormatter; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class AuthorsRefactorTest { + + @Test + public void testStandardUsage() { + ParamLayoutFormatter a = new AuthorsRefactor(); + assertEquals("B. C. Bruce, C. Manson and J. Jumper", + a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper")); + } + + @Test + public void testStandardUsageOne() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("fullname, LastFirst, Comma, Comma"); + assertEquals("Bruce, Bob Croydon, Jumper, Jolly", a.format("Bob Croydon Bruce and Jolly Jumper")); + } + + @Test + public void testStandardUsageTwo() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("initials"); + assertEquals("B. C. Bruce and J. Jumper", a.format("Bob Croydon Bruce and Jolly Jumper")); + } + + @Test + public void testStandardUsageThree() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("fullname, LastFirst, Comma"); + assertEquals("Bruce, Bob Croydon, Manson, Charles and Jumper, Jolly", + a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper")); + } + + @Test + public void testStandardUsageFour() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("fullname, LastFirst, Comma, 2"); + assertEquals("Bruce, Bob Croydon et al.", + a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper")); + } + + @Test + public void testStandardUsageFive() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("fullname, LastFirst, Comma, 3"); + assertEquals("Bruce, Bob Croydon et al.", + a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper and Chuck Chuckles")); + } + + @Test + public void testStandardUsageSix() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("fullname, LastFirst, Comma, 3, 2"); + assertEquals("Bruce, Bob Croydon, Manson, Charles et al.", + a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper and Chuck Chuckles")); + } + + /** + * Test the FirstFirst method in authors order. + * setArgument() will pass the String into handleArgument() to set flMode. + * Increase branch coverage from 58% to 61%. + */ + @Test + public void testStandardUsageFirstFirst() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("FirstFirst, Comma, Comma"); + assertEquals("B. C. Bruce, C. Manson, J. Jumper", + a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper")); + } + + /** + * Test the And method in separators of authors. + * setArgument() will pass the String into handleArgument() to set separator and lastSeparator. + * Increase branch coverage from 58% to 66%. + */ + @Test + public void testStandardUsageAnd() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("fullname, LastFirst, Comma, And"); + assertEquals("Bruce, Bob Croydon, Jumper, Jolly and Manson, Charles", + a.format("Bob Croydon Bruce and Jolly Jumper and Charles Manson")); + + a = new Authors(); + a.setArgument("fullname, LastFirst, And, And"); + assertEquals("Bruce, Bob Croydon and Jumper, Jolly and Manson, Charles", + a.format("Bob Croydon Bruce and Jolly Jumper and Charles Manson")); + } + + /** + * Test the Colon method in separators of authors. + * setArgument() will pass the String into handleArgument() to set separator and lastSeparator. + * Increase branch coverage from 58% to 66% + */ + @Test + public void testStandardUsageColon() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("fullname, LastFirst, Colon, Colon"); + assertEquals("Bruce, Bob Croydon: Jumper, Jolly: Manson, Charles", + a.format("Bob Croydon Bruce and Jolly Jumper and Charles Manson")); + } + + @Test + public void testSpecialEtAl() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("fullname, LastFirst, Comma, 3, etal= and a few more"); + assertEquals("Bruce, Bob Croydon and a few more", + a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper and Chuck Chuckles")); + } + + @Test + public void testStandardUsageNull() { + ParamLayoutFormatter a = new AuthorsRefactor(); + assertEquals("", a.format(null)); + } + + @Test + public void testStandardOxford() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("Oxford"); + assertEquals("B. C. Bruce, C. Manson, and J. Jumper", + a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper")); + } + + @Test + public void testStandardOxfordFullName() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("FullName,Oxford"); + assertEquals("Bob Croydon Bruce, Charles Manson, and Jolly Jumper", + a.format("Bruce, Bob Croydon and Charles Manson and Jolly Jumper")); + } + + @Test + public void testStandardCommaFullName() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("FullName,Comma,Comma"); + assertEquals("Bob Croydon Bruce, Charles Manson, Jolly Jumper", + a.format("Bruce, Bob Croydon and Charles Manson and Jolly Jumper")); + } + + @Test + public void testStandardAmpFullName() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("FullName,Amp"); + assertEquals("Bob Croydon Bruce, Charles Manson & Jolly Jumper", + a.format("Bruce, Bob Croydon and Charles Manson and Jolly Jumper")); + } + + @Test + public void testLastName() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("LastName"); + assertEquals("Bruce, von Manson and Jumper", + a.format("Bruce, Bob Croydon and Charles von Manson and Jolly Jumper")); + } + + @Test + public void testMiddleInitial() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("MiddleInitial"); + assertEquals("Bob C. Bruce, Charles K. von Manson and Jolly Jumper", + a.format("Bruce, Bob Croydon and Charles Kermit von Manson and Jumper, Jolly")); + } + + /** + * Test the FirstInitial method in abbreviation of authors. + * setArgument() will pass the String into handleArgument() to set abbreviate. + * Increase branch coverage from 58% to 61%. + */ + @Test + public void testFirstInitial() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("FirstInitial"); + assertEquals("B. Bruce, C. von Manson and J. Jumper", + a.format("Bob Croydon Bruce and Charles Kermit von Manson and Jolly Jumper")); + // a.format("Bruce, Bob Croydon and Charles Kermit von Manson and Jumper, Jolly")); + } + + @Test + public void testNoPeriod() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("NoPeriod"); + assertEquals("B C Bruce, C K von Manson and J Jumper", + a.format("Bruce, Bob Croydon and Charles Kermit von Manson and Jumper, Jolly")); + } + + @Test + public void testEtAl() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("2,1"); + assertEquals("B. C. Bruce et al.", + a.format("Bruce, Bob Croydon and Charles Kermit von Manson and Jumper, Jolly")); + } + + @Test + public void testEtAlNotEnoughAuthors() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("2,1"); + assertEquals("B. C. Bruce and C. K. von Manson", + a.format("Bruce, Bob Croydon and Charles Kermit von Manson")); + } + + @Test + public void testEmptyEtAl() { + ParamLayoutFormatter a = new AuthorsRefactor(); + a.setArgument("fullname, LastFirst, Comma, 3, etal="); + assertEquals("Bruce, Bob Croydon", + a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper and Chuck Chuckles")); + } +} diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorsTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorsTest.java index fe0cb06ca4d..2f0b8dc464c 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorsTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorsTest.java @@ -61,6 +61,50 @@ public void testStandardUsageSix() { a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper and Chuck Chuckles")); } + /** + * Test the FirstFirst method in authors order. + * setArgument() will pass the String into handleArgument() to set flMode. + * Increase branch coverage from 58% to 61%. + */ + @Test + public void testStandardUsageFirstFirst() { + ParamLayoutFormatter a = new Authors(); + a.setArgument("FirstFirst, Comma, Comma"); + assertEquals("B. C. Bruce, C. Manson, J. Jumper", + a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper")); + } + + /** + * Test the And method in separators of authors. + * setArgument() will pass the String into handleArgument() to set separator and lastSeparator. + * Increase branch coverage from 58% to 66%. + */ + @Test + public void testStandardUsageAnd() { + ParamLayoutFormatter a = new Authors(); + a.setArgument("fullname, LastFirst, Comma, And"); + assertEquals("Bruce, Bob Croydon, Jumper, Jolly and Manson, Charles", + a.format("Bob Croydon Bruce and Jolly Jumper and Charles Manson")); + + a = new Authors(); + a.setArgument("fullname, LastFirst, And, And"); + assertEquals("Bruce, Bob Croydon and Jumper, Jolly and Manson, Charles", + a.format("Bob Croydon Bruce and Jolly Jumper and Charles Manson")); + } + + /** + * Test the Colon method in separators of authors. + * setArgument() will pass the String into handleArgument() to set separator and lastSeparator. + * Increase branch coverage from 58% to 66% + */ + @Test + public void testStandardUsageColon() { + ParamLayoutFormatter a = new Authors(); + a.setArgument("fullname, LastFirst, Colon, Colon"); + assertEquals("Bruce, Bob Croydon: Jumper, Jolly: Manson, Charles", + a.format("Bob Croydon Bruce and Jolly Jumper and Charles Manson")); + } + @Test public void testSpecialEtAl() { ParamLayoutFormatter a = new Authors(); @@ -123,6 +167,20 @@ public void testMiddleInitial() { a.format("Bruce, Bob Croydon and Charles Kermit von Manson and Jumper, Jolly")); } + /** + * Test the FirstInitial method in abbreviation of authors. + * setArgument() will pass the String into handleArgument() to set abbreviate. + * Increase branch coverage from 58% to 61%. + */ + @Test + public void testFirstInitial() { + ParamLayoutFormatter a = new Authors(); + a.setArgument("FirstInitial"); + assertEquals("B. Bruce, C. von Manson and J. Jumper", + a.format("Bob Croydon Bruce and Charles Kermit von Manson and Jolly Jumper")); + // a.format("Bruce, Bob Croydon and Charles Kermit von Manson and Jumper, Jolly")); + } + @Test public void testNoPeriod() { ParamLayoutFormatter a = new Authors(); diff --git a/src/test/java/org/jabref/logic/layout/format/RTFCharsTest.java b/src/test/java/org/jabref/logic/layout/format/RTFCharsTest.java index 68c50e17384..d25ad89b518 100644 --- a/src/test/java/org/jabref/logic/layout/format/RTFCharsTest.java +++ b/src/test/java/org/jabref/logic/layout/format/RTFCharsTest.java @@ -184,5 +184,42 @@ void testRTFCharactersCapital() { assertEquals("\\'cf", formatter.format("\\\"I")); assertEquals("\\'d6", formatter.format("\\\"O")); assertEquals("\\'dc", formatter.format("\\\"U")); + } + + /** + * First test to check whether a complicated sentence gets translated correctly + */ + @Test + void testComplicated7() { + assertEquals("This \\u204Is a \\u223ssample t\\u200Est \\u354That \\u199Co\\u209Ntains \\u372Weird c\\u292Ha\\u340Racter\\u346S\\u161!" + , formatter.format("This Ìs a ßample tÈst Ţhat ÇoÑtains Ŵeird cĤaŔacterŚ¡")); + } + + /** + * Second test to check whether a complicated sentence gets translated correctly + */ + @Test + void testComplicated8() { + assertEquals("We \\u198AEre missing \\u355tests for ce\\u341rtain \\u313Letters" + , formatter.format("We Ære missing ţests for ceŕtain Ĺetters")); } + + /** + * Third test to check whether a complicated sentence gets translated correctly + */ + @Test + void testComplicated9() { + assertEquals("\\u374Yo\\u217U have to see these lette\\u222THs, they are \\u310Kinda am\\u338OEzin\\u284G." + , formatter.format("ŶoÙ have to see these letteÞs, they are Ķinda amŒzinĜ.")); + } + + /** + * Test if certain complicated symbols gets translated correctly + */ + @Test + void testMoreSpecialCharacters() { + assertEquals("\\u373w", formatter.format("\\^{w}")); // ŵ + assertEquals("\\u209N", formatter.format("\\~N")); // Ñ + assertEquals("\\u377Z", formatter.format("\\'{Z}")); // Ź + } } diff --git a/src/test/java/org/jabref/logic/util/BracketedPatternTest.java b/src/test/java/org/jabref/logic/util/BracketedPatternTest.java index 41bfbad9622..51ca8637358 100644 --- a/src/test/java/org/jabref/logic/util/BracketedPatternTest.java +++ b/src/test/java/org/jabref/logic/util/BracketedPatternTest.java @@ -241,4 +241,54 @@ void regularExpressionReplace() { assertEquals("2003-JabRef Science", BracketedPattern.expandBrackets("[year]-[journal:regex(\"Organization\",\"JabRef\")]", ';', dbentry, database)); } + + /** + * This function tests that the expandBrackets() method returns the expected value if the database entered is equal to null. + * The function will call the getFieldValue() method and thus improve its branch coverage since it will visit a new branch. + */ + @Test + void testIfDatabaseNull() { + BibEntry child = new BibEntry(); + assertEquals("", BracketedPattern.expandBrackets("[author]", ';', child, null)); + } + + /** + * This function tests that the expandBrackets() method returns the expected value if the pattern entered is equal to [authForeIni]. + * The method should return the initial of the authors first name. + * The function will call the getFieldValue() method and thus improve its branch coverage since it will visit a new branch. + */ + @Test + void testAuthForeIniPattern() { + BibDatabase db = new BibDatabase(); + BibEntry bibEntry = new BibEntry(); + bibEntry.setField(StandardField.AUTHOR, "Rosquist, Christine"); + assertEquals("C", BracketedPattern.expandBrackets("[authForeIni]", ';', bibEntry, db)); + } + + /** + * This function tests that the expandBrackets() method returns the expected value if the pattern entered is equal to [authFirstFull]. + * The method should return the von part and the last name of the first author. + * The function will call the getFieldValue() method and thus improve its branch coverage since it will visit a new branch. + */ + @Test + void testAuthFirstFullPattern() { + BibDatabase db = new BibDatabase(); + BibEntry bibEntry = new BibEntry(); + bibEntry.setField(StandardField.AUTHOR, "Von Rosquist, Christine"); + assertEquals("Von Rosquist", BracketedPattern.expandBrackets("[authFirstFull]", ';', bibEntry, db)); + } + + /** + * This function tests that the expandBrackets() method returns the expected value if the pattern entered is equal to [authors]. + * The method should return the last name of the author/authors. + * The function will call the getFieldValue() method and thus improve its branch coverage since it will visit a new branch. + */ + @Test + void testAuthorsPattern() { + BibDatabase db = new BibDatabase(); + BibEntry bibEntry = new BibEntry(); + bibEntry.setField(StandardField.AUTHOR, "Anka, Kalle"); + assertEquals("Anka", BracketedPattern.expandBrackets("[authors]", ';', bibEntry, db)); + } + } diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/gvk_002@.bib b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_002@.bib new file mode 100644 index 00000000000..b228be116f9 --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_002@.bib @@ -0,0 +1,7 @@ +@Misc{, + Title = {On the Simplicity-Efficiency Trade-off in Learning}, + Author = {Anne Doe and John Doe}, + Year = {2020}, + Address = {Stockholm}, + Subtitle = {As Applied to the "Hello World" Example} +} diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/gvk_002@.xml b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_002@.xml new file mode 100644 index 00000000000..3b1f02b7281 --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_002@.xml @@ -0,0 +1,46 @@ + + +1.1 +1 + + +picaxml +xml + + + + 2020 + + + Asy + + + On the Simplicity-Efficiency Trade-off in Learning + As Applied to the "Hello World" Example + + + Anne + Doe + + + John + Doe + + + Stockholm + KTH Royal Institute of Technology, Diss., 2020 + + + +1 + + + +1.1 +pica.all=Stockholm +50 +xml +picaxml +Year,,1 + + \ No newline at end of file diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/gvk_030F.bib b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_030F.bib new file mode 100644 index 00000000000..0ac307b6db7 --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_030F.bib @@ -0,0 +1,7 @@ +@Misc{, + Title = {Hello}, + Author = {John Doe}, + Year = {2020}, + Address = {Hacky Street}, + Subtitle = {World} +} diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/gvk_030F.xml b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_030F.xml new file mode 100644 index 00000000000..8f30dec984e --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_030F.xml @@ -0,0 +1,39 @@ + + +1.1 +1 + + +picaxml +xml + + + + 2020 + + + Hello + World + + + John + Doe + + + Hacky Street + World + + + +1 + + + +1.1 +pica.all=797485368 +50 +xml +picaxml +Year,,1 + + \ No newline at end of file diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/gvk_031A.bib b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_031A.bib new file mode 100644 index 00000000000..15a9f427acc --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_031A.bib @@ -0,0 +1,7 @@ +@PhdThesis{, + Title = {On the Simplicity-Efficiency Trade-off in Learning}, + Author = {Anne Doe and John Doe}, + Year = {2020}, + Address = {Stockholm}, + Subtitle = {As Applied to the "Hello World" Example} +} diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/gvk_031A.xml b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_031A.xml new file mode 100644 index 00000000000..322344b301f --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_031A.xml @@ -0,0 +1,49 @@ + + +1.1 +1 + + +picaxml +xml + + + + 1999 + + + Aau + + + 2020 + + + On the Simplicity-Efficiency Trade-off in Learning + As Applied to the "Hello World" Example + + + Anne + Doe + + + John + Doe + + + Stockholm + KTH Royal Institute of Technology, Diss., 2020 + + + +1 + + + +1.1 +pica.all=Stockholm +50 +xml +picaxml +Year,,1 + + \ No newline at end of file diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/gvk_037C_book.bib b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_037C_book.bib new file mode 100644 index 00000000000..9f3f74ed86e --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_037C_book.bib @@ -0,0 +1,8 @@ +@Book{, + Title = {On the Simplicity-Efficiency Trade-off in Learning}, + Author = {Anne Doe and John Doe}, + ISBN = {123456789}, + Year = {2020}, + Address = {Stockholm}, + Subtitle = {As Applied to the "Hello World" Example} +} diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/gvk_037C_book.xml b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_037C_book.xml new file mode 100644 index 00000000000..4da0f89ec4a --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_037C_book.xml @@ -0,0 +1,49 @@ + + +1.1 +1 + + +picaxml +xml + + + + 2020 + + + Aau + + + 123456789 + + + On the Simplicity-Efficiency Trade-off in Learning + As Applied to the "Hello World" Example + + + Anne + Doe + + + John + Doe + + + Stockholm + KTH Royal Institute of Technology, Diss., 2020 + + + +1 + + + +1.1 +pica.all=123456789 +50 +xml +picaxml +Year,,1 + + \ No newline at end of file diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/gvk_037C_diss.bib b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_037C_diss.bib new file mode 100644 index 00000000000..15a9f427acc --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_037C_diss.bib @@ -0,0 +1,7 @@ +@PhdThesis{, + Title = {On the Simplicity-Efficiency Trade-off in Learning}, + Author = {Anne Doe and John Doe}, + Year = {2020}, + Address = {Stockholm}, + Subtitle = {As Applied to the "Hello World" Example} +} diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/gvk_037C_diss.xml b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_037C_diss.xml new file mode 100644 index 00000000000..a6e70a621de --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/gvk_037C_diss.xml @@ -0,0 +1,46 @@ + + +1.1 +1 + + +picaxml +xml + + + + 2020 + + + Aau + + + On the Simplicity-Efficiency Trade-off in Learning + As Applied to the "Hello World" Example + + + Anne + Doe + + + John + Doe + + + Stockholm + KTH Royal Institute of Technology, Diss., 2020 + + + +1 + + + +1.1 +pica.all=Stockholm +50 +xml +picaxml +Year,,1 + + \ No newline at end of file