⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 semanticexperiment.java

📁 显示韩文
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			cycleNum = timeupdate.getCycle();
			time = timeupdate.getTime();
			currentDisplayNum = 0 ;
			total = timeupdate.getNumber();
		}
	}
	/**读取文件,并将文件的内容保存到字符串数组中*/
	class fileReader{		
		public fileReader(String fileName){
			try{
				BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileName),"UTF8"));
				String s = in.readLine();
				int lineNum = 0;
				while(s!=null){
					lineNum++;
					s = in.readLine();
				}
				fileContent = new String[lineNum];
				
				in = new BufferedReader(new InputStreamReader(new FileInputStream(fileName),"UTF8"));
				int i=0;
				while((s=in.readLine())!=null){
					fileContent[i] = s;
					i++;
				}
				thread.stop();
				thread = new Thread(display);
				thread.start();
			}catch(Exception e){
				System.out.println(e);
			}
		}
	}
	/**将单词在屏幕上显示*/
	public void screenDisplay(){
		try{
			panel1.redraw("+");
			Thread.sleep(1000);
			panel1.redraw("");
			Thread.sleep(500);
			//显示启动词
			panel1.redraw(parseStr[0]);
			Thread.sleep(500);
			panel1.redraw("");
			Thread.sleep(500);
			//显示目标词
			panel1.redraw(parseStr[1]);
			date = new Date();
			time1 = date.getTime();
			Thread.sleep(500);
			panel1.redraw("");
			Thread.sleep(1500);	
		}catch(java.lang.InterruptedException e){
			System.out.println(e);
		}
	}
	/**解析字符串
	 *@para str要解析的字符串
	 */
	public void parseLine(String str){
		int len = str.length();
		parseStr = str.split(",");
	}
	/**生成随机数
	 *@para range随机数的范围
	 */
	public int random_int(int range){
		Random rand = new Random();
		return rand.nextInt(range);
	}
	
	public void setData( int index ){
		outputData[index].startup = parseStr[0];
		outputData[index].target = parseStr[1];
		outputData[index].level = Integer.parseInt(parseStr[2]);
		outputData[index].type = Integer.parseInt(parseStr[3]);
		outputData[index].time = 0;
		outputData[index].display = true;
		switch(outputData[index].level){
			case 4:
				outputData[index].result = false;
				break;
			case 3:
				outputData[index].result = false;
				break;
			case 2:
				outputData[index].result = true;
				break;
			case 1:
				outputData[index].result = false;
				break;
			case 0:
				outputData[index].result = true;
				break;
		}
	}

	public void outputFiles(int index,String s){
		try{
			String[] level = {"","弱","无","中","强"};
			String[] type = {"填充组","词汇组"};
			fos = new FileOutputStream(s,true);
			out = new BufferedWriter(new OutputStreamWriter(fos,"UTF8"));
			out.newLine();
			out.write(outputData[index].startup+",");
			out.write(outputData[index].target+",");
			out.write(level[outputData[index].level]+",");
			out.write(type[outputData[index].type]+",");
			if(outputData[index].result)
				 out.write("正确,");
		    else
				 out.write("错误,");
			out.write(Integer.toString((int)outputData[index].time));
			out.close();
		}catch(IOException e){
			System.out.println("outputFiles's exception:\n"+e);
		}
	}

	public void increase(int index){
		resultCount[0].total++;
		switch(outputData[index].level){
			case 4:
				resultCount[1].total++;
				if(outputData[index].result){
					resultCount[0].right++;
					resultCount[1].right++;
				}
				else{
					resultCount[0].wrong++;
					resultCount[1].wrong++;
				}
				break;
			case 3:
				resultCount[2].total++;
				if(outputData[index].result){
					resultCount[0].right++;
					resultCount[2].right++;
				}
				else{
					resultCount[0].wrong++;
					resultCount[2].wrong++;
				}
				break;
			case 2:
				resultCount[3].total++;
				if(outputData[index].result){
					resultCount[0].right++;
					resultCount[3].right++;
				}
				else{
					resultCount[0].wrong++;
					resultCount[3].wrong++;
				}
				break;
			case 1:
				resultCount[4].total++;
				if(outputData[index].result){
					resultCount[0].right++;
					resultCount[4].right++;
				}
				else{
					resultCount[0].wrong++;
					resultCount[4].wrong++;
				}
				break;
			case 0:
				resultCount[5].total++;
				if(outputData[index].result){
					resultCount[0].right++;
					resultCount[5].right++;
				}
				else{
					resultCount[0].wrong++;
					resultCount[5].wrong++;
				}
				break;
		}
				
	}
	/**把当前显示的字符串输出到文件中
	 *@para index 当前显示的行号
	 */
	public void outputFiles(int index){
			 increase(index);
			 outputFiles(index,"output/"+name+"-随机顺序.csv");
			 switch(outputData[index].level){
				case 4:
					outputFiles(index,"output/"+name+"-强联想强度.csv");
					break;
				case 3:
					outputFiles(index,"output/"+name+"-中联想强度.csv");
					break;
				case 2:
					outputFiles(index,"output/"+name+"-无联想强度.csv");
					break;
				case 1:
					outputFiles(index,"output/"+name+"-弱联想强度.csv");
					break;
				case 0:
					outputFiles(index,"output/"+name+"-填充组.csv");
					break;
			 }	 
		
	}
	public void getCount(String s,int total,int right,int wrong){
		try{
		fos = new FileOutputStream(s,true);
		out = new BufferedWriter(new OutputStreamWriter(fos,"UTF8"));
		out.newLine();
		out.write("总数:,");
		out.write(Integer.toString(total)+",,,,");
		out.newLine();
		out.write("正确数:,");
		out.write(Integer.toString(right)+",,,,");
		out.newLine();
		out.write("错误数:,");
		out.write(Integer.toString(wrong)+",,,,");
		out.close();
		}catch(IOException e){
			System.out.println("getCount's Exception\n"+e);
		}

	}
	/**类创建一个线程,用来显示文字*/
	class Display implements Runnable{
		
		public void run(){
				isContinue = false;
				if(Mark_Start == 1){
					outputData = new OutputData[fileContent.length];
					for(int i = 0 ; i<outputData.length;i++){
						outputData[i] = new OutputData();
					}
				}
			while(true){
				panel1.add(BorderLayout.CENTER,label1);
				for(int i = 0;i<fileContent.length;i++){
					int index = i;
					if(Mark_Start == 1){//如果是"工具->开始"随机显示
						index = random_int(fileContent.length);
						while(outputData[index].display)//避免重复显示
							index = random_int(fileContent.length);
					}
					lineNum = index;
					if(fileContent[index].contains("#"))
						continue;
					parseLine(fileContent[index]);
					if(Mark_Start == 1)
					{
						//setData(i);
						setData(index);
					}
					try{
						screenDisplay();
						if(Mark_Start == 1){
							totalNum++;
							outputFiles(index);
						}
						/**下面四句实现一旦显示cycleNum对数
						 *  就休息time秒
						 */
						currentDisplayNum++;
						if(currentDisplayNum == cycleNum){
							panel1.redraw("请休息一会,稍后继续!");
							currentDisplayNum = 0;
							Thread.sleep(time*1000);
							panel1.redraw("休息时间结束,请按Enter键继续!");
							while ( !isContinue)
							{
								;
							}
							isContinue = false;
						}
						
					
					}catch(java.lang.InterruptedException e){
						System.out.println("In run()"+e);
					}
					if(totalNum == total)
						break;
				}//for
				break;
			}//while
			if(Mark_Start == 1){
				int i = 0;
				getCount("output/"+name+"-随机顺序.csv",resultCount[i].total,resultCount[i].right,resultCount[i].wrong);
				i = 1;
				getCount("output/"+name+"-强联想强度.csv",resultCount[i].total,resultCount[i].right,resultCount[i].wrong);
				i = 2;
				getCount("output/"+name+"-中联想强度.csv",resultCount[i].total,resultCount[i].right,resultCount[i].wrong);
				i = 3;
				getCount("output/"+name+"-无联想强度.csv",resultCount[i].total,resultCount[i].right,resultCount[i].wrong);
				i = 4;
				getCount("output/"+name+"-弱联想强度.csv",resultCount[i].total,resultCount[i].right,resultCount[i].wrong);
				i = 5;
				getCount("output/"+name+"-填充组.csv",resultCount[i].total,resultCount[i].right,resultCount[i].wrong);
				//产生原始顺序的文件
				int total = 0 , right = 0 , wrong = 0;
				for(i = 0 ; i<outputData.length;i++){	
					if(fileContent[i].contains("#"))
						continue;
					if(!(outputData[i].display)){
						parseLine(fileContent[i]);
						setData(i);
					}
					outputFiles(i,"output/"+name+"-原始顺序.csv");
					total++;
					if(outputData[i].result)
						right++;
					else 
						wrong++;
					
				}
				getCount("output/"+name+"-原始顺序.csv",total,right,wrong);
				panel1.redraw("恭喜你完成全部练习!按F2键继续!");

			}
			else
				panel1.redraw("恭喜你完成全部测试!");

		}//run
	}


	public static void main(String[] args){
		semanticExperiment frame = new semanticExperiment("语义启动效应实验");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(1050, 750);
		frame.setVisible(true);
	
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -