/** * Maps a GermaNet WordCategory onto the equivalent EOP POS tag * * @param wc GermaNet WordCategory, e.g. "adj" or "nomen" * @return equivalent GermanPartOfSpeech, or "OTHER" if no matching POS tag is found */ private GermanPartOfSpeech wordCategoryToPos(WordCategory wc) { try { switch (wc) { case adj: return new GermanPartOfSpeech("ADJ"); case nomen: return new GermanPartOfSpeech("N"); case verben: return new GermanPartOfSpeech("V"); default: return new GermanPartOfSpeech("OTHER"); } } catch (UnsupportedPosTagStringException e) { return null; } }
/** * Converts DErivBase-internal POS notation to the project-wide one, i.e., * converts "A" to "ADJ". * * @param relatedPair a tuple of lemma and POS, where the POS should be converted * @return */ private PartOfSpeech convertPartOfSpeech(String internalPos) { PartOfSpeech relatedPos = null; try { // TODO: is it problematic for calling functions that getB // returns only N,V,A, but not NN? // enlarge "A" to "ADJ" for GermanPartOfSpeech lookup if (internalPos.equals("A")) { relatedPos = new GermanPartOfSpeech("ADJ"); } else { relatedPos = new GermanPartOfSpeech(internalPos); } } catch (UnsupportedPosTagStringException e) { System.err.println("Problems converting the DErivBase POS string " + internalPos + " to GermanPartOfSpeech."); e.printStackTrace(); } return relatedPos; }
/** An overloaded method for getRulesForRight. In addition to the previous method, * this method also matches the relation field of LexicalRule with the argument. * @param lemma Lemma to be matched on RHS. * @param pos POS to be matched on RHS. null means "don't care". * @param relation The canonical relation of the rule (from LHS to RHS, TERuleRelation.Entailment or .Nonentailment) * @return a list of rules that matches the given condition. Empty list if there's no match. */ public List<LexicalRule<? extends GermanTransDmInfo>> getRulesForRight(String lemma, PartOfSpeech pos, TERuleRelation relation) throws LexicalResourceException { // DistSim can only return Entailment if (relation == TERuleRelation.NonEntailment) return new ArrayList<LexicalRule<? extends GermanTransDmInfo>>(); isReverseMap = true; Set<LexicalRule<? extends GermanTransDmInfo>> result = new HashSet<LexicalRule<? extends GermanTransDmInfo>>(); if (pos == null){ //no pos specified -> get rules for all possible pos tags for (String postag : allPosTags){ try { result.addAll(getFromMap(lemma, new GermanPartOfSpeech(postag), reverse_sims)); } catch (UnsupportedPosTagStringException e) { e.printStackTrace(); } } return new ArrayList<LexicalRule<? extends GermanTransDmInfo>>(result); } else{ return getFromMap(lemma, pos, reverse_sims); } }
GermanPartOfSpeech pos2 = null; try { pos1 = new GermanPartOfSpeech("OTHER"); pos2 = new GermanPartOfSpeech("OTHER");
/** Returns a list of lexical rules whose right side (the target of the lexical relation) matches * the given lemma and POS. An empty list means that no rules were matched. * @param lemma Lemma to be matched on RHS. * @param pos POS to be matched on RHS. null means "don't care". * @return a list of rules that matches the given condition. Empty list if there's no match. */ public List<LexicalRule<? extends GermanTransDmInfo>> getRulesForRight(String lemma, PartOfSpeech pos) throws LexicalResourceException { isReverseMap = true; Set<LexicalRule<? extends GermanTransDmInfo>> result = new HashSet<LexicalRule<? extends GermanTransDmInfo>>(); if (pos == null){ //no pos specified -> get rules for all possible pos tags for (String postag : allPosTags){ try { result.addAll(getFromMap(lemma, new GermanPartOfSpeech(postag), reverse_sims)); } catch (UnsupportedPosTagStringException e) { e.printStackTrace(); } } return new ArrayList<LexicalRule<? extends GermanTransDmInfo>>(result); } else{ return getFromMap(lemma, pos, reverse_sims); } }
/** * Returns a list of lexical rules whose left side (the head of the lexical relation) matches * the given lemma and POS. An empty list means that no rules were matched. If the user * gives null POS, the class will retrieve rules for all possible POSes. * @param lemma Lemma to be matched on LHS. * @param pos POS to be matched on LHS. null means "don't care". * @return a list of rules that matches the given condition. Empty list if there's no match. */ public List<LexicalRule<? extends GermanTransDmInfo>> getRulesForLeft(String lemma, PartOfSpeech pos) throws LexicalResourceException { isReverseMap = false; Set<LexicalRule<? extends GermanTransDmInfo>> result = new HashSet<LexicalRule<? extends GermanTransDmInfo>>(); if (pos == null){ //no pos specified -> get rules for all possible pos tags for (String postag : allPosTags){ try { result.addAll(getFromMap(lemma, new GermanPartOfSpeech(postag), sims)); } catch (UnsupportedPosTagStringException e) { e.printStackTrace(); } } return new ArrayList<LexicalRule<? extends GermanTransDmInfo>>(result); } else{ return getFromMap(lemma, pos, sims); } }
/**an overloaded method for getRulesForLeft. In addition to the previous method, this method * also matches the relation field of LexicalRule with the argument. * @param lemma Lemma to be matched on LHS * @param pos POS to be matched on LHS. null means "don't care". * @param relation The canonical relation of the rule (from LHS to RHS, TERuleRelation.Entailment or .Nonentailment) * @return A list of rules that matches the given condition. Empty list if there's no match. */ public List<LexicalRule<? extends GermanTransDmInfo>> getRulesForLeft(String lemma, PartOfSpeech pos, TERuleRelation relation) throws LexicalResourceException { // DistSim can only return Entailment if (relation == TERuleRelation.NonEntailment) return new ArrayList<LexicalRule<? extends GermanTransDmInfo>>(); isReverseMap = false; Set<LexicalRule<? extends GermanTransDmInfo>> result = new HashSet<LexicalRule<? extends GermanTransDmInfo>>(); if (pos == null){ //no pos specified -> get rules for all possible pos tags for (String postag : allPosTags){ try { result.addAll(getFromMap(lemma, new GermanPartOfSpeech(postag), sims)); } catch (UnsupportedPosTagStringException e) { e.printStackTrace(); } } return new ArrayList<LexicalRule<? extends GermanTransDmInfo>>(result); } else{ return getFromMap(lemma, pos, sims); } }
try { if (lemmapos.substring(lemmapos.lastIndexOf("-") + 1).intern() == "v") { pos1 = new GermanPartOfSpeech("V"); } else if (lemmapos.substring(lemmapos.lastIndexOf("-") + 1).intern() == "n") { pos1 = new GermanPartOfSpeech("N"); } else if (lemmapos.substring(lemmapos.lastIndexOf("-") + 1).intern() == "j") { pos1 = new GermanPartOfSpeech("ADJ"); pos2 = new GermanPartOfSpeech("V"); } else if (rhs.substring(rhs.lastIndexOf("-") + 1).intern() == "n") { pos2 = new GermanPartOfSpeech("N"); } else if (rhs.substring(rhs.lastIndexOf("-") + 1).intern() == "j") { pos2 = new GermanPartOfSpeech("ADJ");
try { if (rightPos.toString().startsWith("V")) { rightPosShort = new GermanPartOfSpeech ("V"); } else if (rightPos.toString().startsWith("N")) { rightPosShort = new GermanPartOfSpeech ("N"); } else if (rightPos.toString().equals("ADJ")) { rightPosShort = new GermanPartOfSpeech ("ADJ");
for (LexicalRule<? extends RuleInfo> rule : gnw .getRulesForLeft(word.split(" ### ")[0], new GermanPartOfSpeech(POS), gnr)) { String tokenText = rule.getRLemma() + " ### " + POS; if (tWordBag.containsKey(tokenText)) {
for (LexicalRule<? extends RuleInfo> rule : lex .getRulesForLeft(word.split(" ### ")[0], new GermanPartOfSpeech(POS))) { String tokenText = rule.getRLemma() + " ### " + POS; if (tWordBag.containsKey(tokenText)) {
if (rightPos.toString().equals("NN") && rule.getRPos().toString().equals("N")) { try { rightPos = new GermanPartOfSpeech("N"); } catch (UnsupportedPosTagStringException e) { e.printStackTrace();
if (rightPos.toString().equals("NN") && rule.getRPos().toString().equals("N")) { try { rightPos = new GermanPartOfSpeech("N"); } catch (UnsupportedPosTagStringException e) { e.printStackTrace();
pos = new GermanPartOfSpeech("OTHER");
pos = new GermanPartOfSpeech("OTHER");
luPos = new GermanPartOfSpeech("NP");
luPos = new GermanPartOfSpeech("NP"); luPos = new GermanPartOfSpeech("NP");