/** * @param canonicalPartOfSpeech the canonicalPartOfSpeech to set * @throws UnsupportedPosTagStringException */ private void setCanonicalPartOfSpeech(SimplerCanonicalPosTag canonicalPartOfSpeech) throws UnsupportedPosTagStringException { this.canonicalPartOfSpeech = canonicalPartOfSpeech; partOfSpeech = new BySimplerCanonicalPartOfSpeech(canonicalPartOfSpeech); }
public WordAndPartOfSpeech(String word, PartOfSpeech pos) throws UnsupportedPosTagStringException { super(); this.word = word; this.pos = ((null==pos)?new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.OTHER):pos); }
/** * Ctor * @param limitOnRetrievedRules * @throws LexicalResourceException */ public AbstractSimilarityLexicalResource(int limitOnRetrievedRules) throws LexicalResourceException { try { ADJECTIVE = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.ADJECTIVE); NOUN = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); VERB = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.VERB); } catch (UnsupportedPosTagStringException e) { throw new LexicalResourceException("Couldn't create UnspecifiedPartOfSpeech", e); } if (limitOnRetrievedRules < 0) throw new LexicalResourceException("the limitOnRetrievedRules must be positive, or zero to mean 'no limit'. I got " + limitOnRetrievedRules); LIMIT_CLAUSE = (limitOnRetrievedRules > 0 ? " LIMIT " + limitOnRetrievedRules : ""); } /**
if (pos.equalsIgnoreCase("V")) posObj = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.VERB); posObj = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); posObj = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.ADVERB); posObj = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.ADJECTIVE);
protected void setOverrideRelationToArtificialRoot(EdgeInfo overrideRelationToArtificialRoot) throws UnsupportedPosTagStringException { this.overrideRelationToArtificialRoot = new ExtendedInfo("", new DefaultNodeInfo("", "", 0, null, new DefaultSyntacticInfo(new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.OTHER))), overrideRelationToArtificialRoot, ExtendedNodeConstructor.EMPTY_ADDITIONAL_NODE_INFORMATION); }
public static void main(String[] args) throws LexicalResourceException, UnsupportedPosTagStringException, FileNotFoundException, RedisRunException { if (args.length != 2) { System.out.println("Usage: eu.excitementproject.eop.core.component.lexicalknowledge.geo.RedisBasedGeoLexicalResource <l2r geo redis file> <r2l geo redfis file>"); System.exit(0); } String lLemma = "San Jose"; PartOfSpeech pos2 = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); String rLemma = "United Kingdom"; RedisBasedGeoLexicalResource GEOLexR = new RedisBasedGeoLexicalResource(args[0],args[1]); List<LexicalRule<? extends EmptyRuleInfo>> rules2 = GEOLexR.getRulesForLeft(lLemma, pos2 ); System.out.println("Got "+rules2.size() + " for: " + lLemma + ", " + pos2 ); for (LexicalRule<? extends EmptyRuleInfo> rule : rules2) System.out.println(rule); System.out.println(lLemma +" has " + rules2.size() + " relations"); System.out.println("\n*****************************\n"); List<LexicalRule<? extends EmptyRuleInfo>> otherRules = GEOLexR.getRules(lLemma, null, rLemma, null); System.out.println("Got "+otherRules.size() + " for: " + lLemma + ", " + pos2 + ", " + rLemma + ", " + pos2 ); for (LexicalRule<? extends EmptyRuleInfo> rule : otherRules) System.out.println(rule); System.out.println(lLemma +" has " + otherRules.size() + " relations"); }
PartOfSpeech pos2 = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); String rLemma = "United Kingdom"; System.out.println("Looking for all rules from \"" + lLemma + "\" to \"" + rLemma + "\"");
return new BySimplerCanonicalPartOfSpeech(canonicalPosTag); } catch (UnsupportedPosTagStringException e)
/** * @param args * @throws ConfigurationException * @throws ConfigurationFileDuplicateKeyException * @throws LexicalResourceException * @throws UnsupportedPosTagStringException */ public static void main(String[] args) throws ConfigurationFileDuplicateKeyException, ConfigurationException, LexicalResourceException, UnsupportedPosTagStringException { ConfigurationFile confFile = new ConfigurationFile(new File("B:/Apps/BIUTEE/workdir/biutee_train.xml")); // ConfigurationParams params = confFile.getModuleConfiguration("LinDependencySimilarity"); // AbstractSimilarityLexicalResource lexResource = new LinDistsimLexicalResource(params); // ConfigurationParams params = confFile.getModuleConfiguration("bap"); // AbstractSimilarityLexicalResource lexResource = new Direct1000LexicalResource(params); ConfigurationParams params = confFile.getModuleConfiguration("LinDependencySimilarity"); AbstractSimilarityLexicalResource lexResource = new LinProximityOriginalLexicalResource(params); String lemma = "left"; PartOfSpeech pos = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); List<LexicalRule<? extends RuleInfo>> rules = lexResource.getRulesForRight(lemma, pos); System.out.println("Found " +rules.size()+" right rules for <"+ lemma+", "+ pos+">"); for (LexicalRule<? extends RuleInfo> rule : rules) System.out.println(rule); }
public static void main(String args[]) throws Exception { if (args.length != 3) { System.out.println("Usage: eu.excitementproject.eop.core.component.lexicalknowledge.wordnet.WordnetLexicalResource <configuration file> <wordnet section name> <tested noun>"); System.exit(0); } ConfigurationFile confFile = new ConfigurationFile(new ImplCommonConfig(new File(args[0]))); ConfigurationParams confParams = confFile.getModuleConfiguration(args[1]); WordnetLexicalResource resource = new WordnetLexicalResource(confParams); List<LexicalRule<? extends WordnetRuleInfo>> rules = resource.getRulesForRight(args[2], new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN)); for (LexicalRule<? extends WordnetRuleInfo> rule : rules) { System.out.println(rule.getLLemma() + " " + rule.getLPos()); } }
public RedisBasedGeoLexicalResource(String leftRedisHost, int leftRedisPort, String rightRedisHost, int rightRedisPort) throws UnsupportedPosTagStringException, LexicalResourceException { leftRules = new RedisBasedStringListBasicMap(leftRedisHost,leftRedisPort); rightRules = new RedisBasedStringListBasicMap(rightRedisHost,rightRedisPort); try { NOUN = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); } catch (UnsupportedPosTagStringException e) { throw new LexicalResourceException("Bug: couldn't construct a new UnspecifiedPartOfSpeech(SimplerCanonicalPosTag.NOUN)",e); } }
PartOfSpeech pos2 = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); String rLemma = "Venice"; System.out.println("Looking for all rules from \"" + lLemma + "\" to \"" + rLemma + "\"");
PartOfSpeech pos1 = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); PartOfSpeech pos2 = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); String rLemma = "fruit"; System.out.println("Looking for all rules from \"" + lLemma + "\" to \"" + rLemma + "\"");
public RedisBasedGeoLexicalResource(String leftRedisDBFile, String rightRedisDBFile) throws UnsupportedPosTagStringException, FileNotFoundException, RedisRunException, LexicalResourceException{ leftRules = new RedisBasedStringListBasicMap(leftRedisDBFile, false); rightRules = new RedisBasedStringListBasicMap(rightRedisDBFile,false); try { NOUN = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); } catch (UnsupportedPosTagStringException e) { throw new LexicalResourceException("Bug: couldn't construct a new UnspecifiedPartOfSpeech(SimplerCanonicalPosTag.NOUN)",e); } }
PartOfSpeech pos2 = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.VERB); String rLemma = "dislike"; System.out.println("Looking for all rules from \"" + lLemma + "\" to \"" + rLemma + "\"");
PartOfSpeech pos2 = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); String rLemma = "Venezia"; System.out.println("Looking for all rules from \"" + lLemma + "\" to \"" + rLemma + "\"");
private List<LexicalRule<? extends RuleInfo>> arrangePosTagInRules(List<LexicalRule<? extends RuleInfo>> orgRules) throws LexicalResourceException{ List<LexicalRule<? extends RuleInfo>> modifiedRules = new ArrayList<LexicalRule<? extends RuleInfo>>(); for(LexicalRule<? extends RuleInfo> r : orgRules){ String[] lhs = r.getLLemma().split(POS_SEP); String[] rhs = r.getRLemma().split(POS_SEP); PartOfSpeech lPos, rPos; try { lPos = lhs.length == 2 ? new BySimplerCanonicalPartOfSpeech(lhs[1]) : defaultPos; rPos = rhs.length == 2 ? new BySimplerCanonicalPartOfSpeech(rhs[1]) : defaultPos; } catch (UnsupportedPosTagStringException e) { throw new LexicalResourceException("nested exception while reading the POS tags of the rule"+r,e); } modifiedRules.add( new LexicalRule<RuleInfo>(lhs[0], lPos, rhs[0], rPos, r.getRelation(), r.getResourceName(), r.getInfo()) ); } return modifiedRules; }
try { NOUN = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); } catch (UnsupportedPosTagStringException e) { throw new LexicalResourceException("Internal error", e); }
PartOfSpeech pos2 = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); String rLemma = "worker"; System.out.println("Looking for all rules from \"" + lLemma + "\" to \"" + rLemma + "\"");
/** * Ctor * @throws LexicalResourceException */ public GeoLexicalResource(String dbConnectionString, String tableName) throws LexicalResourceException { if (dbConnectionString == null) throw new LexicalResourceException("got null connection string"); if (dbConnectionString.isEmpty()) throw new LexicalResourceException("got empty connection string"); if (tableName == null) throw new LexicalResourceException("got null table name"); if (tableName.isEmpty()) throw new LexicalResourceException("got empty table name"); Connection con; try { con = DriverManager.getConnection(dbConnectionString); GET_RULES_ENTAILED_BY_STMT = con.prepareStatement(GET_RULES_QUERY_HEAD + tableName + GET_RULES_ENTAILED_BY_QUERY_TAIL); GET_RULES_ENTAILING_STMT = con.prepareStatement(GET_RULES_QUERY_HEAD + tableName + GET_RULES_ENTAILING_QUERY_TAIL); GET_RULE_FOR_BOTH_SIDES_STMT = con.prepareStatement(GET_RULES_QUERY_HEAD + tableName + GET_RULE_FOR_BOTH_SIDES_QUERY_TAIL); } catch (SQLException e) { throw new LexicalResourceException("Could not open connection or create statments at : " + dbConnectionString, e); } try { NOUN = new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.NOUN); } catch (UnsupportedPosTagStringException e) { throw new LexicalResourceException("Bug: couldn't construct a new UnspecifiedPartOfSpeech(SimplerCanonicalPosTag.NOUN)",e); } }