/** * Fetches a {@link List} of {@link LexicalEntry} instances which written representation is the * specified word. * * Optionally lexical entries can be filtered by part-of-speech and a {@link Lexicon}. * * @param word * the written representation of the lexical entries to be fetched * @param lexicon * If not null, filters lexical entries by the specified lexicon. Note that the * Lexicon instance has to be obtained beforehand. * @return A list of lexical entries matching the specified criteria. If no lexical entry * matches the specified criteria, this method returns an empty list. * @see LexicalEntry#getLemma() */ public List<LexicalEntry> getLexicalEntries(String word, Lexicon lexicon) { return getLexicalEntries(word, null, lexicon); }
/** * Returns an {@link Iterator} over {@link LexicalEntry} instances which written representation * is the specified word. * * Optionally lexical entries can be filtered by part-of-speech and a {@link Lexicon}. * * @param lexicon * If not null, filters lexical entries by the specified lexicon. Note that the * Lexicon instance has to be obtained beforehand. * @return An Iterator over lexical entries matching the specified criteria * * @see EPartOfSpeech * @see LexicalEntry#getLemma() */ public Iterator<LexicalEntry> getLexicalEntryIterator(Lexicon lexicon) { return getLexicalEntryIterator(null, lexicon); }
/** * Fetches the one UBY-LMF {@link LexicalResource} instance named "Uby" from the database * accessed by this {@link Uby} instance. * * This should work if the database has been created correctly and is the recommended way to * obtain the UBY-LMF lexical resource. * * @return a lexical resource named "Uby", contained in the accessed database, or null if the * database does not contain the lexical resource with the name "Uby" */ public LexicalResource getLexicalResource() { return this.getLexicalResource("Uby"); }
wordnet = uby.getLexiconByName("WordNet"); } else if (tokens.get(0).getCAS().getDocumentLanguage().equals("de")) { wordnet = uby.getLexiconByName("GermaNet"); if (uby.getLexicalEntries(lemmaString,null,null).isEmpty()) { return "UNKNOWN"; } else { // there is at least one UBY lexicon that contains the multiword as lemma if (!uby.getLexicalEntries(lemmaString,null,wordnet).isEmpty()) { List<LexicalEntry> lexicalEntries = uby.getLexicalEntries(lemmaString,null,wordnet); Sense sense = getWordnetSense(lexicalEntries); return getSemanticField(sense); List<LexicalEntry> lexicalEntries = uby.getLexicalEntries(lemmaString,null,null); String otherSemanticLabelValue = getOtherSemanticLabelValue(lexicalEntries); return getSemanticField(otherSemanticLabelValue);
private Uby createDB() throws DocumentException, IllegalArgumentException, FileNotFoundException { String uby_user = "root"; String uby_pass = "pass"; DBConfig dbConfig = // new DBConfig("not_important","org.h2.Driver","h2",uby_user,uby_pass,true); new DBConfig("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1","org.h2.Driver",UBYH2Dialect.class.getName(),uby_user,uby_pass,true); LMFDBUtils.createTables(dbConfig); XMLToDBTransformer trans = new XMLToDBTransformer(dbConfig); trans.transform(new File("src/main/resources/UbyTestLexicon.xml"),"UbyTest"); Uby uby = new Uby(dbConfig); return uby; }
/** * Setting the configuration for the Uby database * * @param dbconfig * Database configuration of the Uby database * @deprecated marked for deletion */ @Deprecated public void setDbConfig(DBConfig dbconfig) throws FileNotFoundException{ this.dbConfig=dbconfig; cfg = HibernateConnect.getConfiguration(dbConfig); sessionFactory = cfg.buildSessionFactory(); openSession(); }
wordnet = uby.getLexiconByName("WordNet"); } else if (language.equals("en")) { wordnet = uby.getLexiconByName("WordNet"); } else if (token.getCAS().getDocumentLanguage().equals("de")) { wordnet = uby.getLexiconByName("GermaNet"); } else if (language.equals("de")) { wordnet = uby.getLexiconByName("GermaNet"); return "UNKNOWN"; } else if (uby.getLexicalEntries(token.getLemma().getValue(),null,null).isEmpty()) { return "UNKNOWN"; } else { // there is at least one UBY lexicon that contains the lemma for (EPartOfSpeech pos : corePosToUbyPos(token.getPos().getType().getShortName())) { if (!uby.getLexicalEntries(token.getLemma().getValue(),pos,wordnet).isEmpty()) { List<LexicalEntry> lexicalEntries = uby.getLexicalEntries(token.getLemma().getValue(),pos,wordnet); Sense sense = getWordnetSense(lexicalEntries); return getSemanticField(sense); List<LexicalEntry> lexicalEntries = uby.getLexicalEntries(token.getLemma().getValue(),null,null); String otherSemanticLabelValue = getOtherSemanticLabelValue(lexicalEntries); return getSemanticField(otherSemanticLabelValue);
return new Uby(dbConfig);
/** * Constructor for a {@link Uby} instance used for searching of different elements in a database * containing UBY-LMF {@link LexicalResource}. * * The connection to the database is specified using a {@link DBConfig} instance. * * @param dbConfig * configuration of the database containing UBY-LMF lexical resource. * @throws UbyInvalidArgumentException * if the specified dbConfig is null */ public Uby(DBConfig dbConfig) throws IllegalArgumentException { if(dbConfig == null) { throw new IllegalArgumentException("database configuration is null"); } this.dbConfig = dbConfig; cfg = HibernateConnect.getConfiguration(dbConfig); ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder() .applySettings(cfg.getProperties()); sessionFactory = cfg.buildSessionFactory(serviceRegistryBuilder.buildServiceRegistry()); openSession(); }
private String getSemanticField(String semanticLabelValue) { // get the semantic field of a semantic label value of type "domain" String semanticField = "UNKNOWN"; if (!uby.getLexicalEntries(semanticLabelValue,null,wordnet).isEmpty()) { List<LexicalEntry> lexicalEntries = uby.getLexicalEntries(semanticLabelValue,null,wordnet); Sense sense = getWordnetSense(lexicalEntries); semanticField = getSemanticField(sense); } return semanticField; }
token.getPos().getType().getShortName().equals("ADJ")) && !auxiliariesAndModals.contains(token.getLemma().getValue())) { mfs = getMostFrequentSense(uby.getLexicalEntries(token.getLemma().getValue(), null, null)); String syntacticBehaviour = getSyntacticBehaviour(token.getPos().getType().getShortName(),uby.getLexicalEntries(token.getLemma().getValue(), EPartOfSpeech.verb, null)); List<SemanticField> semanticFieldAnnotations = JCasUtil.selectCovering(jcas,