Skip to content

Commit

Permalink
clean not used and redundant code; factorize margin note and foot not…
Browse files Browse the repository at this point in the history
…e; review footnote object
  • Loading branch information
kermitt2 committed Sep 24, 2022
1 parent 01699b7 commit 1207e0b
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 220 deletions.
63 changes: 52 additions & 11 deletions grobid-core/src/main/java/org/grobid/core/data/Footnote.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@

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 Footnote {

private int number;
public enum NoteType {
FOOT,
MARGIN
};

private String identifier;

private String label;

private List<LayoutToken> tokens;

Expand All @@ -19,25 +27,42 @@ public class Footnote {

private boolean ignored = false;

private NoteType noteType;

public Footnote() {
this.identifier = KeyGen.getKey().substring(0, 7);
}

public Footnote(int number, List<LayoutToken> tokens, String text) {
this.number = number;
public Footnote(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 Footnote(int number, List<LayoutToken> tokens, String text, int offsetStartInPage) {
this.number = number;
public Footnote(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 Footnote(int number, List<LayoutToken> tokens) {
this.number = number;
public Footnote(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() {
Expand Down Expand Up @@ -68,12 +93,12 @@ public void setTokens(List<LayoutToken> tokens) {
this.tokens = tokens;
}

public int getNumber() {
return number;
public String getLabel() {
return this.label;
}

public void setNumber(int number) {
this.number = number;
public void setLabel(String label) {
this.label = label;
}

public int getOffsetEndInPage() {
Expand All @@ -87,4 +112,20 @@ public boolean isIgnored() {
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 1207e0b

Please sign in to comment.