File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
dl4j-examples/src/main/java/org/deeplearning4j/examples/recurrent/word2vecsentiment Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change 32
32
33
33
import java .io .File ;
34
34
import java .io .IOException ;
35
+ import java .nio .charset .Charset ;
35
36
import java .util .ArrayList ;
36
37
import java .util .Arrays ;
37
38
import java .util .List ;
@@ -100,13 +101,13 @@ private DataSet nextDataSet(int num) throws IOException {
100
101
if (cursor % 2 == 0 ){
101
102
//Load positive review
102
103
int posReviewNumber = cursor / 2 ;
103
- String review = FileUtils .readFileToString (positiveFiles [posReviewNumber ]);
104
+ String review = FileUtils .readFileToString (positiveFiles [posReviewNumber ], ( Charset ) null );
104
105
reviews .add (review );
105
106
positive [i ] = true ;
106
107
} else {
107
108
//Load negative review
108
109
int negReviewNumber = cursor / 2 ;
109
- String review = FileUtils .readFileToString (negativeFiles [negReviewNumber ]);
110
+ String review = FileUtils .readFileToString (negativeFiles [negReviewNumber ], ( Charset ) null );
110
111
reviews .add (review );
111
112
positive [i ] = false ;
112
113
}
@@ -253,7 +254,7 @@ public boolean isPositiveReview(int index){
253
254
* @throws IOException If file cannot be read
254
255
*/
255
256
public INDArray loadFeaturesFromFile (File file , int maxLength ) throws IOException {
256
- String review = FileUtils .readFileToString (file );
257
+ String review = FileUtils .readFileToString (file , ( Charset ) null );
257
258
return loadFeaturesFromString (review , maxLength );
258
259
}
259
260
Original file line number Diff line number Diff line change 1
- /** *****************************************************************************
1
+ /* *****************************************************************************
2
2
* Copyright (c) 2015-2019 Skymind, Inc.
3
3
*
4
4
* This program and the accompanying materials are made available under the
40
40
41
41
import java .io .File ;
42
42
import java .net .URL ;
43
+ import java .nio .charset .Charset ;
43
44
44
45
/**Example: Given a movie review (raw text), classify that movie review as either positive or negative based on the words it contains.
45
46
* This is done by combining Word2Vec vectors and a recurrent neural network model. Each word in a review is vectorized
@@ -118,7 +119,7 @@ public static void main(String[] args) throws Exception {
118
119
119
120
//After training: load a single example and generate predictions
120
121
File shortNegativeReviewFile = new File (FilenameUtils .concat (DATA_PATH , "aclImdb/test/neg/12100_1.txt" ));
121
- String shortNegativeReview = FileUtils .readFileToString (shortNegativeReviewFile );
122
+ String shortNegativeReview = FileUtils .readFileToString (shortNegativeReviewFile , ( Charset ) null );
122
123
123
124
INDArray features = test .loadFeaturesFromString (shortNegativeReview , truncateReviewsToLength );
124
125
INDArray networkOutput = net .output (features );
You can’t perform that action at this time.
0 commit comments