Context Free Grammar for a specific lanuage - grammar

I want a context free grammar for the language L={ww | w belongs to 0*10*}.
I tried the following grammar:
S->K1KK1K
K->0K | 1K | e
but i know that is wrong. Can anyone help me please?

S->A1A
A->BA|e
B->0
As you can see , here A->BA represents 0*(0 closure).

Related

How can I put several extracted values from a Json in an array in Kusto?

I'm trying to write a query that returns the vulnerabilities found by "Built-in Qualys vulnerability assessment" in log analytics.
It was all going smoothly I was getting the values from the properties Json and turning then into separated strings but I found out that some of the terms posses more than one value, and I need to get all of them in a single cell.
My query is like this right now
securityresources | where type =~ "microsoft.security/assessments/subassessments"
| extend assessmentKey=extract(#"(?i)providers/Microsoft.Security/assessments/([^/]*)", 1, id), IdAzure=tostring(properties.id)
| extend IdRecurso = tostring(properties.resourceDetails.id)
| extend NomeVulnerabilidade=tostring(properties.displayName),
Correcao=tostring(properties.remediation),
Categoria=tostring(properties.category),
Impacto=tostring(properties.impact),
Ameaca=tostring(properties.additionalData.threat),
severidade=tostring(properties.status.severity),
status=tostring(properties.status.code),
Referencia=tostring(properties.additionalData.vendorReferences[0].link),
CVE=tostring(properties.additionalData.cve[0].link)
| where assessmentKey == "1195afff-c881-495e-9bc5-1486211ae03f"
| where status == "Unhealthy"
| project IdRecurso, IdAzure, NomeVulnerabilidade, severidade, Categoria, CVE, Referencia, status, Impacto, Ameaca, Correcao
Ignore the awkward names of the columns, for they are in Portuguese.
As you can see in the "Referencia" and "CVE" columns, I'm able to extract the values from a specific index of the array, but I want all links of the whole array
Without sample input and expected output it's hard to understand what you need, so trying to guess here...
I think that summarize make_list(...) by ... will help you (see this to learn how to use make_list)
If this is not what you're looking for, please delete the question, and post a new one with minimal sample input (using datatable operator), and expected output, and we'll gladly help.

adding (|) functionality to determiner on GF

On GF writing sentences' tree often encounter many options where multiple prepositions could be used in the same tree such as
Download it on my phone
Download it to my phone
Download it onto my phone
... and the list goes on and on.
this kind of problem could be solved as below
(on_Prep|to_Prep|...)
But in some situations, this problem occurs with determiners such as
Eat the food
Eat food
I know the meaning of the above sentences is not exactly the same but is there any way to accomplish such a goal?
I tried the following but it seemed unlogical.
mkNP
(the_Det|)
(mkN ("food"))
I also tried to add an empty string for determiner such as mkDet (mkDigits (""))
but unfortunately, the above two ways seem not smart enough.😁😁
Your general approach with using | is correct.
There is no empty determiner, but rather another overload instance of mkNP. There's one with a determiner (so Det -> N -> NP) and another without, just N -> NP. So you can do this:
eat_food_VP : VP =
mkVP eat_V2 (mkNP the_Det food_N | mkNP food_N) ;

Feature level data table in cucumber

I have a situation where I need to have multiple scenarios within the same feature file and I need them to share the data table so that the user need not enter the same test data in all the relevant data tables in that feature.
Eg:
Feature: ABC
Scenario : 1
<<Steps of Scenario>>
Enter the data here:
|fieldNickName|fieldValue|
|ABC | <aaa> |
<<Steps of Scenario>>
Examples:
|AAA|
|111|
Scenario : 2
<<Steps of Scenario>>
Enter the data here:
|fieldNickName|fieldValue|
|ABC | <aaa> |
|DEF | <bbb> |
<<Steps of Scenario>>
|HIJ | <ccc> |
<<Steps of Scenario>>
Examples:
|AAA|BBB|CCC|
|111|232|AJ|
Here as you can see, "ABC" is a shared parameter & AAA its value between both scenarios. Is there a way I can have a "COMMON" Examples section for a Feature which can feed to all the scenarios in it?
The way to do this is to take the examples out of the feature and push them down into the step definitions. I could explain this in greater details if you provided the actual scenarios with their steps and explained the business context behind them.
Your cuking can be much simpler if avoid using examples and outlines. There really is no need to make things so complicated. Scenarios should be clear, simple and descriptive. They should talk about WHAT you are doing not HOW it is done.
I do not think there is a way for having the common Example parameters. I am not sure about your scenario but if you are using the same step with same data in all the scenarios, you can make them a part of Background

How to put a value in Scenario Outline Examples (karate framework)?

In my feature I have:
* def loc = responseHeaders['location'][10]
* def id = loc.substring(loc.lastIndexOf('/') + 1)
And I would like to use id in scenario outline examples:
Scenario Outline: fkdfslqknfd
Given url 'foo.com'
And path <bar>
When method get
......
Examples:
|bar |
|(id)|
|"id"|
|'id'|
|id |> The last example is ok.
But instead of receiving 'foo.com/13' (assuming that id is 13) I have 'foo.com/id'. I tried with #, but it doesn't work. How I can replace this id? I need to test this id put in String format. Thanks
At least within JSON parameter, it was working for me
Examples:
| request_body |
| {username: '#(email)', password: '#(password)'} |
This is a known limitation of Cucumber, that the Examples cannot be dynamic. Refer to this last paragraph of the documentation: https://github.com/intuit/karate#the-karate-way
If you are really trying to loop over a feature with different values, again, refer to the above doc, and there are plenty of examples if you look around. Look at all the ones that start with call- here: https://github.com/intuit/karate/tree/master/karate-demo

Creating a string from a path

I have a chain of nodes, e.g.
{Name: 'X'}->{Name: 'Y'}->{Name: 'Z'}
and I'd like to create a string representing the path in cypher (I know I can do it client-side but I want to do it in a query) that would look like this:
'X->Y->Z'
is that feasible? I've investigated use of collect() and UNWIND, and have googled till I'm blue in the face
thoughts?
* Edit I *
as an addendum (and to make the problem more difficult) my query is going to return a collection of paths (a tree, a DAG), so I'll need to create a string for each of the paths in the tree
REDUCE is your friend here:
WITH reduce(s="",n in nodes(p) | s+n.name+"->") as str
RETURN substring(str,0,length(str)-2)
or if you want to save the extra operation
RETURN reduce(s=head(nodes(p)).name, n in tail(nodes(p)) | s+"->"+n.name)
or with APOC
RETURN apoc.text.join([n in nodes(p) | n.name],"->")
found an old posting (2014) from Michael Hunger with the answer:
http://grokbase.com/t/gg/neo4j/147ch1nj9b/concatenate-nodes-properties