Results 1 to 20 of 27
Thread: Calculate similarity
- 02-18-2012, 11:19 AM #1
Member
- Join Date
- Feb 2012
- Posts
- 14
- Rep Power
- 0
Calculate similarity
Hello
I have this assignment and I do not ask you to solve it for me. What I only need is to explain it for me because seriously I spent plenty of times to just recognize what does the tasks mean and I could not.
here are the tasks:
Task 2: Calculate similarity using the following formula:
{█( 0,&ei(command)≠ ej(command)@(2×longest substring ofei(target) and ej(target) )/(lenght of ei(target)+lenght of ej(target)),&otherwise)┤
where e(command) and e(target) represent the command and target of test action e, respectively. For any i and j, s0(i, j) is in the range [0, 1]. s0(i, j)=0 if and only if the two test actions have no common substring in their targets, and s0 (i,j)=1 if and only if they have the same target. For example, s0(i, j)=10/16 =0.625 for test actions ei = “clickAndWait link=abc” and ej = “clickAndWait link=def” because the total length of targets is 16 and the common substring of targets is “link=”.
Task3: Save each similarity between ei and ej in a matrix
>>>>and I have the matrix in my sheet...
Thank you very much
- 02-18-2012, 01:56 PM #2
Re: Calculate similarity
When you get the design / algorithm for solving your problem, post it and ask your questions about how to code it in java.
- 02-18-2012, 02:29 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 14
- Rep Power
- 0
Re: Calculate similarity
for task 2:
{ 2×longest substring of ei(target) and ej(target) / lenght of ei(target) +lenght of ej(target) } otherwise ei(command) ≠ ej(command)
where e(command) and e(target) represent the command and target of test action e, respectively. For any i and j, s0(i, j) is in the range
[0, 1]. s0(i, j)=0 if and only if the two test actions have no common substring in their targets, and s0 (i,j)=1 if and only if they have the
same target. For example, s0(i, j)=10/16 =0.625 for test actions ei = “clickAndWait link=abc” and ej = “clickAndWait link=def” because the total length of targets is 16 and the common substring of targets is “link=”.
this is the formula for the task 2.
I really do not know what to do with that....and task1 asks about to (read file).
- 02-18-2012, 02:48 PM #4
Re: Calculate similarity
Do you have any specific java programming questions?
- 02-18-2012, 03:16 PM #5
Member
- Join Date
- Feb 2012
- Posts
- 14
- Rep Power
- 0
Re: Calculate similarity
YES ,
How can I calculate the similarity for matrices " in file "
- 02-18-2012, 03:19 PM #6
Re: Calculate similarity
That is the design that you need to make. There are no java classes or methods to do that.
What are the steps the program should do to solve this?
First thing would be to read the file.
Then what?
- 02-18-2012, 03:23 PM #7
Member
- Join Date
- Feb 2012
- Posts
- 14
- Rep Power
- 0
Re: Calculate similarity
1. Read the file.
2. Calculate the similarity in the file.
3. Save each similarity in the matrix.
- 02-18-2012, 03:26 PM #8
Re: Calculate similarity
Those are very high level steps. Now break those steps down into a list of much smaller, simpler steps to do the job.
There are no classes will that will do any of those steps.
- 02-18-2012, 03:34 PM #9
Member
- Join Date
- Feb 2012
- Posts
- 14
- Rep Power
- 0
Re: Calculate similarity
I really confused what to use or what is the specific classes or methods to be honest !! plus I am learning the Java " beginner "
- 02-18-2012, 03:39 PM #10
Re: Calculate similarity
After you get a design for the program then you can worry about what classes to use. We can help you there.
Take the first step you listed: Read the file.
What will the file contain?
Where will its contents be stored in the program? Will you define a class to hold the data from each line of the file?
- 02-18-2012, 03:43 PM #11
Member
- Join Date
- Feb 2012
- Posts
- 14
- Rep Power
- 0
Re: Calculate similarity
It contains columns and rows of String.
It will be stored in an array of String.
- 02-18-2012, 03:49 PM #12
Re: Calculate similarity
Look at using the Scanner class to read the file in as Strings. Write a loop to store each String as it is read into an array.
- 02-18-2012, 04:07 PM #13
Member
- Join Date
- Feb 2012
- Posts
- 14
- Rep Power
- 0
Re: Calculate similarity
ok here is what I got
First of all, I create file then try {hasNextLine()} and catch {} ... and make the String[ ] to store the lines on it.
- 02-18-2012, 05:31 PM #14
Re: Calculate similarity
Now write the code and test that it is working as you want.
An easy way to format an array for printing is to use the Arrays class's toString() method.
- 02-19-2012, 08:34 AM #15
Member
- Join Date
- Feb 2012
- Posts
- 14
- Rep Power
- 0
Re: Calculate similarity
here is the file now in the String[][] lineJava Code:import java.io.*; public class apples { public static void main(String[] args) throws FileNotFoundException, IOException { String[][] fileContents = new String[4][41]; BufferedReader br = new BufferedReader(new FileReader("/Users/salateno/Desktop/test.txt")); String line; while ((line = br.readLine()) != null) { fileContents[3][40] = line; System.out.println(" " + line ); } } }
is there any advice to make more efficient than this please I would appreciate it to tell me...
- 02-19-2012, 10:31 AM #16
Re: Calculate similarity
Not if you assign every line to fileContents[3][40], it isn't.here is the file now in the String[][] line
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 02-19-2012, 11:47 AM #17
Member
- Join Date
- Feb 2012
- Posts
- 14
- Rep Power
- 0
Re: Calculate similarity
so, you are saying if I use the ArrayList<string> would work....!!!!
Java Code:ArrayList<String> fileData = new ArrayList<String>(); try{ BufferedReader fileReader = new BufferedReader(new FileReader("the path")); String line = ""; while ( (line = fileReader.readLine()) != null) { fileData.add(line); } }catch (Exception e) { System.out.println("Error"); e.printStackTrace(); } } }
- 02-19-2012, 01:31 PM #18
Re: Calculate similarity
After you read the file in and save it in an arraylist, print out the contents of the arraylist to see if it contains the file.the ArrayList<string> would work
- 02-19-2012, 01:38 PM #19
Member
- Join Date
- Feb 2012
- Posts
- 14
- Rep Power
- 0
Re: Calculate similarity
Java Code:public static void main(String[] args) throws Exception { ArrayList<String> fileData = new ArrayList<String>(); try{ BufferedReader fileReader = new BufferedReader(new FileReader("/Users/salateno/Desktop/test.txt")); String line = ""; while ( (line = fileReader.readLine()) != null) { fileData.add(line); System.out.println("" + line); } }catch (Exception e) { System.out.println("Error"); e.printStackTrace(); } } }
Yes it contains the contents of the file now..But I am wondering now if I can use it to the second task..Also,I was trying to use the split() to make "tap" between each element but it does not work...it gave me java.lang.nullpointer...
- 02-19-2012, 01:39 PM #20
Similar Threads
-
find perceptual similarity between two images
By soheilz92 in forum Advanced JavaReplies: 2Last Post: 09-13-2011, 10:14 PM -
cosine similarity in search engine
By panny in forum New To JavaReplies: 4Last Post: 03-21-2011, 02:03 PM -
Lucene: getting similarity scores per document field
By aneuryzma in forum LuceneReplies: 0Last Post: 03-01-2011, 12:48 PM -
is Cosine Similarity the Default Similarity in Lucene?
By sethu.iit@gmail.com in forum LuceneReplies: 0Last Post: 06-30-2010, 09:49 AM -
Similarity
By John Atsh in forum LuceneReplies: 0Last Post: 03-23-2009, 01:44 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks