Last active
December 21, 2015 13:24
-
-
Save damianoporta/ada5ea7d1699c620b695 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package util; | |
import java.util.HashMap; | |
import java.util.List; | |
import opennlp.tools.util.Span; | |
import org.junit.After; | |
import org.junit.AfterClass; | |
import org.junit.Before; | |
import org.junit.BeforeClass; | |
import org.junit.Test; | |
import static org.junit.Assert.*; | |
public class SearchTest { | |
public SearchTest() { | |
} | |
@BeforeClass | |
public static void setUpClass() { | |
} | |
@AfterClass | |
public static void tearDownClass() { | |
} | |
@Before | |
public void setUp() { | |
} | |
@After | |
public void tearDown() { | |
} | |
/** | |
* Test of buildRegex method, of class Search. | |
*/ | |
@Test | |
public void testBuildRegex() { | |
System.out.println("buildRegex"); | |
Search instance = new Search(); | |
String result, expResult; | |
result = instance.buildRegex("mi chiamo <name|surname>{1,3} (1,3) ok[end]"); | |
expResult = "(mi chiamo (?:\\w*(?:<name>|<surname>)\\w*\\s*){1,3} (?:[\\w-<>]+\\s*){1,3} ok.+?(?=end))"; | |
assertEquals(expResult, result); | |
result = instance.buildRegex("<name|surname>{1,3} test1 (1,3) test2 (3) (2) ggg (1,3) (5) ok[end][last][\n]"); | |
expResult = "((?:\\w*(?:<name>|<surname>)\\w*\\s*){1,3} test1 (?:[\\w-<>]+\\s*){1,3} test2 (?:[\\w-<>]+\\s*){3} (?:[\\w-<>]+\\s*){2} ggg (?:[\\w-<>]+\\s*){1,3} (?:[\\w-<>]+\\s*){5} ok.+?(?=end|last|\n))"; | |
assertEquals(expResult, result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment