TagMaskUtils { public static TagMask createTagMaskFromToken(Token token, String text) { TagMask tm = new TagMask(); Matcher m = REPLACE_R2.matcher(text); while (m.find()) { String property = m.group(1); switch (property) { case "number": tm.setNumber(token.getMorphologicalTag().getNumberE()); break; case "gender": tm.setGender(token.getMorphologicalTag().getGenderE()); break; case "class": tm.setClazz(token.getMorphologicalTag().getClazzE()); break; case "person": tm.setPerson(token.getMorphologicalTag().getPersonE()); break; case "tense": tm.setTense(token.getMorphologicalTag().getTense()); break; case "mood": tm.setMood(token.getMorphologicalTag().getMood()); break; default: break; } } return tm; }  static TagMask clone(TagMask tagMask); static TagMask parse(String text); static TagMask createTagMaskFromToken(Token token, String text);  }
@Test public void testCreateTagMaskFromToken() { Token token = new TokenCogroo("dummy", 42); MorphologicalTag tag = new MorphologicalTag(); tag.setGender(TagMask.Gender.FEMALE); token.setMorphologicalTag(tag); TagMask tm = TagMaskUtils .createTagMaskFromToken(token, "gender number"); assertEquals(token.getMorphologicalTag().getGenderE(), tm.getGender()); }