@Test public void shouldSplitWithRomanNumerals() throws Exception { { final LinkedList<TextBlock> textBlocks = splitter.splitToTextParts("VIII VIIII MMMMM MMMM"); assertThat(textBlocks, hasSize(7)); assertThat(textBlocks.get(0), equalTo(new TextBlock("VIII", TextBlockType.Roman_Numeral))); assertThat(textBlocks.get(1), equalTo(new TextBlock(" ", TextBlockType.Space))); assertThat(textBlocks.get(2), equalTo(new TextBlock("VIIII", TextBlockType.AllCaps_Word))); assertThat(textBlocks.get(3), equalTo(new TextBlock(" ", TextBlockType.Space))); assertThat(textBlocks.get(4), equalTo(new TextBlock("MMMMM", TextBlockType.AllCaps_Word))); assertThat(textBlocks.get(5), equalTo(new TextBlock(" ", TextBlockType.Space))); assertThat(textBlocks.get(6), equalTo(new TextBlock("MMMM", TextBlockType.Roman_Numeral))); } }
protected LinkedList<TextBlock> splitToTextParts(String text) { final LinkedList<TextBlock> textBlocks = new LinkedList<TextBlock>(); while (StringUtils.isNotBlank(text)) { boolean foundOneClass = false; for (TextBlockType textBlockType : TextBlockType.PHYSICAL_TYPES) { final String matchedStr = textBlockType.findMatchFromBeginning(text); if (matchedStr != null) { textBlocks.add(new TextBlock(matchedStr, textBlockType)); text = text.substring(matchedStr.length()); foundOneClass = true; break; } else { continue; } } if (!foundOneClass) { throw new IllegalArgumentException("Text is not matched with any of the classes: \"" + text + "\""); } } return textBlocks; }
TextBlockSplitter { protected LinkedList<TextBlock> splitToTextParts(String text) { final LinkedList<TextBlock> textBlocks = new LinkedList<TextBlock>(); while (StringUtils.isNotBlank(text)) { boolean foundOneClass = false; for (TextBlockType textBlockType : TextBlockType.PHYSICAL_TYPES) { final String matchedStr = textBlockType.findMatchFromBeginning(text); if (matchedStr != null) { textBlocks.add(new TextBlock(matchedStr, textBlockType)); text = text.substring(matchedStr.length()); foundOneClass = true; break; } else { continue; } } if (!foundOneClass) { throw new IllegalArgumentException("Text is not matched with any of the classes: \"" + text + "\""); } } return textBlocks; } }
TextBlockSplitter { protected LinkedList<TextBlock> splitToTextParts(String text) { final LinkedList<TextBlock> textBlocks = new LinkedList<TextBlock>(); while (StringUtils.isNotBlank(text)) { boolean foundOneClass = false; for (TextBlockType textBlockType : TextBlockType.PHYSICAL_TYPES) { final String matchedStr = textBlockType.findMatchFromBeginning(text); if (matchedStr != null) { textBlocks.add(new TextBlock(matchedStr, textBlockType)); text = text.substring(matchedStr.length()); foundOneClass = true; break; } else { continue; } } if (!foundOneClass) { throw new IllegalArgumentException("Text is not matched with any of the classes: \"" + text + "\""); } } return textBlocks; }  }
TextBlockSplitter { protected LinkedList<TextBlock> splitToTextParts(String text) { final LinkedList<TextBlock> textBlocks = new LinkedList<TextBlock>(); while (StringUtils.isNotBlank(text)) { boolean foundOneClass = false; for (TextBlockType textBlockType : TextBlockType.PHYSICAL_TYPES) { final String matchedStr = textBlockType.findMatchFromBeginning(text); if (matchedStr != null) { textBlocks.add(new TextBlock(matchedStr, textBlockType)); text = text.substring(matchedStr.length()); foundOneClass = true; break; } else { continue; } } if (!foundOneClass) { throw new IllegalArgumentException("Text is not matched with any of the classes: \"" + text + "\""); } } return textBlocks; }  TextBlockGroup getTextBlockGroup(List<TextBlock> textBlocks, int blockSize, int startIndex); void addTextStartsAndEnds(List<TextBlock> textBlocks, int blockSize); }
TextBlockSplitter { protected LinkedList<TextBlock> splitToTextParts(String text) { final LinkedList<TextBlock> textBlocks = new LinkedList<TextBlock>(); while (StringUtils.isNotBlank(text)) { boolean foundOneClass = false; for (TextBlockType textBlockType : TextBlockType.PHYSICAL_TYPES) { final String matchedStr = textBlockType.findMatchFromBeginning(text); if (matchedStr != null) { textBlocks.add(new TextBlock(matchedStr, textBlockType)); text = text.substring(matchedStr.length()); foundOneClass = true; break; } else { continue; } } if (!foundOneClass) { throw new IllegalArgumentException("Text is not matched with any of the classes: \"" + text + "\""); } } return textBlocks; }  TextBlockGroup getTextBlockGroup(List<TextBlock> textBlocks, int blockSize, int startIndex); void addTextStartsAndEnds(List<TextBlock> textBlocks, int blockSize);  }