Project

General

Profile

« Previous | Next » 

Revision 28483

branch 1.2

View differences:

ClusteringFunctionTest.java
1
package eu.dnetlib.pace.clustering;
2

  
3
import java.util.Map;
4

  
5
import org.junit.Before;
6
import org.junit.Test;
7

  
8
import com.google.common.collect.Lists;
9
import com.google.common.collect.Maps;
10

  
11
import eu.dnetlib.pace.AbstractPaceTest;
12

  
13
/**
14
 * The Class ClusteringFunctionTest.
15
 */
16
public class ClusteringFunctionTest extends AbstractPaceTest {
17

  
18
	/** The params. */
19
	private Map<String, Integer> params;
20

  
21
	/**
22
	 * Sets the up.
23
	 * 
24
	 * @throws Exception
25
	 *             the exception
26
	 */
27
	@Before
28
	public void setUp() throws Exception {
29
		params = Maps.newHashMap();
30
	}
31

  
32
	/**
33
	 * Test ngram.
34
	 */
35
	@Test
36
	public void testNgram() {
37
		params.put("ngramLen", 2);
38
		params.put("max", 8);
39
		params.put("maxPerToken", 1);
40
		params.put("minNgramLen", 3);
41

  
42
		ClusteringFunction ngram = new Ngrams(params);
43

  
44
		String s = "Search for the Standard Model Higgs Boson";
45
		System.out.println(s);
46
		System.out.println(ngram.apply(Lists.newArrayList(title(s))));
47
	}
48

  
49
	/**
50
	 * Test ngram pairs.
51
	 */
52
	@Test
53
	public void testNgramPairs() {
54
		params.put("ngramLen", 2);
55
		params.put("max", 4);
56

  
57
		ClusteringFunction np = new NgramPairs(params);
58

  
59
		String s = "Search for the Standard Model Higgs Boson";
60
		System.out.println(s);
61
		System.out.println(np.apply(Lists.newArrayList(title(s))));
62
	}
63

  
64
	/**
65
	 * Test acronym.
66
	 */
67
	@Test
68
	public void testAcronym() {
69
		params.put("max", 4);
70
		params.put("minLen", 1);
71
		params.put("maxLen", 3);
72

  
73
		ClusteringFunction acro = new Acronyms(params);
74

  
75
		String s = "Search for the Standard Model Higgs Boson";
76
		System.out.println(s);
77
		System.out.println(acro.apply(Lists.newArrayList(title(s))));
78
	}
79

  
80
	/**
81
	 * Test suffix prefix.
82
	 */
83
	@Test
84
	public void testSuffixPrefix() {
85
		params.put("len", 2);
86
		params.put("max", 3);
87

  
88
		ClusteringFunction sp = new SuffixPrefix(params);
89

  
90
		String s = "Search for the Standard Model Higgs Boson";
91
		System.out.println(s);
92
		System.out.println(sp.apply(Lists.newArrayList(title(s))));
93
	}
94

  
95
}
0 96

  

Also available in: Unified diff