''Text' object has no attribute 'lower'
I am trying to show my machine learning project through web-based and using voila
text = widgets.Text(placeholder='Input text here')
button_send = widgets.Button(
description='Identify gender',
tooltip='Send',
style={'description_width': 'initial'}
)
output = widgets.Output()
def on_button_clicked(event):
with output:
clear_output()
features = find_features(top_words, text)
print("Naive Bayes = " + NB_classifier.classify(features))
button_send.on_click(on_button_clicked)
vbox_result = widgets.VBox([button_send, output])
text_0 = widgets.HTML(value="<h1>Hello!</h1>")
text_1 = widgets.HTML(value="<h2>Type anything</h2>")
vbox_text = widgets.VBox([text_0, text_1, text, vbox_result])
page = widgets.HBox([vbox_headline, vbox_text])
display(page)
and i got this following callback after input the text: my error
Solution 1:[1]
Your text object is an object that is of the type ipywidgets.widgets.widget_string.Text.
The .lower() method, that appears to be used as part of the processing in find_features() is for strings.
For passing to find_features therefore you want the string object contained in your text object.
Your line should be:
features = find_features(top_words, text.value)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Wayne |
