package OSU.PEQ.AVC.SUQ.test; import java.io.IOException; import AEU.AVC.SUQ.engine.EmotionInit; import SVQ.stable.StableString; //作者,著作权人: 罗瑶光,浏阳 public class EmotionTest{ public static void main(String[] argv) throws IOException { EmotionInit emotionInit = new EmotionInit(); emotionInit.IV_(StableString.text1); //reduce double positiveCount = emotionInit.getPositiveCount(); double negativeCount = emotionInit.getNegativeCount(); double totalCount = emotionInit.getTotalCount(); System.out.println("正面数:" + positiveCount); System.out.println("负面数:" + negativeCount); if(positiveCount == 0) { positiveCount = 1; } if(negativeCount == 0) { negativeCount = 1; } double adjRatio = Math.abs(positiveCount/negativeCount -negativeCount/positiveCount); System.out.println("渲染比率:" + adjRatio); double phychologicRatio = (positiveCount + negativeCount)/totalCount; System.out.println("情绪比率:" + phychologicRatio); double infectionRatio = adjRatio*phychologicRatio; System.out.println("感染比率:" + infectionRatio); } } // package OEI.AVC.SUQ.SVQ.MPC.fhmm.E; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; import SVQ.stable.StablePOS; import OCI.AVC.SUQ.SVQ.MPC.fhmm.C.EmotionMap; //作者,著作权人: 罗瑶光,浏阳 public class EmotionMap_E implements EmotionMap{ private Map positiveMap; private Map negativeMap; private Map motivationMap; private Map trendingMap; private Map predictionMap; private Map distinctionMap; public Map getPredictionMap() { return predictionMap; } public void I_PredictionMap(Map predictionMap) { this.predictionMap = predictionMap; } public Map getPositiveMap() { return positiveMap; } public void I_PositiveMap(Map positiveMap) { this.positiveMap = positiveMap; } public Map getNegativeMap() { return negativeMap; } public void I_NegativeMap(Map negativeMap) { this.negativeMap = negativeMap; } public Map getMotivationMap() { return motivationMap; } public void I_MotivationMap(Map motivationMap) { this.motivationMap = motivationMap; } public Map getTrendingMap() { return trendingMap; } public void I_TrendingMap(Map trendingMap) { this.trendingMap = trendingMap; } public Map getDistinctionMap() { return distinctionMap; } public void I_DistinctionMap(Map distinctionMap) { this.distinctionMap = distinctionMap; } public void IV_PositiveMap() throws IOException{ positiveMap = new HashMap<>(); InputStream in = getClass().getResourceAsStream(StablePOS.WORDS_SOURSE_LINK_POS_POSITIVE); BufferedReader cReader = new BufferedReader(new InputStreamReader(in, StablePOS.UTF8_STRING)); String cInputString; while ((cInputString = cReader.readLine()) != null) { if(!positiveMap.containsKey(cInputString)) { positiveMap.put(cInputString, true); } } cReader.close(); } public void IV_MotivationMap() throws IOException{ motivationMap = new HashMap<>(); InputStream in = getClass().getResourceAsStream(StablePOS.WORDS_SOURSE_LINK_MOTIVATION); BufferedReader cReader = new BufferedReader(new InputStreamReader(in, StablePOS.UTF8_STRING)); String cInputString; while ((cInputString = cReader.readLine()) != null) { String[] value = cInputString.split(StablePOS.NLP_SYMBO_SLASH); if(!motivationMap.containsKey(value[StablePOS.INT_ZERO])) { motivationMap.put(value[StablePOS.INT_ZERO], value[StablePOS.INT_ONE]); } } cReader.close(); } public void IV_TrendingMap() throws IOException{ trendingMap = new HashMap<>(); InputStream in = getClass().getResourceAsStream(StablePOS.WORDS_SOURSE_LINK_TRENDING); BufferedReader cReader = new BufferedReader(new InputStreamReader(in, StablePOS.UTF8_STRING)); String cInputString; while ((cInputString = cReader.readLine()) != null) { String[] value= cInputString.split(StablePOS.NLP_SYMBO_SLASH); if(!trendingMap.containsKey(value[StablePOS.INT_ZERO])) { trendingMap.put(value[StablePOS.INT_ZERO], value[StablePOS.INT_ONE]); } } cReader.close(); } public void IV_NegativeMap() throws IOException{ negativeMap = new HashMap<>(); InputStream in = getClass().getResourceAsStream(StablePOS.WORDS_SOURSE_LINK_POS_NEGATIVE); BufferedReader cReader = new BufferedReader(new InputStreamReader(in, StablePOS.UTF8_STRING)); String cInputString; while ((cInputString = cReader.readLine()) != null) { if(!negativeMap.containsKey(cInputString)) { negativeMap.put(cInputString, true); } } cReader.close(); } public void IV_PredictionMap() throws IOException { predictionMap = new HashMap<>(); InputStream in = getClass().getResourceAsStream(StablePOS.WORDS_SOURSE_LINK_PREDICTION); BufferedReader cReader = new BufferedReader(new InputStreamReader(in, StablePOS.UTF8_STRING)); String cInputString; while ((cInputString = cReader.readLine()) != null) { String[] value= cInputString.split(StablePOS.NLP_SYMBO_SLASH); if(!predictionMap.containsKey(value[StablePOS.INT_ZERO])) { predictionMap.put(value[StablePOS.INT_ZERO], value[StablePOS.INT_ONE]); } } cReader.close(); } public void IV_DistinctionMap() throws IOException { distinctionMap = new HashMap<>(); InputStream in = getClass().getResourceAsStream(StablePOS.WORDS_SOURSE_LINK_DISTINCTION); BufferedReader cReader = new BufferedReader(new InputStreamReader(in, StablePOS.UTF8_STRING)); String cInputString; while ((cInputString = cReader.readLine()) != null) { String[] value= cInputString.split(StablePOS.NLP_SYMBO_SLASH); if(!distinctionMap.containsKey(value[StablePOS.INT_ZERO])) { distinctionMap.put(value[StablePOS.INT_ZERO], value[StablePOS.INT_ONE]); } } cReader.close(); } }