当前位置: 首页>>代码示例>>Java>>正文


Java StringUtil类代码示例

本文整理汇总了Java中com.darkprograms.speech.util.StringUtil的典型用法代码示例。如果您正苦于以下问题:Java StringUtil类的具体用法?Java StringUtil怎么用?Java StringUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringUtil类属于com.darkprograms.speech.util包,在下文中一共展示了StringUtil类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseResponse

import com.darkprograms.speech.util.StringUtil; //导入依赖的package包/类
/**
 * Parses the response into a Google Response
 * @param rawResponse The raw String you want to parse
 * @param gr The GoogleResponse you want to parse into ti.
 */
private void parseResponse(String rawResponse, GoogleResponse gr){
	if(rawResponse == null || !rawResponse.contains("\"result\"")){ return; }
	if(rawResponse.contains("\"confidence\":")){
		String confidence = StringUtil.substringBetween(rawResponse, "\"confidence\":", "}");
		gr.setConfidence(confidence);
	}
	else{
		gr.setConfidence(String.valueOf(1d));
	}
	String array = StringUtil.trimString(rawResponse, "[", "]");
	if(array.contains("[")){
		array = StringUtil.trimString(array, "[", "]");
	}
	String[] parts = array.split(",");
	gr.setResponse(parseTranscript(parts[0]));
	for(int i = 1; i<parts.length; i++){
		gr.getOtherPossibleResponses().add(parseTranscript(parts[i]));
	}
}
 
开发者ID:goxr3plus,项目名称:java-google-speech-api,代码行数:25,代码来源:RecognizerChunked.java

示例2: parseResponse

import com.darkprograms.speech.util.StringUtil; //导入依赖的package包/类
/**
 * Parses the String into a GoogleResponse object
 * 
 * @param rawResponse
 *            The String you want to parse
 * @param gr
 *            the GoogleResponse object to save the data into.
 */
private void parseResponse(String rawResponse , GoogleResponse gr) {
	if (rawResponse == null || !rawResponse.contains("\"result\"") || rawResponse.equals("{\"result\":[]}")) {
		return;
	}
	gr.getOtherPossibleResponses().clear(); // Emptys the list
	if (rawResponse.contains("\"confidence\":")) {
		String confidence = StringUtil.substringBetween(rawResponse, "\"confidence\":", "}");
		gr.setConfidence(confidence);
	} else {
		gr.setConfidence(String.valueOf(1));
	}
	String response = StringUtil.substringBetween(rawResponse, "[{\"transcript\":\"", "\"}],");
	if (response == null) {
		response = StringUtil.substringBetween(rawResponse, "[{\"transcript\":\"", "\",\"");
	}
	gr.setResponse(response);
	gr.setFinalResponse(rawResponse.contains("\"final\":true"));
	String[] currentHypos = rawResponse.split("\\[\\{\"transcript\":\"");
	for (int i = 2; i < currentHypos.length; i++) {
		String cleaned = currentHypos[i].substring(0, currentHypos[i].indexOf('\"'));
		gr.getOtherPossibleResponses().add(cleaned);
	}
}
 
开发者ID:goxr3plus,项目名称:java-google-speech-api,代码行数:32,代码来源:GSpeechDuplex.java

示例3: parseResponse

import com.darkprograms.speech.util.StringUtil; //导入依赖的package包/类
/**
 * Parses the String into a GoogleResponse object
 *
 * @param rawResponse The String you want to parse
 * @param gr the GoogleResponse object to save the data into.
 */
private void parseResponse(String rawResponse, GoogleResponse gr) {
    if (rawResponse == null || !rawResponse.contains("\"result\"")
            || rawResponse.equals("{\"result\":[]}")) {
        return;
    }
    gr.getOtherPossibleResponses().clear(); // Emptys the list
    if (rawResponse.contains("\"confidence\":")) {
        String confidence = StringUtil.substringBetween(rawResponse, "\"confidence\":", "}");
        gr.setConfidence(confidence);
    } else {
        gr.setConfidence(String.valueOf(1));
    }
    String response = StringUtil.substringBetween(rawResponse, "[{\"transcript\":\"", "\"}],");
    gr.setResponse(response);
    String[] currentHypos = rawResponse.split("\\[\\{\"transcript\":\"");
    for (int i = 2; i < currentHypos.length; i++) {
        String cleaned = currentHypos[i].substring(0, currentHypos[i].indexOf("\""));
        gr.getOtherPossibleResponses().add(cleaned);
    }
}
 
开发者ID:tsoglani,项目名称:SpeechRaspberrySmartHouse,代码行数:27,代码来源:GSpeechDuplex.java

示例4: parseResponse

import com.darkprograms.speech.util.StringUtil; //导入依赖的package包/类
/**
 * Parses the String into a GoogleResponse object
 * @param rawResponse The String you want to parse
 * @param gr the GoogleResponse object to save the data into.
 */
private void parseResponse(String rawResponse, GoogleResponse gr){
	if(rawResponse == null || !rawResponse.contains("\"result\"")
			|| rawResponse.equals("{\"result\":[]}")){ return; }
	gr.getOtherPossibleResponses().clear(); // Emptys the list
	if(rawResponse.contains("\"confidence\":")){
		String confidence = StringUtil.substringBetween(rawResponse, "\"confidence\":", "}");
		gr.setConfidence(confidence);
	}
	else{
		gr.setConfidence(String.valueOf(1));
	}
	String response = StringUtil.substringBetween(rawResponse, "[{\"transcript\":\"", "\"}],");
	if (response == null) {
		response = StringUtil.substringBetween(rawResponse, "[{\"transcript\":\"", "\",\"");
	}
	gr.setResponse(response);
	gr.setFinalResponse(rawResponse.contains("\"final\":true"));
	String[] currentHypos = rawResponse.split("\\[\\{\"transcript\":\"");
	for(int i = 2; i<currentHypos.length; i++){
		String cleaned = currentHypos[i].substring(0, currentHypos[i].indexOf("\""));
		gr.getOtherPossibleResponses().add(cleaned);
	}
}
 
开发者ID:OpenASR,项目名称:idear,代码行数:29,代码来源:GSpeechDuplex.java

示例5: parseTranscript

import com.darkprograms.speech.util.StringUtil; //导入依赖的package包/类
/**
 * Cleans up the transcript portion of the String
 * @param s The string you want to process.
 * @return The reformated string.
 */
private String parseTranscript(String s){
	String tmp = s.substring(s.indexOf(":")+1);
	if(s.endsWith("}")){
		tmp = tmp.substring(0, tmp.length()-1);
	}
	tmp = StringUtil.stripQuotes(tmp);
	return tmp;
}
 
开发者ID:goxr3plus,项目名称:java-google-speech-api,代码行数:14,代码来源:RecognizerChunked.java


注:本文中的com.darkprograms.speech.util.StringUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。