use of edu.cmu.cs.hcii.cogtool.model.GensimLSASimilarity in project cogtool by cogtool.
the class ProjectInteraction method requestGenerateDictionaryParms.
/**
* Request new information (name, device type set) about a new or
* existing dictionary.
*/
public ProjectInteraction.GenerateEntriesData requestGenerateDictionaryParms(String request, ITermSimilarity defaultAlg, boolean hasDict) {
String defaultSite = "";
String defaultSpace = "";
String defaultURL = "";
if (defaultAlg instanceof ISitedTermSimilarity) {
defaultSite = ((ISitedTermSimilarity) defaultAlg).getContextSite();
} else if (defaultAlg instanceof LSASimilarity) {
LSASimilarity algLSA = (LSASimilarity) defaultAlg;
defaultSpace = algLSA.getSpace();
defaultURL = algLSA.getURL();
} else if (defaultAlg instanceof GensimLSASimilarity) {
GensimLSASimilarity algLSA = (GensimLSASimilarity) defaultAlg;
defaultSpace = algLSA.getSpace();
defaultURL = algLSA.getURL();
}
GenerateDictEntriesDialog dictDialog = new GenerateDictEntriesDialog(window, request, defaultAlg, defaultSite, defaultSpace, defaultURL, hasDict);
ProjectInteraction.GenerateEntriesData data = null;
boolean notDone = true;
while (notDone) {
Object response = dictDialog.open();
if ((response != null) && response.equals(WindowUtil.PromptDialog.OK)) {
data = dictDialog.getData();
notDone = false;
} else {
notDone = false;
}
}
return data;
}
use of edu.cmu.cs.hcii.cogtool.model.GensimLSASimilarity in project cogtool by cogtool.
the class DictionaryEditorUI method updateView.
protected void updateView() {
Table dictTable = view.getDictTable();
int selectionCount = 0;
try {
selectionCount = dictTable.getSelectionCount();
} catch (SWTException e) {
return;
}
if (selectionCount == 1) {
int index = dictTable.getSelectionIndex();
DictEntry entry = dictionary.getEntry(index);
if (entry != null) {
String url = null;
String space = null;
if (entry.algorithm instanceof ISitedTermSimilarity) {
url = ((ISitedTermSimilarity) entry.algorithm).getContextSite();
view.setURLEnabled(true);
view.setSpaceEnabled(false);
} else if (entry.algorithm instanceof LSASimilarity) {
LSASimilarity lsa = (LSASimilarity) entry.algorithm;
space = lsa.getSpace();
url = lsa.getURL();
if (url == null) {
url = LSASimilarity.DEFAULT_LSA_URL;
}
view.setURLEnabled(true);
view.setSpaceEnabled(true);
} else if (entry.algorithm instanceof GensimLSASimilarity) {
GensimLSASimilarity lsa = (GensimLSASimilarity) entry.algorithm;
space = lsa.getSpace();
url = lsa.getURL();
if (url == null) {
url = GensimLSASimilarity.DEFAULT_LSA_URL;
}
view.setURLEnabled(true);
view.setSpaceEnabled(true);
} else {
view.setURLEnabled(false);
view.setSpaceEnabled(false);
}
view.setURL(url);
view.setSpace(space);
} else {
TableItem row = dictTable.getItem(index);
Combo c = (Combo) row.getData();
int seln = c.getSelectionIndex();
boolean isLSA = (seln == DictionaryEditorUIModel.LSA_INDEX);
view.setURLEnabled((seln == DictionaryEditorUIModel.GOOGLE_WORD_INDEX) || (seln == DictionaryEditorUIModel.GOOGLE_PHRASE_INDEX) || isLSA);
view.setSpaceEnabled(isLSA);
}
} else {
// disable if 0 or more than 1 are selected
view.setURL(null);
view.setSpace(null);
view.setURLEnabled(false);
view.setSpaceEnabled(false);
}
}
Aggregations