code: public static Map<Integer, NerClassification> positionClassificationMap(final NerResultSet nerResultSet) {
          final Map<Integer, NerClassification> m = new HashMap<>();
  
          for (final List<Phrase> sentence : nerResultSet.phrases) {
              for (final Phrase p : sentence) {
                  final int phraseStartIndex = p.phrase.get(0).startIndex;
                  for (final Token t : p.phrase) {
                      final NerClassification clas =
                              new NerClassification(t.text, p.phraseType, phraseStartIndex, p.score);
                      final NerClassification replaced = m.put(t.startIndex, clas);
                      if (replaced != null) {
                          // since modifying the contents of the map this error should now never happen
                          System.err.println("########### Error start");
                          System.err.print(nerResultSet);
                          throw new IllegalStateException("Tried to add a Token to the position classification map " +
                                                          "with startIndex " + t.startIndex + " that is already there!");
                      }
                  }
              }
          }
  
          return m;
      }
docs: Return a Map of Token startIndex to classification of the Phrase that Token is a part of.