I have a script with lots of RatingScale components, used to record 1-through-5 ratings (subjects pressed keys 1 through 5 on the keyboard).
I now need to change the script to accept five letter inputs instead of the first five numbers (i.e., the keys, Q,W,E,R,T). I would like to keep the rating-scale components in the script and just change the expected input type (letter as opposed to digits), but I did not find any options for this among RatingScale's parameters. The 'low' and 'high' parameters just accept numerical values.
Any thoughts how I can achieve this? Many thanks.
Use the respKeys argument.
visual.RatingScale(win, respKeys=['q', 'w', 'e', 'r', 't'])
It's in the RatingScale documentation.
Figured it out - there is a respKeys parameter that can be set, within the customised code tab of the rating scale component!
Related
I'm searching for a way to have suggestions "persisting" in a input widget so that user can use suggestions to create more complex strings.
E.g. if I were to create this list of possible input values:
html.Datalist(id='browser', children=[
html.Option(value="apple"),
html.Option(value="pear"),
html.Option(value="banana")
]),
(and say parameter multiple is set to True (see Dash input widget documentation))
user wouldn't be able to use the suggestions/autocomplete to create more complex strings, for instance:
apple pear and tomatoe
where the fruits names would be suggested.
I spent a great deal of time searching online but couldn't find out anythin hint on this. Any suggestion/direction much welcome.
If I have a text string to be vectorized, how should I handle numbers inside it? Or if I feed a Neural Network with numbers and words, how can I keep the numbers as numbers?
I am planning on making a dictionary of all my words (as suggested here). In this case all strings will become arrays of numbers. How should I handle characters that are numbers? how to output a vector that does not mix the word index with the number character?
Does converting numbers to strings weakens the information i feed the network?
Expanding your discussion with #user1735003 - Lets consider both ways of representing numbers:
Treating it as string and considering it as another word and assign an ID to it when forming a dictionary. Or
Converting the numbers to actual words : '1' becomes 'one', '2' as 'two' and so on.
Does the second one change the context in anyway?. To verify it we can find similarity of two representations using word2vec. The scores will be high if they have similar context.
For example,
1 and one have a similarity score of 0.17, 2 and two have a similarity score of 0.23. They seem to suggest that the context of how they are used is totally different.
By treating the numbers as another word, you are not changing the
context but by doing any other transformation on those numbers, you
can't guarantee its for better. So, its better to leave it untouched and treat it as another word.
Note: Both word-2-vec and glove were trained by treating the numbers as strings (case 1).
The link you provide suggests that everything resulting from a .split(' ') is indexed -- words, but also numbers, possibly smileys, aso. (I would still take care of punctuation marks). Unless you have more prior knowledge about your data or your problem you could start with that.
EDIT
Example literally using your string and their code:
corpus = {'my car number 3'}
dictionary = {}
i = 1
for tweet in corpus:
for word in tweet.split(" "):
if word not in dictionary: dictionary[word] = i
i += 1
print(dictionary)
# {'my': 1, '3': 4, 'car': 2, 'number': 3}
The following paper can be helpful: http://people.csail.mit.edu/mcollins/6864/slides/bikel.pdf
Specifically, page 7.
Before they use an <unknown> tag they try to replace alphanumeric symbol combination with common pattern names tags, such as:
FourDigits (good for years)
I've tried to implement it and it gave great results.
See this property file:
S=1
M=2
[...]
IA=i
S=g
First, the value 1 will be assigned to S and then g will be assigned to S in the last line.
I want to keep multiple values for the same key S, how can I do this?
I think you need to specify whether this is a Java properties file or some other file, as I've rarely seen it possible to define two separate "keys" with different values without some kind of a section break (ie .ini files).
The only other way I can think of for reading this type of file would be to pull it in as nested dict using the alphabet as the index (a-z, aa-az, etc), storing the key value pairs you've seen, so for example you'd have "a" = {S='1'}, "b" = {M='2'} [..] "z" = {S='g'} and then you could do a query for "letterKey" in dict "alpha" where key.value("innerKey") = 'S', which would give you both 'a' and 'z' due to the 'S' = '1' and 'g'. This may not be any easier than simply rewriting some of the existing code though.
Since a dictionary can't have multiple keys with the same "index" ie 'S' can't appear twice, if you could do as a commenter suggested and store two values in an array in 'S' and reference them via position S.value([0]) and S.value([1]), you'd have a much better program overall.
Problem
I need to format an input field visually in order to help the user know what they should type as a phone number. For example, I want to accept a phone number as being a 3 digit area code, 3 digit prefix and 4 digit suffix: (207) 555-1212. I want to:
provide the helper formatting to the input field -- those parentheses and the hyphen
I don't want the 'helper' characters to be included in the actual data I store in my model.
As the user types, I want the parentheses to magically appear, then have the hyphen also appear at the right point.
What's the best way to do it?
Note: This is not for displaying of a number -- I could use a filter for that. This is for formatting data within an input field.
Thanks for your help!
If you are looking for a simple solution, you could give AngularUI a try, http://angular-ui.github.com/
This is the example from the "Mask" section of that page:
<input ng-model="maskDemo" ui-mask="'99-99-9999'">
The "9"'s are numbers, and other stuff is just a mask / placeholders. It should only submit the actual values. You would edit the mask to include parentheses and anything else you may need.
In my example I have a table where each row is a user for example. Columns could include their name, address, email address, etc. I now need to add a column for (hypothetical example) their cat's names. While most people will have no cats and some people will have 1- 2 cats there will be the occasional person with 20 cats that create one very long row in the table. This is giving me an issue in presentation and for filtering/searching for cat names. Is there a good solution to displaying this type of data?
Have the first 50 (or whatever) characters of the field displayed as normal then put the rest in a block with its visibility set to hidden through CSS. Include a link / button / icon that will allow the user to toggle the visibility so they can see the entire value.
Several options:
Set a maximum width for the cell and allow the data to wrap
Place the content inside a wrapper tag (such as a div) and set the div with a fixed width/height and style of overflow:hidden to ensure that a particularly long word doesn't force out the width of the cell.
Truncate the output text on the server side
For cases #2 and #3, set the Title attribute of the TD tag to contain the full non-truncated text. This will present itself as a tooltip when hovering over the cell.
I would mention other CSS-based solutions but they're very sparsely supported right now, so not worth mentioning.
You might want to try doing something like what SO does. Namely, once someone reaches a certain point in their Rep, it suffixes the number and appromixates it. Ex. 10k instead of 10,236.
That way the numbers don't get out of hand.