Branch Coverage

blib/lib/Word2vec/Word2vec.pm
Criterion Covered Total %
branch 180 846 21.2


line true false branch
102 1 0 unless defined $self->{'_debugLog'}
103 1 0 unless defined $self->{'_writeLog'}
104 1 0 unless defined $self->{'_trainFileName'}
105 1 0 unless defined $self->{'_outputFileName'}
106 1 0 unless defined $self->{'_wordVecSize'}
107 1 0 unless defined $self->{'_windowSize'}
108 1 0 unless defined $self->{'_sample'}
109 1 0 unless defined $self->{'_hSoftMax'}
110 1 0 unless defined $self->{'_negative'}
111 1 0 unless defined $self->{'_numOfThreads'}
112 1 0 unless defined $self->{'_numOfIterations'}
113 1 0 unless defined $self->{'_minCount'}
114 1 0 unless defined $self->{'_classes'}
115 1 0 unless defined $self->{'_debug'}
116 1 0 unless defined $self->{'_binaryOutput'}
117 1 0 unless defined $self->{'_saveVocab'}
118 1 0 unless defined $self->{'_readVocab'}
119 1 0 unless defined $self->{'_useCBOW'}
121 1 0 if not defined $self->{'_alpha'} and $self->{'_useCBOW'} == 1
122 0 1 if not defined $self->{'_alpha'} and $self->{'_useCBOW'} == 0
124 1 0 unless defined $self->{'_workingDir'}
127 1 0 unless defined $self->{'_hashRefOfWordVectors'}
128 1 0 unless defined $self->{'_overwriteOldFile'}
129 1 0 unless defined $self->{'_sparseVectorMode'}
130 1 0 unless defined $self->{'_vectorLength'}
131 1 0 unless defined $self->{'_numberOfWords'}
132 1 0 unless defined $self->{'_minimizeMemoryUsage'}
138 0 11 if -e "$dir/External/Word2vec"
139 0 11 if -e "$dir/../External/Word2vec"
140 0 11 if -e "$dir/../../External/Word2vec"
141 3 8 if -e "$dir/Word2vec/External/Word2vec"
145 0 1 if ($self->{'_writeLog'})
154 1 0 if defined $self->{'_word2VecExeDir'}
155 1 0 if defined $self->{'_word2VecExeDir'}
170 0 1 if $self->{'_fileHandle'}
184 0 2 if $self->GetOSType eq 'MSWin32'
187 2 0 if defined $trainFilePath
188 0 2 unless defined $trainFilePath
191 2 0 if defined $outputFilePath
192 0 2 unless defined $outputFilePath
195 0 2 if defined $overwrite
196 2 0 unless defined $overwrite
199 2 0 unless -e "$executableFileDir"
200 2 0 unless -e "$executableFileDir"
201 0 0 unless -e "$trainFilePath"
202 0 0 if -z "$trainFilePath"
203 0 0 if not -e "$trainFilePath" or -z "$trainFilePath"
206 0 0 if $self->GetUseCBOW == 0
209 0 0 if -e "$outputFilePath" and $overwrite == 0
210 0 0 if -e "$outputFilePath" and $overwrite == 0
211 0 0 if -e "$outputFilePath" and $overwrite == 0
214 0 0 if defined $vectorSize
215 0 0 unless defined $vectorSize
217 0 0 if defined $windowSize
218 0 0 unless defined $windowSize
220 0 0 if defined $minCount
221 0 0 unless defined $minCount
223 0 0 if defined $sample
224 0 0 unless defined $sample
226 0 0 if defined $negative
227 0 0 unless defined $negative
229 0 0 if defined $alpha
230 0 0 unless defined $alpha
232 0 0 if defined $hs
233 0 0 unless defined $hs
235 0 0 if defined $binary
236 0 0 unless defined $binary
238 0 0 if defined $numOfThreads
239 0 0 unless defined $numOfThreads
241 0 0 if defined $iterations
242 0 0 unless defined $iterations
244 0 0 if defined $useCBOW
245 0 0 unless defined $useCBOW
247 0 0 if defined $classes
248 0 0 unless defined $classes
250 0 0 if defined $readVocab
251 0 0 unless defined $readVocab
253 0 0 if defined $saveVocab
254 0 0 unless defined $saveVocab
256 0 0 if defined $debug
257 0 0 unless defined $debug
275 0 0 if defined $readVocab and $readVocab ne ''
276 0 0 if defined $saveVocab and $saveVocab ne ''
288 0 0 if $result == 65280
290 0 0 unless -e "$outputFilePath"
291 0 0 if -z "$outputFilePath"
292 0 0 if not -e "$outputFilePath" or -z "$outputFilePath"
294 0 0 if $result == 0 and -e "$outputFilePath"
295 0 0 if $result != 0
306 0 1 unless defined $trainingStr
307 0 1 unless defined $trainingStr
309 0 1 if $trainingStr eq ''
310 0 1 if $trainingStr eq ''
318 0 1 unless open my $fileHandle, '>:encoding(utf8)', "$tempFilePath"
320 0 1 if $result == -1
321 0 1 if $result == -1
324 1 0 if defined $fileHandle
338 0 1 if $result == 0
339 1 0 if $result == -1 and $self->GetWriteLog == 0
340 0 1 if $result == -1 and $self->GetWriteLog == 1
350 1 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
351 1 0 if $self->IsVectorDataInMemory == 0
352 1 0 if $self->IsVectorDataInMemory == 0
354 0 0 unless defined $wordA and defined $wordB
355 0 0 unless defined $wordA and defined $wordB
366 0 0 if defined $wordAData
367 0 0 if defined $wordBData
370 0 0 if @wordAVtr == 0
371 0 0 if @wordBVtr == 0
372 0 0 if @wordAVtr == 0 or @wordBVtr == 0
381 0 0 unless defined $wordAVtrSize
382 0 0 unless defined $wordBVtrSize
420 0 0 if $ldpA != 0 and $ldpB != 0
432 1 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
433 1 0 if $self->IsVectorDataInMemory == 0
434 1 0 if $self->IsVectorDataInMemory == 0
436 0 0 unless defined $wordA and defined $wordB
437 0 0 unless defined $wordA and defined $wordB
439 0 0 if $wordA eq '' or $wordB eq ''
440 0 0 if $wordA eq '' or $wordB eq ''
450 0 0 unless defined $wordA
451 0 0 unless defined $wordB
452 0 0 unless defined $wordA and defined $wordB
460 0 0 unless defined $avgAVtrSize
461 0 0 unless defined $avgBVtrSize
502 0 0 if $ldpA != 0 and $ldpB != 0
514 2 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
515 2 0 if $self->IsVectorDataInMemory == 0
516 2 0 if $self->IsVectorDataInMemory == 0
518 0 0 unless defined $wordA and defined $wordB
519 0 0 unless defined $wordA and defined $wordB
538 0 0 if (defined $wordData)
550 0 0 if (defined $wordData)
563 0 0 if index($wordsFoundA, $wordAAry[$i]) == -1
564 0 0 if index($wordsFoundA, $wordAAry[$i]) == -1
569 0 0 if index($wordsFoundB, $wordBAry[$i]) == -1
570 0 0 if index($wordsFoundB, $wordBAry[$i]) == -1
573 0 0 if $error != 0
660 0 0 if $ldpA != 0 and $ldpB != 0
672 1 0 unless defined $wordAData and defined $wordBData
673 1 0 unless defined $wordAData and defined $wordBData
675 0 0 if $wordAData eq '' or $wordBData eq ''
676 0 0 if $wordAData eq '' or $wordBData eq ''
690 0 0 unless defined $wordAVtrSize
691 0 0 unless defined $wordBVtrSize
729 0 0 if $ldpA != 0 and $ldpB != 0
741 0 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
742 0 0 if $self->IsVectorDataInMemory == 0
743 0 0 if $self->IsVectorDataInMemory == 0
748 0 0 if $self->GetDebugLog == 0
753 0 0 if $input eq 'EXIT'
756 0 0 if @wordAry == 0 or @wordAry == 1
757 0 0 if @wordAry == 0 or @wordAry == 1
760 0 0 if $self->GetDebugLog == 0 and @wordAry == 0 || @wordAry == 1
761 0 0 if $self->GetDebugLog == 0 and @wordAry == 0 || @wordAry == 1
762 0 0 if @wordAry == 0 or @wordAry == 1
765 0 0 if defined $value
769 0 0 if not defined $value and $self->GetDebugLog == 0
770 0 0 if defined $value and $self->GetDebugLog == 0
771 0 0 if $self->GetDebugLog == 0
780 0 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
781 0 0 if $self->IsVectorDataInMemory == 0
782 0 0 if $self->IsVectorDataInMemory == 0
787 0 0 if $self->GetDebugLog == 0
792 0 0 if $input eq 'EXIT'
795 0 0 if @wordAry == 0 or @wordAry == 1
796 0 0 if @wordAry == 0 or @wordAry == 1
799 0 0 if $self->GetDebugLog == 0 and @wordAry == 0 || @wordAry == 1
800 0 0 if $self->GetDebugLog == 0 and @wordAry == 0 || @wordAry == 1
801 0 0 if @wordAry == 0 or @wordAry == 1
808 0 0 if defined $value
812 0 0 if not defined $value and $self->GetDebugLog == 0
813 0 0 if defined $value and $self->GetDebugLog == 0
814 0 0 if $self->GetDebugLog == 0
823 1 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
824 1 0 if $self->IsVectorDataInMemory == 0
825 1 0 if $self->IsVectorDataInMemory == 0
827 0 0 unless defined $wordAryRef
828 0 0 unless defined $wordAryRef
841 0 0 if ($self->GetMinimizeMemoryUsage == 0) { }
847 0 0 if ($self->GetSparseVectorMode == 0) { }
853 0 0 if defined $result
856 0 0 if defined $result
857 0 0 if @wordData > 0
859 0 0 if $wordDataSize == 0 and defined $result
868 0 0 if defined $result
871 0 0 if defined $result
873 0 0 if $wordDataSize == 0 and defined $result
878 0 0 if @foundWords > 0
886 0 0 if ($self->GetSparseVectorMode == 0) { }
922 0 0 if (@foundWordData > 1)
933 0 0 if ($self->GetSparseVectorMode == 0) { }
959 0 0 if ($self->GetSparseVectorMode == 0) { }
964 0 0 unless defined $result
967 0 0 if defined $result
970 0 0 if defined $result
973 0 0 if $wordDataSize == 0 and defined $result
976 0 0 if @resultAry == 0 and @resultAry != $wordDataSize
988 0 0 if defined $result and $result ne ''
997 0 0 if @resultAry == 0
1003 0 0 if defined $result
1006 0 0 if defined $result
1022 0 0 if @foundWords > 0
1025 0 0 if (@foundWords > 1)
1039 0 0 if @resultAry > 0
1040 0 0 if @resultAry == 0
1042 0 0 if @resultAry > 0
1043 0 0 if @resultAry == 0
1053 1 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
1054 1 0 if $self->IsVectorDataInMemory == 0
1055 1 0 if $self->IsVectorDataInMemory == 0
1057 0 0 unless defined $wordA and defined $wordB
1058 0 0 unless defined $wordA and defined $wordB
1063 0 0 unless defined $wordAData
1064 0 0 unless defined $wordBData
1065 0 0 unless defined $wordAData and defined $wordBData
1071 0 0 if @wordAVtr != @wordBVtr
1072 0 0 if @wordAVtr != @wordBVtr
1100 1 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
1101 1 0 if $self->IsVectorDataInMemory == 0
1102 1 0 if $self->IsVectorDataInMemory == 0
1104 0 0 unless defined $wordA and defined $wordB
1105 0 0 unless defined $wordA and defined $wordB
1110 0 0 unless defined $wordAData
1111 0 0 unless defined $wordBData
1112 0 0 unless defined $wordAData and defined $wordBData
1118 0 0 if @wordAVtr != @wordBVtr
1119 0 0 if @wordAVtr != @wordBVtr
1147 1 0 unless defined $wordA and defined $wordB
1148 1 0 unless defined $wordA and defined $wordB
1154 0 0 if @wordAVtr != @wordBVtr
1155 0 0 if @wordAVtr != @wordBVtr
1179 1 0 unless defined $wordA and defined $wordB
1180 1 0 unless defined $wordA and defined $wordB
1186 0 0 if @wordAVtr != @wordBVtr
1187 0 0 if @wordAVtr != @wordBVtr
1211 1 0 unless defined $wordA and defined $wordB
1212 1 0 unless defined $wordA and defined $wordB
1218 0 0 if @wordAVtr != @wordBVtr
1219 0 0 if @wordAVtr != @wordBVtr
1242 0 5 if defined $returnRawSparseText
1243 5 0 unless defined $returnRawSparseText
1246 5 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
1247 5 0 if $self->IsVectorDataInMemory == 0
1248 5 0 if $self->IsVectorDataInMemory == 0
1252 0 0 unless defined $wordVectorData
1254 0 0 unless defined $wordVectorData
1259 0 0 if ($self->GetSparseVectorMode == 1) { }
1261 0 0 if ($returnRawSparseText == 1)
1270 0 0 if $vectorSize != 0
1275 0 0 if $i % 2 == 0
1278 0 0 if defined $index
1281 0 0 if defined $index and defined $element
1306 0 37 if $numberOfWordsInMemory > 0
1315 0 0 unless defined $aryRef
1316 0 0 if defined $aryRef
1318 0 0 if keys %{$vocabHashRef;} == 0
1319 0 0 if keys %{$vocabHashRef;} == 0
1324 0 0 if defined $vocabHashRef->{$numOfWords} and $vocabHashRef->{$numOfWords} eq "$vectorLength #\$\@RTED#"
1333 0 3 unless defined $fileDir
1334 0 3 unless defined $fileDir
1336 1 2 unless -e $fileDir
1337 1 2 unless -e $fileDir
1346 0 2 unless open my $fh, '<:', "$fileDir"
1353 2 2 if ($i == 0)
1358 0 2 if @dimensionsAry >= 2
1361 0 2 if @dimensionsAry >= 2
1370 2 0 if length $oldData == length $newData
1371 0 2 if length $oldData != length $newData
1374 0 2 if defined $oldData
1375 0 2 if defined $oldData and @dataAry - 1 != $sizeOfVectors
1379 2 0 if ($fileType eq 'text')
1381 0 2 if $numOfWordVectors > 50
1382 2 0 if $numOfWordVectors < 50
1388 0 0 if defined $data
1389 0 0 if defined $data and @dataAry - 1 != $sizeOfVectors
1392 0 2 if $sparseVectorsFlag == 1
1408 0 4 unless defined $fileDir
1409 0 4 unless defined $fileDir
1411 3 1 unless -e "$fileDir"
1412 3 1 unless -e "$fileDir"
1414 1 0 if -z "$fileDir"
1415 1 0 if -z "$fileDir"
1418 0 0 if $numberOfWordsInMemory > 0
1419 0 0 if $numberOfWordsInMemory > 0
1426 0 0 unless defined $fileType
1427 0 0 unless defined $fileType
1429 0 0 if $fileType eq 'text'
1430 0 0 if $fileType eq 'sparsetext'
1431 0 0 if $fileType eq 'binary'
1433 0 0 if $fileType eq 'sparsetext'
1434 0 0 if $fileType eq 'sparsetext'
1435 0 0 if $fileType ne 'sparsetext'
1444 0 0 if ($fileType eq 'text') { }
0 0 elsif ($fileType eq 'sparsetext') { }
0 0 elsif ($fileType eq 'binary') { }
1454 0 0 if ($lineCount == 0)
1458 0 0 if @data < 2
1459 0 0 if @data < 2
1460 0 0 if @data < 2
1486 0 0 if ($lineCount == 0) { }
0 0 elsif ($lineCount > 0) { }
1490 0 0 if (@data >= 2)
1512 0 0 if (@data > 2 and @data % 2 == 0)
1522 0 0 unless defined $data[0]
1523 0 0 unless defined $data[0]
1552 0 0 if @strAry < 2
1576 0 0 if $buffer ne ' ' and defined $buffer
1579 0 0 if eof
1580 0 0 if $buffer eq ' '
1581 0 0 if eof
1582 0 0 if eof
1583 0 0 if eof
1584 0 0 if eof
1585 0 0 if eof
1586 0 0 if eof
1587 0 0 if eof
1598 0 0 if not defined $buffer or $buffer eq 0
1599 0 0 if not defined $buffer or $buffer eq 0
1601 0 0 if (defined $buffer and $buffer ne '')
1613 0 0 if $word ne ''
1626 0 0 if defined $self->GetVocabularyHash
1627 0 0 unless defined $numberOfWords
1639 0 3 unless defined $savePath
1640 0 3 unless defined $savePath
1642 0 3 unless defined $saveFormat
1648 1 2 if ($saveFormat == 0) { }
1 1 elsif ($saveFormat == 1) { }
1 0 elsif ($saveFormat == 2) { }
1652 0 1 unless open $fileHandle, '>:encoding(utf8)', "$savePath"
1656 0 1 if ($self->GetSparseVectorMode == 1) { }
1666 0 0 if $wordVectorData eq ''
1667 0 0 if $wordVectorData eq ''
1669 0 0 if ($i == 0) { }
1681 0 0 if $vectorSize != 0
1686 0 0 if $j % 2 == 1
1689 0 0 if defined $index
1692 0 0 if defined $index and defined $element
1717 0 0 if $i == 0
1718 0 0 if $i > 0
1737 1 0 if @dataAry == 0
1738 1 0 if @dataAry == 0
1740 0 0 unless open $fileHandle, '>:raw', "$savePath"
1745 0 0 if @headerAry < 2
1761 0 0 if $i == 0
1764 0 0 if ($self->GetSparseVectorMode == 1)
1775 0 0 if @ary < $windowSize
1804 0 1 unless open $fileHandle, '>:encoding(utf8)', "$savePath"
1808 0 1 if ($self->GetSparseVectorMode == 1) { }
1825 0 0 if $i == 0
1827 0 0 if ($i > 0 and defined $data)
1841 0 0 if $value != 0
1865 1 1 if length $strA != length $strB
1866 0 1 if index($strA, $strB) != 0
1876 3 0 unless defined $dataStr
1891 0 1 unless defined $rawSparseText
1892 0 1 unless defined $rawSparseText
1894 0 1 if $rawSparseText eq ''
1895 0 1 if $rawSparseText eq ''
1899 1 0 if $vectorSize == 0
1900 1 0 if $vectorSize == 0
1911 0 0 if $i == 0
1914 0 0 if $i % 2 == 1
1917 0 0 if defined $index
1920 0 0 if defined $index and defined $element
1936 0 0 unless defined $rawSparseText
1937 0 0 unless defined $rawSparseText
1939 0 0 if $rawSparseText eq ''
1940 0 0 if $rawSparseText eq ''
1944 0 0 if $vectorSize == 0
1945 0 0 if $vectorSize == 0
1955 0 0 if $i == 0
1958 0 0 if $i % 2 == 1
1961 0 0 if defined $index
1964 0 0 if defined $index and defined $element
1989 0 60 unless defined $self->{'_debugLog'}
1996 0 50 unless defined $self->{'_writeLog'}
2003 1 0 unless defined $self->{'_fileHandle'}
2010 0 2 unless defined $self->{'_trainFileName'}
2017 0 2 unless defined $self->{'_outputFileName'}
2024 0 2 unless defined $self->{'_wordVecSize'}
2031 0 2 unless defined $self->{'_windowSize'}
2038 0 2 unless defined $self->{'_sample'}
2045 0 2 unless defined $self->{'_hSoftMax'}
2052 0 2 unless defined $self->{'_negative'}
2059 0 2 unless defined $self->{'_numOfThreads'}
2066 0 2 unless defined $self->{'_numOfIterations'}
2073 0 2 unless defined $self->{'_minCount'}
2080 0 3 if not defined $self->{'_alpha'} and $self->GetUseCBOW == 1
2081 0 3 if not defined $self->{'_alpha'} and $self->GetUseCBOW == 0
2088 0 2 unless defined $self->{'_classes'}
2095 0 2 unless defined $self->{'_debug'}
2102 0 2 unless defined $self->{'_binaryOutput'}
2109 0 2 unless defined $self->{'_saveVocab'}
2116 0 2 unless defined $self->{'_readVocab'}
2123 0 2 unless defined $self->{'_useCBOW'}
2130 0 5 unless defined $self->{'_workingDir'}
2137 0 5 unless defined $self->{'_word2VecExeDir'}
2144 0 42 unless defined $self->{'_hashRefOfWordVectors'}
2151 0 4 unless defined $self->{'_overwriteOldFile'}
2158 0 4 unless defined $self->{'_sparseVectorMode'}
2165 0 5 unless defined $self->{'_vectorLength'}
2172 0 4 unless defined $self->{'_numberOfWords'}
2179 0 2 unless defined $self->{'_minimizeMemoryUsage'}
2305 0 1 unless defined $ref
2325 0 0 unless defined $wordVectorStr
2329 0 0 unless defined $self->{'_hashRefOfWordVectors'}
2330 0 0 if @tempAry != 2
2362 1 1 if $temp == 0
2363 1 1 if $temp == 1
2377 0 1 if ($hour < 10)
2382 1 0 if ($min < 10)
2387 0 1 if ($sec < 10)
2412 0 47 unless defined $string
2413 47 0 unless defined $printNewLine
2416 0 47 if ($self->GetDebugLog)
2418 0 0 if (ref $self ne 'Word2vec::Word2vec')
2424 0 0 unless defined $string
2426 0 0 if $printNewLine != 0
2429 0 47 if ($self->GetWriteLog)
2431 0 0 if (ref $self ne 'Word2vec::Word2vec')
2439 0 0 if (defined $fileHandle)
2442 0 0 if $printNewLine != 0