public class BasicRelationExtractor extends Object implements Extractor
| Modifier and Type | Field and Description |
|---|---|
protected LinearClassifier<String,String> |
classifier |
protected boolean |
createUnrelatedRelations
If true, it creates automatically negative examples by generating all combinations between EntityMentions in a sentence
This is the common behavior, but for some domain (i.e., KBP) it must disabled.
|
int |
featureCountThreshold |
RelationFeatureFactory |
featureFactory |
String |
relationExtractorClassifierType
which classifier to use (can be 'linear' or 'svm')
|
protected RelationMentionFactory |
relationMentionFactory |
double |
sigma
strength of the prior on the linear classifier (passed to LinearClassifierFactory) or the C constant if relationExtractorClassifierType=svm
|
| Constructor and Description |
|---|
BasicRelationExtractor(RelationFeatureFactory featureFac,
Boolean createUnrelatedRelations,
RelationMentionFactory factory) |
| Modifier and Type | Method and Description |
|---|---|
void |
annotate(Annotation dataset)
Annotates the given dataset with the current model This works in place,
i.e., it adds ExtractionObject objects to the sentences in the dataset To
make sure you are not messing with gold annotation create a copy of the
ExtractionDataSet first!
|
List<String> |
annotateMulticlass(List<Datum<String,String>> testDatums) |
void |
annotateSentence(CoreMap sentence) |
protected String |
classOf(Datum<String,String> datum,
ExtractionObject rel) |
protected GeneralDataset<String,String> |
createDataset(Annotation corpus) |
protected Datum<String,String> |
createDatum(RelationMention rel) |
protected Datum<String,String> |
createDatum(RelationMention rel,
String label) |
protected List<RelationMention> |
extractAllRelations(CoreMap sentence)
Predict a relation for each pair of entities in the sentence; including relations of type unrelated.
|
protected void |
justificationOf(Datum<String,String> testDatum,
PrintWriter pw,
String label) |
static BasicRelationExtractor |
load(String modelPath) |
protected Counter<String> |
probabilityOf(Datum<String,String> testDatum) |
protected static void |
reportWeights(LinearClassifier<String,String> classifier,
String classLabel) |
void |
save(String modelpath)
Serializes this extractor to a file
|
void |
setCreateUnrelatedRelations(boolean b) |
void |
setFeatureCountThreshold(int i) |
void |
setLoggerLevel(Level level) |
void |
setRelationExtractorClassifierType(String s) |
void |
setSigma(double d) |
void |
setValidator(LabelValidator lv) |
void |
train(Annotation sentences)
Train on a list of ExtractionSentence containing labeled RelationMention objects
|
void |
trainMulticlass(GeneralDataset<String,String> trainSet) |
protected LinearClassifier<String,String> classifier
@Execution.Option(name="featureCountThreshold", gloss="feature count threshold to apply to dataset") public int featureCountThreshold
@Execution.Option(name="featureFactory", gloss="Feature factory for the relation extractor") public RelationFeatureFactory featureFactory
@Execution.Option(name="sigma", gloss="strength of the prior on the linear classifier (passed to LinearClassifierFactory) or the C constant if relationExtractorClassifierType=svm") public double sigma
public String relationExtractorClassifierType
protected boolean createUnrelatedRelations
protected RelationMentionFactory relationMentionFactory
public BasicRelationExtractor(RelationFeatureFactory featureFac, Boolean createUnrelatedRelations, RelationMentionFactory factory)
public void setValidator(LabelValidator lv)
public void setRelationExtractorClassifierType(String s)
public void setFeatureCountThreshold(int i)
public void setSigma(double d)
public void setCreateUnrelatedRelations(boolean b)
public static BasicRelationExtractor load(String modelPath) throws IOException, ClassNotFoundException
IOExceptionClassNotFoundExceptionpublic void save(String modelpath) throws IOException
Extractorsave in interface Extractormodelpath - where to save the extractorIOExceptionpublic void train(Annotation sentences)
public void trainMulticlass(GeneralDataset<String,String> trainSet)
protected static void reportWeights(LinearClassifier<String,String> classifier, String classLabel)
protected String classOf(Datum<String,String> datum, ExtractionObject rel)
protected void justificationOf(Datum<String,String> testDatum, PrintWriter pw, String label)
protected List<RelationMention> extractAllRelations(CoreMap sentence)
public void annotateSentence(CoreMap sentence)
public void annotate(Annotation dataset)
Extractorprotected GeneralDataset<String,String> createDataset(Annotation corpus)
protected Datum<String,String> createDatum(RelationMention rel)
protected Datum<String,String> createDatum(RelationMention rel, String label)
public void setLoggerLevel(Level level)
setLoggerLevel in interface Extractor