public void testNormalizeWinDelimToLinuxDelim() throws Exception { NormalizeCharMap.Builder builder = new NormalizeCharMap.Builder(); builder.add("\\", "/"); NormalizeCharMap normMap = builder.build(); String path = "c:\\a\\b\\c"; Reader cs = new MappingCharFilter(normMap, new StringReader(path)); PathHierarchyTokenizer t = new PathHierarchyTokenizer(newAttributeFactory(), cs, DEFAULT_DELIMITER, DEFAULT_DELIMITER, DEFAULT_SKIP); assertTokenStreamContents(t, new String[]{"c:", "c:/a", "c:/a/b", "c:/a/b/c"}, new int[]{0, 0, 0, 0}, new int[]{2, 4, 6, 8}, new int[]{1, 0, 0, 0}, path.length()); }
@Override protected Reader wrapReader(String fieldName, Reader reader) { NormalizeCharMap.Builder builder = new NormalizeCharMap.Builder(); for (Map.Entry<String, String> e : customMappings.entrySet()) { builder.add(e.getKey(), e.getValue()); } return new MappingCharFilter(builder.build(), reader); }
public void testNormalizeWinDelimToLinuxDelim() throws Exception { NormalizeCharMap.Builder builder = new NormalizeCharMap.Builder(); builder.add("\\", "/"); NormalizeCharMap normMap = builder.build(); String path = "c:\\a\\b\\c"; Reader cs = new MappingCharFilter(normMap, new StringReader(path)); PathHierarchyTokenizer t = new PathHierarchyTokenizer( cs ); assertTokenStreamContents(t, new String[]{"c:", "c:/a", "c:/a/b", "c:/a/b/c"}, new int[]{0, 0, 0, 0}, new int[]{2, 4, 6, 8}, new int[]{1, 0, 0, 0}, path.length()); }
@Override public Reader create(Reader input) { for (NormalizeCharMap charMap : normMapList) { input = charMap == null ? input : new MappingCharFilter(charMap, input); } return input; }
@Override public Reader create(Reader tokenStream) { return new MappingCharFilter(normMap, tokenStream); }
@Override protected Reader initReader(String fieldName, Reader reader) { return new MappingCharFilter(UkrainianLemmatizerResources.NORMALIZE_MAP, reader); }
@Override public Reader create(Reader input) { // if the map is null, it means there's actually no mappings... just return the original stream // as there is nothing to do here. return normMap == null ? input : new MappingCharFilter(normMap,input); }