/** * Counts the number of {@link LexicalEntry} instances within the UBY-LMF {@link LexicalResource} * contained in the database accessed by this {@link UbyStatistics} instance. * * @return the number of lexical entries in the lexical resource or zero if the * lexical resource does not contain any lexical entries */ public long countLexicalEntries(){ return countClassEntities(LexicalEntry.class); }
@Override public Iterator<T> iterator() { return new CriteriaIterator<T>(criteria, sessionFactory, bufferSize); }
/** * 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"); }
/** * 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); }
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; }
/** * 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); }
@Override public boolean hasNext() { boolean hasNext = buffer==null ? false : buffer.hasNext(); if(!hasNext) hasNext = fillBuffer(); return hasNext; }
/** * * @param config * database's configuration * @param useHibernate * false for direct access; true connect via Hibernate * @deprecated use {@link #UbyQuickAPI(DBConfig)} instead */ @Deprecated public UbyQuickAPI(DBConfig config, boolean useHibernate,boolean useTempTables) throws ClassNotFoundException, SQLException, FileNotFoundException{ setDBConfig(config,useHibernate,useTempTables); }
/** * @param config * Database's Configuration * @param useHibernate * true if you want to connect to database via Hibernate; false for direct access * @deprecated use {@link #UbyQuickAPI(DBConfig)} instead */ @Deprecated public void setDBConfig(DBConfig config, boolean useHibernate, boolean useTemporaryTables) throws ClassNotFoundException, SQLException, FileNotFoundException { this.dbConfig = config; if(useHibernate){ setDbConfig(config); }/*else{ this.useTemporaryTables=useTemporaryTables; mysql=new MySQLConnect(config,this.useTemporaryTables); }*/ }
/** * Count the number of lemma+pos combinations per lexicon, * part-of-speech prefix * and language * @param lexiconName * Name of the lexicon * @param prefix * The partOfSpeech prefix * @param lang * The language identifier of the lexicon * @return the number of lemma+pos combinations */ public long countLemmaPosPerLexiconAndPosPrefixAndLanguage(String lexiconName, String prefix, String lang){ Set<String> l= getLemmaPosPerLexiconAndPosPrefixAndLanguage(lexiconName, prefix, lang); int res = 0; if (!l.isEmpty()){ res = l.size(); } return res; }
Set<String> l = getLemmaPosPerLexicon(lexiconName); int res = 0; if (!l.isEmpty()){
/** * 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(); }
/** * Returns an {@link Iterator} over {@link SenseAxis} instances * * @return An iterator over sense axes matching the specified criteria */ public Iterator<SenseAxis> getSenseAxisIterator() { DetachedCriteria criteria = DetachedCriteria.forClass(SenseAxis.class); CriteriaIterator<SenseAxis> senseAxisIterator = new CriteriaIterator<SenseAxis>( criteria, sessionFactory, 500); return senseAxisIterator; }
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; }
/** * Counts the number of {@link SenseAxis} instances within the UBY-LMF {@link LexicalResource} * contained in the database accessed by this {@link UbyStatistics} instance. * * @return the number of sense axes in the lexical resource or zero if the * lexical resource does not contain any sense axes */ public long countSenseAxes() { return countClassEntities(SenseAxis.class); }
/** * Returns {@link Iterator} over all {@link Synset} instances contained in the database accessed * by this {@link Uby} instance.<br> * Optionally, the returned synsets can be filtered by {@link Lexicon}. * * @param lexicon * If not null, synsets are filtered by the given lexicon * * @return an iterator over all synsets in the accessed database filtered by the given lexicon * if not null */ public Iterator<Synset> getSynsetIterator(Lexicon lexicon) { DetachedCriteria criteria = DetachedCriteria.forClass(Synset.class); if (lexicon != null) { criteria = criteria.add(Restrictions.eq("lexicon", lexicon)); } CriteriaIterator<Synset> synsetIterator = new CriteriaIterator<Synset>( criteria, sessionFactory, 500); return synsetIterator; }
/** * Counts the number of {@link Sense} instances within the UBY-LMF {@link LexicalResource} * contained in the database accessed by this {@link UbyStatistics} instance. * * @return the number of senses in the lexical resource or zero if the * lexical resource does not contain any senses */ public long countSenses(){ return countClassEntities(Sense.class); }
/** * Returns {@link Iterator} over all {@link Sense} instances contained in the database accessed * by this {@link Uby} instance.<br> * Optionally, the returned senses can be filtered by {@link Lexicon}. * * @param lexicon * If not null, senses are filtered by the given lexicon * * @return an iterator over all senses in the accessed database filtered by the given lexicon if * not null */ public Iterator<Sense> getSenseIterator(Lexicon lexicon) { DetachedCriteria criteria = DetachedCriteria.forClass(Sense.class); if (lexicon != null) { criteria = criteria.createCriteria("lexicalEntry").add( Restrictions.eq("lexicon", lexicon)); } CriteriaIterator<Sense> senseIterator = new CriteriaIterator<Sense>( criteria, sessionFactory, 500); return senseIterator; }
CriteriaIterator<LexicalEntry> lexEntryIterator = new CriteriaIterator<LexicalEntry>( criteria, sessionFactory, 500); return lexEntryIterator;
/** * Return an {@link Iterator} over {@link SemanticPredicate} instances, * optionally filtered by a {@link Lexicon}. * * @param lexicon * if not null, the iterator will only be for semantic predicates * of the specified lexicon * * @return iterator over the semantic predicates in the specified lexicon.<br> * If the specified lexicon is null, this method returns an iterator * over all semantic predicates in the {@link LexicalResource}, * accessed by this {@link Uby} instance. */ public Iterator<SemanticPredicate> getSemanticPredicateIterator( Lexicon lexicon) { DetachedCriteria criteria = DetachedCriteria.forClass(SemanticPredicate.class); if (lexicon != null) { String lexId = lexicon.getId(); criteria = criteria.add(Restrictions.sqlRestriction("lexiconId='" + lexId + "'")); } CriteriaIterator<SemanticPredicate> predicateIterator = new CriteriaIterator<SemanticPredicate>( criteria, sessionFactory, 500); return predicateIterator; }