-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLexicalPragFeatureLoader.java
More file actions
96 lines (69 loc) · 1.94 KB
/
Copy pathLexicalPragFeatureLoader.java
File metadata and controls
96 lines (69 loc) · 1.94 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.deft.sarcasm.features;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringEscapeUtils;
import com.deft.sarcasm.train.SarcasmResourceLoader;
public class LexicalPragFeatureLoader extends FeatureLoader
{
private SarcasmResourceLoader sarcasmRLObject ;
private static String LEX_PRAG_PATH ;
//this function will be deprecated
public LexicalPragFeatureLoader() throws IOException
{
loadDictionaries();
}
public LexicalPragFeatureLoader(SarcasmResourceLoader sarcasmRLObject) throws IOException
{
this.sarcasmRLObject = sarcasmRLObject ;
}
public void setLexPath ( String resourcePath) throws IOException
{
LEX_PRAG_PATH = resourcePath ;
loadDictionaries();
}
protected void loadDictionaries() throws IOException
{
sarcasmRLObject.loadLIWCDictionaries(LEX_PRAG_PATH);
}
@Override
public Map<String, Double> loadNonLexFeatures(String[] tokens)
{
// TODO Auto-generated method stub
Map<String, Double> featureMap = new HashMap<String, Double>();
for (String token : tokens)
{
token = StringEscapeUtils.escapeXml(token);
List<String> featColumnNames = getFeatureColumn(token);
if (!featColumnNames.isEmpty()) // that is the feature is
// present in the token
{
for (String featColumnName : featColumnNames)
{
// if(featColumnName.equals("66.csv"))
// {
// System.out.println("here") ;
//}
Double old = featureMap.get(featColumnName);
if (null == old)
{
old = 0.0;
}
featureMap.put(featColumnName, old + 1.0);
}
}
}
return featureMap ;
}
private List<String> getFeatureColumn(String token)
{
// TODO Auto-generated method stub
return sarcasmRLObject.getListOfColumns(token);
}
@Override
public Map<Integer, Double> loadFeatures(String[] tokens) {
// TODO Auto-generated method stub
return null;
}
}