mirror of https://github.com/zlatinb/muwire
split by newlines
parent
94678bad3c
commit
9181829e4a
|
@ -2,7 +2,7 @@ package com.muwire.core
|
|||
|
||||
class SplitPattern {
|
||||
|
||||
public static final String SPLIT_PATTERN = "[\\*\\+\\-,\\.:;\\(\\)=_/\\\\\\!\\\"\\\'\\\$%\\|\\[\\]\\{\\}\\?]";
|
||||
public static final String SPLIT_PATTERN = "[\\*\\+\\-,\\.:;\\(\\)=_/\\\\\\!\\\"\\\'\\\$%\\|\\[\\]\\{\\}\\?\r\n]";
|
||||
|
||||
private static final Set<Character> SPLIT_CHARS = new HashSet<>()
|
||||
static {
|
||||
|
|
|
@ -24,4 +24,12 @@ class SplitPatternTest {
|
|||
assert SplitPattern.termify('"siamese cat" any cat "persian cat"') ==
|
||||
['siamese cat','any','cat','persian cat']
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNewLine() {
|
||||
def s = "first\nsecond"
|
||||
s = s.replaceAll(SplitPattern.SPLIT_PATTERN, " ")
|
||||
s = s.split(" ")
|
||||
assert s.length == 2
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,4 +120,26 @@ class SearchIndexTest {
|
|||
assert index.search(['cat', 'video siamese']).size() == 0
|
||||
assert index.search(['cat','video','siamese']).size() == 3
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNewLine() {
|
||||
initIndex(['first\nsecond'])
|
||||
assert index.search(['first']).size() == 1
|
||||
assert index.search(['second']).size() == 1
|
||||
assert index.search(['first','second']).size() == 1
|
||||
assert index.search(['second','first']).size() == 1
|
||||
assert index.search(['second first']).size() == 0
|
||||
assert index.search(['first second']).size() == 0
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDosNewLine() {
|
||||
initIndex(['first\r\nsecond'])
|
||||
assert index.search(['first']).size() == 1
|
||||
assert index.search(['second']).size() == 1
|
||||
assert index.search(['first','second']).size() == 1
|
||||
assert index.search(['second','first']).size() == 1
|
||||
assert index.search(['second first']).size() == 0
|
||||
assert index.search(['first second']).size() == 0
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue