Skip to content

Commit

Permalink
Merge pull request #944 from kermitt2/features/footnotes
Browse files Browse the repository at this point in the history
Link footnotes in the text
  • Loading branch information
kermitt2 committed Sep 27, 2022
2 parents 54d1c29 + 655ccdf commit f9dc68f
Show file tree
Hide file tree
Showing 6 changed files with 521 additions and 95 deletions.
131 changes: 131 additions & 0 deletions grobid-core/src/main/java/org/grobid/core/data/Note.java
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";
}
}
}
Loading

0 comments on commit f9dc68f

Please sign in to comment.