public void evaluateAnalogies ( Matrix projection ) { try { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { String analogy = sc . next ( ) ; if ( ! isAnalogyFormat ( analogy , true ) ) { System . err . println ( "\"" + analogy + "\" not in proper format." ) ; continue ; } double cosineVal = computeCosineSimilarity ( analogy , projection ) ; //does the actual cosine value calculations and comparisons System . out . println ( analogy + " = " + cosineVal ) ; } sc . close ( ) ; } catch ( Exception e ) { System . err . println ( "Could not read file." ) ; } }
Reads analogies from Standard In and outputs their cosine similarities to Standard Out .