1   package eu.fbk.knowledgestore.populator.naf;
2   
3   import java.io.BufferedReader;
4   import java.io.BufferedWriter;
5   import java.io.File;
6   import java.io.FileInputStream;
7   import java.io.FileNotFoundException;
8   import java.io.FileOutputStream;
9   import java.io.IOException;
10  import java.io.InputStreamReader;
11  import java.io.Reader;
12  import java.util.Hashtable;
13  import java.util.LinkedList;
14  
15  public class sumStatistics {
16  
17  	/**
18  	 * @param args
19  	 * @throws IOException 
20  	 */
21  	public static void main(String[] args) throws IOException {
22  		//String inputFile="/Users/qwaider/Desktop/NewsReader/download/coreset_13-19/report.txt";
23  		String inputFile="/Users/qwaider/Desktop/NewsReader/download/coreset_8_9_10_11_12/report.txt";
24  
25  		
26  		FileInputStream in = new FileInputStream(inputFile);
27          Reader reader = new InputStreamReader(in, "utf-8");
28          BufferedReader br = new BufferedReader(reader);
29          String line;
30         int NumberOfFiles= 0;
31          int Entity=0;
32          int Coreference=0;
33          int Srl=0;
34          int Participation=0;
35          int RoleWithEntity=0;
36          int RoleWithoutEntity=0;
37          int Timex=0;
38          int Factuality=0;
39          int discarded=0;
40          int i=0;
41          while((line = br.readLine()) != null){
42          	if(line.length()>0){
43          	if(!line.contains("null")){
44          	switch(i){
45          	case 0: NumberOfFiles++; break;
46          	case 1:break;
47          	case 2: Entity+=getNumber("Entity:",line); break;
48          	case 3: Coreference+=getNumber("Coreference:",line); break;
49          	case 4: Srl+=getNumber("Srl:",line); break;
50          	case 5: Participation+=getNumber("Participation:",line); break;
51          	case 6: RoleWithEntity+=getNumber("Role with entity=",line); break;
52          	case 7: RoleWithoutEntity+=getNumber("Role without entity=",line); break;
53          	case 8: Factuality+=getNumber("Timex:",line); break;
54          	case 9: Factuality+=getNumber("Factuality:",line); break;
55          	}
56          	if(i<9)
57          		i++;
58          	else
59          		i=0;
60          	}else{
61          		discarded++;
62          		i=0;
63          		br.readLine();//an empty line
64          	}
65          	}
66          }
67          
68          System.out.println("Number of involved Files: "+NumberOfFiles+"\nNumber of discarded files: "+discarded+"\nExtracted mentions:\nEntity:"+Entity+"\nCoreference:"+Coreference+"\nSrl:"+Srl);
69  		System.out.println("\nParticipation:"+Participation);
70  		System.out.println("\nRole with entity="+RoleWithEntity);
71  		System.out.println("\nRole without entity="+RoleWithoutEntity+"\nTimex: "+Timex+"\nFactuality:"+Factuality);
72         
73  
74  	}
75  
76  	private static int getNumber(String head, String line) {
77  		if(line.startsWith(head)){
78  			line=line.replace(head, "");
79  			return Integer.parseInt(line);
80  		}else{
81  			System.err.println("Head: "+head+"=line="+line);
82  		}
83  		return 0;
84  	}
85  
86  }