use of gate.Corpus in project gate-core by GateNLP.
the class TestAnnotationMerging method testAnnotationMerging.
/**
* The test for AnnotationMerging.
*/
public void testAnnotationMerging() throws Exception {
Boolean savedSpaceSetting = Gate.getUserConfig().getBoolean(GateConstants.DOCUMENT_ADD_SPACE_ON_UNPACK_FEATURE_NAME);
Gate.getUserConfig().put(GateConstants.DOCUMENT_ADD_SPACE_ON_UNPACK_FEATURE_NAME, Boolean.FALSE);
try {
// Gate.setGateHome(new File("C:\\svn\\gate"));
// Gate.setUserConfigFile(new File("C:\\svn\\gate.xml"));
// Gate.init();
// Load the documents into a corpus
Corpus data = Factory.newCorpus("data");
// Put the annotated document into a matrix for IAA
String nameAnnSet;
String nameAnnType = "";
String nameAnnFeat = "";
// Use the dataset of one document and three annotators
data.add(loadDocument("tests/iaa/beijing-opera.xml", "beijing-opera.xml"));
// ExtensionFileFilter fileFilter = new ExtensionFileFilter();
// fileFilter.addExtension("xml");
// data.populate(new File("C:\\yaoyong_h\\work\\iaa\\data\\smallData").toURI().toURL(), fileFilter, "UTF-8", false);
nameAnnSet = "ann1;ann2;ann3";
boolean isUsingMajority = false;
nameAnnType = "sent";
nameAnnFeat = "Op";
caseN = 1;
isUsingMajority = true;
testWithfeat(nameAnnSet, nameAnnType, nameAnnFeat, data, isUsingMajority);
caseN = 2;
isUsingMajority = false;
testWithfeat(nameAnnSet, nameAnnType, nameAnnFeat, data, isUsingMajority);
nameAnnType = "Os";
nameAnnFeat = null;
caseN = 3;
isUsingMajority = true;
testWithfeat(nameAnnSet, nameAnnType, nameAnnFeat, data, isUsingMajority);
caseN = 4;
isUsingMajority = false;
testWithfeat(nameAnnSet, nameAnnType, nameAnnFeat, data, isUsingMajority);
} finally {
Gate.getUserConfig().put(GateConstants.DOCUMENT_ADD_SPACE_ON_UNPACK_FEATURE_NAME, savedSpaceSetting);
}
}
use of gate.Corpus in project gate-core by GateNLP.
the class LuceneDataStoreSearchGUI method resourceWritten.
/**
* This method is called when a resource is written into the datastore
*/
@Override
public void resourceWritten(DatastoreEvent de) {
Resource resource = de.getResource();
if (resource instanceof Corpus) {
// lets check if it is already available in our list
Object id = de.getResourceID();
if (!corpusIds.contains(id)) {
// we need to add its name to the combobox
corpusIds.add(id);
((DefaultComboBoxModel<String>) corpusToSearchIn.getModel()).addElement(resource.getName());
}
}
}
use of gate.Corpus in project gate-core by GateNLP.
the class CorpusQualityAssurance method setTarget.
@Override
public void setTarget(Object target) {
if (corpus != null && corpus != target) {
// we already had a different corpus
corpus.removeCorpusListener(this);
}
if (!(target instanceof Corpus)) {
throw new IllegalArgumentException("This view can only be used with a GATE corpus!\n" + target.getClass().toString() + " is not a GATE corpus!");
}
this.corpus = (Corpus) target;
corpus.addCorpusListener(this);
corpusChanged = true;
if (!isShowing()) {
return;
}
if (timerTask != null) {
timerTask.cancel();
}
Date timeToRun = new Date(System.currentTimeMillis() + 2000);
timerTask = new TimerTask() {
@Override
public void run() {
readSetsTypesFeatures(0);
}
};
// add a delay before updating
timer.schedule(timerTask, timeToRun);
}
use of gate.Corpus in project gate-core by GateNLP.
the class SerialControllerEditor method resourceUnloaded.
@Override
public void resourceUnloaded(CreoleEvent e) {
if (Gate.getHiddenAttribute(e.getResource().getFeatures()))
return;
if (e.getResource() instanceof ProcessingResource) {
ProcessingResource pr = (ProcessingResource) e.getResource();
if (controller != null && controller.getPRs().contains(pr)) {
controller.remove(pr);
}
refreshPRLists();
} else if (e.getResource() instanceof LanguageResource) {
if (e.getResource() instanceof Corpus && corpusControllerMode) {
Corpus c = (Corpus) e.getResource();
if (controller instanceof CorpusController) {
if (c == ((CorpusController) controller).getCorpus()) {
// setCorpus(null) is also called in the controller's
// resourceUnloaded(), but we can't be sure which handler is
// called first...
((CorpusController) controller).setCorpus(null);
}
} else {
throw new GateRuntimeException("Controller editor in analyser mode " + "but the target controller is not an " + "analyser!");
}
corpusComboModel.fireDataChanged();
}
}
}
use of gate.Corpus in project gate-core by GateNLP.
the class CorpusBenchmarkTool method processDocument.
// evaluateMarkedClean
protected void processDocument(Document doc) {
try {
if (application instanceof CorpusController) {
Corpus tempCorpus = Factory.newCorpus("temp");
tempCorpus.add(doc);
((CorpusController) application).setCorpus(tempCorpus);
application.execute();
Factory.deleteResource(tempCorpus);
tempCorpus = null;
} else {
Iterator<ProcessingResource> iter = application.getPRs().iterator();
while (iter.hasNext()) iter.next().setParameterValue("document", doc);
application.execute();
}
} catch (ResourceInstantiationException ex) {
throw (RuntimeException) new RuntimeException("Error executing application: " + ex.getMessage()).initCause(ex);
} catch (ExecutionException ex) {
throw (RuntimeException) new RuntimeException("Error executing application: " + ex.getMessage()).initCause(ex);
}
}
Aggregations