I want to reference a specific part of a shape. For example: From Best Apple to Basket 1, instead of apple_node to Basket 1.
The below image will better explain what I wish to achieve.
https://imgur.com/a/B0TEoWO
This is my graphviz code and what I have achieved so far:
digraph fruits {
node [shape=record]
apple_node [label="Apple | {{Best Apple} | {Worst Apple}}"];
banana_node [label="Banana | {{Best Banana} | {Worst Banana}}"];
basket1_node [label="basket1|{Colour 10 | Seeds 10}"];
basket2_node [label="basket2|{Colour 10 | Seeds 10}"];
apple_node -> basket1_node;
banana_node -> basket2_node;
}
Since you are using record-based nodes, you can add field id's to the label and use them as portnames which indicate where to attach an edge to (see also the official documentation about record-based nodes).
Example:
examplenode [shape=record; label="<fieldid1> one|<fieldid2> two"];
examplenode:fieldid1 -> othernode;
Your apple-banana example:
digraph fruits {
node [shape=record]
apple_node [label="Apple | {{<bestapple>Best Apple} | {<worstapple>Worst Apple}}"];
banana_node [label="Banana | {{Best Banana} | {<worstbanana>Worst Banana}}"];
basket1_node [label="basket1|{Colour 10 | Seeds 10}"];
basket2_node [label="basket2|{Colour 10 | Seeds 10}"];
apple_node:bestapple -> basket1_node;
apple_node:worstapple -> basket1_node;
banana_node:worstbanana -> basket2_node;
}
Related
module Digits
type Digit = Unison | Semitone | Tone | MinorThird | MajorThird | PerfectFourth | AugmentedFourth | PerfectFifth | MinorSixth | MajorSixth | MinorSeventh | MajorSeventh type 'd GeneralizedDigit = SmallDigit of 'd | Octave type 't Number = EmptyNumber | CountedNumber of 't * 't Number
let swapOctave: Digit GeneralizedDigit -> Digit GeneralizedDigit = fun x -> match x with SmallDigit Unison -> Octave | Octave -> SmallDigit Unison | g -> g
let limitLength: 'r Number -> Digit = fun a -> match a with EmptyNumber -> Unison | CountedNumber(_,EmptyNumber) -> Semitone | CountedNumber(_,CountedNumber(_,EmptyNumber)) -> Tone | CountedNumber(_,CountedNumber(_,CountedNumber(_,EmptyNumber))) -> MinorThird | _ -> MajorSeventh
In F# I can put multiple type definitions on the same line without semicolons without any problems, but when I remove the newline between the let statements I get the error FS0010. I know that in Haskell statements can be separated by a single semicolon but in F# neither a single semicolon nor a double semicolon will work. How do I have multiple let statements on the same line?
You can do this with the let .. in syntax like so:
let f () = let a = 1 in let b = 2 in a + b
f () // gives 3 as a result
But I would really recommend against doing multiple single-line definitions like this. It's hard for people to read.
If you want multiple let bindings to bound values to variables, then you also can use the "tuple syntax".
let x,y,z = 1, "Hi", 3.0
As explained by Phillip, the let .. in .. construct allows you to define a local variable as part of a one-line expression.
However, your example seems to be trying to define multiple top-level definitions in a module, which is something you cannot achieve with let .. in ...
As far as I can tell, you can actually do this by separating the definitions with two semicolons, i.e. ;;. If I save the following as test.fs and load it using #load, I get no errors:
module Digits
type Digit = Unison | Semitone | Tone | MinorThird | MajorThird | PerfectFourth | AugmentedFourth | PerfectFifth | MinorSixth | MajorSixth | MinorSeventh | MajorSeventh type 'd GeneralizedDigit = SmallDigit of 'd | Octave type 't Number = EmptyNumber | CountedNumber of 't * 't Number
let swapOctave: Digit GeneralizedDigit -> Digit GeneralizedDigit = fun x -> match x with SmallDigit Unison -> Octave | Octave -> SmallDigit Unison | g -> g;; let limitLength: 'r Number -> Digit = fun a -> match a with EmptyNumber -> Unison | CountedNumber(_,EmptyNumber) -> Semitone | CountedNumber(_,CountedNumber(_,EmptyNumber)) -> Tone | CountedNumber(_,CountedNumber(_,CountedNumber(_,EmptyNumber))) -> MinorThird | _ -> MajorSeventh
I tested this in F# 5.0. It may be the case that this has changed in F# 6 which removed deprecated features like #light "off". The removal of ;; is not discussed in the post, but it may have been a related change. If that is the case, you may report it as a regression - but it is likely support for ;; should also be removed!
As mentioned by Phillip, I do not see any reason for actually trying to do this.
I have the following search:
_sourceCategory="/api/SQLWatch" AND "'checktype':'AGDetails'"
| parse "'synchronization_pair':''" as synchronization_pair
| parse "'Database_Name':''" as Database_Name
| parse "'synchronization_health_desc':''" as synchronization_health_desc
| parse "'AG_Name':''" as AG_Name
| parse "'DAG':'*'" as DAG
| IF (synchronization_health_desc = "HEALTHY", 1, 0) as isHealthy
| first(_messagetime) group by synchronization_pair, Database_Name, synchronization_health_desc, AG_Name, DAG, isHealthy
which produces results like this:
synchronization_pair Database_Name synchronization_health_desc AG_Name DAG Healthy
ServerA-ServerB DB1 HEALTHY AG1 No 1
ServerC-ServerD DB2 UNHEALTHY AG2 Yes 0
When I add a honeycomb panel to my dashboard with this search all the honeycombs are blue.
I add the following settings to my Visual Settings and they are still blue.
1 to 1 GREEN
0 to 0 RED
Please help.
Thanks.
Charles.
i figured it out!
the column in the first() is the value used for the visual settings
i changed the last line to the following and it works now!!!
| first(isHealthy) group by synchronization_pair, Database_Name, synchronization_health_desc, AG_Name, DAG //, isHealthy
Given a trained contextual bandit model, how can I retrieve a prediction vector on test samples?
For example, let's say I have a train set named "train.dat" containing lines formatted as below
1:-1:0.3 | a b c # <action:cost:probability | features>
2:2:0.3 | a d d
3:-1:0.3 | a b e
....
And I run below command.
vw -d train.dat --cb 30 -f cb.model --save_resume
This produces a file, 'cb.model'. Now, let's say I have a test dataset as below
| a d d
| a b e
I'd like to see probabilities as below
0.2 0.7 0.1
The interpretation of these probabilities would be that action 1 should be picked 20% of the time, action 2 - 70%, and action 3 - 10% of the time.
Is there a way to get something like this?
When you use "--cb K", the prediction is the optimal arm/action based on argmax policy, which is a static policy.
When using "--cb_explore K", the prediction output contains the probability for each arm/action. Depending the policy you pick, the probabilities are calculated differently.
If you send those lines to a daemon running your model, you'd get just that. You send a context, and the reply is a probability distribution across the number of allowed actions, presumably comprising the "recommendation" provided by the model.
Say you have 3 actions, like in your example. Start a contextual bandits daemon:
vowpalwabbit/vw -d train.dat --cb_explore 3 -t --daemon --quiet --port 26542
Then send a context to it:
| a d d
You'll get just what you want as the reply.
In the Workspace Class, initialize the object and then call the method predict(prediction_type: int). Below are the corresponding parameter values
class PredictionType(IntEnum):
SCALAR = pylibvw.vw.pSCALAR
SCALARS = pylibvw.vw.pSCALARS
ACTION_SCORES = pylibvw.vw.pACTION_SCORES
ACTION_PROBS = pylibvw.vw.pACTION_PROBS
MULTICLASS = pylibvw.vw.pMULTICLASS
MULTILABELS = pylibvw.vw.pMULTILABELS
PROB = pylibvw.vw.pPROB
MULTICLASSPROBS = pylibvw.vw.pMULTICLASSPROBS
DECISION_SCORES = pylibvw.vw.pDECISION_SCORES
ACTION_PDF_VALUE = pylibvw.vw.pACTION_PDF_VALUE
PDF = pylibvw.vw.pPDF
ACTIVE_MULTICLASS = pylibvw.vw.pACTIVE_MULTICLASS
NOPRED = pylibvw.vw.pNOPRED
I am trying to use NLTK package to capture the following chunk in a sentence:
verb + smth + noun
or it may be
verb + smth + noun + and + noun
I truthfully spent entire day messing with regex, but still nothing proper is produced..
I was looking at this tutorial which wasn't much of help.
When you have an idea of what those somethings that might come in between are, there is a relatively easy method using NLTK's CFG. This is most certainly not the most efficient way. For a comprehensive analysis, consult NLTK's book on chapter 8.
We have two patterns as you mentioned:
<verb> ... <noun>
<verb> ... <noun> "and" <noun>
We should assemble a list of VPs and NPs and also the range of possible words that could happen in between. As a silly little example:
grammar = nltk.CFG.fromstring("""
% start S
S -> VP SOMETHING NP
VP -> V
SOMETHING -> WORDS SOMETHING
SOMETHING ->
NP -> N 'and' N
NP -> N
V -> 'told' | 'scolded' | 'loved' | 'respected' | 'nominated' | 'rescued' | 'included'
N -> 'this' | 'us' | 'them' | 'you' | 'I' | 'me' | 'him'|'her'
WORDS -> 'among' | 'others' | 'not' | 'all' | 'of'| 'uhm' | '...' | 'let'| 'finish' | 'certainly' | 'maybe' | 'even' | 'me'
""")
Now suppose this is the list of the sentences we want to use our filter against:
sentences = ['scolded me and you', 'included certainly uhm maybe even her and I', 'loved me and maybe many others','nominated others not even him', 'told certainly among others uhm let me finish ... us and them', 'rescued all of us','rescued me and somebody else']
As you can see, the third and the last phrases don't pass the filter. We can check whether the rest match the pattern:
def sentence_filter(sent, grammar):
rd_parser = nltk.RecursiveDescentParser(grammar)
try:
for p in rd_parser.parse(sent):
print("SUCCESS!")
except:
print("Doesn't match the filter...")
for s in sentences:
s = s.split()
sentence_filter(s, grammar)
When we run this, we get this result:
>>>
SUCCESS!
SUCCESS!
Doesn't match the filter...
SUCCESS!
SUCCESS!
SUCCESS!
Doesn't match the filter...
>>>
If i have a table in a WebFocus Raport design
+--------+---------+--------+---------+
| left_1 | right_1 | left_2 | right_2 |
+--------+---------+--------+---------+
| v11 | p11 | v21 | v21 |
+--------+---------+--------+---------+
| v12 | p12 | v22 | v22 |
....
How to do a such table with syllabus column titles:
+-------+-------+-------+-------+
| One | Two |
+-------+-------+-------+-------+
| left | right | left | right |
+-------+-------+-------+-------+
| v11 | p11 | v21 | v21 |
+-------+-------+-------+-------+
| v12 | p12 | v22 | v22 |
....
Thank you
Sorry for the delay of the answer :)
To rename columns, with the AS command. Example:
TABLE FILE SYSTABLE
PRINT NAME
COMPUTE LEFT1/A3 = 'v11'; AS 'left';
COMPUTE RIGHT1/A3 = 'p11'; AS 'right';
COMPUTE LEFT2/A3 = 'v21'; AS 'left';
COMPUTE RIGHT2/A3 = 'p21'; AS 'right';
IF RECORDLIMIT EQ 10
END
To put the heading columns, you can work with the ACROSS command but it will be more tricky that if u use simply SUBHEAD. With the same example:
TABLE FILE SYSTABLE
PRINT NAME NOPRINT
COMPUTE LEFT1/A3 = 'v11'; AS 'left';
COMPUTE RIGHT1/A3 = 'p11'; AS 'right';
COMPUTE LEFT2/A3 = 'v21'; AS 'left';
COMPUTE RIGHT2/A3 = 'p21'; AS 'right';
IF RECORDLIMIT EQ 10
ON TABLE SUBHEAD
"<+0>One<+0> Two"
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN, PAGESIZE='Letter',
LEFTMARGIN=0.500000, RIGHTMARGIN=0.500000,
TOPMARGIN=0.500000, BOTTOMMARGIN=0.500000,
SQUEEZE=ON, GRID=OFF, ORIENTATION=LANDSCAPE, $
TYPE=REPORT,FONT='ARIAL',SIZE=9,$
TYPE=TABHEADING,HEADALIGN=BODY,$
TYPE=TABHEADING, LINE=1, ITEM=1, COLSPAN=2, SQUEEZE=ON,$
TYPE=TABHEADING, LINE=1, ITEM=2, COLSPAN=2, SQUEEZE=ON,$
ENDSTYLE
END
Hope it helps!
I'm not entirely sure if you load the headers as a field or if that is the field name
But this might help you
Define fields
TITL1/A3 = 'One';
TITL2/A3 = 'Two';
BLANK/A1 = '';
Edit the Left and Right title fields to remove the _1 or _2
Print the fields BY BLANK NOPRINT
Add
ON BLANK SUBHEAD
"
You can also add more rows to the subhead if you need more titles
You can easily do it by embedding HTML/CSS scripts in report(.fex) file.
just add the HTML/css code at the end of the file.
For eg.
-HTMLFORM BEGIN // to start styling your generated report table with HTML/CSS
TABLE tr
td:first-child // applies on 1st row ONLY.It can be td or th.
{
colspan = "2"; //to merge 2 columns
}
-HTMLFORM END //end HTML.
So the first row must have two cells having title "ONE" and "TWO"(in your case), and both cells must have property of colspan = "2"
Also you can refer:
Colspan propery from here
manipulating first row of table from here
Second option is to write the whole code in a file and save it in .htm/.html format and just insert the file in to WEBFOCUS(.fex) file.For eg.
-HTMLFORM BEGIN
-INCLUDE HTML_FILE.HTML
-HTMLFORM END
Hope it helps.Thanks.