Closed Jereemi closed 5 years ago
Hi @Jereemi, this is possible to do. I created a quick example using SQL queries to demonstrate it for you.
SELECT statement.id AS statement_id,
statement.text AS statement_text,
statement.conversation AS statement_conversation,
tag.name
FROM "statement"
JOIN tag_association
ON statement.id = tag_association.statement_id
JOIN tag
ON tag.id = tag_association.tag_id
WHERE tag.NAME IN ( "greetings", "trivia" )
This will return data in the following format:
statement_id | statement_text | statement_conversation | tag_name |
---|---|---|---|
742 | Very well, thanks. | training | greetings |
768 | The sky's up but I'm fine thanks. What about you? | training | greetings |
743 | How are you doing? | training | greetings |
1386 | Who was the 37th President of the United States? | training | trivia |
1387 | Richard Nixon | training | trivia |
Hi @Jereemi, this is possible to do. I created a quick example using SQL queries to demonstrate it for you.
SELECT statement.id AS statement_id, statement.text AS statement_text, statement.conversation AS statement_conversation, tag.name FROM "statement" JOIN tag_association ON statement.id = tag_association.statement_id JOIN tag ON tag.id = tag_association.tag_id WHERE tag.NAME IN ( "greetings", "trivia" )
This will return data in the following format:
statement_id statement_text statement_conversation tag_name 742 Very well, thanks. training greetings 768 The sky's up but I'm fine thanks. What about you? training greetings 743 How are you doing? training greetings 1386 Who was the 37th President of the United States? training trivia 1387 Richard Nixon training trivia
@gunthercox Thank you so much for the valuable answer. This means that I can create my own corpus and name it as doctors.yml (say) and use the above SQL query to extract the category statements. This is awesome. Thank you:D
@gunthercox In context to the above query, I have used the learn_new_response.py and the bot learns the new response but it won't give any tag_association with the newly learned statement.
So is there a way to tag the new statement without having to include it in the training file explicitly and re-train it?
The Statement
objects that ChatterBot uses have an add_tags
method that can be used to add one or more tags to a statement. Once the statement is saved, the tags will be created for it.
The
Statement
objects that ChatterBot uses have anadd_tags
method that can be used to add one or more tags to a statement. Once the statement is saved, the tags will be created for it.
@gunthercox Ok thank you for your suggestion. Then using this method can I approach it something like:
@Jereemi That sounds correct to me :+1:
@Jereemi That sounds correct to me
@gunthercox Thank you so much:) I shall try the approach and update it here so that we can close the issue after its done.
@gunthercox I have tried the add_tags method, but I don't know why I am getting the error: AttributeError: 'StatementMixin' object has no attribute 'tags'
Here is how I wrote the code: from chatterbot.conversation import StatementMixin StatementMixin().add_tags('name-of-the-tag')
Can you please correct my mistake?
You'll need to use Statement
instead of StatementMixin
. The StatementMixin
object is used to give various statement-like objects in ChatterBot the nessesary shared attributes but it is not intended to be used directly. More information on mixins can be found here: https://chrisbartos.com/articles/what-is-a-mixin/
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I am trying to train multiple corpus, say for instance doctors corpus, faculties corpus and students corpus. This will train all the data and put it in the statement table one after the other. Is it possible to know if the statement is coming from which corpus?
I have thought of the approach but I am not sure if this is allowed in the default database created by chatterbot. Here is my approach: If I can create an additional column called TAGS in the statement table and label each statement as DOC for doctor corpus, STUD for student corpus, then querying the table as *select from statement where TAGS="DOC|STUD"**
@gunthercox Can you please suggest if this can be achieved?? Thanks!!