<NME> MultiLabelIndexBuilder.java
<BEF> ADDFILE
<MSG> improve indexBuilder get

<DFF> @@ -0,0 +1,91 @@
+package edu.neu.ccs.pyramid.data_formatter.imdb;
+
+import org.apache.commons.io.FileUtils;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Scanner;
+
+/**
+ * Created by chengli on 2/4/15.
+ */
+public class MultiLabelIndexBuilder {
+    static String[] extLabels={"neg","pos"};
+    static Map<String,Integer> map = createMap();
+
+    public static boolean acceptFile(File file){
+        boolean condition1 = file.getParentFile().getName().equals("pos");
+        boolean condition2 = file.getParentFile().getName().equals("neg");
+        boolean condition3 = file.getParentFile().getParentFile().getName().equals("train");
+        boolean condition4 = file.getParentFile().getParentFile().getName().equals("test");
+        boolean accept = (condition1||condition2)&&(condition3||condition4);
+        return accept;
+    }
+
+    public static XContentBuilder getBuilder(File file) throws Exception{
+        XContentBuilder builder = XContentFactory.jsonBuilder();
+        builder.startObject();
+        builder.field("body",getBody(file));
+        builder.field("file_name",getFileName(file));
+        builder.array("real_label", getExtLabel(file));
+        builder.field("split", getSplit(file));
+        builder.endObject();
+        return builder;
+    }
+
+
+
+    static String getBody(File file) throws Exception{
+        String entireFileText = FileUtils.readFileToString(file);
+        return entireFileText;
+    }
+
+    static String getFileName(File file) throws Exception{
+        String fullPath = file.getAbsolutePath();
+        return fullPath;
+    }
+
+
+
+
+    /**
+     * fixed
+     * @param file
+     * @return
+     * @throws Exception
+     */
+    static String getSplit(File file) throws Exception{
+        String name = file.getParentFile().getParentFile().getName();
+        String res = null;
+        switch (name) {
+            case "train":
+                res = "train";
+                break;
+            case "test":
+                res = "test";
+                break;
+            default:
+                throw new RuntimeException("not train or test");
+        }
+        return res;
+    }
+
+    static String[] getExtLabel(File file) throws Exception{
+        String[] labels = new String[1];
+        labels[0] = file.getParentFile().getName();
+        return labels;
+    }
+
+
+
+    static Map<String,Integer> createMap(){
+        Map<String,Integer> map = new HashMap<>();
+        for (int i=0;i<extLabels.length;i++){
+            map.put(extLabels[i],i);
+        }
+        return map;
+    }
+}

improve indexBuilder get