I guess it's caused by line no.31 in python script:
response = Bot.get_response(input_statement)
If I run the same python script with PyCharm on windows, it works like a charm.
Maybe it's not chatterbot related issue, maybe it's a user permission problem (I've set android studio app premission to read and write in the AndroidManifest), maybe it's a Chaquopy problem or maybe I'm a really bad programmer, I don't know.
I really appreciate any help, I'm desperate here..
Python Script:
from chatterbot import ChatBot
from chatterbot import comparisons
from chatterbot.conversation import Statement
from chatterbot.response_selection import get_most_frequent_response
Bot = ChatBot(
'Dr. Lito',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
database_uri=uri,
logic_adapters=[
{
"import_path": "chatterbot.logic.BestMatch",
"statement_comparison_function": "comparisons.levenshtein_distance",
"response_selection_method": get_most_frequent_response,
"default_response": "I am sorry, but I do not understand.",
"maximum_similarity_threshold": 0.90
}
]
)
Hello Sir,
I'm trying to get chatterbot to work on android device using (Chaquopy) and android studio of course, I'm getting this error:
[Errno30] Read-only file system: 'sentence_tokenizer.pickle'
I guess it's caused by line no.31 in python script: response = Bot.get_response(input_statement)
If I run the same python script with PyCharm on windows, it works like a charm. Maybe it's not chatterbot related issue, maybe it's a user permission problem (I've set android studio app premission to read and write in the AndroidManifest), maybe it's a Chaquopy problem or maybe I'm a really bad programmer, I don't know.
I really appreciate any help, I'm desperate here..
Thank you
buildgradle: apply plugin: 'com.android.application' apply plugin: 'com.chaquo.python'
android { compileSdkVersion 29 buildToolsVersion "29.0.3"
defaultConfig { applicationId "com.example.pythontest2" sourceSets { main { python { srcDirs = ["src/main/python"] } } } minSdkVersion 16 targetSdkVersion 29 versionCode 1 versionName "1.0"
}
buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } }
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.google.android.material:material:1.1.0' implementation 'androidx.annotation:annotation:1.1.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.navigation:navigation-fragment:2.2.2' implementation 'androidx.navigation:navigation-ui:2.2.2' implementation 'androidx.vectordrawable:vectordrawable:1.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta5" }
Python Script: from chatterbot import ChatBot from chatterbot import comparisons from chatterbot.conversation import Statement from chatterbot.response_selection import get_most_frequent_response
uri='sqlite:///data/data/com.example.pythontest2/files/BotData.sqlite3'
Bot = ChatBot( 'Dr. Lito', storage_adapter='chatterbot.storage.SQLStorageAdapter', database_uri=uri, logic_adapters=[ { "import_path": "chatterbot.logic.BestMatch", "statement_comparison_function": "comparisons.levenshtein_distance", "response_selection_method": get_most_frequent_response, "default_response": "I am sorry, but I do not understand.", "maximum_similarity_threshold": 0.90 } ] )
def start_bot(): return "Hi"
def start_chat(userentry): try: input_statement = Statement(text=userentry) response = Bot.get_response(input_statement) except Exception as e: return 'Error: ' + str(e) return response.text