public static void main(String[] args) throws Exception{
		
		ArrayList<ArrayList<Integer>> all_Docs;
		ArrayList<Integer> docSize;
		ReadDataFile rin;
		ContextPCARepresentation contextPCARep;
		HashMap<String,Integer> corpusInt=new HashMap<String,Integer>();
		HashMap<String,Integer> corpusIntOldMapping=new HashMap<String,Integer>();
		ContextPCARun contextPCARun;
		ContextPCAWriter wout;
		Object[] matrices=new Object[3];
		long numTokens;
		
		Options opt=new Options(args);
		
		if(opt.algorithm==null){
			System.out.println("WARNING: YOU NEED TO SPECIFY A VALID ALGORITHM NAME AS algorithm:");
		}
		if(opt.trainUnlab){
			System.out.println("+++Inducing Context PCA Embedddings from unlabeled data+++\n");
			all_Docs=new ArrayList<ArrayList<Integer>>();
			docSize=new ArrayList<Integer>();
			rin=new ReadDataFile(opt);
			
			long maxMemory = Runtime.getRuntime().maxMemory();
		    /* Maximum amount of memory the JVM will attempt to use */
		    System.out.println("Maximum memory (bytes): " + 
		        (maxMemory == Long.MAX_VALUE ? "no limit" : maxMemory));

		    /* Total memory currently in use by the JVM */
		    System.out.println("Total memory (bytes): " + 
		        Runtime.getRuntime().totalMemory());
			
			corpusInt= rin.convertAllDocsInt(0);
			rin.readAllDocs(0);
			all_Docs=rin.getAllDocs();
			docSize=rin.getDocSizes();
			numTokens=rin.getNumTokens();
			rin.serializeCorpusIntMapped();
			//corpus=new Corpus(all_Docs,docSize,opt);
			
			contextPCARep= new ContextPCARepresentation(opt, numTokens,rin,all_Docs);
			
		    /* Total memory currently in use by the JVM */
		    System.out.println("Total memory (bytes): " + 
		        Runtime.getRuntime().totalMemory());
			
			
			contextPCARun=new ContextPCARun(opt,contextPCARep);
			contextPCARun.serializeContextPCARun();
			matrices=deserializeContextPCARun(opt);

			wout=new ContextPCAWriter(opt,all_Docs,matrices,rin);
			wout.writeEigenDict();
			wout.writeEigContextVectors();
			
			if (opt.randomBaseline){
				wout.writeEigenDictRandom();
				wout.writeEigContextVectorsRandom();
			}
			
		    /* Total memory currently in use by the JVM */
		    System.out.println("Total memory (bytes): " + Runtime.getRuntime().totalMemory());
			
			System.out.println("+++Context PCA Embedddings Induced+++\n");
		}
		if (opt.train){
			System.out.println("+++Generating Context PCA Embedddings for training data+++\n");
			all_Docs=new ArrayList<ArrayList<Integer>>();
			docSize=new ArrayList<Integer>();
			corpusIntOldMapping=deserializeCorpusIntMapped(opt);
			rin=new ReadDataFile(opt);
			rin.setCorpusIntMapped(corpusIntOldMapping);
			rin.readAllDocs(1);
			all_Docs=rin.getAllDocs();
			docSize=rin.getDocSizes();
			numTokens=rin.getNumTokens();
			//corpus=new Corpus(all_Docs,docSize,opt);
			matrices=deserializeContextPCARun(opt);
			contextPCARep= new ContextPCARepresentation(opt, numTokens,rin,all_Docs);
			wout=new ContextPCAWriter(opt,all_Docs,matrices,rin);
			
			//Matrix contextSpecificEmbed=contextPCARep.generateProjections((Matrix)matrices[0], 
				//	(Matrix)matrices[1], (Matrix)matrices[2]);
			//wout.writeContextSpecificEmbed(contextSpecificEmbed);
			
			Matrix contextObliviousEmbed=contextPCARep.getContextOblEmbeddings((Matrix)matrices[1]);
			wout.writeContextObliviousEmbed(contextObliviousEmbed);
			
			Matrix contextObliviousEmbedContext=contextPCARep.getContextOblEmbeddings((Matrix)matrices[0]);
			wout.writeContextObliviousEmbedContext(contextObliviousEmbedContext);
			
			if (opt.randomBaseline){
				wout.writeContextObliviousEmbedRandom();
			}
			
			System.out.println("+++Generated Context PCA Embeddings for training data+++\n");
		}
	}