I am new in using <oob> tag, I am using pandora-bot for chat bot.
I have used many aiml tags and completed my work. Please guide how to use oob tag in aiml so that its response can be implemented in android programming.
Please feel free to ask question if any thing is unclear.
oob tag is responding but not opening search or dialing call.
private static String recursEval(Node node, ParseState ps) {
LOG.info("AIMLProcessor.recursEval(node: " + node + ", ps: " + ps + ")");
try {
LOG.info("in AIMLProcessor.recursEval(), node string: " + DomUtils.nodeToString(node));
String nodeName = node.getNodeName();
LOG.info("in AIMLProcessor.recursEval(), nodeName: " + nodeName);
LOG.info("in AIMLProcessor.recursEval(), node.getNodeValue(): " + node.getNodeValue());
if (nodeName.equals("#text")) return node.getNodeValue();
else if (nodeName.equals("#comment")) {
LOG.info("in AIMLProcessor.recursEval(), comment = "+node.getTextContent());
return "";
}
else if (nodeName.equals("template"))
return evalTagContent(node, ps, null);
else if (nodeName.equals("random"))
return random(node, ps);
else if (nodeName.equals("condition"))
return loopCondition(node, ps);
else if (nodeName.equals("srai"))
return srai(node, ps);
else if (nodeName.equals("sr"))
return respond(ps.starBindings.inputStars.star(0), ps.that, ps.topic, ps.chatSession, sraiCount);
else if (nodeName.equals("sraix"))
return sraix(node, ps);
else if (nodeName.equals("set"))
return set(node, ps);
else if (nodeName.equals("get"))
return get(node, ps);
else if (nodeName.equals("map")) // AIML 2.0 -- see also <set> in pattern
return map(node, ps);
else if (nodeName.equals("bot"))
return bot(node, ps);
else if (nodeName.equals("id"))
return id(node, ps);
else if (nodeName.equals("size"))
return size(node, ps);
else if (nodeName.equals("vocabulary")) // AIML 2.0
return vocabulary(node, ps);
else if (nodeName.equals("program"))
return program(node, ps);
else if (nodeName.equals("date"))
return date(node, ps);
else if (nodeName.equals("interval"))
return interval(node, ps);
//else if (nodeName.equals("gossip")) // removed from AIML 2.0
// return gossip(node, ps);
else if (nodeName.equals("think"))
return think(node, ps);
else if (nodeName.equals("system"))
return system(node, ps);
else if (nodeName.equals("explode"))
return explode(node, ps);
else if (nodeName.equals("normalize"))
return normalize(node, ps);
else if (nodeName.equals("denormalize"))
return denormalize(node, ps);
else if (nodeName.equals("uppercase"))
return uppercase(node, ps);
else if (nodeName.equals("lowercase"))
return lowercase(node, ps);
else if (nodeName.equals("formal"))
return formal(node, ps);
else if (nodeName.equals("sentence"))
return sentence(node, ps);
else if (nodeName.equals("person"))
return person(node, ps);
else if (nodeName.equals("person2"))
return person2(node, ps);
else if (nodeName.equals("gender"))
return gender(node, ps);
else if (nodeName.equals("star"))
return inputStar(node, ps);
else if (nodeName.equals("thatstar"))
return thatStar(node, ps);
else if (nodeName.equals("topicstar"))
return topicStar(node, ps);
else if (nodeName.equals("that"))
return that(node, ps);
else if (nodeName.equals("input"))
return input(node, ps);
else if (nodeName.equals("request"))
return request(node, ps);
else if (nodeName.equals("response"))
return response(node, ps);
else if (nodeName.equals("learn") || nodeName.equals("learnf"))
return learn(node, ps);
else if (nodeName.equals("addtriple"))
return addTriple(node, ps);
else if (nodeName.equals("deletetriple"))
return deleteTriple(node, ps);
else if (nodeName.equals("javascript"))
return javascript(node, ps);
else if (nodeName.equals("select"))
return select(node, ps);
else if (nodeName.equals("uniq"))
return uniq(node, ps);
else if (nodeName.equals("first"))
return first(node, ps);
else if (nodeName.equals("rest"))
return rest(node, ps);
else if (nodeName.equals("resetlearnf"))
return resetlearnf(node, ps);
else if (nodeName.equals("resetlearn"))
return resetlearn(node, ps);
else if (extension != null && extension.extensionTagSet().contains(nodeName)) return extension.recursEval(node, ps) ;
else return (genericXML(node, ps));
} catch (Exception ex) {
ex.printStackTrace();
return "";
}
}
You would find a method like this one in program ab in AIMLProcessor class there you have to add the implementation of oob tags . this is the method which parses the response from aiml files based on what tags found in the response it call the necessary funtion
Related
How do I make coverage more than 75% using apex test class for this controller class. I try to write test class for this but, I'm not able to make its coverage as 75 or above 75. I am tried to cover its second method but its covers only 1 line of its try block i.e. Id recordId = hostId; Other part of code is not covered. It is only cover its catch block. So could you help me to make its coverage more than 75.
public with sharing class DocumentSelectorController {
#AuraEnabled(cacheable = true)
public static List<dmpl__CreateRelatedSetting__mdt> getCreateRelatedSettings(string objectApiName)
{
try {
return CreateRelatedSettingHelper.getCreateRelatedSettings(objectApiName);
} catch (Exception error) {
ExceptionLogHelper.logException(error);
throw error;
}
}
#AuraEnabled
public static List<SObject> getChildObjects(
Id recordSettingId,
Id hostId,
String searchKey)
{
try {
Id recordId = hostId;
return Database.query(
CreateRelatedSettingHelper.getSOQLQuery(
CreateRelatedSettingHelper.getCreateRelatedSetting(recordSettingId),
searchKey,
hostId
)
) ;
} catch (Exception error) {
ExceptionLogHelper.logException(error);
throw error;
}
}
#AuraEnabled
public static CreateRelatedResult releaseDocument(
Id recordSettingId,
Id hostId)
{
try {
dmpl__CreateRelatedSetting__mdt recordSetting = CreateRelatedSettingHelper.getCreateRelatedSetting(recordSettingId);
switch on recordSetting.dmpl__HostObjectId__r.QualifiedApiName {
when 'dmpl__SaleOrder__c'{
if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__InventoryFulfillment__c'){
return FulfillmentHelper.createFulfillmentFromSaleOrder(hostId);
}else if(recordSetting.dmpl__Tag__c == 'OTC' && recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__SaleInvoice__c'){
return SaleInvoiceHelper.createSaleInvoiceFromSaleOrder(hostId);
}else if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__SaleInvoice__c'){
return SaleInvoiceHelper.createSaleInvoiceFromAllocatedLines(hostId);
}
}
when 'dmpl__InventoryFulfillment__c'{
if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__InventoryFulfillment__c'){
return InventoryFulfillmentAllocationLineHelper.createAllocationFromFulfillment(hostId);
} else if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__DeliveryOrder__c'){
return SaleDeliveryHelper.createSaleDeliveryFromFulfillment(hostId);
}
}
when 'dmpl__PurchaseReturn__c'{
if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__DeliveryOrder__c'){
return SaleDeliveryHelper.createSaleDeliveryFromPurchaseReturn(hostId);
}
}
}
return new CreateRelatedResult('No handler attached');
} catch (Exception error) {
ExceptionLogHelper.logException(error);
throw error;
}
}
#AuraEnabled
public static CreateRelatedResult releaseChildDocuments(
Id hostId,
Id recordSettingId,
List<SourceObjectInfo> childObjectsInfo)
{
try {
dmpl__CreateRelatedSetting__mdt recordSetting = CreateRelatedSettingHelper.getCreateRelatedSetting(recordSettingId);
switch on recordSetting.dmpl__HostObjectId__r.QualifiedApiName {
when 'dmpl__SaleOrder__c'{
if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__InventoryFulfillment__c'){
return FulfillmentHelper.createFulfillmentFromSaleOrder(childObjectsInfo);
}
else if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__SaleInvoice__c'){
if(recordSetting.dmpl__Tag__c == 'OTC')
return SaleInvoiceHelper.createSaleInvoiceFromSaleOrder(childObjectsInfo);
else
return SaleInvoiceHelper.createSaleInvoiceFromAllocatedLines(childObjectsInfo);
} else if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__PurchaseOrder__c'){
return SaleOrderLineHelper.createSaleOrderLinesFromPurchaseOrder(childObjectsInfo, hostId);
}
}
when 'dmpl__InventoryFulfillment__c'{
if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__SaleOrder__c'){
return FulfillmentHelper.populateFulfillmentFromSaleOrder(childObjectsInfo, hostId);
} else if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__InventoryFulfillment__c'){
return InventoryFulfillmentAllocationLineHelper.createAllocationFromFulfillment(childObjectsInfo);
} else if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__DeliveryOrder__c'){
return SaleDeliveryHelper.createSaleDeliveryFromFulfillment(childObjectsInfo);
}
}
when 'dmpl__SaleReturn__c'{
if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__SaleInvoice__c'){
return SaleReturnHelper.createSaleReturnFromSaleInvoice(childObjectsInfo, hostId);
}
}
when 'dmpl__PurchaseReturn__c'{
if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__Bill__c'){
return PurchaseReturnHelper.createPurchaseReturnFromPurchaseInvoice(childObjectsInfo, hostId);
} else if(recordSetting.dmpl__RelatedObjectId__r.QualifiedApiName == 'dmpl__DeliveryOrder__c'){
return SaleDeliveryHelper.createSaleDeliveryFromPurchaseReturn(childObjectsInfo);
}
}
}
return new CreateRelatedResult('No handler attached');
} catch (Exception error) {
}
}
}
here the code
all operator can't be invoked because the receiver cab be 'null'
class Bmicalculator {
final height;
final weight;
double? _bmi;
Bmicalculator({this.height, this.weight});
String calculateBmi() {
double _bmi = weight / pow(height / 100, 2);
return _bmi.toStringAsFixed(1);
}
String getResult() {
if (_bmi >= 25) {
return 'overweight';
} else if (_bmi >= 18.5) {
return 'Normal';
} else {
return 'underWeight';
}
}
please solve the essue
use null safe !
String getResult() {
if (_bmi! >= 25) { // here need to change
return 'overweight';
} else if (_bmi! >= 18.5) {// here need to change
return 'Normal';
} else {
return 'underWeight';
}
}
On your class level, _bmi is nullable double double? _bmi;.
you can do it like
String getResult() {
if(_bmi==null){
return "got null on BMI";
}
else if (_bmi! >= 25) {
return 'overweight';
} else if (_bmi! >= 18.5) {
return 'Normal';
} else {
return 'underWeight';
}
}
! is use If you know that an expression never evaluates to null.
Learn more about null-safety
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
Does anyone know how to replace this code properly to the updated one
Starting from Unity 2020.2 you now use UnityWebRequest.result
Example from UnityWebRequest.Get
using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
{
// Request and wait for the desired page.
yield return webRequest.SendWebRequest();
string[] pages = uri.Split('/');
int page = pages.Length - 1;
switch (webRequest.result)
{
case UnityWebRequest.Result.ConnectionError:
case UnityWebRequest.Result.DataProcessingError:
Debug.LogError(pages[page] + ": Error: " + webRequest.error);
break;
case UnityWebRequest.Result.ProtocolError:
Debug.LogError(pages[page] + ": HTTP Error: " + webRequest.error);
break;
case UnityWebRequest.Result.Success:
Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text);
break;
}
}
Or the simplier example from UnityWebRequest.Post
WWWForm form = new WWWForm();
form.AddField("myField", "myData");
using (UnityWebRequest www = UnityWebRequest.Post("https://www.my-server.com/myform", form))
{
yield return www.SendWebRequest();
if (www.result != UnityWebRequest.Result.Success)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Form upload complete!");
}
}
I solve mine like that!
instead using: if(www.isNetworkError)
I wrote: if(www.result == UnityWebRequest.Result.ConnectionError)
Full example is below:
IEnumerator Get(string url)
{
using (UnityWebRequest www = UnityWebRequest.Get(url))
{
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.ConnectionError)
{
Debug.LogError(www.error);
}
}
}
Replace "www.isHttpError" with "(www.result== UnityWebRequest.Result.ProtocolError)" and "www.isNetworkError" with "(www.result == UnityWebRequest.Result.ConnectionError)".
Assuming www means the request object.
I'd like to have a function that checks to see if any of the text edit controller fields are null.
I wrote this method below, but I wanted to see if there was a more elegant solution.
bool _nullfieldExists(){
//return a true if any of the textEditController fields are null
if (_textEditControllerNumberPlayers.text == null ){
return true;
}
else if (_textEditControllerSmallBlind.text == null ){
return true;
}
else if (_textEditControllerBigBlind.text == null ){
return true;
}
else if (_textEditControllerAnte.text == null ){
return true;
}
else if (_textEditControllerMyStack.text == null ){
return true;
}
else {
return false;
}
}
Im trying to build flutter app
that has a feature which is using keypoint of posenet to detect some poses
I start from this code and modify BndBox class
https://heartbeat.fritz.ai/implementing-real-time-pose-estimation-on-mobile-using-flutter-af281d3740df
if (((kx[3] - kx[5]).abs() <= 0.05) &&
((kx[3] - kx[11]).abs() <= 0.1)) {
widget.setMsg = "this is right";
print("this is right");
} else if (((kx[3] - kx[5]) > 0.05 && (kx[3] - kx[5]) < 0.1) &&
(((kx[3] - kx[11]) > 0.1) && (kx[3] - kx[11]) < 0.2)) {
setState(() {
widget.setMsg = "this is right";
});
print("this is wrong ");
setState(() {
widget.setMsg = "this is wrongg";
});
widget.setMsg = "this is wrong";
} else {
setState(() {
widget.setMsg = "undefined";
});
widget.setMsg = "undefined";
print("undetected");
}
}
return lists;
}
return Stack(children: widget.model == posenet ? _renderKeypoints() : null);
now my program return list of widget (the ket point )I also want to return the msg("this is wrong ", "this is right"....
I tried to make the stack return the renderKeypoints() ((list of widget )) and widget text but it doesn't work
tried to make variable "msg="start" in my class and pass it to home class but its just keep "start " and did not change to the messages I assigned it to ...