提高智能

This commit is contained in:
icewithcola 2024-05-23 21:27:22 +08:00
parent 58d9a791bc
commit 1b4302ed23
3 changed files with 68 additions and 19 deletions

View file

@ -11,8 +11,8 @@ android {
applicationId = "uk.kagurach.android101"
minSdk = 31
targetSdk = 34
versionCode = 141
versionName = "1.4.1"
versionCode = 151
versionName = "1.5.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

View file

@ -1,14 +1,10 @@
package uk.kagurach.android101;
import static uk.kagurach.misc.AIAnswerServiceKt.AIAnswerService;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
public class Page4OtherActivity extends AppCompatActivity {
@ -19,13 +15,7 @@ public class Page4OtherActivity extends AppCompatActivity {
if (bundle == null) throw new NullPointerException();
String content = bundle.getString("request_content");
if (content!=null){
content = content.replace("","?")
.replace("?","!")
.replace("","")
.replace("","");
if (!content.contains("!")){
content = "对不起我不知道";
}
content = AIAnswerService(content);
}else {
content = "对不起坏掉了";
}
@ -37,8 +27,4 @@ public class Page4OtherActivity extends AppCompatActivity {
setResult(RESULT_OK,intent);
finish();
}
private void reply(String s){
}
}

View file

@ -0,0 +1,63 @@
package uk.kagurach.misc
import java.time.Instant
import java.util.Date
import kotlin.random.Random
fun AIAnswerService(s: String):String {
val rng = Random(Date.from(Instant.now()).time)
var result = s
result = result.replace("","?")
val isMoral = s.contains("")
val needAI = s.contains("")
result = result.replace("","^")
result = result.replace("","")
result = result.replace("","@")
if (isMoral){
result = if (rng.nextBoolean()) {
"谢谢@的提问,$result"
} else{
if (result.endsWith(".")||
result.endsWith("")||
result.endsWith("?")){
result = result.dropLast(1);
}
"$result,谢谢。"
}
result = result.replace("","")
}
if (needAI){
result = result.replace("","")
}
result = result.replace("",
if (rng.nextBoolean()){
"可以"
}else{
"不可以"
}
)
result = result.replace("什么","很多")
result = result.replace("","")
result = result.replace("?","")
result = result.replace("^","")
result = result.replace("@","")
return result
}
fun main(){
println(AIAnswerService("我想吃饭"))
println(AIAnswerService("咱可以吃饭吗"))
println(AIAnswerService("您可以做什么?"))
println(AIAnswerService("您吃了吗?"))
}