Skip to content

Commit

Permalink
The Wordnet reader now returns a canonical sense name for every synset
Browse files Browse the repository at this point in the history
  • Loading branch information
fozziethebeat committed Sep 9, 2011
1 parent d135685 commit 456d639
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public class BaseLemma implements Lemma {
*/
private List<String> frameStrings;

/**
* Creates a new {@link Lemma}.
*/
public BaseLemma(Synset synset, String lemmaName, String syntacticMarker) {
this(synset, lemmaName, "", 0, 0, syntacticMarker);
}

/**
* Creates a new {@link Lemma}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ public void saveWordNet(String newDictPath) throws IOException {
senseMappingWriters.add(null);
}
}


// Create an array that will store the sense keys lines. The sense key
// lines will be written to "index.sense" in alphabetical order after
Expand Down Expand Up @@ -914,9 +913,10 @@ public Synset getSynset(String lemma, PartsOfSpeech pos, int senseNum) {
Synset[][] lemmaSynsets = lemmaPosOffsetMap.get(lemma);
if (lemmaSynsets == null)
return null;
if (senseNum < 1 || senseNum > lemmaSynsets[pos.ordinal()].length)
Sysnet[] lemmaPosSynsets = lemmaSynsets[pos.ordinal()];
if (senseNum < 1 || senseNum > lemmaPosSynsets.length)
return null;
return lemmaSynsets[pos.ordinal()][senseNum-1];
return lemmaPosSynsets[senseNum-1];
}

/**
Expand All @@ -934,8 +934,13 @@ public int getMaxDepth(PartsOfSpeech pos) {
return maxDepths[pIndex];
}

/**
* Returns a {@link Synset} based on it's btye offset and part of speech.
* This is to be used internally to the package only by other methods that
* track the offset information.
*/
/* package private */ Synset getSynsetFromOffset(int offset,
PartsOfSpeech pos) {
PartsOfSpeech pos) {
return posOffsetToSynsetMap.get(pos.ordinal()).get(offset);
}

Expand Down Expand Up @@ -1078,7 +1083,9 @@ private void loadLemmaPosOffsetMap() throws IOException {
synsets[s] = offsetToSynset.get(offset);
if (synsets[s] == null) {
synsets[s] = new BaseSynset(offset, posTag);
synsets[s].setSenseNumber(s);
synsets[s].setSenseNumber(s+1);
synsets[s].addLemma(
new BaseLemma(synsets[s], lemma, pos));
offsetToSynset.put(offset, synsets[s]);
}
}
Expand Down

0 comments on commit 456d639

Please sign in to comment.