### Question:
PosTagger { public static List<Word> concatenateSuccessiveNounsToNounSequence(List<Word> in) { XMatcher<Word> noun = posIn(PosTag.NOUN, PosTag.NOUN_PLURAL); Pattern<Word> nounPattern = Pattern.create(noun.oneOrMore()); return nounPattern.replaceToOne(in, new TransformerToElement<Word>() { @Override public Word transform(Match<Word> match) { List<Word> words = match.getMatchedSubsequence(); if (words.size() == 1) { return words.get(0); } return new Word(joinWords(words), PosTag.NOUN_SEQUENCE); } }); } PosTagger(StanfordCoreNLP nlpPipeline); static PosTagger create(BaseConfig cfg); List<Sentence> process(String cleanText, List<MathTag> formulas); List<List<Word>> annotate(String cleanText, Map<String, MathTag> formulas,
                                   Set<String> allIdentifiers); static List<Sentence> postprocess(List<List<Word>> input, Map<String, MathTag> formulaIndex,
                                           Set<String> allIdentifiers); static Sentence toSentence(List<Word> input, Map<String, MathTag> formulaIndex,
                                    Set<String> allIdentifiers); static List<List<Word>> concatenateTags(List<List<Word>> sentences, Set<String> allIdentifiers); static List<Word> concatenateLinks(List<Word> in, Set<String> allIdentifiers); static List<Word> concatenateSuccessiveNounsToNounSequence(List<Word> in); static List<Word> contatenateSuccessive2Tags(List<Word> in, String tag1, String tag2,
                                                      String outputTag); static String joinWords(List<Word> list); static XMatcher<Word> pos(String tag); static XMatcher<Word> posIn(String... tags); static XMatcher<Word> anyWord();  }### Answer:
@Test public void concatenate_inside() { List<Word> in = Arrays.asList(w("Since", "IN"), w("energy", "NN"), w("momentum", "NN"), w("related", "VBN")); List<Word> expected = Arrays.asList(w("Since", "IN"), w("energy momentum", "NN+"), w("related", "VBN")); List<Word> actual = PosTagger.concatenateSuccessiveNounsToNounSequence(in); assertEquals(expected, actual); }
@Test public void concatenate_noSucc() { List<Word> in = Arrays.asList(w("Since", "IN"), w("energy", "NN"), w("and", "CC"), w("momentum", "NN"), w("are", "VBP"), w("related", "VBN")); List<Word> expected = in; List<Word> actual = PosTagger.concatenateSuccessiveNounsToNounSequence(in); assertEquals(expected, actual); }