Not able to catch slot color values in rasa - rasa-nlu

Hi I am not able to catch slot values in my custom action I have made a custom action that returns a slot set of the clinks ie. links that are correspoding to colors like red blue or black The clinks is a list of dict.Here is my run method
def run(self, dispatcher, tracker, domain):
clinks = [ {“color”: “red”,“link”:“Amazon.com: red shirts”}, {“color”: “blue”, “link”: “Amazon.com: blue shirts”}, {“color”:“black”,“link”:“Amazon.com: black shirts”} ]
color = tracker.get_slot(“color”)
print(color)
link = [c[“link”] for c in clinks if c[“color”] == color]
print(link)
dispatcher.utter_message("{}".format(link))
return [SlotSet("clinks", clinks)]
I am using spacy pipeline But the output of server shows that value of slot is None How to solve this problem

Related

Create Buttons and it's signals dynamically in Ruby GTK

i'm trying to make a Nurikabe puzzle with Ruby GTK and i'm having trouble creating button signals dynamically.
Basically, i have a matrix, some boxes have a number ( clicking them won't do anything), others can have one of 3 states (white, black or unplayed). The matrix can have different sizes so i did this :
def construction
# we get the width and height of the matrix
taille_hauteur = ##partie.grilleEnCours.hauteur
taille_largeur = ##partie.grilleEnCours.largeur
#boutons = {}
#We create a table which will include all of our buttons (one for each box of our matrix)
table = Table.new(taille_hauteur,taille_largeur,false)
# we go through our matrix
for i in 0..taille_largeur-1
for j in 0..taille_hauteur-1
# if the box has a number, we create a button with that number as a label
if ##partie.grilleEnCours.matriceCases[i][j].is_a?(CaseNombre)
# we add this button to a hash
#boutons[[i,j]] = Button.new(:label=> ##partie.grilleEnCours.matriceCases[i][j].to_s)
table.attach(#boutons[[i,j]], i, i+1, j, j+1)
else
# otherwise,we create and add a button to the hash without a label
#boutons[[i,j]] = Button.new()
# we create a signal, changing the state of the box of the matrix at the same coordinates as the button
#boutons[[i,j]].signal_connect('clicked'){
puts "#{i} #{j}"
# we change the box's state of the matrix
##partie.clicSurCase(i,j)
puts ##partie.grilleEnCours
# here we are just changing the label corresponding to the box's state
if(##partie.grilleEnCours.matriceCases[i][j].etat==0)
lab = ""
elsif (##partie.grilleEnCours.matriceCases[i][j].etat==1)
lab = "Noir"
else
lab = "Point"
end
#boutons[[i,j]].set_label(lab)
}
table.attach(#boutons[[i,j]], i, i+1, j, j+1)
end
end
end
#object.add(table)
end
The problem is, doing this, when we click any button, it will change the last box of the matrix and the last button's label (bottom right). I believe this is because Integers are objects in Ruby so clicking a button will change the box's state and button's state at the coordinates (i,j) (which are matrix height-1, matrix width-1) and not the values i and j had when we created the signal.
I have no idea how to link a button to a specific box of the matrix (knowing matrixes can have multiple sizes), could you help me on this one ?
It is quite hard to read such a large block of code - maybe start by chopping it into logic-based functions?
It will clear the code up.
you don't need to set "lab =" in each branch of if - just:
lab = if (i==1)
1
else
2
end
in additions - use "case" in this case. Once you split the code up - you will(probably) find the issue you have.
it will be easier to debbug.

Two colors in one string

Hi I'm trying to do a GUI code using GTK in Ruby and I'm stuck trying to change the color of a String.
I would like the Welcome to be blue and the #name to be red but I can't seem to figure out a way to get both of them
#user = Gtk::Label.new("Welcome #{#name}")
css_user = Gtk::CssProvider.new
css_user.load(data: "label{color: blue;}")
If anybody could help I would be really greatful
I had to change a little bit the gtk display
#box = Gtk::Box.new(:horizontal, 1)
#welcome = Gtk::Label.new("Welcome ")
#user = Gtk::Label.new(#usuari)
css_user = Gtk::CssProvider.new
css_user.load(data: "label{color: blue;}")
css_welcome = Gtk::CssProvider.new
css_welcome.load(data: "label{color: black;}")
#user.style_context.add_provider(css_user, Gtk::StyleProvider::PRIORITY_USER)
#welcome.style_context.add_provider(css_welcome, Gtk::StyleProvider::PRIORITY_USER)
As you can see I created two labels (one for each color) and I placed them inside a Horizontal Box

How can I create a static title/border on a Python cmd line application

I'm using the Python cmd module to create a CLI application. Everything works great! However, I'm attempting to tailor the app to a certain type of presence: text colors, title, using alpha-numeric characters as borders, etc.
Is there a standard way to create a screen overrun of sorts: the top of the screen where I have set a border and color title remain static? And from the middle of the screen, or thereabouts, down to the bottom of the screen, any text or commands entered at the prompt will stop being visible as they reach the title/border. Basically, what I'm after is for a user to always see the title/border unless they exit the CLI app. If they type help, of course, they will see the commands below the title/border. But, as they enter commands, ideally, the command menu will disappear behind the screen title/border.
Any direction on the best way I can achieve this is appreciated.
Check curses
You should be able to decorate CLI/Terminal with colors and static borders.
I have extended example taken from HERE:
import curses
from multiprocessing import Process
p = None
def display(stdscr):
stdscr.clear()
stdscr.timeout(500)
maxy, maxx = stdscr.getmaxyx()
curses.newwin(2,maxx,3,1)
# invisible cursor
curses.curs_set(0)
if (curses.has_colors()):
# Start colors in curses
curses.start_color()
curses.use_default_colors()
curses.init_pair(1, curses.COLOR_RED, -1)
stdscr.refresh()
curses.init_pair(1, 0, -1)
curses.init_pair(2, 1, -1)
curses.init_pair(3, 2, -1)
curses.init_pair(4, 3, -1)
bottomBox = curses.newwin(8,maxx-2,maxy-8,1)
bottomBox.box()
bottomBox.addstr("BottomBox")
bottomBox.refresh()
bottomwindow = curses.newwin(6,maxx-4,maxy-7,2)
bottomwindow.addstr("This is my bottom view", curses.A_UNDERLINE)
bottomwindow.refresh()
stdscr.addstr("{:20s}".format("Hello world !"), curses.color_pair(4))
stdscr.refresh()
while True:
event = stdscr.getch()
if event == ord("q"):
break
def hang():
while True:
temp = 1 + 1
if __name__ == '__main__':
p = Process(target = hang)
curses.wrapper(display)

Dynamically change background colour of a Dashing widget

I've built a dashboard using the ruby based Dashing framework and all seems to be running well but I'd like to be able to change the background colour of one of my List widgets (mywidget) based on one of the values in the list.
My updatelist.rb job file currently looks like:
hashdata = Hash.new({ value: 0 })
SCHEDULER.every '10s' do
File.open('xxx.txt').each do |line|
field = line.split(;).first
value = line.split(;).last
if ['Status', 'Active', 'Duration].include? field
hashdata[field] = { label: field, value: value }
end
end
send_event('mywidget', { items: hashdata.values })
end
The file it is reading (xxx.txt) is formatted like:
Status; Good
Active; No
Duration; 1000
I'd like change the background colour of the list widget based on the value of Status i.e. Good=green, Average=yellow, Poor=red.
How can I do this? Adding something to the coffee script seems the obvious solution but I can't see how to achieve it
You are correct about needing code in the coffeescript. I suggest something like the following:
class Dashing.List extends Dashing.List
color: () ->
data = #get('items')
status = # code to process color from your data (I'm not sure exactly your format)
switch status
when "Good" then "#33cc33" # green
when "Average" then "#ffff00" # yellow
when "Poor" then "#ff0000" # red
else "#000000"
onData: (data) ->
# change the background color every time that new data is sent
$(#get('node')).css 'background-color', #color()

Highlight orders with different status on orders page

On the Magento Admin back end , Sales>orders it then it displays a list of orders . Based on the order status , I would like to assign different background to it , or any noticeable way to to visually differentiate different orders based on their status.
Like pending order have a Red Background or some red tick mark , while a completed order with green background or green tick and so on ..
Proper way or any quick fix will do either
Quick fix: app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php, add this function:
public function getRowClass($row)
{
return $row->getStatus();
}
This adds the order's Status as a table row CSS class. Then you can throw some CSS into skin/adminhtml to do whatever you want with the row classes. To override the default background color I used this CSS:
.grid .data .<status> {background-color: somecolor;}

Resources