@Test void testRegexPattern() { assertEquals( 4603, termFrequencyService .parseResponse( "<eSearchResult><Count>4603</Count><RetMax>20</RetMax><RetStart>0</RetStart><IdList>") .getOccurrence()); assertEquals( null, termFrequencyService.parseResponse( "<eSearchResult><RetMax>20</RetMax><RetStart>0</RetStart><IdList>")); assertEquals( null, termFrequencyService.parseResponse( "<eSearchResult><Count></Count><RetMax>20</RetMax><RetStart>0</RetStart><IdList>")); }
public PubMedTFEntity parseResponse(String response) { Matcher matcher = PATTERN_REGEX.matcher(response); if (matcher.find()) { String countString = matcher.group(1); if (StringUtils.isNotEmpty(countString)) { int occurrence = Integer.parseInt(countString); if (occurrence != 0) { double frequency = Math.abs(Math.log10((double) occurrence / TOTAL_NUMBER_PUBLICATION)); return new PubMedTFEntity(occurrence, frequency); } } } return null; }
PubMedTermFrequencyService { public PubMedTFEntity parseResponse(String response) { Matcher matcher = PATTERN_REGEX.matcher(response); if (matcher.find()) { String countString = matcher.group(1); if (StringUtils.isNotEmpty(countString)) { int occurrence = Integer.parseInt(countString); if (occurrence != 0) { double frequency = Math.abs(Math.log10((double) occurrence / TOTAL_NUMBER_PUBLICATION)); return new PubMedTFEntity(occurrence, frequency); } } } return null; } }
PubMedTermFrequencyService { public PubMedTFEntity parseResponse(String response) { Matcher matcher = PATTERN_REGEX.matcher(response); if (matcher.find()) { String countString = matcher.group(1); if (StringUtils.isNotEmpty(countString)) { int occurrence = Integer.parseInt(countString); if (occurrence != 0) { double frequency = Math.abs(Math.log10((double) occurrence / TOTAL_NUMBER_PUBLICATION)); return new PubMedTFEntity(occurrence, frequency); } } } return null; }  }
PubMedTermFrequencyService { public PubMedTFEntity parseResponse(String response) { Matcher matcher = PATTERN_REGEX.matcher(response); if (matcher.find()) { String countString = matcher.group(1); if (StringUtils.isNotEmpty(countString)) { int occurrence = Integer.parseInt(countString); if (occurrence != 0) { double frequency = Math.abs(Math.log10((double) occurrence / TOTAL_NUMBER_PUBLICATION)); return new PubMedTFEntity(occurrence, frequency); } } } return null; }  PubMedTFEntity getTermFrequency(String term); PubMedTFEntity parseResponse(String response); String httpGet(String targetURL); }
PubMedTermFrequencyService { public PubMedTFEntity parseResponse(String response) { Matcher matcher = PATTERN_REGEX.matcher(response); if (matcher.find()) { String countString = matcher.group(1); if (StringUtils.isNotEmpty(countString)) { int occurrence = Integer.parseInt(countString); if (occurrence != 0) { double frequency = Math.abs(Math.log10((double) occurrence / TOTAL_NUMBER_PUBLICATION)); return new PubMedTFEntity(occurrence, frequency); } } } return null; }  PubMedTFEntity getTermFrequency(String term); PubMedTFEntity parseResponse(String response); String httpGet(String targetURL);  }