com.aliasi.test.unit.util.SgmlTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aliasi-lingpipe Show documentation
Show all versions of aliasi-lingpipe Show documentation
This is the original Lingpipe:
http://alias-i.com/lingpipe/web/download.html
There were not made any changes to the source code.
package com.aliasi.test.unit.util;
import com.aliasi.util.Sgml;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
public class SgmlTest {
@Test
public void test() {
assertNull(Sgml.entityToCharacter("foobar"));
assertEquals(Character.valueOf('\u200C'), Sgml.entityToCharacter("zwnj"));
assertSub("","");
assertSub("foobar","foobar");
assertSub("&Agr;","\u0391");
assertSub("foo&Agr;","foo\u0391");
assertSub("&Agr;foo","\u0391foo");
assertSub("foo&Agr;bar","foo\u0391bar");
assertSub("&Foobar;","?");
assertSub("ℵ","\u2135");
assertSub("ℵ´","\u2135\u00B4");
assertSub("ℵfoo´","\u2135foo\u00B4");
assertSub("fooℵbar´baz","foo\u2135bar\u00B4baz");
assertSub("&Foobar;","baz","baz");
}
void assertSub(String in, String expected) {
assertSub(in,expected,null);
}
void assertSub(String in, String expected, String unk) {
assertEquals(expected,
unk != null
? Sgml.replaceEntities(in,unk)
: Sgml.replaceEntities(in));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy