本文整理汇总了Java中com.darkprograms.speech.util.StringUtil.substringBetween方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtil.substringBetween方法的具体用法?Java StringUtil.substringBetween怎么用?Java StringUtil.substringBetween使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.darkprograms.speech.util.StringUtil
的用法示例。
在下文中一共展示了StringUtil.substringBetween方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]));
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}