@Override public String toString() { return this.getId(); }
@Override public List<String> getSenses(String sod) throws SenseInventoryException { try { List<String> senses = new ArrayList<String>(); for (Entity entity : lsr.getEntity(sod)) { senses.add(entity.getId()); } return senses; } catch (LexicalSemanticResourceException e) { throw new SenseInventoryException(e); } }
@Override public String getMostFrequentSense(String sod) throws SenseInventoryException, UnsupportedOperationException { try { return lsr.getMostFrequentEntity(sod).getId(); } catch (LexicalSemanticResourceException e) { throw new SenseInventoryException(e); } }
@Override public Map<String, List<String>> getSenseInventory() throws SenseInventoryException { System.out.println("Be careful, this is a quite slow operation."); Map<String, List<String>> senseInventory = new HashMap<String, List<String>>(); try { for (Entity entity : lsr.getEntities()) { for (String lexeme : entity.getLexemes()) { if (!senseInventory.containsKey(lexeme)) { senseInventory.put(lexeme, new ArrayList<String>()); } String sense = entity.getId(); List<String> senses = senseInventory.get(lexeme); senses.add(sense); senseInventory.put(lexeme, senses); } } } catch (LexicalSemanticResourceException e) { throw new SenseInventoryException(e); } return senseInventory; }
@Override public List<String> getSenses(String sod, POS pos) throws SenseInventoryException { try { PoS lsrPos = LsrSenseInventoryUtil.convertPos(pos); List<String> senses = new ArrayList<String>(); for (Entity entity : lsr.getEntity(sod, lsrPos)) { senses.add(entity.getId()); } return senses; } catch (LexicalSemanticResourceException e) { throw new SenseInventoryException(e); } }
@Override public Set<String> getSenseNeighbours(String senseId) throws SenseInventoryException, UnsupportedOperationException { Set<Entity> entities; try { entities = lsr.getNeighbors(lsr.getEntityById(senseId)); } catch (LexicalSemanticResourceException e) { throw new SenseInventoryException(e); } Set<String> neighbours = new HashSet<String>(); for (Entity entity : entities) { neighbours.add(entity.getId()); } return neighbours; }
@Override public String getMostFrequentSense(String sod, POS pos) throws SenseInventoryException, UnsupportedOperationException { try { PoS lsrPos = LsrSenseInventoryUtil.convertPos(pos); return lsr.getMostFrequentEntity(sod, lsrPos).getId(); } catch (LexicalSemanticResourceException e) { throw new SenseInventoryException(e); } }