@Override public Set<Entity> getEntity(String aLexeme) throws LexicalSemanticResourceException { String usLexeme = aLexeme; usLexeme = usLexeme.replace('-', ' '); usLexeme = usLexeme.replace('_', ' '); usLexeme = StringUtils.join(usLexeme.split("[ ]+"), "_"); Set<Entity> result = cache.get(usLexeme+"-ALL"); if (result != null) { return result; } result = lsr.getEntity(usLexeme); if (result.size() > 0) { return result; } result = new HashSet<Entity>(); for (String fragment : usLexeme.split("[_]+")) { result.addAll(lsr.getEntity(fragment)); } if (cache != null) { cache.put(usLexeme+"-ALL", result); } return result; }
@Override public Set<Entity> getEntity(String aLexeme, PoS aPos) throws LexicalSemanticResourceException { String usLexeme = aLexeme; usLexeme = usLexeme.replace('-', ' '); usLexeme = usLexeme.replace('_', ' '); usLexeme = StringUtils.join(usLexeme.split("[ ]+"), "_"); Set<Entity> result = cache.get(usLexeme+"-"+aPos); if (result != null) { return result; } result = lsr.getEntity(usLexeme, aPos); if (result.size() > 0) { return result; } result = new HashSet<Entity>(); for (String fragment : usLexeme.split("[_]+")) { result.addAll(lsr.getEntity(fragment, aPos)); } if (cache != null) { cache.put(usLexeme+"-"+aPos, result); } return result; }
@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 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); } }