@Test public void testParserMixStringByReturnFrequencyMap() { fail("Not yet implemented"); }
public Map<String, WordFrequency> parserMixStringByReturnFrequencyMap(String mixedString) { mixedString += StableData.SPACE_STRING; Map<String, String> wordsForest = fHMMList.getPosCnToCn(); Map<String, WordFrequency> outputList = new ConcurrentHashMap<>(); Map<Long, FMHMMNode> forestRoots = fHMMList.getMap(); int inputStringLength = mixedString.length(); int forestDepth = StableData.INT_ZERO; int countInputStringLength; StringBuilder[] fixWords = new StringBuilder[StableData.INT_TWO]; fixWords[StableData.INT_ZERO] = new StringBuilder(); fixWords[StableData.INT_ONE] = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder(); int find = StableData.INT_ZERO; Here: for (int charPosition = StableData.INT_ZERO; charPosition < inputStringLength; charPosition += (countInputStringLength == StableData.INT_ZERO ? StableData.INT_ONE : countInputStringLength)) { if(mixedString.charAt(charPosition) < StableData.INT_ONE_TWO_EIGHT && charPosition < mixedString.length() - StableData.INT_ONE){ if(find == StableData.INT_ZERO) { fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); } fixWords[StableData.INT_ZERO].append(mixedString.charAt(charPosition)); countInputStringLength = StableData.INT_ONE; find = StableData.INT_ONE; continue Here; } if(find == StableData.INT_ONE) { find = StableData.INT_ZERO; Iterator<String> it = fHMMList.englishStringToWordsList(fixWords[StableData.INT_ZERO].toString()).iterator(); while(it.hasNext()) { String temp=it.next(); if (outputList.containsKey(temp)) { WordFrequency wordFrequency = outputList.get(temp); wordFrequency.setFrequency(wordFrequency.getFrequency() + StableData.INT_ONE); outputList.put(temp, wordFrequency); } else { WordFrequency wordFrequency = new WordFrequency(); wordFrequency.setFrequency(StableData.INT_ONE); wordFrequency.setWord(temp); outputList.put(temp, wordFrequency); } } fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); } stringBuilder.delete(StableData.INT_ZERO, stringBuilder.length()); stringBuilder = neroController.getBinaryForestRecurWordOneTime(stringBuilder.append(mixedString .charAt(charPosition)), mixedString, charPosition, inputStringLength, forestRoots, forestDepth , charPosition + StableData.INT_ONE); String countWordNode = stringBuilder.toString(); int compare = countInputStringLength = countWordNode.length(); if (compare == StableData.INT_TWO) { countInputStringLength = nlpController.doSlangPartAndPOSCheckForTwoCharForMap(countInputStringLength , outputList, stringBuilder, wordsForest, fixWords, posController); continue Here; } if (compare == StableData.INT_THREE) { addFixWords(charPosition, mixedString, fixWords); countInputStringLength = nlpController.doPOSAndEMMCheckOfThreeForMap(countInputStringLength, outputList , wordsForest, stringBuilder, fixWords, posController); continue Here; } if (compare == StableData.INT_ONE) { if (outputList.containsKey(countWordNode)) { WordFrequency wordFrequency = outputList.get(countWordNode); wordFrequency.setFrequency(wordFrequency.getFrequency() + StableData.INT_ONE); outputList.put(countWordNode, wordFrequency); } else { WordFrequency wordFrequency = new WordFrequency(); wordFrequency.setFrequency(StableData.INT_ONE); wordFrequency.setWord(fixWords[StableData.INT_ZERO].toString()); outputList.put(countWordNode, wordFrequency); } fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); fixWords[StableData.INT_ZERO].append(countWordNode); continue Here; } if (compare == StableData.INT_FOUR) { addFixWords(charPosition, mixedString, fixWords); countInputStringLength = nlpController.doSlangCheckForMap(countInputStringLength, outputList, stringBuilder , wordsForest, fixWords, posController); } } return outputList; }
AnalyzerImp implements Analyzer { public Map<String, WordFrequency> parserMixStringByReturnFrequencyMap(String mixedString) { mixedString += StableData.SPACE_STRING; Map<String, String> wordsForest = fHMMList.getPosCnToCn(); Map<String, WordFrequency> outputList = new ConcurrentHashMap<>(); Map<Long, FMHMMNode> forestRoots = fHMMList.getMap(); int inputStringLength = mixedString.length(); int forestDepth = StableData.INT_ZERO; int countInputStringLength; StringBuilder[] fixWords = new StringBuilder[StableData.INT_TWO]; fixWords[StableData.INT_ZERO] = new StringBuilder(); fixWords[StableData.INT_ONE] = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder(); int find = StableData.INT_ZERO; Here: for (int charPosition = StableData.INT_ZERO; charPosition < inputStringLength; charPosition += (countInputStringLength == StableData.INT_ZERO ? StableData.INT_ONE : countInputStringLength)) { if(mixedString.charAt(charPosition) < StableData.INT_ONE_TWO_EIGHT && charPosition < mixedString.length() - StableData.INT_ONE){ if(find == StableData.INT_ZERO) { fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); } fixWords[StableData.INT_ZERO].append(mixedString.charAt(charPosition)); countInputStringLength = StableData.INT_ONE; find = StableData.INT_ONE; continue Here; } if(find == StableData.INT_ONE) { find = StableData.INT_ZERO; Iterator<String> it = fHMMList.englishStringToWordsList(fixWords[StableData.INT_ZERO].toString()).iterator(); while(it.hasNext()) { String temp=it.next(); if (outputList.containsKey(temp)) { WordFrequency wordFrequency = outputList.get(temp); wordFrequency.setFrequency(wordFrequency.getFrequency() + StableData.INT_ONE); outputList.put(temp, wordFrequency); } else { WordFrequency wordFrequency = new WordFrequency(); wordFrequency.setFrequency(StableData.INT_ONE); wordFrequency.setWord(temp); outputList.put(temp, wordFrequency); } } fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); } stringBuilder.delete(StableData.INT_ZERO, stringBuilder.length()); stringBuilder = neroController.getBinaryForestRecurWordOneTime(stringBuilder.append(mixedString .charAt(charPosition)), mixedString, charPosition, inputStringLength, forestRoots, forestDepth , charPosition + StableData.INT_ONE); String countWordNode = stringBuilder.toString(); int compare = countInputStringLength = countWordNode.length(); if (compare == StableData.INT_TWO) { countInputStringLength = nlpController.doSlangPartAndPOSCheckForTwoCharForMap(countInputStringLength , outputList, stringBuilder, wordsForest, fixWords, posController); continue Here; } if (compare == StableData.INT_THREE) { addFixWords(charPosition, mixedString, fixWords); countInputStringLength = nlpController.doPOSAndEMMCheckOfThreeForMap(countInputStringLength, outputList , wordsForest, stringBuilder, fixWords, posController); continue Here; } if (compare == StableData.INT_ONE) { if (outputList.containsKey(countWordNode)) { WordFrequency wordFrequency = outputList.get(countWordNode); wordFrequency.setFrequency(wordFrequency.getFrequency() + StableData.INT_ONE); outputList.put(countWordNode, wordFrequency); } else { WordFrequency wordFrequency = new WordFrequency(); wordFrequency.setFrequency(StableData.INT_ONE); wordFrequency.setWord(fixWords[StableData.INT_ZERO].toString()); outputList.put(countWordNode, wordFrequency); } fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); fixWords[StableData.INT_ZERO].append(countWordNode); continue Here; } if (compare == StableData.INT_FOUR) { addFixWords(charPosition, mixedString, fixWords); countInputStringLength = nlpController.doSlangCheckForMap(countInputStringLength, outputList, stringBuilder , wordsForest, fixWords, posController); } } return outputList; } }
AnalyzerImp implements Analyzer { public Map<String, WordFrequency> parserMixStringByReturnFrequencyMap(String mixedString) { mixedString += StableData.SPACE_STRING; Map<String, String> wordsForest = fHMMList.getPosCnToCn(); Map<String, WordFrequency> outputList = new ConcurrentHashMap<>(); Map<Long, FMHMMNode> forestRoots = fHMMList.getMap(); int inputStringLength = mixedString.length(); int forestDepth = StableData.INT_ZERO; int countInputStringLength; StringBuilder[] fixWords = new StringBuilder[StableData.INT_TWO]; fixWords[StableData.INT_ZERO] = new StringBuilder(); fixWords[StableData.INT_ONE] = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder(); int find = StableData.INT_ZERO; Here: for (int charPosition = StableData.INT_ZERO; charPosition < inputStringLength; charPosition += (countInputStringLength == StableData.INT_ZERO ? StableData.INT_ONE : countInputStringLength)) { if(mixedString.charAt(charPosition) < StableData.INT_ONE_TWO_EIGHT && charPosition < mixedString.length() - StableData.INT_ONE){ if(find == StableData.INT_ZERO) { fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); } fixWords[StableData.INT_ZERO].append(mixedString.charAt(charPosition)); countInputStringLength = StableData.INT_ONE; find = StableData.INT_ONE; continue Here; } if(find == StableData.INT_ONE) { find = StableData.INT_ZERO; Iterator<String> it = fHMMList.englishStringToWordsList(fixWords[StableData.INT_ZERO].toString()).iterator(); while(it.hasNext()) { String temp=it.next(); if (outputList.containsKey(temp)) { WordFrequency wordFrequency = outputList.get(temp); wordFrequency.setFrequency(wordFrequency.getFrequency() + StableData.INT_ONE); outputList.put(temp, wordFrequency); } else { WordFrequency wordFrequency = new WordFrequency(); wordFrequency.setFrequency(StableData.INT_ONE); wordFrequency.setWord(temp); outputList.put(temp, wordFrequency); } } fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); } stringBuilder.delete(StableData.INT_ZERO, stringBuilder.length()); stringBuilder = neroController.getBinaryForestRecurWordOneTime(stringBuilder.append(mixedString .charAt(charPosition)), mixedString, charPosition, inputStringLength, forestRoots, forestDepth , charPosition + StableData.INT_ONE); String countWordNode = stringBuilder.toString(); int compare = countInputStringLength = countWordNode.length(); if (compare == StableData.INT_TWO) { countInputStringLength = nlpController.doSlangPartAndPOSCheckForTwoCharForMap(countInputStringLength , outputList, stringBuilder, wordsForest, fixWords, posController); continue Here; } if (compare == StableData.INT_THREE) { addFixWords(charPosition, mixedString, fixWords); countInputStringLength = nlpController.doPOSAndEMMCheckOfThreeForMap(countInputStringLength, outputList , wordsForest, stringBuilder, fixWords, posController); continue Here; } if (compare == StableData.INT_ONE) { if (outputList.containsKey(countWordNode)) { WordFrequency wordFrequency = outputList.get(countWordNode); wordFrequency.setFrequency(wordFrequency.getFrequency() + StableData.INT_ONE); outputList.put(countWordNode, wordFrequency); } else { WordFrequency wordFrequency = new WordFrequency(); wordFrequency.setFrequency(StableData.INT_ONE); wordFrequency.setWord(fixWords[StableData.INT_ZERO].toString()); outputList.put(countWordNode, wordFrequency); } fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); fixWords[StableData.INT_ZERO].append(countWordNode); continue Here; } if (compare == StableData.INT_FOUR) { addFixWords(charPosition, mixedString, fixWords); countInputStringLength = nlpController.doSlangCheckForMap(countInputStringLength, outputList, stringBuilder , wordsForest, fixWords, posController); } } return outputList; }  }
AnalyzerImp implements Analyzer { public Map<String, WordFrequency> parserMixStringByReturnFrequencyMap(String mixedString) { mixedString += StableData.SPACE_STRING; Map<String, String> wordsForest = fHMMList.getPosCnToCn(); Map<String, WordFrequency> outputList = new ConcurrentHashMap<>(); Map<Long, FMHMMNode> forestRoots = fHMMList.getMap(); int inputStringLength = mixedString.length(); int forestDepth = StableData.INT_ZERO; int countInputStringLength; StringBuilder[] fixWords = new StringBuilder[StableData.INT_TWO]; fixWords[StableData.INT_ZERO] = new StringBuilder(); fixWords[StableData.INT_ONE] = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder(); int find = StableData.INT_ZERO; Here: for (int charPosition = StableData.INT_ZERO; charPosition < inputStringLength; charPosition += (countInputStringLength == StableData.INT_ZERO ? StableData.INT_ONE : countInputStringLength)) { if(mixedString.charAt(charPosition) < StableData.INT_ONE_TWO_EIGHT && charPosition < mixedString.length() - StableData.INT_ONE){ if(find == StableData.INT_ZERO) { fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); } fixWords[StableData.INT_ZERO].append(mixedString.charAt(charPosition)); countInputStringLength = StableData.INT_ONE; find = StableData.INT_ONE; continue Here; } if(find == StableData.INT_ONE) { find = StableData.INT_ZERO; Iterator<String> it = fHMMList.englishStringToWordsList(fixWords[StableData.INT_ZERO].toString()).iterator(); while(it.hasNext()) { String temp=it.next(); if (outputList.containsKey(temp)) { WordFrequency wordFrequency = outputList.get(temp); wordFrequency.setFrequency(wordFrequency.getFrequency() + StableData.INT_ONE); outputList.put(temp, wordFrequency); } else { WordFrequency wordFrequency = new WordFrequency(); wordFrequency.setFrequency(StableData.INT_ONE); wordFrequency.setWord(temp); outputList.put(temp, wordFrequency); } } fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); } stringBuilder.delete(StableData.INT_ZERO, stringBuilder.length()); stringBuilder = neroController.getBinaryForestRecurWordOneTime(stringBuilder.append(mixedString .charAt(charPosition)), mixedString, charPosition, inputStringLength, forestRoots, forestDepth , charPosition + StableData.INT_ONE); String countWordNode = stringBuilder.toString(); int compare = countInputStringLength = countWordNode.length(); if (compare == StableData.INT_TWO) { countInputStringLength = nlpController.doSlangPartAndPOSCheckForTwoCharForMap(countInputStringLength , outputList, stringBuilder, wordsForest, fixWords, posController); continue Here; } if (compare == StableData.INT_THREE) { addFixWords(charPosition, mixedString, fixWords); countInputStringLength = nlpController.doPOSAndEMMCheckOfThreeForMap(countInputStringLength, outputList , wordsForest, stringBuilder, fixWords, posController); continue Here; } if (compare == StableData.INT_ONE) { if (outputList.containsKey(countWordNode)) { WordFrequency wordFrequency = outputList.get(countWordNode); wordFrequency.setFrequency(wordFrequency.getFrequency() + StableData.INT_ONE); outputList.put(countWordNode, wordFrequency); } else { WordFrequency wordFrequency = new WordFrequency(); wordFrequency.setFrequency(StableData.INT_ONE); wordFrequency.setWord(fixWords[StableData.INT_ZERO].toString()); outputList.put(countWordNode, wordFrequency); } fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); fixWords[StableData.INT_ZERO].append(countWordNode); continue Here; } if (compare == StableData.INT_FOUR) { addFixWords(charPosition, mixedString, fixWords); countInputStringLength = nlpController.doSlangCheckForMap(countInputStringLength, outputList, stringBuilder , wordsForest, fixWords, posController); } } return outputList; }  void init(); void initMixed(); List<String> parserMixedString(String mixedString); List<String> parserString(String inputString); Map<String, WordFrequency> parserStringByReturnFrequencyMap(String inputString); void addFixWords(int charPosition, String inputString, StringBuilder[] fixWords); Map<String, String> getEnToCn(); Map<String, String> getCnToEn(); Map<String, WordFrequency> getWordFrequencyMap(List<String> sets); List<WordFrequency> sortWordFrequencyMap(Map<String, WordFrequency> map); List<WordFrequency> getWordFrequency(List<String> sets); Map<Integer, WordFrequency> getWordFrequencyByReturnSortMap(List<String> sets); Map<Integer, WordFrequency> sortWordFrequencyMapToUnsortMap(Map<String, WordFrequency> map); Map<Integer, WordFrequency> sortWordFrequencyMapToSortMap(Map<String, WordFrequency> map); String[] parserEnglishString(String englishString); Map<String, String> getPosEnToCn(); Map<String, String> getPosEnToEn(); Map<String, String> getPosCnToCn(); Map<String, String> getFullEnToCn(); Map<String, String> getFullCnToEn(); Map<String, WordFrequency> parserMixStringByReturnFrequencyMap(String mixedString); void studyNewWord(String study, String token, String posStudy); @Override Map<String, String> getStudyPos(); }
AnalyzerImp implements Analyzer { public Map<String, WordFrequency> parserMixStringByReturnFrequencyMap(String mixedString) { mixedString += StableData.SPACE_STRING; Map<String, String> wordsForest = fHMMList.getPosCnToCn(); Map<String, WordFrequency> outputList = new ConcurrentHashMap<>(); Map<Long, FMHMMNode> forestRoots = fHMMList.getMap(); int inputStringLength = mixedString.length(); int forestDepth = StableData.INT_ZERO; int countInputStringLength; StringBuilder[] fixWords = new StringBuilder[StableData.INT_TWO]; fixWords[StableData.INT_ZERO] = new StringBuilder(); fixWords[StableData.INT_ONE] = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder(); int find = StableData.INT_ZERO; Here: for (int charPosition = StableData.INT_ZERO; charPosition < inputStringLength; charPosition += (countInputStringLength == StableData.INT_ZERO ? StableData.INT_ONE : countInputStringLength)) { if(mixedString.charAt(charPosition) < StableData.INT_ONE_TWO_EIGHT && charPosition < mixedString.length() - StableData.INT_ONE){ if(find == StableData.INT_ZERO) { fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); } fixWords[StableData.INT_ZERO].append(mixedString.charAt(charPosition)); countInputStringLength = StableData.INT_ONE; find = StableData.INT_ONE; continue Here; } if(find == StableData.INT_ONE) { find = StableData.INT_ZERO; Iterator<String> it = fHMMList.englishStringToWordsList(fixWords[StableData.INT_ZERO].toString()).iterator(); while(it.hasNext()) { String temp=it.next(); if (outputList.containsKey(temp)) { WordFrequency wordFrequency = outputList.get(temp); wordFrequency.setFrequency(wordFrequency.getFrequency() + StableData.INT_ONE); outputList.put(temp, wordFrequency); } else { WordFrequency wordFrequency = new WordFrequency(); wordFrequency.setFrequency(StableData.INT_ONE); wordFrequency.setWord(temp); outputList.put(temp, wordFrequency); } } fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); } stringBuilder.delete(StableData.INT_ZERO, stringBuilder.length()); stringBuilder = neroController.getBinaryForestRecurWordOneTime(stringBuilder.append(mixedString .charAt(charPosition)), mixedString, charPosition, inputStringLength, forestRoots, forestDepth , charPosition + StableData.INT_ONE); String countWordNode = stringBuilder.toString(); int compare = countInputStringLength = countWordNode.length(); if (compare == StableData.INT_TWO) { countInputStringLength = nlpController.doSlangPartAndPOSCheckForTwoCharForMap(countInputStringLength , outputList, stringBuilder, wordsForest, fixWords, posController); continue Here; } if (compare == StableData.INT_THREE) { addFixWords(charPosition, mixedString, fixWords); countInputStringLength = nlpController.doPOSAndEMMCheckOfThreeForMap(countInputStringLength, outputList , wordsForest, stringBuilder, fixWords, posController); continue Here; } if (compare == StableData.INT_ONE) { if (outputList.containsKey(countWordNode)) { WordFrequency wordFrequency = outputList.get(countWordNode); wordFrequency.setFrequency(wordFrequency.getFrequency() + StableData.INT_ONE); outputList.put(countWordNode, wordFrequency); } else { WordFrequency wordFrequency = new WordFrequency(); wordFrequency.setFrequency(StableData.INT_ONE); wordFrequency.setWord(fixWords[StableData.INT_ZERO].toString()); outputList.put(countWordNode, wordFrequency); } fixWords[StableData.INT_ZERO].delete(StableData.INT_ZERO, fixWords[StableData.INT_ZERO].length()); fixWords[StableData.INT_ZERO].append(countWordNode); continue Here; } if (compare == StableData.INT_FOUR) { addFixWords(charPosition, mixedString, fixWords); countInputStringLength = nlpController.doSlangCheckForMap(countInputStringLength, outputList, stringBuilder , wordsForest, fixWords, posController); } } return outputList; }  void init(); void initMixed(); List<String> parserMixedString(String mixedString); List<String> parserString(String inputString); Map<String, WordFrequency> parserStringByReturnFrequencyMap(String inputString); void addFixWords(int charPosition, String inputString, StringBuilder[] fixWords); Map<String, String> getEnToCn(); Map<String, String> getCnToEn(); Map<String, WordFrequency> getWordFrequencyMap(List<String> sets); List<WordFrequency> sortWordFrequencyMap(Map<String, WordFrequency> map); List<WordFrequency> getWordFrequency(List<String> sets); Map<Integer, WordFrequency> getWordFrequencyByReturnSortMap(List<String> sets); Map<Integer, WordFrequency> sortWordFrequencyMapToUnsortMap(Map<String, WordFrequency> map); Map<Integer, WordFrequency> sortWordFrequencyMapToSortMap(Map<String, WordFrequency> map); String[] parserEnglishString(String englishString); Map<String, String> getPosEnToCn(); Map<String, String> getPosEnToEn(); Map<String, String> getPosCnToCn(); Map<String, String> getFullEnToCn(); Map<String, String> getFullCnToEn(); Map<String, WordFrequency> parserMixStringByReturnFrequencyMap(String mixedString); void studyNewWord(String study, String token, String posStudy); @Override Map<String, String> getStudyPos();  }