6 Replies - 359 Views - Last Post: 21 March 2011 - 08:25 AM Rate Topic: -----

#1 jasperFernandes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 02-March 11

2D arrays do not receive my calculated values

Posted 21 March 2011 - 07:21 AM

                System.out.println("Please enter the query  :");
		Scanner scan2 = new Scanner(System.in);
		String word2 = scan2.nextLine();
		String[] array2 = word2.split(" ");

double similarity = 0.0;
for (a = 0; a < filename; a++) {
for (int i = 0; i < array2.length; i++) {
similarity = (totalWords * queryVector)/ ((Math.sqrt((totalwordPower)) * (Math.sqrt(((queryVector * 3)))))); 
}
}

                System.out.println("\n");
		//Array of text files    
		
		
		arrays[0][0] =  "        ";        
		arrays[1][0] =  "abc0.txt";        
		arrays[2][0] =  "abc1.txt";        
		arrays[3][0] =  "abc2.txt";
		arrays[4][0] =  "abc3.txt";
		arrays[5][0] =  "abc4.txt";
		arrays[6][0] =  "abc5.txt";
		arrays[7][0] =  "abc6.txt";
		arrays[8][0] =  "abc7.txt";
		arrays[9][0] =  "abc8.txt";
		arrays[10][0] =  "abc9.txt";
		arrays[11][0] =  "abc10.txt";
		
		//arrays of query
		arrays[0][1] = array2[0];
		arrays [0][2]  = array2[1];
		arrays [0][3] = array2[2];	
		
		for(int row = 0; row<12; row++){
			for( int col=0; col<4; col ++){
				
				System.out.print(arrays[row][col]+"\t");
			}
			System.out.print("\n");
		}
		}
	}



The code above is used to calculate the similarity between the text files and the query. Now my output of the program is like this


how are you
abc0.txt null null null
abc1.txt null null null
abc2.txt null null null
abc3.txt null null null
abc4.txt null null null
abc5.txt null null null
abc6.txt null null null
abc7.txt null null null
abc8.txt null null null
abc9.txt null null null
abc10.txt null null null

How do i store the calculate similarity values in the NULL space ? Any advices would be appreciated.

This post has been edited by jasperFernandes: 21 March 2011 - 07:43 AM


Is This A Good Question/Topic? 0
  • +

Replies To: 2D arrays do not receive my calculated values

#2 TFoSSDQ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 123
  • View blog
  • Posts: 253
  • Joined: 09-December 10

Re: 2D arrays do not receive my calculated values

Posted 21 March 2011 - 07:32 AM

Where are you loading anything into array2?
Was This Post Helpful? 1
  • +
  • -

#3 jasperFernandes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 02-March 11

Re: 2D arrays do not receive my calculated values

Posted 21 March 2011 - 07:46 AM

View PostTFoSSDQ, on 21 March 2011 - 07:32 AM, said:

Where are you loading anything into array2?


sorry i miss the important part. Array2 i loading the query as you can see the "how are you". I updated my code. Thanks for your attention.
Was This Post Helpful? 0
  • +
  • -

#4 TFoSSDQ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 123
  • View blog
  • Posts: 253
  • Joined: 09-December 10

Re: 2D arrays do not receive my calculated values

Posted 21 March 2011 - 07:57 AM

Well, since the values in arrays are null and it gets its values from array2 it means something is wrong with the input going into array2. Can you include your input?
Was This Post Helpful? 0
  • +
  • -

#5 jasperFernandes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 02-March 11

Re: 2D arrays do not receive my calculated values

Posted 21 March 2011 - 08:06 AM

View PostTFoSSDQ, on 21 March 2011 - 07:57 AM, said:

Well, since the values in arrays are null and it gets its values from array2 it means something is wrong with the input going into array2. Can you include your input?


Yes, i input three strings which is "how are you". The input is just strings.
Was This Post Helpful? 0
  • +
  • -

#6 TFoSSDQ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 123
  • View blog
  • Posts: 253
  • Joined: 09-December 10

Re: 2D arrays do not receive my calculated values

Posted 21 March 2011 - 08:17 AM

As I see it you just need multiple inputs. Why not do:
System.out.println("Please enter the query:");
Scanner scan2 = new Scanner(System.in);
String word2 = "";
String[] array2 = new String[3];
for(int i = 0; i < 12; i++)
{
    word2 = scan2.nextLine();
    array2 = word2.split(" ");
    arrays[i][1] = array2[0];
    arrays [i][2]  = array2[1];
    arrays [i][3] = array2[2];
}


That way you can get multiple inputs.
Was This Post Helpful? 1
  • +
  • -

#7 jasperFernandes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 02-March 11

Re: 2D arrays do not receive my calculated values

Posted 21 March 2011 - 08:25 AM

View PostTFoSSDQ, on 21 March 2011 - 08:17 AM, said:

As I see it you just need multiple inputs. Why not do:
System.out.println("Please enter the query:");
Scanner scan2 = new Scanner(System.in);
String word2 = "";
String[] array2 = new String[3];
for(int i = 0; i < 12; i++)
{
    word2 = scan2.nextLine();
    array2 = word2.split(" ");
    arrays[i][1] = array2[0];
    arrays [i][2]  = array2[1];
    arrays [i][3] = array2[2];
}


That way you can get multiple inputs.


thanks. I appreciate your help. I try modify my code. Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1