/** * Gets the best super sense for a word. * * @param pos the pos * @param word the word * @return the best super sense */ public Optional<String> getBestSuperSense(POS pos, String word) { final Optional<IndexWord> indexWord = lookupWord(pos, word); if (!indexWord.isPresent()) { return Optional.empty(); } else { final List<Synset> senses = indexWord.get().getSenses(); if (senses.isEmpty()) { return Optional.empty(); } else { // At this stage we could do something clever, look at the gloss to see is there are // word overlaps // but we opt for a more predicatable concept of selecting the most commonly used // meaning sense. return Optional.of(stripPOSFromSupersense(senses.get(0).getLexFileName())); } } }
/** * Gets the best super sense for a word. * * @param pos the pos * @param word the word * @return the best super sense */ public Optional<String> getBestSuperSense(POS pos, String word) { final Optional<IndexWord> indexWord = lookupWord(pos, word); if (!indexWord.isPresent()) { return Optional.empty(); } else { final List<Synset> senses = indexWord.get().getSenses(); if (senses.isEmpty()) { return Optional.empty(); } else { // At this stage we could do something clever, look at the gloss to see is there are // word overlaps // but we opt for a more predicatable concept of selecting the most commonly used // meaning sense. return Optional.of(stripPOSFromSupersense(senses.get(0).getLexFileName())); } } }
/** * Gets the super senses of a word. * * <p>The supersense is the original 'sense file' in which word was defined. * * @param pos the pos * @param word the word * @return the super senses */ public Stream<String> getSuperSenses(POS pos, String word) { final Optional<IndexWord> indexWord = lookupWord(pos, word); if (!indexWord.isPresent()) { return Stream.empty(); } else { // NOTE: This was stream but it WordNet getSenses() somehow seems incompatible with // streams final List<Synset> senses = indexWord.get().getSenses(); final Set<String> set = new HashSet<>(); for (final Synset s : senses) { set.add(stripPOSFromSupersense(s.getLexFileName())); } return set.stream(); } }
/** * Gets the super senses of a word. * * <p>The supersense is the original 'sense file' in which word was defined. * * @param pos the pos * @param word the word * @return the super senses */ public Stream<String> getSuperSenses(POS pos, String word) { final Optional<IndexWord> indexWord = lookupWord(pos, word); if (!indexWord.isPresent()) { return Stream.empty(); } else { // NOTE: This was stream but it WordNet getSenses() somehow seems incompatible with // streams final List<Synset> senses = indexWord.get().getSenses(); final Set<String> set = new HashSet<>(); for (final Synset s : senses) { set.add(stripPOSFromSupersense(s.getLexFileName())); } return set.stream(); } }
System.out.print("<" + synset.getLexFileName() + "> ");
System.out.print("<" + synset.getLexFileName() + "> ");
SemanticLabel semanticLabel = new SemanticLabel(); semanticLabels.add(semanticLabel); semanticLabel.setLabel(lexemeSynset.getLexFileName()); semanticLabel.setType(ELabelTypeSemantics.semanticField);