I Have problem with searching results in system Y related with my system X (REST API).
Unfortunately I haven't got known about system Y and I haven't got any documentation.
Only what I've got is query given above:
Do You know this notation? Maybe it's some familiar syntax for queries in some language or API.
Expected result:
Typing "John Doe" gives me list of all Johns Doe
Current Result:
Typing "John Doe" gives me list of all Johns that's slows down my system. (lastName is omitted)
Related
I am creating a discord bot with NodeJs and I want to utilize the commander.js package to make the commands a bit more structured.
I want to declare a param to give a username, eq('-u, --user <USERNAME>', 'the user to handle').
This works great, until the username consists of more than 1 word. eq. John Doe. what happens is that after parsing the arguments I get a ('-u' == 'John') and I have a leftover argument array with the word 'Doe' in it.
I have tried passing the username between quotes. eqnode program -u "John Doe" but the result is the same.
Am I missing something or is commander.js not capable of handling multi word arguments?
Turns out the args where wrongly splitted in another part of my bot. so this isn't an issue with either NodeJS or commander.js.
#Mods this question can be closed
We are working on as Alexa Skill which references information by a letter+number sequence. For example, we want to ask "Give me the status of item B1".
We have tried several ways to sort out the "B1" in our Alexa intent configuration, but we are getting very inconsistent (and usually wrong) results.
Our latest attempt was to create a "letters" slot and a "numbers" slot and create our invocation such as: give me the status of {letter} {number} but again, we usually get our slots back with no value in the JSON - or often Alexa will send JSON that contains values that are not in our slot definitions. If I say "B1", Alexa might return "viva" or some other random word.
The problem is in Alexa's interpretation of the voice. If we use the test text entry in the developer console, it (usually) works as expected.
Has anyone had success with letter/number combinations like this?
Ran into similar issues developing a "battleship"-like game: https://www.amazon.com/Josep-Valls-Vargas-Audio-Battleship/dp/B01KJ91K5U/ref=sr_1_3
You are doing it the right way, separate slots for letter and number. Although numbers were usually recognized right, the letters were much more tricky (specially the letter E for some reason). The only thing that worked was to allow users to use arbitrary words and/or a phonetic alphabet. Then in my skill I just slice the first letter of the recognized word.
"intent": "ShootIntent"
"slots": [
{
"name": "Column",
"type": "LIST_OF_COLUMNS"
},
{
"name": "Row",
"type": "AMAZON.NUMBER"
}
],
Then, LIST_OF_COLUMNS is something like: a Adams Alpha b Beta Boston Bravo c Charlie Chi Chicago d Delta Denver e Easy Echo Epsilon f Foxtrot Frank g Gamma George Golf h Henry Hotel i Ida India Iota j John Juliet k Kappa Kilo King l Lambda Lima Lincoln...
In this other similar game I added several alternatives in the sample utterances and added words used within the game: https://www.amazon.com/Josep-Valls-Vargas-Easy-Hangman/dp/B06VY1TK8L/ref=sr_1_2
Try using correct Slot type. AMAZON.Number and AMAZON.firstName are two different slot types.
Also, you can use SSML for this, to make Alexa speak numbers and words.
I have an extern API sending info to my Prolog application and I found a problem creating my facts.
When the information received is extensive, Prolog automatically adds ' (single quotes) to that info.
Example: with the data received, the fact I create is:
object(ObjectID,ObjectName,'[(1,09:00,12:00),(2,10:00,12:00)]',anotherID)
The fact I would like to create is
object(ObjectID,ObjectName,[(1,09:00,12:00),(2,10:00,12:00)] ,anotherID)
without the ' before the list.
Does anyone know how to solve this problem? With a predicate that receives '[(1,09:00,12:00),(2,10:00,12:00)]' and returns [(1,09:00,12:00),(2,10:00,12:00)]?
What you see is an atom, and you want to convert it to a term I think.
If you use swi-prolog, you can use the builtin term_to_atom/2:
True if Atom describes a term that unifies with Term. When Atom is instantiated, Atom is parsed and the result unified with Term.
Example:
?- term_to_atom(X,'[(1,09:00,12:00),(2,10:00,12:00)]').
X = [ (1, 9:0, 12:0), (2, 10:0, 12:0)].
So at the right hand side, you enter the atom, at the left side the "equivalent" term. Mind however that for instance 00 is interpreted as a number and thus is equal to 0, this can be unintended behavior.
You can thus translate the predicate as:
translate(object(A,B,C,D),object(A,B,CT,D)) :-
term_to_atom(CT,C).
Since you do not fully specify how you get this data, it is unknown to me how you will convert it. But the above way will probably be of some help.
ive been lurking in this website for some time so ill finally post my 1st question.
atm i have to do a school project which is to create the game Sokoban with haskell,and so far its been going good until i got to the part where i have to validate the coordinates.
they come as such
11 2
3 4
5 6
it should return "Ok"
i have a function that turns them into a tuple of ints so i can check if they point to a place inside the map ,however that function doesnt give me a nice error message if its a a or just a number, which i need it to do that, for example
a a
11 2
3 4
the message should be "1", as in error in line 1.
1 3
2
4 5
the error message should be "2" too
Is there any way to do that sort of thing, ive ran out of ideas
the function that turns from String into (Int,Int)
processcoordinates::[String]->(Int,Int)
processcoordinates [x,y]= (read x,read y)
processcoordinates xs = error "invalid format"
Note:the function above is applied with the map function
among the things ive already tried but failed were using something along the lines of
valcoor::Int->[String]->Int
valcoor n []=-1
valcoor n ((x,y):t)
|isDigit x && isDigit y =valcoor (n+1) t
|otherwise =n
Note:sorry first time posting a question so im making a lot of mistakes :D
ive edited this function so many times so i cant remember exactly the kind of error messages it gave although among them were
Couldn't match expected type ‘[String]’
with actual type ‘([[Char]], [[Char]])’
which happened when testing with actual values such as
(["1","1"],["2","2"])
What you need is to create a parser that will convert a string input into a data structure.
As this is a homework, I don't want to give you a direct answer. Rather I'd suggest you to read Using Parsec from a great book Real World Haskell, which solves a problem very similar to yours. A parser will allow you to have nice and location-specific error messages.
Note that you probably want to treat the whole input as one String so that everything (including counting lines etc.) is done by the parser. So the signature you're looking would be probably something like
processcoordinates :: String -> Either ParseError [(Int, Int)]
where the left part of Either describes an error, and the right part a successful outcome.
I have a feeling this might be a simple question, but I've searched through SO for a bit now and found many interesting related Q/A, I'm still stumped.
Here's what I need to learn (in honesty, I'm playing with the kaggle Titanic dataset, but I want to use data.table)...
Let's say you have the following data.table:
dt <- data.table(name=c("Johnston, Mr. Bob", "Stone, Mrs. Mary", "Hasberg, Mr. Jason"))
I want my output to be JUST the titles "Mr.", "Mrs.", and "Mr." -- heck we can leave out the period as well.
I've been playing around (all night) and discovered that using regular expressions might hold the answer, but I've only been able to get that to work on a single string, not with the whole data.table.
For example,
substr(dt$name[1], gregexpr(",.", dt$name[1]), gregexpr("[.]", dt$name[1]))
Returns:
[1] ", Mr."
Which is cool, and I can do some further processing to get rid of the ", " and ".", but, the optimist(/optimizer) in me feels that that's ugly, gross, and inefficent.
Besides, even if I wanted to settle on that, (it pains me to admit) I don't know how to apply that into the J of data.table....
So, how do I add a column to dt called "Title", that contains:
[1] "Mr"
[2] "Mrs"
[3] "Mr"
I firmly believe that if I'm able to use regular expressions to select and extract data within a data.table that I will probably use this 100x a day. So thank you in advance for helping me figure out this pivotal technique.
PS. I'm an excel refugee, in excel I would just do this:
=mid(data, find(", ", data), find(".", data))
Umm.. I may have figured it out:
dt[, Title:=sub(".*?, (.*?)[.].*", "\\1", name)]
But I'm going to leave this here in case anyone else needs help, or perhaps there's an even better way of doing this!
You can use the stringr package
library(stringr)
str_extract(dt$name, "M.+\\.")
[1] "Mr." "Mrs." "Mr."
Different variations on the regular expression will let you extract other titles, like Dr., Master, or Reverend which may also be of interest to you.
To get all characters between "," and "." (inclusive) you can use
str_extract(dt$name, ",.+\\.")
and then remove the first and last characters of the result with str_sub (also from stringr package).
But as I think about it more, I might use grepl to create indicator variables for all the different titles that are in the Titanic dataset. For example
dr_ind <- grepl("Dr|Doctor", dt$name)
titled_ind <- grepl("Count|Countess|Baron", dt$name)
etc.