### Question:
PosTagger { public static List<Word> contatenateSuccessive2Tags(List<Word> in, String tag1, String tag2, String outputTag) { Pattern<Word> pattern = Pattern.create(pos(tag1), pos(tag2)); return pattern.replaceToOne(in, m -> new Word(joinWords(m.getMatchedSubsequence()), outputTag)); } 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 concatenateJJtoNP() { List<Word> in = Arrays.asList(w("to", "TO"), w("be", "VB"), w("the", "DT"), w("same", "JJ"), w("type", "NN")); List<Word> expected = Arrays.asList(w("to", "TO"), w("be", "VB"), w("the", "DT"), w("same type", "NP")); List<Word> actual = PosTagger.contatenateSuccessive2Tags(in, "JJ", "NN", "NP"); assertEquals(expected, actual); }
@Test public void concatenateJJtoNP_notFollowed() { List<Word> in = Arrays.asList(w("be", "VB"), w("the", "DT"), w("same", "JJ"), w("to", "TO")); List<Word> expected = in; List<Word> actual = PosTagger.contatenateSuccessive2Tags(in, "JJ", "NN", "NP"); assertEquals(expected, actual); }
@Test public void concatenateJJtoNP_JPLast() { List<Word> in = Arrays.asList(w("to", "TO"), w("be", "VB"), w("the", "DT"), w("same", "JJ")); List<Word> expected = in; List<Word> actual = PosTagger.contatenateSuccessive2Tags(in, "JJ", "NN", "NP"); assertEquals(expected, actual); }