-
Notifications
You must be signed in to change notification settings - Fork 11
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 #4 from lfoppiano/training_generation
Training data can be generated automatically from the command line - the training data format is the CONLL format which is shared among NER project. See page: http://www.cnts.ua.ac.be/conll2003/ner/
- Loading branch information
Showing
31 changed files
with
1,082 additions
and
868 deletions.
There are no files selected for viewing
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
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
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
12 changes: 0 additions & 12 deletions
12
.../java/org/grobid/ner/core/data/Sense.java → ...main/java/org/grobid/core/data/Sense.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
60 changes: 60 additions & 0 deletions
60
grobid-ner/src/main/java/org/grobid/core/data/TextBlocks.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,60 @@ | ||
package org.grobid.core.data; | ||
|
||
import org.grobid.core.utilities.TextUtilities; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.StringTokenizer; | ||
|
||
public class TextBlocks { | ||
private List<String> textBlocks = new ArrayList<String>(); | ||
private List<String> tokens = new ArrayList<String>(); | ||
private List<Integer> textBlocksPositions = new ArrayList<Integer>(); | ||
|
||
|
||
public List<String> getTextBlocks() { | ||
return textBlocks; | ||
} | ||
|
||
public void setTextBlocks(List<String> textBlocks) { | ||
this.textBlocks = textBlocks; | ||
} | ||
|
||
public List<String> getTokens() { | ||
return tokens; | ||
} | ||
|
||
public void setTokens(List<String> tokens) { | ||
this.tokens = tokens; | ||
} | ||
|
||
public List<Integer> getTextBlocksPositions() { | ||
return textBlocksPositions; | ||
} | ||
|
||
public void setTextBlocksPositions(List<Integer> textBlocksPositions) { | ||
this.textBlocksPositions = textBlocksPositions; | ||
} | ||
|
||
public static TextBlocks getTextBlocks(String text) { | ||
|
||
TextBlocks blocks = new TextBlocks(); | ||
|
||
StringTokenizer st = new StringTokenizer(text, TextUtilities.fullPunctuations, true); | ||
if (st.countTokens() == 0) { | ||
return null; | ||
} | ||
|
||
int pos = 0; // current offset | ||
while (st.hasMoreTokens()) { | ||
String tok = st.nextToken(); | ||
blocks.getTokens().add(tok); | ||
if (!tok.equals(" ")) { | ||
blocks.getTextBlocks().add(tok + "\t<ner>"); | ||
blocks.getTextBlocksPositions().add(pos); | ||
} | ||
pos += tok.length(); | ||
} | ||
return blocks; | ||
} | ||
} |
Oops, something went wrong.