14
14
import java .util .Map ;
15
15
16
16
import fr .inria .coming .core .entities .interfaces .IRevisionPair ;
17
- import fr .inria .prophet4j .feature .extended . ExtendedFeatureCross ;
17
+ import fr .inria .prophet4j .feature .enhanced . EnhancedFeatureCross ;
18
18
import org .apache .log4j .Logger ;
19
19
20
20
import com .google .gson .JsonObject ;
24
24
import fr .inria .coming .core .entities .AnalysisResult ;
25
25
import fr .inria .coming .core .entities .DiffResult ;
26
26
import fr .inria .coming .core .entities .RevisionResult ;
27
- import fr .inria .coming .main .ComingProperties ;
28
27
import fr .inria .prophet4j .feature .Feature ;
29
28
import fr .inria .prophet4j .feature .FeatureCross ;
30
29
import fr .inria .prophet4j .utility .CodeDiffer ;
@@ -98,49 +97,20 @@ public JsonObject extractFeatures(Map<String, File> filePaths) {
98
97
return null ;
99
98
}
100
99
Option option = new Option ();
101
- option .featureOption = FeatureOption .EXTENDED ;
102
- //We set the first parameter of CodeDiffer as False to not allow the code generation at buggy location
103
- //By default, coming extracts simple P4J features, so the cross sets to false
104
- Boolean cross = ComingProperties .getPropertyBoolean ("cross" );
100
+ option .featureOption = FeatureOption .ENHANCED ;
105
101
106
- CodeDiffer codeDiffer = new CodeDiffer (false , option , cross );
102
+ CodeDiffer codeDiffer = new CodeDiffer (false , option );
107
103
//Get feature matrix
108
104
List <FeatureMatrix > featureMatrix = codeDiffer .runByGenerator (src , target );
109
105
//Get feature vector
110
106
JsonObject jsonfile = null ;
111
107
// csvfile = genVectorsCSV(option,target,featureMatrix);
112
- jsonfile = getP4JJSON (option ,target ,featureMatrix , true );
108
+ jsonfile = genVectorsJSON (option ,target ,featureMatrix );
113
109
return jsonfile ;
114
110
}
115
-
116
-
117
- public JsonObject getP4JJSON (Option option , File target , List <FeatureMatrix > featureMatrix , Boolean numericalIndixator ) {
118
-
119
- JsonObject jsonfile = new JsonObject ();
120
-
121
- for (FeatureVector featureVector : featureMatrix .get (0 ).getFeatureVectors ()) {
122
- List <FeatureCross > featureCrosses = featureVector .getNonSortedFeatureCrosses ();
123
-
124
- for (FeatureCross featureCross : featureCrosses ) {
125
- List <Feature > simpleP4JFeatures = featureCross .getFeatures ();
126
- for (Feature f : simpleP4JFeatures ) {
127
- Boolean positive = featureCross .containFeature (f );
128
- if (numericalIndixator ) {
129
- jsonfile .addProperty ("P4J_" +f , positive ?"1" :"0" );
130
- }else {
131
- jsonfile .addProperty ("P4J_" +f , positive ?"true" :"false" );
132
- }
133
- }
134
-
135
- }
136
- }
137
- return jsonfile ;
138
-
139
- }
140
111
141
112
142
-
143
- public JsonObject genVectorsCSV (Option option , File patchedFile , List <FeatureMatrix > featureMatrices ) {
113
+ public JsonObject genVectorsJSON (Option option , File patchedFile , List <FeatureMatrix > featureMatrices ) {
144
114
145
115
String [] pathStr = patchedFile .getAbsolutePath ().split ("/" );
146
116
String fileName = pathStr [pathStr .length -1 ];
@@ -152,10 +122,23 @@ public JsonObject genVectorsCSV(Option option, File patchedFile, List<FeatureMat
152
122
List <String > values = new ArrayList <>();
153
123
JsonObject jsonfile = new JsonObject ();
154
124
155
- //Initial all vector as 0.
125
+
126
+ for (FeatureVector featureVector : featureMatrices .get (0 ).getFeatureVectors ()) {
127
+ List <FeatureCross > featureCrosses = featureVector .getNonSortedFeatureCrosses ();
128
+ for (FeatureCross featureCross : featureCrosses ) {
129
+ List <Feature > simpleP4JFeatures = featureCross .getFeatures ();
130
+ for (Feature f : simpleP4JFeatures ) {
131
+ Boolean positive = featureCross .containFeature (f );
132
+ jsonfile .addProperty ("P4J_" +f , positive ?"true" :"false" );
133
+ }
134
+
135
+ }
136
+ }
137
+
138
+ //Initial all vector as 0.
156
139
for (int idx = 0 ; idx < parameterVector .size (); idx ++) {
157
140
FeatureCross featureCross ;
158
- featureCross = new ExtendedFeatureCross (idx );
141
+ featureCross = new EnhancedFeatureCross (idx );
159
142
header .add (featureCross .getFeatures ().toString ());
160
143
values .add ("0" );
161
144
}
0 commit comments