### Question:
StanfordCoreNLPService { public Map<String, List<String>> extractEntities(final String text, final String entityTypes) throws RuntimeException { final String[] entityTypeList = entityTypes.split((",")); boolean extractLocations = false; final List<String> locationNerTagList = new ArrayList<String>(); locationNerTagList.add("LOCATION"); locationNerTagList.add("CITY"); locationNerTagList.add("COUNTRY"); locationNerTagList.add("STATE_OR_PROVINCE"); final List<String> nerTagList = new ArrayList<String>(); final Map<String, List<String>> output = new HashMap<String, List<String>>(); for (final String tag : entityTypeList) { output.put(tag, new ArrayList<String>()); if (tag.equals("location")) { extractLocations = true; } else { nerTagList.add(tag.toUpperCase()); } } final Annotation annotation = new Annotation(text); pipeline.annotate(annotation); if (annotation.containsKey(CoreAnnotations.ExceptionAnnotation.class)) { final Throwable t = annotation.get(CoreAnnotations.ExceptionAnnotation.class); throw new RuntimeException(t); } final CoreDocument document = new CoreDocument(annotation); List<CoreEntityMention> mentions = document.entityMentions(); if (document.entityMentions() == null) { mentions = new ArrayList<CoreEntityMention>(); } for (final CoreEntityMention entityMention : mentions) { final String eType = entityMention.entityType(); if (extractLocations && locationNerTagList.contains(eType)) { final List<String> locs = output.get("location"); locs.add(entityMention.text()); output.put("location", locs); continue; } if (nerTagList.contains(eType)) { final List<String> e = output.get(eType.toLowerCase()); e.add(entityMention.text()); output.put(eType.toLowerCase(), e); } } return output; } StanfordCoreNLPService(final AnnotationPipeline pipeline); Map<String, List<String>> extractEntities(final String text, final String entityTypes); static Properties sanitizeProps(Properties props); static AnnotationPipeline createPipeline(final Properties rawProps); static AnnotationPipeline createPipeline(final Properties rawProps, final String host, final int port,
      final String key, final String secret);  }### Answer:
@Test public void testExtractEntities() { StanfordCoreNLPService svc = new StanfordCoreNLPService(StanfordCoreNLPService.createPipeline(null)); final String text = "ALBUQUERQUE, N.M. — A worldwide film production company is expanding to Albuquerque, according to Albuquerque Business First. The company, Production Resource Group, has worked on various movie productions including \"House of Cards.\" They plan to move into a 6,000-square-foot warehouse space in northeast Albuquerque, located at 5821 Midway Park Blvd. NE. For more information, click here."; final Map<String, List<String>> entities = svc.extractEntities(text, "location,organization"); System.out.println("Entities: " + entities); assertNotNull(entities); assertEquals("Albuquerque Business First", entities.get("organization").get(0)); svc = null; }