package com.grayben.riskExtractor;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;

import com.grayben.riskExtractor.htmlScorer.HtmlScorer;
import com.grayben.riskExtractor.htmlScorer.ScoredText;
import com.grayben.riskExtractor.htmlScorer.TreeHtmlScorer;

public class RiskExtractor {
	
	static long startTime;

	public static void main(String[] args) {
		startingMain();
		
		boolean testParse = false;
		if(testParse == true){
			testParse("http://google.com");
		} else takeArgs(args);
		
		completingMain();
	}
	
	private static void startingMain(){
		startTimer();
		System.out.println("Starting main");
	}
	
	private static void completingMain(){
		System.out.println();
		System.out.println("Program finished.");
		printTimeElapsed();
	}
	
	private static void startTimer(){
		startTime = System.currentTimeMillis();
	}
	
	private static void printTimeElapsed(){
		long currentTime = System.currentTimeMillis();
		float secondsElapsed = (float)(currentTime - startTime)/1000;
		System.out.println("Time elapsed: " + secondsElapsed + " seconds");
	}
	
	private static void testParse(String url){
		HtmlScorer scorer = new TreeHtmlScorer();
		ScoredText scoredText = scorer.scoreHtml(url);
		System.out.print(scoredText.toString());
	}
	
	private static void takeArgs(String[] args){
		checkArgs(args);
		String fileName = args[0];
		File htmlFile = new File(fileName);
		String charsetName = args[1];
		HtmlScorer scorer = new TreeHtmlScorer();
		ScoredText scoredText = scorer.scoreHtml(htmlFile, charsetName);
		System.out.print(scoredText.toString());
		File outFile = new File("/Volumes/MBS Data/EDGAR-Form10K/output.txt");
		PrintWriter writer;
		try {
			writer = new PrintWriter(outFile);
			writer.print(scoredText.toString());
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	
	private static void checkArgs(String[] args){
		int argsLen = 2;
		if(args.length != argsLen){
			System.err.println("ERROR: must pass " + argsLen + " arguments.");
			System.exit(1);
		}
	}

}

@@ -40,89 +40,408 @@
 ort 
-java.io.File;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.PrintWrit
+com.grayben.riskExtractor.htmlScorer.HtmlScorer;%0Aimport com.grayben.riskExtractor.htmlScorer.ScoredText;%0Aimport com.grayben.riskExtractor.htmlScorer.ScoringAndFlatteningNodeVisitor;%0Aimport com.grayben.riskExtractor.htmlScorer.TreeHtmlScorer;%0Aimport com.grayben.riskExtractor.htmlScorer.partScorers.Scorer;%0Aimport com.grayben.riskExtractor.htmlScorer.partScorers.elementScorers.EmphasisElementScor
 er;%0A
-%0A
 impo
@@ -472,36 +472,78 @@
 ctor.htmlScorer.
-Html
+partScorers.elementScorers.SegmentationElement
 Scorer;%0Aimport c
@@ -582,78 +582,396 @@
 rer.
+part
 Score
-dText;%0Aimport com.grayben.riskExtractor.htmlScorer.TreeHtmlScorer
+rs.tagScorers.TagAndAttributeScorer;%0Aimport com.grayben.riskExtractor.htmlScorer.partScorers.tagScorers.TagEmphasisScorer;%0Aimport com.grayben.riskExtractor.htmlScorer.partScorers.tagScorers.TagSegmentationScorer;%0Aimport org.jsoup.nodes.Element;%0A%0Aimport java.io.File;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.PrintWriter;%0Aimport java.util.HashSet;%0Aimport java.util.Set
 ;%0A%0Ap
@@ -1773,53 +1773,675 @@
 %0A%09%7D%0A
-%09%0A%09private static void testParse(String url)%7B
+%0A%09private static ScoringAndFlatteningNodeVisitor setupNodeVisitor()%7B%0A%09%09Set%3CScorer%3CElement%3E%3E elementScorers = new HashSet%3C%3E();%0A%09%09elementScorers.add(%0A%09%09%09%09new SegmentationElementScorer(%0A%09%09%09%09%09%09new TagSegmentationScorer(TagSegmentationScorer.defaultMap())%0A%09%09%09%09)%0A%09%09);%0A%09%09elementScorers.add(%0A%09%09%09%09new EmphasisElementScorer(%0A%09%09%09%09%09%09new TagEmphasisScorer(TagEmphasisScorer.defaultMap()),%0A%09%09%09%09%09%09new TagAndAttributeScorer(TagAndAttributeScorer.defaultMap())%0A%09%09%09%09)%0A%09%09);%0A%09%09ScoringAndFlatteningNodeVisitor nv = new ScoringAndFlatteningNodeVisitor(elementScorers);%0A%09%09return nv;%0A%09%7D%0A%09%0A%09private static void testParse(String url)%7B%0A%09%09ScoringAndFlatteningNodeVisitor nv = setupNodeVisitor();
 %0A%09%09H
@@ -2470,32 +2470,34 @@
  TreeHtmlScorer(
+nv
 );%0A%09%09ScoredText 

Make RiskExtractor conform to new IoC from last commit