Author: rwesten
Date: Mon Oct 29 10:29:10 2012
New Revision: 1403242
URL: http://svn.apache.org/viewvc?rev=1403242&view=rev
Log:
STANBOL-734, STANBOL-739: Minor changes related to the API changes in PosTag;
Mapped some POS tags to the Pos Enum (but only those that where linking to
removed LexicalCategory entries (tree of former members of the LexicalCategory
enum where moved to the Pos enum)
Modified:
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliMorphoFeatures.java
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliTagSetRegistry.java
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliAnalyzedTextLemmatizerEngine.java
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliAnalyzedTextLemmatizerEngineTest.java
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngineTest.java
Modified:
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliMorphoFeatures.java
URL:
http://svn.apache.org/viewvc/stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliMorphoFeatures.java?rev=1403242&r1=1403241&r2=1403242&view=diff
==============================================================================
---
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliMorphoFeatures.java
(original)
+++
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliMorphoFeatures.java
Mon Oct 29 10:29:10 2012
@@ -116,8 +116,10 @@ public class CeliMorphoFeatures extends
result.add(new TripleImpl(textAnnotation,
CeliLemmatizerEnhancementEngine.hasLemmaForm,
new PlainLiteralImpl(getLemma(), lang)));
for(PosTag pos: getPosList()){
- if(pos.getCategory() != null){
- result.add(new TripleImpl(textAnnotation, RDF_TYPE,
pos.getCategory().getUri()));
+ if(pos.isMapped()){
+ for(LexicalCategory cat : pos.getCategories()){
+ result.add(new TripleImpl(textAnnotation, RDF_TYPE,
cat.getUri()));
+ }
}
}
for(NumberTag num : getNumberList()){
Modified:
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliTagSetRegistry.java
URL:
http://svn.apache.org/viewvc/stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliTagSetRegistry.java?rev=1403242&r1=1403241&r2=1403242&view=diff
==============================================================================
---
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliTagSetRegistry.java
(original)
+++
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliTagSetRegistry.java
Mon Oct 29 10:29:10 2012
@@ -4,8 +4,6 @@ import java.lang.reflect.InvocationTarge
import java.util.HashMap;
import java.util.Map;
-import javax.swing.text.DefaultEditorKit.PasteAction;
-
import org.apache.stanbol.enhancer.nlp.model.tag.Tag;
import org.apache.stanbol.enhancer.nlp.model.tag.TagSet;
import org.apache.stanbol.enhancer.nlp.morpho.Case;
@@ -23,6 +21,7 @@ import org.apache.stanbol.enhancer.nlp.m
import org.apache.stanbol.enhancer.nlp.morpho.VerbMood;
import org.apache.stanbol.enhancer.nlp.morpho.VerbMoodTag;
import org.apache.stanbol.enhancer.nlp.pos.LexicalCategory;
+import org.apache.stanbol.enhancer.nlp.pos.Pos;
import org.apache.stanbol.enhancer.nlp.pos.PosTag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -401,14 +400,14 @@ public final class CeliTagSetRegistry {
ITALIAN.addTag(new PosTag("DETPOSS",
LexicalCategory.PronounOrDeterminer));
ITALIAN.addTag(new PosTag("DETWH",
LexicalCategory.PronounOrDeterminer));
ITALIAN.addTag(new PosTag("CHEWH",
LexicalCategory.PronounOrDeterminer));
- ITALIAN.addTag(new PosTag("CLI", LexicalCategory.Clitic));
+ ITALIAN.addTag(new PosTag("CLI")); //not mapped
ITALIAN.addTag(new PosTag("CONJ", LexicalCategory.Conjuction));
ITALIAN.addTag(new PosTag("CONGWH", LexicalCategory.Conjuction));
ITALIAN.addTag(new PosTag("PREP", LexicalCategory.Adposition));
ITALIAN.addTag(new PosTag("V", LexicalCategory.Verb));
ITALIAN.addTag(new PosTag("INT", LexicalCategory.Interjection));
ITALIAN.addTag(new PosTag("NEG", LexicalCategory.Adverb));
- ITALIAN.addTag(new PosTag("NUM", LexicalCategory.Numeral));
+ ITALIAN.addTag(new PosTag("NUM", Pos.Numeral));
getInstance().addPosTagset(ITALIAN);
}
@@ -424,7 +423,7 @@ public final class CeliTagSetRegistry {
GERMAN.addTag(new PosTag("PREPART", LexicalCategory.Adposition));
GERMAN.addTag(new PosTag("V", LexicalCategory.Verb));
GERMAN.addTag(new PosTag("INT", LexicalCategory.Interjection));
- GERMAN.addTag(new PosTag("NUM", LexicalCategory.Numeral));
+ GERMAN.addTag(new PosTag("NUM", Pos.Numeral));
getInstance().addPosTagset(GERMAN);
}
@@ -433,7 +432,7 @@ public final class CeliTagSetRegistry {
DANISH.addTag(new PosTag("N", LexicalCategory.Noun));
DANISH.addTag(new PosTag("NF", LexicalCategory.Noun));
DANISH.addTag(new PosTag("NN", LexicalCategory.Noun));
- DANISH.addTag(new PosTag("NP", LexicalCategory.ProperNoun));
+ DANISH.addTag(new PosTag("NP", LexicalCategory.Noun));//ProperNoun));
DANISH.addTag(new PosTag("ADJ", LexicalCategory.Adjective));
DANISH.addTag(new PosTag("ADV", LexicalCategory.Adverb));
DANISH.addTag(new PosTag("ART", LexicalCategory.PronounOrDeterminer));
@@ -443,7 +442,7 @@ public final class CeliTagSetRegistry {
DANISH.addTag(new PosTag("V", LexicalCategory.Verb));
DANISH.addTag(new PosTag("INT", LexicalCategory.Interjection));
DANISH.addTag(new PosTag("INVAR", LexicalCategory.Residual));
- DANISH.addTag(new PosTag("NUM", LexicalCategory.Numeral));
+ DANISH.addTag(new PosTag("NUM", Pos.Numeral));
getInstance().addPosTagset(DANISH);
}
@@ -453,7 +452,7 @@ public final class CeliTagSetRegistry {
RUSSIAN.addTag(new PosTag("NF", LexicalCategory.Noun));
RUSSIAN.addTag(new PosTag("NM", LexicalCategory.Noun));
RUSSIAN.addTag(new PosTag("NN", LexicalCategory.Noun));
- RUSSIAN.addTag(new PosTag("NP", LexicalCategory.ProperNoun));
+ RUSSIAN.addTag(new PosTag("NP", LexicalCategory.Noun));//ProperNoun));
RUSSIAN.addTag(new PosTag("NPLUR", LexicalCategory.Noun));
RUSSIAN.addTag(new PosTag("ADJ", LexicalCategory.Adjective));
RUSSIAN.addTag(new PosTag("ADV", LexicalCategory.Adverb));
@@ -462,7 +461,7 @@ public final class CeliTagSetRegistry {
RUSSIAN.addTag(new PosTag("PREP", LexicalCategory.Adposition));
RUSSIAN.addTag(new PosTag("V", LexicalCategory.Verb));
RUSSIAN.addTag(new PosTag("INT", LexicalCategory.Interjection));
- RUSSIAN.addTag(new PosTag("NUM", LexicalCategory.Numeral));
+ RUSSIAN.addTag(new PosTag("NUM", Pos.Numeral));
RUSSIAN.addTag(new PosTag("NUMNON",
LexicalCategory.PronounOrDeterminer));
RUSSIAN.addTag(new PosTag("PART", LexicalCategory.Unique));
getInstance().addPosTagset(RUSSIAN);
@@ -480,7 +479,7 @@ public final class CeliTagSetRegistry {
ROMANIAN.addTag(new PosTag("V", LexicalCategory.Verb));
ROMANIAN.addTag(new PosTag("I", LexicalCategory.Interjection));
ROMANIAN.addTag(new PosTag("INVAR", LexicalCategory.Residual));
- ROMANIAN.addTag(new PosTag("NU", LexicalCategory.Numeral));
+ ROMANIAN.addTag(new PosTag("NU", Pos.Numeral));
ROMANIAN.addTag(new PosTag("R", LexicalCategory.Residual));
ROMANIAN.addTag(new PosTag("U", LexicalCategory.Unique));
getInstance().addPosTagset(ROMANIAN);
Modified:
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliAnalyzedTextLemmatizerEngine.java
URL:
http://svn.apache.org/viewvc/stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliAnalyzedTextLemmatizerEngine.java?rev=1403242&r1=1403241&r2=1403242&view=diff
==============================================================================
---
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliAnalyzedTextLemmatizerEngine.java
(original)
+++
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliAnalyzedTextLemmatizerEngine.java
Mon Oct 29 10:29:10 2012
@@ -9,8 +9,10 @@ import java.net.URL;
import java.util.Collections;
import java.util.Dictionary;
import java.util.EnumMap;
+import java.util.EnumSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.xml.soap.SOAPException;
@@ -144,19 +146,27 @@ public class CeliAnalyzedTextLemmatizerE
Token token = at.addToken(term.getFrom(), term.getTo());
//Now try to get POS annotations for the Token
for(Value<PosTag> posAnno :
token.getAnnotations(NlpAnnotations.POS_ANNOTATION)){
- if(posAnno.value().getCategory() != null){
- tokenLexCats.put(posAnno.value().getCategory(),
posAnno.probability());
+ if(posAnno.value().isMapped()){
+ for(LexicalCategory cat :posAnno.value().getCategories()){
+ if(!tokenLexCats.containsKey(cat)){ //do not override
with lover prob
+ tokenLexCats.put(cat, posAnno.probability());
+ }
+ }
}
}
for(Reading reading : term.getTermReadings()){
MorphoFeatures mf = CeliMorphoFeatures.parseFrom(reading,
language);
//add the readings (MorphoFeatures)
if(mf != null){
- //use the POS tags of the morpho analysis and compair it
+ //use the POS tags of the morpho analysis and compare it
//with existing POS tags.
double posProbability = -1;
+ Set<LexicalCategory> mfCats =
EnumSet.noneOf(LexicalCategory.class);
for(PosTag mfPos : mf.getPosList()){
- Double prob = tokenLexCats.get(mfPos.getCategory());
+ mfCats.addAll(mfPos.getCategories());
+ }
+ for(LexicalCategory mfCat : mfCats){
+ Double prob = tokenLexCats.get(mfCat);
if(prob != null && posProbability < prob){
posProbability = prob;
}
Modified:
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliAnalyzedTextLemmatizerEngineTest.java
URL:
http://svn.apache.org/viewvc/stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliAnalyzedTextLemmatizerEngineTest.java?rev=1403242&r1=1403241&r2=1403242&view=diff
==============================================================================
---
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliAnalyzedTextLemmatizerEngineTest.java
(original)
+++
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliAnalyzedTextLemmatizerEngineTest.java
Mon Oct 29 10:29:10 2012
@@ -118,6 +118,7 @@ public class CeliAnalyzedTextLemmatizerE
engine.computeEnhancements(ci);
} catch (EngineException e) {
RemoteServiceHelper.checkServiceUnavailable(e);
+ return; //deactivate test
}
//now validate the enhancements
boolean foundVerb = false;
@@ -149,7 +150,7 @@ public class CeliAnalyzedTextLemmatizerE
private void validateMorphFeatureProbability(List<Value<MorphoFeatures>>
mfs, LexicalCategory lc, double prob) {
for(Value<MorphoFeatures> mf : mfs){
for(PosTag pos : mf.value().getPosList()){
- if(pos.getCategory() == lc){
+ if(pos.hasCategory(lc)){
Assert.assertEquals(prob, mf.probability());
}
}
Modified:
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngineTest.java
URL:
http://svn.apache.org/viewvc/stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngineTest.java?rev=1403242&r1=1403241&r2=1403242&view=diff
==============================================================================
---
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngineTest.java
(original)
+++
stanbol/branches/stanbol-nlp-processing/enhancer/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngineTest.java
Mon Oct 29 10:29:10 2012
@@ -115,6 +115,7 @@ public class CeliLemmatizerEnhancementEn
morphoAnalysisEngine.computeEnhancements(ci);
} catch (EngineException e) {
RemoteServiceHelper.checkServiceUnavailable(e);
+ return; //Deactivate this test
}
TestUtils.logEnhancements(ci);