Search in sources :

Example 1 with LSASimilarity

use of edu.cmu.cs.hcii.cogtool.model.LSASimilarity 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;
}
Also used : GensimLSASimilarity(edu.cmu.cs.hcii.cogtool.model.GensimLSASimilarity) LSASimilarity(edu.cmu.cs.hcii.cogtool.model.LSASimilarity) ISitedTermSimilarity(edu.cmu.cs.hcii.cogtool.model.ISitedTermSimilarity) GensimLSASimilarity(edu.cmu.cs.hcii.cogtool.model.GensimLSASimilarity)

Example 2 with LSASimilarity

use of edu.cmu.cs.hcii.cogtool.model.LSASimilarity 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);
    }
}
Also used : Table(org.eclipse.swt.widgets.Table) SWTException(org.eclipse.swt.SWTException) TableItem(org.eclipse.swt.widgets.TableItem) DictEntry(edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary.DictEntry) GensimLSASimilarity(edu.cmu.cs.hcii.cogtool.model.GensimLSASimilarity) LSASimilarity(edu.cmu.cs.hcii.cogtool.model.LSASimilarity) Combo(org.eclipse.swt.widgets.Combo) ISitedTermSimilarity(edu.cmu.cs.hcii.cogtool.model.ISitedTermSimilarity) Point(org.eclipse.swt.graphics.Point) GensimLSASimilarity(edu.cmu.cs.hcii.cogtool.model.GensimLSASimilarity)

Aggregations

GensimLSASimilarity (edu.cmu.cs.hcii.cogtool.model.GensimLSASimilarity)2 ISitedTermSimilarity (edu.cmu.cs.hcii.cogtool.model.ISitedTermSimilarity)2 LSASimilarity (edu.cmu.cs.hcii.cogtool.model.LSASimilarity)2 DictEntry (edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary.DictEntry)1 SWTException (org.eclipse.swt.SWTException)1 Point (org.eclipse.swt.graphics.Point)1 Combo (org.eclipse.swt.widgets.Combo)1 Table (org.eclipse.swt.widgets.Table)1 TableItem (org.eclipse.swt.widgets.TableItem)1