watson conversation check entity exists - entity

I want to check if an entity is part of the users input.
Example:
entities['#PRODUKT_INTENT_STOP_LIST']?.contains($variables.tmpEntity)
As you can see by this example, the value of the entity#PRODUKT_INTENT_STOP_LIST
is a variable. I put this at a condition for a node, but this is not working.
If I use a hardcoded string instead of the variable it is working fine.
entities['#PRODUKT_INTENT_STOP_LIST']?.contains('Chart') works fine
but setting $variables.tmpEntity to 'Chart' a and then ask for
entities['#PRODUKT_INTENT_STOP_LIST']?.contains($variables.tmpEntity)
is not working.
Can someone tells me what's wrong here?

Still trying to understand what you are trying to do.But if you want to check whether an entity exist in your input or not you can do it by applying condition on size of that entity.
"context":{
"size":"<?#Entity.size()?>"
}
now if size is equals to 0 then entity does not exist.
I know this is a longer way but it also tells you how many times does that entity exist in your input.

Hi I used the wrong statement.
This statement should work:
entities[PRODUKT_INTENT_STOP_LIST]?.get($variables.countEntity).value==$variables.$variables.tmpEntity
$variables.countEntity : counter to iterate thru entity array #PRODUKT_INTENT_STOP_LIST to check if an entity value is equal $variables.tmpEntity
Regards

Related

Different parameter count in FORM and PERFORM

I am trying to add a formal parameter in the FORM and PERFORM in an existing code, as I will be need it the extra parameter in a new function that I have to call. The idea is that when executing the new code it keeps showing the error: Different parameter count in FORM and PERFORM (routine: CM_SHOW_CRC, number of formal parameters: 2, number of actual parameters: 3).
The code that I have for the form part is as follows:
FORM cm_show_crc
USING
civ_matnr TYPE matnr
civ_charg TYPE charg_d
civ_werks TYPE werks_d. "The parameter that I added
And the perform code is:
PERFORM cm_show_crc
USING
pis_sdow_alv-matnr
pis_sdow_alv-charg
pis_sdow_alv-werks. "The parameter that I added
The table pis_sdow_alv is type of a structure that also includes the variable WERK(Component type WERKS_D)
Before adding the new parameter WERK the code was working fine.
May anyone know what the problem in this part of the code may be?
There was also another similar question in: Different number of parameters in FORM and PERFORM, however I am not using the syntax CHANGING in my code, as it was also not used prior.
Please do tell me if you need additional information.
Thank you all in advance!
This problem can occur when FORM and PERFORM are in different includes and you only activate one but not the other.
When you activate an include, then it is checked against the active version of all other repository objects it depends on. Not the saved version. This can lead to an annoying catch-22 situation. You can not activate A because it does not match the previous version of B, and you can not activate B because it does not match the previous version of A.
The solution to this conundrum is to activate both objects together. When you activate something in SE80 and you have multiple inactive objects, you get a window where you can select multiple objects to activate together:
In Eclipse, you get a similar list by clicking on the "activate multiple" button:

Cypher-Neo4j Node Single Property change to Array

Following is a Node we having in DB
P:Person { name:"xxx", skill:"Java" }
and after awhile, we would like to change the Skill to skill array, is it possible?
P:Person { name:"xxx", skill:["Java", "Javascript"] }
Which Cypher query should I use?
If you have a single skill value in skill, then just do
MATCH (p:Person)
WHERE HAS (p.skill)
SET p.skill=[p.skill]
If there are multiple values you need to convert to an array such as P:Person { name:"xxx", skill:"Java","JavaScript" } then this should work:
MATCH (p:P)
SET p.skill= split(p.skill,",")
In fact, I think your real problem here is not how to get an array property in a node, but how to store it. Your data model is wrong in my opinion, storign data as array in neo4j is not common, since you have relations to store multiple skills (in your example).
How to create your data model
With your question, I can already see that you have one User, and one User can have 1..n skills.
I guess that one day (maybe tomorrow) you will need to know which users are able to use Java, C++, PHP, and every othre skills.
So, Here you can already see that every skill should have its own node.
What is the correct model in this case?
I think that, still with only what you said in question, you should have something like this:
(:Person{name:"Foo"})-[:KNOWS]->(:Skill{name:"Bar"})
using such a data model, you can get every Skill known by a Person using this query:
MATCH (:Person{name:"Foo"})-[:KNOWS]->(skill:Skill)
RETURN skill //or skill.name if you just want the name
and you can also get every Person who knows a Skill using this:
MATCH (:Skill{name:"Bar"})<-[:KNOWS]-(person)
RETURN person //Or person.name if you just want the name
Keep in mind
Storing array values in properties should be the last option when you are using neo4j.
If a property can be found in multiple nodes, having the same value, you can create a node to store it, then you will be able to link it the other nodes using relations, and finding every node having the property X = Y will be easier.

