Skip to content

Commit

Permalink
More fields added to FieldName (#1614)
Browse files Browse the repository at this point in the history
* More fields added to FieldName

* Some Medline fixes
  • Loading branch information
oscargus authored Jul 22, 2016
1 parent 32319ff commit 2989a1b
Show file tree
Hide file tree
Showing 34 changed files with 247 additions and 238 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private void setupPrevEntry() {
prevEntry.setField(FieldName.YEAR, "2008");
prevEntry.setField(FieldName.JOURNAL, "BibTeX journal");
prevEntry.setField(FieldName.PUBLISHER, "JabRef publishing");
prevEntry.setField("address", "Trondheim");
prevEntry.setField(FieldName.ADDRESS, "Trondheim");
prevEntry.setField("www", "https://github.com/JabRef");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public boolean processQuery(String query, ImportInspector inspector, OutputPrint
entry.setField(FieldName.TITLE, title);
});

entry.getFieldOptional("institution").ifPresent(
institution -> entry.setField("institution", new UnicodeToLatexFormatter().format(institution)));
entry.getFieldOptional(FieldName.INSTITUTION).ifPresent(
institution -> entry.setField(FieldName.INSTITUTION, new UnicodeToLatexFormatter().format(institution)));
// Do not use the provided key
// entry.clearField(InternalBibtexFields.KEY_FIELD);
inspector.addEntry(entry);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/sf/jabref/importer/fetcher/GVKParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,13 @@ private BibEntry parseEntry(Element e) {
result.setField(FieldName.YEAR, year);
}
if (address != null) {
result.setField("address", address);
result.setField(FieldName.ADDRESS, address);
}
if (series != null) {
result.setField("series", series);
result.setField(FieldName.SERIES, series);
}
if (edition != null) {
result.setField("edition", edition);
result.setField(FieldName.EDITION, edition);
}
if (isbn != null) {
result.setField(FieldName.ISBN, isbn);
Expand Down Expand Up @@ -427,13 +427,13 @@ private BibEntry parseEntry(Element e) {
result.setField(FieldName.URL, url);
}
if (note != null) {
result.setField("note", note);
result.setField(FieldName.NOTE, note);
}

if ("article".equals(entryType) && (journal != null)) {
result.setField(FieldName.JOURNAL, journal);
} else if ("incollection".equals(entryType) && (booktitle != null)) {
result.setField("booktitle", booktitle);
result.setField(FieldName.BOOKTITLE, booktitle);
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ private BibEntry cleanup(BibEntry entry) {
String sourceField = "";
if ("article".equals(type)) {
sourceField = FieldName.JOURNAL;
entry.clearField("booktitle");
entry.clearField(FieldName.BOOKTITLE);
} else if ("inproceedings".equals(type)) {
sourceField = "booktitle";
sourceField = FieldName.BOOKTITLE;
}
if (entry.hasField(sourceField)) {
String fullName = entry.getField(sourceField);
Expand All @@ -393,7 +393,7 @@ private BibEntry cleanup(BibEntry entry) {
if (parts.length == 3) {
fullName += parts[2];
}
String note = entry.getField("note");
String note = entry.getField(FieldName.NOTE);
if ("Early Access".equals(note)) {
entry.setField(FieldName.YEAR, "to be published");
entry.clearField(FieldName.MONTH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
comments
.add("Secondary Authors: " + entry.getValue());
} else if ("NT".equals(entry.getKey())) {
hm.put("note", entry
hm.put(FieldName.NOTE, entry
.getValue().toString());
} else if ("PB".equals(entry.getKey())) {
hm.put(FieldName.PUBLISHER, entry
Expand All @@ -131,7 +131,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
comments
.add("Tertiary Title: " + entry.getValue());
} else if ("ED".equals(entry.getKey())) {
hm.put("edition", entry
hm.put(FieldName.EDITION, entry
.getValue().toString());
} else if ("TW".equals(entry.getKey())) {
type[1] = entry.getValue()
Expand All @@ -152,7 +152,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
address = entry.getValue()
.toString();
} else if ("LG".equals(entry.getKey())) {
hm.put("language", entry
hm.put(FieldName.LANGUAGE, entry
.getValue().toString());
} else if ("CO".equals(entry.getKey())) {
country = entry.getValue()
Expand Down Expand Up @@ -239,14 +239,14 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
}
} else if ("inbook".equals(bibtexType)) {
if (titleST != null) {
hm.put("booktitle", titleST);
hm.put(FieldName.BOOKTITLE, titleST);
}
if (titleTI != null) {
hm.put(FieldName.TITLE, titleTI);
}
} else {
if (titleST != null) {
hm.put("booktitle", titleST); // should not
hm.put(FieldName.BOOKTITLE, titleST); // should not
}
// happen, I
// think
Expand All @@ -262,7 +262,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {

// concatenate address and country
if (address != null) {
hm.put("address", address + (country == null ? "" : ", " + country));
hm.put(FieldName.ADDRESS, address + (country == null ? "" : ", " + country));
}

if (!comments.isEmpty()) { // set comment if present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
} else if ("PU- ".equals(code)) {
setOrAppend(b, FieldName.PUBLISHER, line.substring(4).trim(), ", ");
} else if ("SE- ".equals(code)) {
setOrAppend(b, "series", line.substring(4).trim(), ", ");
setOrAppend(b, FieldName.SERIES, line.substring(4).trim(), ", ");
} else if ("IS- ".equals(code)) {
setOrAppend(b, FieldName.ISBN, line.substring(4).trim(), ", ");
} else if ("KW- ".equals(code)) {
setOrAppend(b, FieldName.KEYWORDS, line.substring(4).trim(), ", ");
} else if ("NT- ".equals(code)) {
setOrAppend(b, "note", line.substring(4).trim(), ", ");
setOrAppend(b, FieldName.NOTE, line.substring(4).trim(), ", ");
} else if ("PD- ".equals(code)) {
setOrAppend(b, "physicaldimensions", line.substring(4).trim(), ", ");
} else if ("DT- ".equals(code)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
type = "misc"; //
}
} else if ("7".equals(prefix)) {
hm.put("edition", val);
hm.put(FieldName.EDITION, val);
} else if ("C".equals(prefix)) {
hm.put("address", val);
hm.put(FieldName.ADDRESS, val);
} else if ("D".equals(prefix)) {
hm.put(FieldName.YEAR, val);
} else if ("8".equals(prefix)) {
Expand All @@ -189,14 +189,14 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
if ("article".equals(type)) {
hm.put(FieldName.JOURNAL, val);
} else if ("book".equals(type) || "inbook".equals(type)) {
hm.put("series", val);
hm.put(FieldName.SERIES, val);
} else {
/* type = inproceedings */
hm.put("booktitle", val);
hm.put(FieldName.BOOKTITLE, val);
}
} else if ("I".equals(prefix)) {
if ("phdthesis".equals(type)) {
hm.put("school", val);
hm.put(FieldName.SCHOOL, val);
} else {
hm.put(FieldName.PUBLISHER, val);
}
Expand All @@ -222,7 +222,7 @@ else if ("P".equals(prefix)) {
String[] tokens = val.split("\\s");
artnum = tokens[1];
} else {
hm.put("note", val);
hm.put(FieldName.NOTE, val);
}
} else if ("K".equals(prefix)) {
hm.put(FieldName.KEYWORDS, val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,24 @@ public ParserResult importEntries(String text) {
// the content of the "tech" field seems to contain the number of the technical report
e.setField(FieldName.NUMBER, parser.getElementText());
} else if (FieldName.DOI.equals(ln)
|| "institution".equals(ln)
|| FieldName.INSTITUTION.equals(ln)
|| "location".equals(ln)
|| FieldName.NUMBER.equals(ln)
|| "note".equals(ln)
|| FieldName.NOTE.equals(ln)
|| FieldName.TITLE.equals(ln)
|| FieldName.PAGES.equals(ln)
|| FieldName.PUBLISHER.equals(ln)
|| FieldName.VOLUME.equals(ln)
|| FieldName.YEAR.equals(ln)) {
e.setField(ln, parser.getElementText());
} else if ("booktitle".equals(ln)) {
} else if (FieldName.BOOKTITLE.equals(ln)) {
String booktitle = parser.getElementText();
if (booktitle.startsWith("In ")) {
// special treatment for parsing of
// "In proceedings of..." references
booktitle = booktitle.substring(3);
}
e.setField("booktitle", booktitle);
e.setField(FieldName.BOOKTITLE, booktitle);
} else if ("raw_string".equals(ln)) {
// raw input string is ignored
} else {
Expand All @@ -200,13 +200,13 @@ public ParserResult importEntries(String text) {

if (noteSB.length() > 0) {
String note;
if (e.hasField("note")) {
if (e.hasField(FieldName.NOTE)) {
// "note" could have been set during the parsing as FreeCite also returns "note"
note = e.getFieldOptional("note").get().concat(Globals.NEWLINE).concat(noteSB.toString());
note = e.getFieldOptional(FieldName.NOTE).get().concat(Globals.NEWLINE).concat(noteSB.toString());
} else {
note = noteSB.toString();
}
e.setField("note", note);
e.setField(FieldName.NOTE, note);
}

// type has been derived from "genre"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
Type = "inproceedings";
}
} else if ("JO".equals(beg)) {
hm.put("booktitle", value);
hm.put(FieldName.BOOKTITLE, value);
} else if ("AU".equals(beg)) {
String author = IsiImporter.isiAuthorsConvert(value.replace("EOLEOL", " and "));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static BibEntry parseSpringerJSONtoBibtex(JSONObject springerJsonEntry) {
} else {
// Probably book chapter or from proceeding, go for book chapter
entry.setType("incollection");
nametype = "booktitle";
nametype = FieldName.BOOKTITLE;
entry.setField(FieldName.ISBN, isbn);
}

Expand Down
Loading

0 comments on commit 2989a1b

Please sign in to comment.