package org.greenstone.mat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; import java.io.PrintWriter; import java.math.BigDecimal; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.greenstone.gsdl3.core.MessageRouter; import org.greenstone.gsdl3.util.XMLConverter; public class DataMaker { MetadataStats ms; ArrayList nameList = new ArrayList(); private int Mode = 0; private int TotalDoc = 0; private String path = null; protected Document doc=null; protected MessageRouter mr = null; protected XMLConverter converter=null; private ArrayList removedID = new ArrayList(); private final String rootDocument = "archivedir"; private final String documentTag = "Document"; private final String frequencyTag ="Frequency"; private final String valueTag = "ActualValue"; private final String ASCII_sort = "ASCII"; private final String urlFile = "dc.Identifier"; private static final int DEF_DIV_SCALE = 10; public DataMaker(MetadataStats stats){ ms = stats; nameList = stats.metadataNameList; path = stats.StatsDirectory; setTotalDocNumber(); } private Element getRootNode(String core_element){ try{ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); doc = docBuilder.parse (new File(path+core_element+".xml")); Element rootNode = doc.getDocumentElement(); return rootNode; }catch (Exception e) { e.printStackTrace(); return null; } } public void setTotalDocNumber(){ Element ex = getRootNode(rootDocument); NodeList listOfFrequency = ex.getElementsByTagName(documentTag); TotalDoc = listOfFrequency.getLength(); } public int getTotalDocNumber(){ return TotalDoc; } public int getTotalElementUsed(){ int totalNumber = 0; for(int i = 0 ; imaxNumber){maxNumber=x;} } return maxNumber; } public int getMode(String core_element){ Element rootElement = getRootNode(core_element); NodeList listOfDocument = rootElement.getElementsByTagName(documentTag); if(listOfDocument.getLength()==0){ Mode = 0; return 0; } ArrayList alist = new ArrayList(); String[] idList = getDocumentIDs(core_element); for(int i = 0; i max_cnt) { max_cnt = count; max_idx = i; } } Mode = list [max_idx]; return list [max_idx]; } public double ModeFrequency(String core_element){ Element rootElement = getRootNode(core_element); NodeList listOfDocument = rootElement.getElementsByTagName(documentTag); if(listOfDocument.getLength()==0){ return 100; } ArrayList alist = new ArrayList(); String[] idList = getDocumentIDs(core_element); for(int i = 0; i