TypeError: string indices must be integers error in BERT model - bert-language-model

I am trying to run a BERT model for a dataset of emotion annotated tweets. When running our command in cmd line to begin this process, this type error is thrown
Going to the line the error is shown, how could we fix this error in order for the model to work?
Our data files are two column csv files , the column on the left with the tweet and the column on the right with the annotated emotion in binary (0 for false 1 for positive)
How could we fix this?
Let me know!! Thanks

The variable emb is a string. An index looks like this:
>>> mystring = 'helloworld'
>>> print mystring[0]
>>> 'h'
The above example uses the 0 index of the string to refer to the first character. Strings can't have string indices (like dictionaries can). So this won't work:
>>> mystring = 'helloworld'
>>> print mystring['stringindex']
TypeError: string indices must be integers
I suggest you try to print the data and check what you are trying to do.

Related

Robot framework not allowing me to break message across multiple lines

I've got the following code and it won't allow me to break my message over multiple lines. I've looked at over a dozen stack exchange questions but none of them work.
Should Be Equal As Integers ${ans} 0 msg=Failed stuff, the accepted value did not match. Expected value \n
... was between max and min, returned value is below this
It is giving me the error
Keyword 'BuiltIn.Should Be Equal As Integers' got positional argument after named arguments.
I've looked at the following links but they don't work
How I can write code in 2 lines in the Robot framework
Robot framework not allowing me to print over multiple lines
You can achieve this by using catenate:
${ans} = Convert To Integer 1
${message} = Catenate Failed stuff, the accepted value did not match. Expected value \n
... was between max and min, returned value is below this
Should Be Equal As Integers ${ans} 0 msg=${message}
Keep the error message on single line and you can Add ${\n} at the end of the string to get a newline character.
I think, you are using a kw which has positional argument it may not allow using real new line using ...
However, you can use Catenate keyword with SEPARATOR=\n as below:
${str3} = Catenate SEPARATOR=\n line1 text
... line2 text

How to count columns of an output csv file using robot script

I am trying to get the column count from an output csv file using Robot script.
I tried the following lines. Count of rows is working fine. But the 'Get Column Count' is throwing error :
No keyword with name 'Get Column Count' found.
${file-content}= Get File ${OUTPUT_CSV_FILE}
${numberOfLine=}= Get Line Count ${file-content}
Should Be Equal As Integers ${numberOfLine=} X
${numberOfColumn=}= Get Column Count ${file-content}
Should Be Equal As Integers ${columnCount=} Y
I haven't defined any keywords for 'Get Line Count'..but its working.
Then why not Get Column Count. Is it necessary to write a keyword in robot?
Thanks in advance
Aneesh
I haven't defined any keywords for 'Get Line Count'..but its working. Then why not Get Column Count. Is it necessary to write a keyword in robot?
The reason why "Get line count" is working is that you have likely imported robot's String library which has a keyword named Get Line Count. It's not counting rows in a csv file, it's counting lines of text by splitting the string on newlines.
Robot doesn't itself have a keyword for counting columns in a csv file. For that you'll need to use a library that specifically imports the data as csv and has a keyword for counting columns.

Can't Assign Value of Excel cell To variable in Robot Framework [duplicate]

I'm writing a test case in robot framework. I'm getting the response in below json string:
{"responseTimeStamp":"1970-01-01T05:30:00",
"statusCode":"200",
"statusMsg":"200",
"_object":{"id":"TS82",
"name":"newgroup",
"desc":"ttesteste",
"parentGroups":[],
"childGroups":[],
"devices":null,
"mos":null,
"groupConfigRules" {
"version":null,
"ruleContents":null
},
"applications":null,"type":0
}
}
From that I want to take "_object" using:
${reqresstr} = ${response['_object']}
... but am getting the error "No keyword with name '=' found" error
If I try the following:
${reqresstr}= ${response['_object']}
... I'm getting the error "Keyword name cannot be empty." I tried removing the '=' but still get the same error.
How can I extract '_object' from that json string?
When using the "=" for variable assignment with the space-separated format, you must make sure you have no more than a single space before the "=". Your first example shows that you've got more than one space on either side of the "=". You must have only a single space before the = and two or more after, or robot will think the spaces are a separator between a keyword and argument.
For the "keyword must not be empty" error, the first cell after a variable name must be a keyword. Unlike traditional programming languages, you cannot directly assign a string to a variable.
To set a variable to a string you need to use the Set Variable keyword (or one of the variations such as Set Test Variable). For example:
${reqresstr}= Set variable ${response['_object']}
${reqresstr}= '${response["_object"]}'
wrap it inside quotes and two spaces after =
There is a syntax error in your command. Make sure there is a space between ${reqresstr} and =.
Using your example above:
${reqresstr} = ${response['_object']}

Error: Result 1 must be a single string, not a character vector of length 0 when using "make_choose_all_table" from tidyREDCap

I am receiving an error when using make_choose_all_table() from the tidyREDCap package and I'm hoping someone can help me understand what it means. When I export my data from REDCap using REDCapR and then run the code make_choose_all_table() the error below it pops up. The "boo_do_co_no" is my checkbox variable that I am trying to make a table with.
What does the error mean and how do I fix it?
library(REDCapR)
data <- redcap_read()
library(tidyREDCap)
make_choose_all_table(data, "boo_do_co_no")
Error: Result 1 must be a single string, not a character vector of length 0
It needs to come out like the picture below
I am guessing that you are missing an argument within data <- redcap_read() When I run that line, data contains the function code for redcap_read(), not any data output that might come from the function when all the arguments are specified.
See ?redcap_read()

TypeError: Expected argument 1 to be a list or list-like, got string instead. robot frame work

When I tried to add the string value to the list in the robot frame work. I am getting below error. Can anyone help me here?
Error:Expected argument 1 to be a list or list-like, got string instead.
${a}= 'H'
Append_to_list ${Elementlist2} ${a}
That error is telling you that ${Elementlist2} is a string, not a list. It must be a list if you are using Append to list

Resources