use of gate.creole.ir.IREngine in project gate-core by GateNLP.
the class SerialCorpusImpl method setIndexDefinition.
// readObject
@Override
public void setIndexDefinition(IndexDefinition definition) {
if (definition != null) {
this.getFeatures().put(GateConstants.CORPUS_INDEX_DEFINITION_FEATURE_KEY, definition);
String className = definition.getIrEngineClassName();
try {
// Class aClass = Class.forName(className);
Class<?> aClass = Class.forName(className, true, Gate.getClassLoader());
IREngine engine = (IREngine) aClass.newInstance();
this.indexManager = engine.getIndexmanager();
this.indexManager.setIndexDefinition(definition);
this.indexManager.setCorpus(this);
} catch (Exception e) {
e.printStackTrace(Err.getPrintWriter());
}
// switch (definition.getIndexType()) {
// case GateConstants.IR_LUCENE_INVFILE:
// this.indexManager = new LuceneIndexManager();
// this.indexManager.setIndexDefinition(definition);
// this.indexManager.setCorpus(this);
// break;
// }
this.addedDocs = new Vector<Document>();
this.removedDocIDs = new Vector<String>();
this.changedDocs = new Vector<Document>();
}
}
use of gate.creole.ir.IREngine in project gate-core by GateNLP.
the class CreateIndexGUI method initGUIComponents.
protected void initGUIComponents() {
setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.WEST;
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.insets = new Insets(2, 5, 2, 5);
// first line
constraints.gridy = 0;
constraints.gridwidth = 2;
add(new JLabel("IR Engine type:"), constraints);
constraints.gridwidth = 4;
irEngineCombo = new JComboBox<String>();
add(irEngineCombo, constraints);
// second line
constraints.gridy = 1;
constraints.gridwidth = 2;
add(new JLabel("Index location:"), constraints);
constraints.gridwidth = 4;
indexLocationTextField = new JTextField(40);
add(indexLocationTextField, constraints);
constraints.gridwidth = 1;
add(new JButton(new SelectDirAction()), constraints);
// third line
constraints.gridy = 2;
constraints.gridwidth = 2;
add(new JLabel("Features to index:"), constraints);
featuresListTextField = new JTextField(40);
featuresListTextField.setEditable(false);
constraints.gridwidth = 4;
add(featuresListTextField, constraints);
constraints.gridwidth = 1;
add(new JButton(new EditFeatureListAction()), constraints);
// fourth line
constraints.gridy = 3;
constraints.gridwidth = 4;
useContentChk = new JCheckBox("Use document content", true);
add(useContentChk, constraints);
// populate engine names combo
String oldIREngineName = (String) irEngineCombo.getSelectedItem();
List<String> irEngines = new ArrayList<String>(Gate.getRegisteredIREngines());
engineByName.clear();
for (int i = 0; i < irEngines.size(); i++) {
String anIREngineClassName = irEngines.get(i);
try {
Class<?> aClass = Class.forName(anIREngineClassName, true, Gate.getClassLoader());
IREngine engine = (IREngine) aClass.newInstance();
engineByName.put(engine.getName(), engine);
} catch (ClassNotFoundException cnfe) {
} catch (IllegalAccessException iae) {
} catch (InstantiationException ie) {
}
}
String[] names = new String[engineByName.size()];
int i = 0;
Iterator<String> namesIter = engineByName.keySet().iterator();
while (namesIter.hasNext()) {
names[i++] = namesIter.next();
}
irEngineCombo.setModel(new DefaultComboBoxModel<String>(names));
if (oldIREngineName != null && engineByName.containsKey(oldIREngineName)) {
irEngineCombo.setSelectedItem(oldIREngineName);
} else if (engineByName.size() > 0)
irEngineCombo.setSelectedIndex(0);
}
Aggregations