A way to check if a category is a last level node in category.tpl, prestashop

I know it is possible to know what depth you are at with $category->depth, but is there a straght-forward way to check if it is indeed last level node?
Thanks
Within the category class there is a method called getLastPosition. It requires two parameters to be passed, but if you can get those it looks to me like it returns an integer of the last position. If depth also returns an integer then you should be able to compare the two to see if it comes out true.
You will need to pass the id of the parent category and the id of the shop to the getLastPosition method for it to work.
{if $category->getLastPosition($id_parent, $id_shop) == $category->depth}
{/if}
I think that should work, however I did not test it.

How do you get the field name, instead of the value, from the model?

Suppose I have a Model Class named Anything, in Yii, and all I want is to get not the field value, but the field name, how could I do that?
Because using something like:
$anything = new Anything;
$anything->field_name;
Returns the value of that field, which is the purpose for that, still, if all you want is the string of the name of the field, how could you do that?
I tried using:
$anything->attributes;
But it just returns an array of field names, I want to try and get a specific value as a defined constant.
What I want to do is use the $_POST with specific and practical use, so I wouldn't need to use:
$_POST["Model_name"];
Instead I could use:
$_POST[Anything::model()->name][Anything::model()->field_name->name]
Which seems a lot better than "" and '' here and there. Mostly because I'm trying to set multiple fieldsets of different Models in the same formulary.
So if I could use:
$_POST[Anything::model()->name][Anything::model()->field_name->name];
and
$_POST[Something::model()->name][Something::model()->field_name->name]
and
$_POST[Godspeed::model()->name][Godspeed::model()->field_name->name]
It would save a lot of problems I might had in the future.
$strModelName = 'ModelName'; //dynamic - whatever model name you put in it
$find_id = 3;
$record = $strModelName::model()->findByPK($find_id); //it's same with ModelName::model()->findByPK(3)
foreach($record->attributes as $key=>$value){
var_dump($_POST[$strModelName][$key]); //get value corresponding to given key
}
Btw, you still need check whether the model is exist or not
http://www.yiiframework.com/forum/index.php/topic/22790-check-if-model-exists/

Newbie issue with LINQ in vb.net

Here is the single line from one of my functions to test if any objects in my array have a given property with a matching value
Return ((From tag In DataCache.Tags Where (tag.FldTag = strtagname) Select tag).Count = 1)
WHERE....
DataCache.Tags is an array of custom objects
strtagname = "brazil"
and brazil is definitely a tag name stored within one of the custom objects in the array.
However the function continually returns false.
Can someone confirm to me that the above should or should not work.
and if it wont work can someone tell me the best way to test if any of the objects in the array contain a property with a specific value.
I suppose in summary I am looking for the equivalent of a SQL EXISTS statement.
Many thanks in hope.
Your code is currently checking whether the count is exactly one.
The equivalent of EXISTS in LINQ is Any. You want something like:
Return DataCache.Tags.Any(Function(tag) tag.FldTag = strtagname)
(Miraculously it looks like that syntax may be about right... it looks like the docs examples...)
Many Thanks for the response.
Your code did not work. Then I realised that I was comparing to an array value so it would be case sensitive.
However glad I asked the question, as I found a better way than mine.
Many thanks again !