public SemanticRoleLabelSet( ImmutableSet<SemanticRoleLabelByString> srlByString, Set<SemanticRoleLabelById> srlByNode) { this(srlByString,new ImmutableSetWrapper<SemanticRoleLabelById>(srlByNode)); }
@Override public ImmutableSet<R> rightSet() { return new ImmutableSetWrapper<>(Collections.singleton(this.right)); }
@Override public ImmutableSet<L> leftSet() { return new ImmutableSetWrapper<>(Collections.singleton(this.left)); }
public ImmutableSet<DirectedPair<K>> getAll() { Set<DirectedPair<K>> ret = new LinkedHashSet<DirectedPair<K>>(); for (Pair<K> pair : super.pairsSet) ret.add((DirectedPair<K>) pair); return new ImmutableSetWrapper<DirectedPair<K>>(ret); } }
public ImmutableSet<DirectedPair<K>> getDirectedPairsContaining(K key) { Set<DirectedPair<K>> ret = new LinkedHashSet<DirectedPair<K>>(); for (Pair<K> pair : super.mapKeyToPairContainingIt.get(key)) ret.add((DirectedPair<K>) pair); return new ImmutableSetWrapper<DirectedPair<K>>(ret); }
public SetBagOfRulesRuleBase(Set<SyntacticRule<I,S>> simpleSet) throws RuleBaseException { Set<RuleWithConfidenceAndDescription<I, S>> setWithConfidenceAndDescription = new LinkedHashSet<RuleWithConfidenceAndDescription<I,S>>(); for (SyntacticRule<I,S> rule : simpleSet) { setWithConfidenceAndDescription.add( new RuleWithConfidenceAndDescription<I, S>(rule, EMINUS1, "generic rule")); } this.setOfRules = new ImmutableSetWrapper<RuleWithConfidenceAndDescription<I,S>>(setWithConfidenceAndDescription); }
public ImmutableSet<RuleWithConfidenceAndDescription<Info, BasicNode>> getRules() throws RuleBaseException { if ( (null==this.immutableRulesSet) || (this.dynamicMode) ) { createSetOfRules(); immutableRulesSet = new ImmutableSetWrapper<RuleWithConfidenceAndDescription<Info,BasicNode>>(this.rulesSet); logger.info("manual rules loaded: "+rulesSet.size()); } return immutableRulesSet; }
@Override public ImmutableSet<T> getImmutableSetCopy() { return new ImmutableSetWrapper<T>(getMutableSetCopy()); }
public static <I, S extends AbstractNode<I, S>> SetBagOfRulesRuleBase<I,S> fromSetWithConfidenceAndDescription(Set<RuleWithConfidenceAndDescription<I, S>> setRules) { SetBagOfRulesRuleBase<I,S> ret = new SetBagOfRulesRuleBase<I, S>(); ret.setOfRules = new ImmutableSetWrapper<RuleWithConfidenceAndDescription<I,S>>(setRules); return ret; }
/** * Returns a set of all pairs that are: * <UL> * <LI>exist as keys in the set</LI> * <LI>contain the given "<code>key</code>"</LI> * </UL> * May return null * @param key * @return */ public eu.excitementproject.eop.common.datastructures.immutable.ImmutableSet<Pair<K>> getPairContaining(K key) { eu.excitementproject.eop.common.datastructures.immutable.ImmutableSet<Pair<K>> ret = null; if (mapKeyToPairContainingIt.containsKey(key)) { if (null!=mapKeyToPairContainingIt.get(key)) ret = new eu.excitementproject.eop.common.datastructures.immutable.ImmutableSetWrapper<Pair<K>>(mapKeyToPairContainingIt.get(key)); } return ret; }
public void load() throws IOException { Set<String> setStopWords = new LinkedHashSet<String>(); BufferedReader reader = new BufferedReader(new FileReader(new File(fileName))); try { for (String line = reader.readLine();line != null;line = reader.readLine()) { line = line.trim(); if (line.length()>0) { setStopWords.add(line); } } } finally { reader.close(); } this.stopWords = new ImmutableSetWrapper<String>(setStopWords); }
@Override protected ImmutableSet<LexicalRule> getRulesNotInCache(String lhsLemma, PartOfSpeech lhsPos) throws RuleBaseException { Set<LexicalRule> ret = new LinkedHashSet<LexicalRule>(); try { statement.setString(1, lhsLemma); ResultSet resultSet = statement.executeQuery(); while(resultSet.next()) { String entailing = resultSet.getString("entailing"); String entailed = resultSet.getString("entailed"); ret.add(new LexicalRule(entailing, lhsPos, entailed, lhsPos, CONFIDENCE)); } return new ImmutableSetWrapper<LexicalRule>(ret); } catch(SQLException e) { throw new RuleBaseException("SQL problem",e); } }
/** * Ctor * @param verbs * @param nouns * @param predicateType * @throws AnnotationCompilationException */ public PhrasalVerbTemplate(Set<String> verbs, Set<String> nouns, PredicateSignature predicateType) throws AnnotationCompilationException { if (verbs == null || verbs.isEmpty()) throw new AnnotationCompilationException("got empty/null verbs"); if (nouns == null || nouns.isEmpty()) throw new AnnotationCompilationException("got empty/null nouns"); if (predicateType == null ) throw new AnnotationCompilationException("got null predicate type"); this.verbs = new ImmutableSetWrapper<String>(verbs); this.nouns = new ImmutableSetWrapper<String>(nouns); this.predicateType = predicateType; }
private ImmutableSet<CanonicalLemmaAndPos> convertToCanonicalSet(ImmutableSet<LemmaAndPos> setLemmaAndPos) throws TeEngineMlException { Set<CanonicalLemmaAndPos> set = new LinkedHashSet<CanonicalLemmaAndPos>(); for (LemmaAndPos lemmaAndPos : setLemmaAndPos) { set.add( new CanonicalLemmaAndPos(lemmaAndPos.getLemma(),lemmaAndPos.getPartOfSpeech()) ); } return new ImmutableSetWrapper<CanonicalLemmaAndPos>(set); }
/** * Ctor * @param extractionTypes * @param coocurenceScore * @throws LexicalResourceException */ public WikiRuleInfo(Set<WikiExtractionType> extractionTypes, double coocurenceScore) throws LexicalResourceException { if (extractionTypes == null) throw new LexicalResourceException("got null extractionTypes"); if (extractionTypes.isEmpty()) throw new LexicalResourceException("got empty extractionTypes"); this.extractionTypes = new ImmutableSetWrapper<WikiExtractionType>( new LinkedHashSet<WikiExtractionType>(extractionTypes)); this.coocurenceScore = coocurenceScore; setBestExtractionType(extractionTypes); }
protected ImmutableSet<LexicalRule> getRulesImpl(String lhsLemma, PartOfSpeech lhsPos) throws RuleBaseException { try { Set<LexicalRule> setRules = new LinkedHashSet<LexicalRule>(); if (MAP_POS_TO_TABLE.get(simplerPos(lhsPos.getCanonicalPosTag()))!=null) { PreparedStatement statement = connection.prepareStatement(MAP_POS_TO_TABLE.get(simplerPos(lhsPos.getCanonicalPosTag()))); statement.setString(1,lhsLemma); statement.setInt(2, limitNumberOfRules); // linQueryTracker.start(); ResultSet rs = statement.executeQuery(); while (rs.next()) { String rhsLemma = rs.getString("word1"); double score = rs.getDouble("sim"); setRules.add(new LexicalRule(lhsLemma, lhsPos, rhsLemma, lhsPos, score)); } // linQueryTracker.end(); } return new ImmutableSetWrapper<LexicalRule>(setRules); } catch(SQLException e) { throw new RuleBaseException("SQL problem",e); } }
@Override public ImmutableSet<K> getKeysOf(V value) { ImmutableSet<K> ret = null; if (this.bidirectionalMap!=null) { LinkedHashSet<K> set = new LinkedHashSet<K>(); if (this.bidirectionalMap.rightContains(value)) { K key = this.bidirectionalMap.rightGet(value); set.add(key); } ret = new ImmutableSetWrapper<K>(set); } else { ret = this.valueSetMap.getKeysOf(value); } return ret; }
@Override public ImmutableSet<ChainOfLexicalRules> getRules(String lhsLemma, PartOfSpeech lhsPos) throws RuleBaseException { if (null==this.rules) throw new RuleBaseException("Rules were not set!"); try { CanonicalLemmaAndPos lemmaAndPos = new CanonicalLemmaAndPos(lhsLemma, lhsPos); ImmutableSet<ChainOfLexicalRules> ret = null; if (rules.containsKey(lemmaAndPos)) { ret = rules.get(lemmaAndPos); } if (null==ret) { ret = new ImmutableSetWrapper<ChainOfLexicalRules>(new DummySet<ChainOfLexicalRules>()); } return ret; } catch(TeEngineMlException e) { throw new RuleBaseException("Failed to fetch rules",e); } }
public ImmutableSet<String> getAllowedDatasetNames() throws TeEngineMlException { if (null==this.teSystemEnvironment.getFeatureVectorStructureOrganizer().getDynamicGlobalFeatures()) { return new ImmutableSetWrapper<String>(new DummySet<String>()); } else { return this.teSystemEnvironment.getFeatureVectorStructureOrganizer().getDynamicGlobalFeatures().keySet(); } }
@Override public ImmutableSet<V> get(K key) { ImmutableSet<V> ret = null; if (this.bidirectionalMap!=null) { Set<V> set = null; if (this.bidirectionalMap.leftContains(key)) { V value = this.bidirectionalMap.leftGet(key); set = new SingleItemSet<V>(value); } else { set = new DummySet<V>(); } ret = new ImmutableSetWrapper<V>(set); } else { ret = this.valueSetMap.get(key); } return ret; }