@@ -0,0 +1,1727 @@
+package edu.neu.ccs.pyramid.data_formatter.review_polarity;%0A%0Aimport org.elasticsearch.common.xcontent.XContentBuilder;%0Aimport org.elasticsearch.common.xcontent.XContentFactory;%0A%0Aimport java.io.File;%0Aimport java.util.Map;%0Aimport java.util.Scanner;%0Aimport java.util.Set;%0A%0A/**%0A * Created by chengli on 10/24/14.%0A */%0Apublic class IndexBuilder %7B%0A%0A    static String getBody(File file) throws Exception%7B%0A        String entireFileText = new Scanner(file)%0A                .useDelimiter(%22%5C%5CA%22).next();%0A        return entireFileText;%0A    %7D%0A%0A    static String getFileName(File file) throws Exception%7B%0A        String fullPath = file.getAbsolutePath();%0A        return fullPath;%0A    %7D%0A%0A    public static XContentBuilder getBuilder(File file) throws Exception%7B%0A        XContentBuilder builder = XContentFactory.jsonBuilder();%0A        builder.startObject();%0A        builder.field(%22body%22,getBody(file));%0A        builder.field(%22file_name%22,getFileName(file));%0A        builder.array(%22real_label%22, getRealLabel(file));%0A        builder.array(%22label%22,getLabel(file));%0A        builder.field(%22split%22,getTrainOrTest());%0A        builder.endObject();%0A        return builder;%0A    %7D%0A%0A    static String getLabel(File file)%7B%0A        String parent = file.getParentFile().getName();%0A        if (parent.equals(%22pos%22))%7B%0A            return %221%22;%0A        %7D else %7B%0A            return %220%22;%0A        %7D%0A    %7D%0A%0A    static String getRealLabel(File file)%7B%0A        String parent = file.getParentFile().getName();%0A        return parent;%0A    %7D%0A%0A    static String getTrainOrTest() %7B%0A        String res = null;%0A        double ran = Math.random();%0A%0A        if ( ran%3C 0.6)%7B%0A            res = %22train%22;%0A        %7D else %7B%0A            res = %22test%22;%0A        %7D%0A        return res;%0A    %7D%0A%7D%0A

add IndexBuilder for review_polarity