2020-11-18

Artificial intelligence worth 100 million is not right for artificial intelligence.
Just ask if you understand, I don’t necessarily answer anyway. Because I don't have a dime profit from me, I don't explain this dark society.
Paste the code, simple implementation, the dialogue of Android artificial mental retardation, the accuracy of the dialogue, you need to provide a think tank, or input one by one yourself. Because it is just a dialogue, it does not provide al judgment, and al decision. And first assume that the answer is unique and correct.
Paste the code.
package com.mycompany.myAl;

import android.app.;
import android.os.
;
import android.view.;
import android.widget.
;
import java.io.;
import java.util.
;

public class MainActivity extends Activity
{ private StringBuffer storage = new StringBuffer(); private StringBuffer read = new StringBuffer(); private byte[] read; private String additional storage data, additional data, read string, tex1, tex2; TextView tv1,tv2,tv3; EditText ed1,ed2,ed3; private HashMap<String,String> role = new HashMap<String,String>();//add element






/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
	tv1=(TextView) findViewById(R.id.tv1);
	ed1=(EditText) findViewById(R.id.ed1);
	tv2=(TextView) findViewById(R.id.tv2);
	tv3=(TextView) findViewById(R.id.tv3);
	
	ed2=(EditText) findViewById(R.id.ed2);
	ed3=(EditText) findViewById(R.id.ed3);
	
	tex1=ed1.getText().toString();
	tex2=ed2.getText().toString();
	读();//无论是否读取到,下次操作都为保存
	try
	{
		save();
	}
	catch (IOException e)
	{}
	
	
}

public void btn(View p){
	
	String a=ed1.getText().toString();

	if(角色.get(a)==null){
		//角色.put(a, "");
		tv1.setText("\n没有查询到结果");
	}
	else if(角色.get(a)==""){
		tv1.setText("\n有记录,可是为空白的");
	
	
	}
	else{
		tv2.setText("\n"+角色.get(a));
	}
	
	}

	
public void btn2(View p){

	String a=ed1.getText().toString();
	String a1=ed2.getText().toString();
		
		
	if(角色.get(a)==null&&角色.get(a)==null){
		
			角色.put(a,a1);
			存储.append(a+"|"+a1+"|");//追加
			try
			{
				save();
				读();
				ed1.setText("");
				ed2.setText("");
				tv2.setText("\n以更新结果,可以重新问啦!");
			}
			catch (IOException e)
			{}

		}
	else{Toast.makeText(this,"输入需要更正,或者此结果已经提交了",Toast.LENGTH_LONG).show();
		
			
		}
	}	
		
		public void btn3(View p){
		
			ed3.setText(读取);
						tv3.setText("");
				}
				
					
	 
		/*
	else{
		//角色.put(a,a1);
		tv2.setText(a+"以记录,答案是\n"+a1);
		tv1.setText(角色.get(a1));
		for(String i:角色.keySet()) {
			if(角色.get(a1)==角色.get(i)){
				角色.remove(a1);
				tv2.setText(a1+"问答结果一致,删除此项数据:"+a);

				
			}
			}*/
			
	
		
	
			
		
		
	
	
		
	



public void save() throws IOException
{
	//String  of=""+人物数组[0][0];
	//StringBuffer buffer = new StringBuffer(of);
	//存储.append(追加存数据); //向 StringBuffer 对象追加 0f字符串;
	try {
		FileOutputStream outStream=new FileOutputStream("/storage/emulated/0/Al.txt");//,Context.MODE_WORLD_READABLE);

		{outStream.write(存储.toString().getBytes());
			outStream.close();
			//Toast.makeText(this,"读取存储数据,以覆盖Al.txt文件。",Toast.LENGTH_LONG).show();
			}


	} catch (FileNotFoundException e) {
		Toast.makeText(this,"错误",Toast.LENGTH_LONG).show();
		return;
	}}
public void 读(){
	try
	{

		FileInputStream fis = new FileInputStream("/storage/emulated/0/Al.txt");//,Context.MODE_WORLD_READABLE);
		读=	readInputStream(fis);
		读取 = new StringBuffer(new String(readInputStream(new FileInputStream("/storage/emulated/0/Al.txt"))));//使用构造函数转换成stringbuff字符串
		存储=读取;
		//tv2.setText(""+存储.toString());
		
		读取的string = new String(读);//使用构造函数转换成字符串
		//打印显示(读取.toString());
		String[] al=读取的string.split("\\|");
		for (int i = 0; i < al.length-1; i++){
			if(i%2==0){
				if(al[i]==al[i+1]){
					
				}
				else{
				角色.put(al[i],al[i+1]);
				}
				追加存数据=追加存数据+al[i];
			}
		}
	
		//tv2.setText(""+存储.toString());
		//tv1.setText(""+追加存数据);

			
	}
	catch (FileNotFoundException e)
	{}
	
	
	}



public static byte[] readInputStream(InputStream inputStream)
{


    // 1.建立通道对象
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    // 2.定义存储空间
    byte[] buffer = new byte[1024];
    // 3.开始读文件
    int len = -1;
    try {
        if (inputStream != null) {
            while ((len = inputStream.read(buffer)) != -1) {
                // 将Buffer中的数据写到outputStream对象中
                outputStream.write(buffer, 0, len);

            }
        }
        // 4.关闭流
        outputStream.close();
        inputStream.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return outputStream.toByteArray();
}

}

In the xml part below, you can communicate directly and answer directly. It is normal for the code to be bad. After all, the money is confiscated, and it may be even worse for others to collect money.

<?xml version="1.0" encoding="utf-8"?>

<TextView
	android:layout_width="match_parent"
	android:layout_height="100dp"
	android:text="我是al复读机"
	android:ellipsize="marquee"
	android:id="@+id/tv1"/>

<LinearLayout
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
	android:gravity="center"
	android:orientation="horizontal">

	<EditText
		android:layout_width="wrap_content"
		android:ems="10"
		android:layout_height="wrap_content"
		android:id="@+id/ed1"/>

	<Button
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:text="问"
		android:id="@+id/btn"
		android:onClick="btn"/>

</LinearLayout>

<TextView
	android:layout_width="match_parent"
	android:layout_height="100dp"
	android:text="需要先存储答案才能回答"
	android:ellipsize="marquee"
	android:id="@+id/tv2"/>

<LinearLayout
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
	android:gravity="center"
	android:orientation="horizontal">

	<EditText
		android:layout_width="wrap_content"
		android:ems="10"
		android:layout_height="wrap_content"
		android:id="@+id/ed2"/>

	<Button
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:text="提交正确答案"
		android:id="@+id/btn2"
		android:onClick="btn2"/>

</LinearLayout>

<Button
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:text="智库"
	android:id="@+id/btn3"
	android:onClick="btn3"/>

<EditText
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:id="@+id/ed3"/>

<TextView
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:text="数据库显示"
	android:ellipsize="marquee"
	android:id="@+id/tv3"/>

I really want to complain about ┐('~`;)┌neural
algorithm, artificial mental retardation is so awesome
and now the dialogue is very retarded. Read and write permissions are needed above, how to add yourself to Baidu.

Guess you like

Origin blog.csdn.net/qq_41619005/article/details/109765776