当前位置:网站首页>2020-11-18

2020-11-18

2020-12-08 11:56:50 osc_ 25qqqijt

value 1 Million artificial intelligence , No, it's artificial disabilities .
Ask if you can understand , I don't have to answer anyway . Because you don't have a dime with me , I don't explain , This dark society .
Post code , Simple implementation , Android's dialogue with AI , Dialogue accuracy , You need to provide think tanks , Or input them one by one . Because it's just a conversation , All do not offer al Judge , and al Decision making . Let's assume that the answer is unique , And right .
Post 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 Add data , Additional data , Read the string,tex1,tex2;
TextView tv1,tv2,tv3;
EditText ed1,ed2,ed3;
private HashMap<String,String> role = new HashMap<String,String>();// Additive elements







/** 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();
	 read ();// Whether or not you read , The next operation is to save 
	try
	{
		save();
	}
	catch (IOException e)
	{}
	
	
}

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

	if( role .get(a)==null){
		// role .put(a, "");
		tv1.setText("\n No results found ");
	}
	else if( role .get(a)==""){
		tv1.setText("\n Records , But it's blank ");
	
	
	}
	else{
		tv2.setText("\n"+ role .get(a));
	}
	
	}

	
public void btn2(View p){

	String a=ed1.getText().toString();
	String a1=ed2.getText().toString();
		
		
	if( role .get(a)==null&& role .get(a)==null){
		
			 role .put(a,a1);
			 Storage .append(a+"|"+a1+"|");// Additional 
			try
			{
				save();
				 read ();
				ed1.setText("");
				ed2.setText("");
				tv2.setText("\n To update the results , You can ask again !");
			}
			catch (IOException e)
			{}

		}
	else{Toast.makeText(this," Input needs to be corrected , Or the result has been submitted ",Toast.LENGTH_LONG).show();
		
			
		}
	}	
		
		public void btn3(View p){
		
			ed3.setText( Read );
						tv3.setText("");
				}
				
					
	 
		/*
	else{
		// role .put(a,a1);
		tv2.setText(a+" To record , The answer is \n"+a1);
		tv1.setText( role .get(a1));
		for(String i: role .keySet()) {
			if( role .get(a1)== role .get(i)){
				 role .remove(a1);
				tv2.setText(a1+" The results of question and answer are consistent , Delete this data :"+a);

				
			}
			}*/
			
	
		
	
			
		
		
	
	
		
	



public void save() throws IOException
{
	//String  of=""+ Character array [0][0];
	//StringBuffer buffer = new StringBuffer(of);
	// Storage .append( Add data ); // towards  StringBuffer  Object appending  0f character string ;
	try {
		FileOutputStream outStream=new FileOutputStream("/storage/emulated/0/Al.txt");//,Context.MODE_WORLD_READABLE);

		{outStream.write( Storage .toString().getBytes());
			outStream.close();
			//Toast.makeText(this," Read stored data , To cover Al.txt file .",Toast.LENGTH_LONG).show();
			}


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

		FileInputStream fis = new FileInputStream("/storage/emulated/0/Al.txt");//,Context.MODE_WORLD_READABLE);
		 read =	readInputStream(fis);
		 Read  = new StringBuffer(new String(readInputStream(new FileInputStream("/storage/emulated/0/Al.txt"))));// Use the constructor to convert to stringbuff character string 
		 Storage = Read ;
		//tv2.setText(""+ Storage .toString());
		
		 Read the string = new String( read );// Use the constructor to convert to a string 
		// Print display ( Read .toString());
		String[] al= Read the string.split("\\|");
		for (int i = 0; i < al.length-1; i++){
			if(i%2==0){
				if(al[i]==al[i+1]){
					
				}
				else{
				 role .put(al[i],al[i+1]);
				}
				 Add data = Add data +al[i];
			}
		}
	
		//tv2.setText(""+ Storage .toString());
		//tv1.setText(""+ Add data );

			
	}
	catch (FileNotFoundException e)
	{}
	
	
	}



public static byte[] readInputStream(InputStream inputStream)
{


    // 1. Create a channel object 
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    // 2. Define storage space 
    byte[] buffer = new byte[1024];
    // 3. Start reading the file 
    int len = -1;
    try {
        if (inputStream != null) {
            while ((len = inputStream.read(buffer)) != -1) {
                //  take Buffer The data in is written as outputStream In the object 
                outputStream.write(buffer, 0, len);

            }
        }
        // 4. Closed flow 
        outputStream.close();
        inputStream.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return outputStream.toByteArray();
}

}

below xml part , Communication can , Answer directly , Bad code is normal , After all, there was no charge , What's more, it may be worse to collect money from others .

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

<TextView
	android:layout_width="match_parent"
	android:layout_height="100dp"
	android:text=" I am a al Repeater "
	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=" ask "
		android:id="@+id/btn"
		android:onClick="btn"/>

</LinearLayout>

<TextView
	android:layout_width="match_parent"
	android:layout_height="100dp"
	android:text=" You need to store your answers before you can answer "
	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=" Submit the correct answer "
		android:id="@+id/btn2"
		android:onClick="btn2"/>

</LinearLayout>

<Button
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:text=" Think tanks "
	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=" Database display "
	android:ellipsize="marquee"
	android:id="@+id/tv3"/>

I really want to make complaints about that ┐(‘~`;)┌
Neural algorithm , Artificial mental retardation is being blown so much
And now conversation is retarded . Read and write permissions are required , How to add your own Baidu .

版权声明
本文为[osc_ 25qqqijt]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201208115629459a.html