@@ -0,0 +1,2981 @@
+package edu.neu.ccs.pyramid.data_formatter.ohsumed;%0A%0Aimport org.elasticsearch.common.xcontent.XContentBuilder;%0Aimport org.elasticsearch.common.xcontent.XContentFactory;%0A%0Aimport java.io.File;%0Aimport java.util.Scanner;%0A%0A/**%0A * Created by chengli on 10/1/14.%0A */%0Apublic class IndexBuilder %7B%0A    static String%5B%5D extLabels=%7B%0A            %22Bacterial Infections and Mycoses%22,%0A            %22Virus Diseases%22,%0A            %22Parasitic Diseases%22,%0A            %22Neoplasms%22,%0A            %22Musculoskeletal Diseases%22,%0A            %22Digestive System Diseases%22,%0A            %22Stomatognathic Diseases%22,%0A            %22Respiratory Tract Diseases%22,%0A            %22Otorhinolaryngologic Diseases%22,%0A            %22Nervous System Diseases%22,%0A            %22Eye Diseases%22,%0A            %22Urologic and Male Genital Diseases%22,%0A            %22Female Genital Diseases and Pregnancy Complications%22,%0A            %22Cardiovascular Diseases%22,%0A            %22Hemic and Lymphatic Diseases%22,%0A            %22Neonatal Diseases and Abnormalities%22,%0A            %22Skin and Connective Tissue Diseases%22,%0A            %22Nutritional and Metabolic Diseases%22,%0A            %22Endocrine Diseases%22,%0A            %22Immunologic Diseases%22,%0A            %22Disorders of Environmental Origin%22,%0A            %22Animal Diseases%22,%0A            %22Pathological Conditions, Signs and Symptoms%22%0A    %7D;%0A%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.field(%22real_label%22,getExtLabel(file));%0A        builder.field(%22label%22,%22%22+getLabel(file));%0A        builder.field(%22split%22,getTrainOrTest(file));%0A        builder.endObject();%0A        return builder;%0A    %7D%0A%0A%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    static int getLabel(File file) throws Exception%7B%0A        String name = file.getParentFile().getName();%0A        String code = name.substring(1);%0A        String simplified;%0A        if (code.startsWith(%220%22))%7B%0A            simplified = code.substring(1);%0A        %7D else %7B%0A            simplified = code;%0A        %7D%0A        //return 0 for C01%0A        int label = Integer.parseInt(simplified) -1;%0A        return label;%0A    %7D%0A%0A    static String getTrainOrTest(File file) throws Exception%7B%0A        String name = file.getParentFile().getParentFile().getName();%0A        String res = null;%0A        if (name.equals(%22training%22))%7B%0A            res = %22train%22;%0A        %7D else %7B%0A            res = %22test%22;%0A        %7D%0A        return res;%0A    %7D%0A%0A    static String getExtLabel(File file) throws Exception%7B%0A        int label = getLabel(file);%0A        return extLabels%5Blabel%5D;%0A    %7D%0A%0A%0A%7D%0A

add IndexBuilder for Ohsumed