Skip to content

Commit bf788c7

Browse files
committed
a sample code for printing out hyponyms
1 parent ef68130 commit bf788c7

File tree

1 file changed

+44
-15
lines changed

1 file changed

+44
-15
lines changed

freya/freya-annotate/src/main/java/org/freya/similarity/WordnetInvoker.java

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,50 @@ private static Set<String> wordsFrom(final Synset[] synsets) {
9494
return words;
9595
}
9696

97-
/**
98-
* @param args
99-
*/
100-
public static void main(String[] args) {
101-
// System.setProperty("wordnet.database.dir", wordnetDir);
102-
WordNetDatabase database = WordNetDatabase.getFileInstance();
103-
// database.getSynsets(wordForm);
104-
// retrieve synsets from the database
105-
Synset[] nounFlies = database.getSynsets("split", SynsetType.NOUN);
106-
Synset[] allFlies = database.getSynsets("split");
107-
System.out.println("Synsets for split:");
108-
for (Synset s : allFlies) {
109-
System.out.println(s.toString());
110-
}
111-
}
97+
/**
98+
* @param args
99+
*/
100+
public static void main(String[] args) {
101+
System.setProperty(
102+
"wordnet.database.dir",
103+
"/Users/danica/projects/freya/freya/freya-annotate/src/main/resources/WordNet-3.0/dict/");
104+
WordNetDatabase database = WordNetDatabase.getFileInstance();
105+
// database.getSynsets(wordForm);
106+
// retrieve synsets from the database
107+
// Synset[] nounFlies = database.getSynsets("split", SynsetType.NOUN);
108+
// Synset[] allFlies = database.getSynsets("split");
109+
// System.out.println("Synsets for split:");
110+
// for (Synset s : allFlies) {
111+
// System.out.println(s.toString());
112+
//
113+
// }
114+
String a[] = { "music", "art", "school" };
115+
116+
int j = 0;
117+
while (j < 2) {
118+
119+
NounSynset nounSynset;
120+
NounSynset[] hyponyms;
121+
122+
Synset[] synsets = database.getSynsets(a[j], SynsetType.NOUN);
123+
System.out.println("*********************************************");
124+
for (int i = 0; i < synsets.length; i++) {
125+
nounSynset = (NounSynset) (synsets[i]);
126+
hyponyms = nounSynset.getHyponyms();
127+
128+
System.err.println(nounSynset.getWordForms()[0] + ": "
129+
+ nounSynset.getDefinition() + ") has "
130+
+ hyponyms.length + " hyponyms:");
131+
132+
for (NounSynset hyponym : hyponyms) {
133+
System.out.println(hyponym.getWordForms()[0]);
134+
}
135+
}
136+
j++;
137+
}
138+
System.out.println("*********************************************");
139+
140+
}
112141

113142
/**
114143
* @param text

0 commit comments

Comments
 (0)