Word2vec::Spearmans - Spearman's Rank Correlation Score Module
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); $spearmans->SetPrecision( 8 ); my $score = $spearmans->CalculateSpearmans( "MiniMayoSRS.comp_results", "MiniMayoSRS.coders", undef ); print( "Spearman's Rank Correlation Score: $score\n" ); undef( $spearmans ); # Or use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); $spearmans->SetIsFileOfWords( 1 ); my $score = $spearmans->CalculateSpearmans( "MiniMayoSRS.terms.comp_results", "MiniMayoSRS.terms.coders", undef ); print( "Spearman's Rank Correlation Score: $score\n" ); undef( $spearmans );
Word2vec::Spearmans is a Spearman's Rank Correlation Score Module for the Word2vec::Inteface package.
Description:
Returns a new 'Word2vec::Spearmans' module object. Note: Specifying no parameters implies default options. Default Parameters: debugLog = 0 writeLog = 0 precision = 4 isFileOfWords = undef N = undef aCount = -1 bCount = -1 NValue = -1
Input:
$debugLog -> Instructs module to print debug statements to the console. (1 = True / 0 = False) $writeLog -> Instructs module to print debug statements to a log file. (1 = True / 0 = False) $isFileOfWords -> Specifies the word option, default is Auto-Detect. (undef = Auto-Detect, 0 = CUI Terms, 1 = Word Terms) $N -> Specifies the N option, default is undef. (defined = Print N / undef = Do Not Print N) $aCount -> Term count for $aFile post Spearman's Rank Correlation calculation. $bCount -> Term count for $bFile post Spearman's Rank Correlation calculation. $NValue -> N Value post Spearmans's Rank Correlation calculation. Warning: Only debugLog, writeLog, precision, word and N variables should be specified.
Output:
Word2vec::Spearmans object.
Example:
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); undef( $spearmans );
Removes member variables and file handle from memory.
None
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); $spearmans->DESTROY(); undef( $spearmans );
Calculates Spearman's Rank Correlation Score between two data-sets (files) using _precision, _isWordOfFile and _printN Variables. Note: _precision, _isFileOfWords and _printN variables must be set prior to calling this function or default values will be used.
$fileA -> File To Process $fileB -> File To Process $includeCountsInResults -> Specifies whether to return file counts in score. (undef = False / defined = True)
$value -> Spearman's Rank Correlation Score or "undef"
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); $spearmans->SetPrecision( 8 ); my $score = $spearmans->CalculateSpearmans( "MiniMayoSRS.comp_results", "MiniMayoSRS.coders", undef ); print( "Spearman's Rank Correlation Score: $score\n" ) if defined( $score ); print( "Spearman's Rank Correlation Score: undef\n" ) if !defined( $score ); undef( $spearmans ); # Or use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); $spearmans->SetIsFileOfWords( 1 ); my $score = $spearmans->CalculateSpearmans( "MiniMayoSRS.terms.comp_results", "MiniMayoSRS.terms.coders", 1 ); print( "Spearman's Rank Correlation Score: $score\n" ) if defined( $score ); print( "Spearman's Rank Correlation Score: undef\n" ) if !defined( $score ); undef( $spearmans );
Determines if a file is composed of CUI or word terms by checking the first line.
$string -> File Path
$string -> "undef" = Unable to determine, "cui" = CUI Term File, "word" = Word Term File
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); my $isWordOrCuiFile = $spearmans->IsFileWordOrCUIFile( "samples/MiniMayoSRS.terms" ); print( "MiniMayoSRS.terms File Is A \"$isWordOrCuiFile\" File\n" ) if defined( $isWordOrCuiFile ); print( "Unable To Determine Type Of File\n" ) if !defined( $isWordOrCuiFile undef( $spearmans );
Checks to see whether passed string argument is a word or CUI term. Note: This is an internal function and should not be called.
$value -> String
$value -> 0 = Word Term, 1 = CUI Term
This is a private function and should not be utilized.
Resets _aCount, _bCount and _NValue variables. Note: This is an internal function and should not be called.
Returns the _debugLog member variable set during Word2vec::Spearmans object initialization of new function.
$value -> 0 = False, 1 = True
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); my $debugLog = $spearmans->GetDebugLog(); print( "Debug Logging Enabled\n" ) if $debugLog == 1; print( "Debug Logging Disabled\n" ) if $debugLog == 0; undef( $spearmans );
Returns the _writeLog member variable set during Word2vec::Spearmans object initialization of new function.
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); my $writeLog = $spearmans->GetWriteLog(); print( "Write Logging Enabled\n" ) if $writeLog == 1; print( "Write Logging Disabled\n" ) if $writeLog == 0; undef( $spearmans );
Returns file handle used by WriteLog() method.
$fileHandle -> Returns file handle blob used by 'WriteLog()' function or undefined.
<This should not be called.>
Returns floating point precision value.
$value -> Spearmans Float Precision Value
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); my $value = $spearmans->GetPrecision(); print( "Float Precision Value: $value\n" ) if defined( $value ); undef( $spearmans );
Returns the variable indicating whether the files to be parsed are files consisting of words or CUI terms.
$value -> "undef = Auto-Detect, 0 = CUI Terms, 1 = Word Terms"
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); my $isFileOfWords = $spearmans->GetIsFileOfWords(); print( "IsFileOfWords Is Undefined\n" ) if !defined( $isFileOfWords ); print( "IsFileOfWords Value: $isFileOfWords\n" ) if defined( $isFileOfWords ); undef( $spearmans );
Returns the variable indicating whether to print NValue.
$value -> "undef" = Do not print NValue, "defined" = Print NValue
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); my $printN = $spearmans->GetPrintN(); print "Print N\n" if defined( $printN ); print "Do Not Print N\n" if !defined( $printN ); undef( $spearmans );
Returns the non-negative count for file A.
$value -> Integer
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); print "A Count: " . $spearmans->GetACount() . "\n"; undef( $spearmans );
Returns the non-negative count for file B.
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); print "B Count: " . $spearmans->GetBCount() . "\n"; undef( $spearmans );
Returns the N value.
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); print "N Value: " . $spearmans->GetNValue() . "\n"; undef( $spearmans );
Sets number of decimal places after the decimal point of the Spearman's Rank Correlation Score to represent.
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); $spearmans->SetPrecision( 8 ); my $score = $spearmans->CalculateSpearmans( "samples/MiniMayoSRS.term.comp_results", "Similarity/MiniMayoSRS.terms.coders", undef ); print "Spearman's Rank Correlation Score: $score\n" if defined( $score ); print "Spearman's Rank Correlation Score: undef\n" if !defined( $score ); undef( $spearmans );
Specifies the main method to auto-detect if file consists of CUI or Word terms, or manual override with user setting.
$value -> "undef" = Auto-Detect, 0 = CUI Terms, 1 = Word Terms
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); $spearmans->SetIsFileOfWords( undef ); my $score = $spearmans->CalculateSpearmans( "samples/MiniMayoSRS.term.comp_results", "Similarity/MiniMayoSRS.terms.coders", undef ); print "Spearman's Rank Correlation Score: $score\n" if defined( $score ); print "Spearman's Rank Correlation Score: undef\n" if !defined( $score ); undef( $spearmans );
Specifies the main method print _NValue post Spearmans::CalculateSpearmans() function completion.
$value -> "undef" = Do Not Print _NValue, "defined" = Print _NValue
use Word2vec::Spearmans; my $spearmans = Word2vec::Spearmans->new(); $spearmans->SetPrintN( 1 ); my $score = $spearmans->CalculateSpearmans( "samples/MiniMayoSRS.term.comp_results", "Similarity/MiniMayoSRS.terms.coders", undef ); print "Spearman's Rank Correlation Score: $score\n" if defined( $score ); print "Spearman's Rank Correlation Score: undef\n" if !defined( $score ); undef( $spearmans );
Sets _aCount variable. Note: This is an internal function and should not be called.
Sets _bCount variable. Note: This is an internal function and should not be called.
Sets _NValue variable. Note: This is an internal function and should not be called.
Returns current time string in "Hour:Minute:Second" format.
$string -> XX:XX:XX ("Hour:Minute:Second")
use Word2vec::Spearmans: my $spearmans = Word2vec::Spearmans->new(); my $time = $spearmans->GetTime(); print( "Current Time: $time\n" ) if defined( $time ); undef( $spearmans );
Returns current month, day and year string in "Month/Day/Year" format.
$string -> XX/XX/XXXX ("Month/Day/Year")
use Word2vec::Spearmans: my $spearmans = Word2vec::Spearmans->new(); my $date = $spearmans->GetDate(); print( "Current Date: $date\n" ) if defined( $date ); undef( $spearmans );
Prints passed string parameter to the console, log file or both depending on user options. Note: printNewLine parameter prints a new line character following the string if the parameter is undefined and does not if parameter is 0.
$string -> String to print to the console/log file. $value -> 0 = Do not print newline character after string, all else prints new line character including 'undef'.
use Word2vec::Spearmans: my $spearmans = Word2vec::Spearmans->new(); $spearmans->WriteLog( "Hello World" ); undef( $spearmans );
Bridget T McInnes, Virginia Commonwealth University Clint Cuffy, Virginia Commonwealth University
Copyright (c) 2016
Bridget T McInnes, Virginia Commonwealth University btmcinnes at vcu dot edu Clint Cuffy, Virginia Commonwealth University cuffyca at vcu dot edu
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to:
The Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
To install Word2vec::Interface, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Word2vec::Interface
CPAN shell
perl -MCPAN -e shell install Word2vec::Interface
For more information on module installation, please visit the detailed CPAN module installation guide.