forked from hankcs/HanLP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCharType.java
More file actions
73 lines (65 loc) · 2.21 KB
/
TestCharType.java
File metadata and controls
73 lines (65 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* <summary></summary>
* <author>He Han</author>
* <email>hankcs.cn@gmail.com</email>
* <create-date>2014/05/2014/5/20 13:30</create-date>
*
* <copyright file="testCharType.java" company="上海林原信息科技有限公司">
* Copyright (c) 2003-2014, 上海林原信息科技有限公司. All Right Reserved, http://www.linrunsoft.com/
* This source is subject to the LinrunSpace License. Please contact 上海林原信息科技有限公司 to get more information.
* </copyright>
*/
package com.hankcs.test.seg;
import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.corpus.io.ByteArray;
import com.hankcs.hanlp.dictionary.other.CharType;
import com.hankcs.hanlp.utility.TextUtility;
import junit.framework.TestCase;
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
/**
* @author hankcs
*/
public class TestCharType extends TestCase
{
/**
* 测试字符类型表
* @throws Exception
*/
public void testGet() throws Exception
{
// for (int i = 0; i < Character.MAX_VALUE; ++i)
// {
// System.out.printf("%d %d %d\n", i, TextUtility.charType((char) i) , (int)CharType.get((char) i));
// }
for (int i = 0; i <= Character.MAX_VALUE; ++i)
{
assertEquals(TextUtility.charType((char) i) , (int)CharType.get((char) i));
}
}
public void testNumber() throws Exception
{
for (int i = 0; i <= Character.MAX_VALUE; ++i)
{
if (CharType.get((char) i) == CharType.CT_NUM)
System.out.println((char)i);
}
assertEquals(CharType.CT_NUM, CharType.get('1'));
}
public void testWhiteSpace() throws Exception
{
// CharType.type[' '] = CharType.CT_OTHER;
String text = "1 + 2 = 3; a+b= a + b";
System.out.println(HanLP.segment(text));
}
public void testTab() throws Exception
{
assertTrue(TextUtility.charType('\t') == CharType.CT_DELIMITER);
assertTrue(TextUtility.charType('\r') == CharType.CT_DELIMITER);
assertTrue(TextUtility.charType('\0') == CharType.CT_DELIMITER);
System.out.println(HanLP.segment("\t"));
}
}