### Question:
NIFHelper { public static final IRI getNifHashURI(IRI base, int start, int end, String text){ if(base == null){ throw new IllegalArgumentException("Base URI MUST NOT be NULL!"); } start = start < 0 ? 0 : start; end = end < 0 ? start : end; if(end < start){ throw new IllegalArgumentException("End index '"+end+"' < start '"+start+"'!"); } if(end >= text.length()){ throw new IllegalArgumentException("The End index '"+end+"' exeeds the " + "length of the text '"+text.length()+"'!"); } int contextStart = Math.max(0, start-NIF_HASH_CONTEXT_LENGTH); int contextEnd = Math.min(text.length(), end+NIF_HASH_CONTEXT_LENGTH); StringBuilder sb = new StringBuilder(base.getUnicodeString()); sb.append("#hash_"); sb.append(NIF_HASH_CONTEXT_LENGTH); sb.append('_'); sb.append(end-start); sb.append('_'); sb.append(getContextDigest(text, contextStart, start, end, contextEnd)); sb.append('_'); sb.append(text.substring(start, Math.min(end,start+NIF_HASH_MAX_STRING_LENGTH))); return new IRI(sb.toString()); } private  NIFHelper(); static final IRI getNifFragmentURI(IRI base, int start,int end); static final IRI getNifOffsetURI(IRI base, int start, int end); static final IRI getNifHashURI(IRI base, int start, int end, String text); static IRI writeSpan(Graph graph, IRI base, AnalysedText text, Language language, Span span); static void writePos(Graph graph, Annotated annotated, IRI segmentUri); static void writePhrase(Graph graph, Annotated annotated, IRI segmentUri); static final Map<SpanTypeEnum,IRI> SPAN_TYPE_TO_SSO_TYPE; static final Map<LexicalCategory,IRI> LEXICAL_TYPE_TO_PHRASE_TYPE; static final int NIF_HASH_CONTEXT_LENGTH; static final int NIF_HASH_MAX_STRING_LENGTH; static final Charset UTF8; }### Answer:
@Test public void testHashURI() throws IOException { String selected = text.substring(23,26); String context = text.substring(13,23)+'('+selected+')'+text.substring(26,36); byte[] contextData = context.getBytes(Charset.forName("UTF8")); String md5 = ContentItemHelper.streamDigest(new ByteArrayInputStream(contextData), null, "MD5"); IRI expected = new IRI(base.getUnicodeString()+"#hash_10_3_"+md5+"_NLP"); Assert.assertEquals(expected, NIFHelper.getNifHashURI(base, 23, 26, text)); }