I need to write a method which returns all the synonym lemma forms for an
arbitrary sense. As I understand it, there are two ways synonymy can be
encoded for Uby senses:
1. If the Sense is part of a Synset, you can find all the Sense's synonyms
implicitly by calling getSenses() on its parent Synset.
2. The Sense may have explicitly stored synonym relations which can be
found by calling getSenseRelations() on the Sense.
So with this in mind I wrote the following:
public static Set<String> getSynonymLemmas(Sense sense)
{
Set<String> synonyms = new HashSet<String>();
// First thing to check: Are we part of a synset? If so, we can
// find the synonyms through the synset.
Synset synset = sense.getSynset();
if (synset != null) {
for (Sense s : synset.getSenses()) {
synonyms.add(s.getLexicalEntry().getLemmaForm());
}
}
// Second thing to check: See if we have any sense relations of type
// "SYNONYM":
for (SenseRelation senseRelation : sense.getSenseRelations()) {
if (senseRelation.getRelName().equals("SYNONYM")
&& senseRelation.getTargetFormRepresentation() != null) {
synonyms.add(senseRelation.getTargetFormRepresentation()
.getWrittenForm());
}
}
return synonyms;
}
My question is whether the part of the method labelled "Second thing to
check" -- and specifically the test on getRelName() -- is correct. That
is, is it guaranteed that for all SenseRelations from all lexical resources
which provide sense relations, the value of getRelName() will be "SYNONYM"
if and only if the sense relation is synonymy? Is there a master list of
relation names I should be referring to?
Regards,
Tristan
--
Tristan Miller, Doctoral Researcher | Tel: +49 6151 16 6166
Ubiquitous Knowledge Processing Lab | Fax: +49 6151 16 5455
Department of Computer Science | mil...@ukp.informatik.tu-darmstadt.de
Technische Universität Darmstadt | http://www.ukp.tu-darmstadt.de/