-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #944 from kermitt2/features/footnotes
Link footnotes in the text
- Loading branch information
Showing
6 changed files
with
521 additions
and
95 deletions.
There are no files selected for viewing
131 changes: 131 additions & 0 deletions
131
grobid-core/src/main/java/org/grobid/core/data/Note.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package org.grobid.core.data; | ||
|
||
import org.grobid.core.layout.LayoutToken; | ||
import org.grobid.core.layout.Page; | ||
import org.grobid.core.utilities.*; | ||
|
||
import java.util.List; | ||
|
||
import static com.google.common.collect.Iterables.getLast; | ||
|
||
public class Note { | ||
|
||
public enum NoteType { | ||
FOOT, | ||
MARGIN | ||
}; | ||
|
||
private String identifier; | ||
|
||
private String label; | ||
|
||
private List<LayoutToken> tokens; | ||
|
||
private String text; | ||
|
||
private int offsetStartInPage; | ||
|
||
private boolean ignored = false; | ||
|
||
private NoteType noteType; | ||
|
||
public Note() { | ||
this.identifier = KeyGen.getKey().substring(0, 7); | ||
} | ||
|
||
public Note(String label, List<LayoutToken> tokens, String text, NoteType noteType) { | ||
this.identifier = KeyGen.getKey().substring(0, 7); | ||
this.label = label; | ||
this.tokens = tokens; | ||
this.text = text; | ||
this.noteType = noteType; | ||
} | ||
|
||
public Note(String label, List<LayoutToken> tokens, String text, int offsetStartInPage, NoteType noteType) { | ||
this.identifier = KeyGen.getKey().substring(0, 7); | ||
this.label = label; | ||
this.tokens = tokens; | ||
this.text = text; | ||
this.offsetStartInPage = offsetStartInPage; | ||
this.noteType = noteType; | ||
} | ||
|
||
public Note(String label, List<LayoutToken> tokens, NoteType noteType) { | ||
this.identifier = KeyGen.getKey().substring(0, 7); | ||
this.label = label; | ||
this.tokens = tokens; | ||
this.noteType = noteType; | ||
} | ||
|
||
public String getIdentifier() { | ||
return identifier; | ||
} | ||
|
||
public void setIdentifier(String identifier) { | ||
this.identifier = identifier; | ||
} | ||
|
||
public int getOffsetStartInPage() { | ||
return offsetStartInPage; | ||
} | ||
|
||
public void setOffsetStartInPage(int offsetStartInPage) { | ||
this.offsetStartInPage = offsetStartInPage; | ||
} | ||
|
||
public int getPageNumber() { | ||
return tokens.get(0).getPage(); | ||
} | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
|
||
public void setText(String text) { | ||
this.text = text; | ||
} | ||
|
||
public List<LayoutToken> getTokens() { | ||
return tokens; | ||
} | ||
|
||
public void setTokens(List<LayoutToken> tokens) { | ||
this.tokens = tokens; | ||
} | ||
|
||
public String getLabel() { | ||
return this.label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
public int getOffsetEndInPage() { | ||
return getLast(tokens).getOffset(); | ||
} | ||
|
||
public boolean isIgnored() { | ||
return ignored; | ||
} | ||
|
||
public void setIgnored(boolean ignored) { | ||
this.ignored = ignored; | ||
} | ||
|
||
public NoteType getNoteType() { | ||
return this.noteType; | ||
} | ||
|
||
public void setNoteType(NoteType noteType) { | ||
this.noteType = noteType; | ||
} | ||
|
||
public String getNoteTypeName() { | ||
if (this.noteType == NoteType.FOOT) { | ||
return "foot"; | ||
} else { | ||
return "margin"; | ||
} | ||
} | ||
} |
Oops, something went wrong.