Ejemplo n.º 1
0
        private void synSets_SelectedIndexChanged(object sender, EventArgs e)
        {
            synSetRelations.Items.Clear();
            getRelatedSynSets.Enabled = synSets.SelectedItem != null;

            // select a synset if none is selected
            if (synSets.SelectedItem == null)
            {
                if (synSets.Items.Count > 0)
                {
                    synSets.SelectedIndex = 0;
                }
            }
            else
            {
                SynSet selectedSynSet = synSets.SelectedItem as SynSet;

                // populate relation list
                synSetRelations.Items.Clear();
                foreach (WordNetEngine.SynSetRelation synSetRelation in selectedSynSet.SynSetRelations)
                {
                    synSetRelations.Items.Add(synSetRelation + ":  " + selectedSynSet.GetRelatedSynSetCount(synSetRelation));
                }

                // show id
                synsetID.Text = selectedSynSet.ID;
            }
        }
Ejemplo n.º 2
0
        private void synSets_SelectedIndexChanged(object sender, EventArgs e)
        {
            semanticRelations.Items.Clear();
            lexicalRelations.Items.Clear();
            computeSemSim.Enabled = false;
            getRelatedSynSets.Enabled = synSets.SelectedItem != null;

            // select a synset if none is selected and there is one
            if (synSets.SelectedItems.Count == 0)
            {
                if (synSets.Items.Count > 0)
                    synSets.SelectedIndex = 0;
            }
            else if (synSets.SelectedItems.Count == 1)
            {
                SynSet selectedSynSet = synSets.SelectedItem as SynSet;

                // populate semantic relation list for the current synset
                semanticRelations.Items.Clear();
                foreach (WordNetEngine.SynSetRelation synSetRelation in selectedSynSet.SemanticRelations)
                    semanticRelations.Items.Add(synSetRelation + ":  " + selectedSynSet.GetRelatedSynSetCount(synSetRelation));

                // populate list of lexically related words for the current synset
                lexicalRelations.Items.Clear();
                Dictionary<WordNetEngine.SynSetRelation, Dictionary<string, Set<string>>> lexicallyRelatedWords = selectedSynSet.GetLexicallyRelatedWords();
                foreach (WordNetEngine.SynSetRelation lexicalRelation in lexicallyRelatedWords.Keys)
                    foreach (string word1 in lexicallyRelatedWords[lexicalRelation].Keys)
                        foreach (string word2 in lexicallyRelatedWords[lexicalRelation][word1])
                            lexicalRelations.Items.Add(word1 + " -- " + lexicalRelation + " --> " + word2);

                // show id
                synsetID.Text = selectedSynSet.ID;
            }
        }