Branch Coverage

blib/lib/Word2vec/Word2vec.pm
Criterion Covered Total %
branch 182 924 19.7


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 ''
447 0 0 if @wordAAry == 0 or @wordBAry == 0
448 0 0 if @wordAAry == 0 or @wordBAry == 0
454 0 0 unless defined $wordA
455 0 0 unless defined $wordB
456 0 0 unless defined $wordA and defined $wordB
464 0 0 unless defined $avgAVtrSize
465 0 0 unless defined $avgBVtrSize
506 0 0 if $ldpA != 0 and $ldpB != 0
518 2 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
519 2 0 if $self->IsVectorDataInMemory == 0
520 2 0 if $self->IsVectorDataInMemory == 0
522 0 0 unless defined $wordA and defined $wordB
523 0 0 unless defined $wordA and defined $wordB
525 0 0 unless defined $allWordsMustExist
526 0 0 unless defined $allWordsMustExist
541 0 0 if @wordAAry == 0 or @wordBAry == 0
542 0 0 if @wordAAry == 0 or @wordBAry == 0
549 0 0 if (defined $wordData)
561 0 0 if (defined $wordData)
574 0 0 if index($wordsFoundA, $wordAAry[$i]) == -1
575 0 0 if index($wordsFoundA, $wordAAry[$i]) == -1 and $allWordsMustExist == 1
580 0 0 if index($wordsFoundB, $wordBAry[$i]) == -1
581 0 0 if index($wordsFoundB, $wordBAry[$i]) == -1 and $allWordsMustExist == 1
584 0 0 if $wordsFoundA eq '' or $wordsFoundB eq ''
585 0 0 if $wordsFoundA eq '' or $wordsFoundB eq ''
587 0 0 if $error != 0
674 0 0 if $ldpA != 0 and $ldpB != 0
686 1 0 unless defined $wordAData and defined $wordBData
687 1 0 unless defined $wordAData and defined $wordBData
689 0 0 if $wordAData eq '' or $wordBData eq ''
690 0 0 if $wordAData eq '' or $wordBData eq ''
704 0 0 unless defined $wordAVtrSize
705 0 0 unless defined $wordBVtrSize
743 0 0 if $ldpA != 0 and $ldpB != 0
755 0 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
756 0 0 if $self->IsVectorDataInMemory == 0
757 0 0 if $self->IsVectorDataInMemory == 0
762 0 0 if $self->GetDebugLog == 0
767 0 0 if $input eq 'EXIT'
770 0 0 if @wordAry == 0 or @wordAry == 1
771 0 0 if @wordAry == 0 or @wordAry == 1
774 0 0 if $self->GetDebugLog == 0 and @wordAry == 0 || @wordAry == 1
775 0 0 if $self->GetDebugLog == 0 and @wordAry == 0 || @wordAry == 1
776 0 0 if @wordAry == 0 or @wordAry == 1
779 0 0 if defined $value
783 0 0 if not defined $value and $self->GetDebugLog == 0
784 0 0 if defined $value and $self->GetDebugLog == 0
785 0 0 if $self->GetDebugLog == 0
794 0 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
795 0 0 if $self->IsVectorDataInMemory == 0
796 0 0 if $self->IsVectorDataInMemory == 0
801 0 0 if $self->GetDebugLog == 0
806 0 0 if $input eq 'EXIT'
809 0 0 if @wordAry == 0 or @wordAry == 1
810 0 0 if @wordAry == 0 or @wordAry == 1
813 0 0 if $self->GetDebugLog == 0 and @wordAry == 0 || @wordAry == 1
814 0 0 if $self->GetDebugLog == 0 and @wordAry == 0 || @wordAry == 1
815 0 0 if @wordAry == 0 or @wordAry == 1
822 0 0 if defined $value
826 0 0 if not defined $value and $self->GetDebugLog == 0
827 0 0 if defined $value and $self->GetDebugLog == 0
828 0 0 if $self->GetDebugLog == 0
837 1 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
838 1 0 if $self->IsVectorDataInMemory == 0
839 1 0 if $self->IsVectorDataInMemory == 0
841 0 0 unless defined $wordAryRef
842 0 0 unless defined $wordAryRef
855 0 0 if ($self->GetMinimizeMemoryUsage == 0) { }
861 0 0 if ($self->GetSparseVectorMode == 0) { }
867 0 0 if defined $result
870 0 0 if defined $result
871 0 0 if @wordData > 0
873 0 0 if $wordDataSize == 0 and defined $result
882 0 0 if defined $result
885 0 0 if defined $result
887 0 0 if $wordDataSize == 0 and defined $result
892 0 0 if @foundWords > 0
900 0 0 if ($self->GetSparseVectorMode == 0) { }
936 0 0 if (@foundWordData > 1)
947 0 0 if ($self->GetSparseVectorMode == 0) { }
973 0 0 if ($self->GetSparseVectorMode == 0) { }
978 0 0 unless defined $result
981 0 0 if defined $result
984 0 0 if defined $result
987 0 0 if $wordDataSize == 0 and defined $result
990 0 0 if @resultAry == 0 and @resultAry != $wordDataSize
1002 0 0 if defined $result and $result ne ''
1011 0 0 if @resultAry == 0
1017 0 0 if defined $result
1020 0 0 if defined $result
1036 0 0 if @foundWords > 0
1039 0 0 if (@foundWords > 1)
1053 0 0 if @resultAry > 0
1054 0 0 if @resultAry == 0
1056 0 0 if @resultAry > 0
1057 0 0 if @resultAry == 0
1067 1 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
1068 1 0 if $self->IsVectorDataInMemory == 0
1069 1 0 if $self->IsVectorDataInMemory == 0
1071 0 0 unless defined $wordA and defined $wordB
1072 0 0 unless defined $wordA and defined $wordB
1077 0 0 unless defined $wordAData
1078 0 0 unless defined $wordBData
1079 0 0 unless defined $wordAData and defined $wordBData
1085 0 0 if @wordAVtr != @wordBVtr
1086 0 0 if @wordAVtr != @wordBVtr
1114 1 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
1115 1 0 if $self->IsVectorDataInMemory == 0
1116 1 0 if $self->IsVectorDataInMemory == 0
1118 0 0 unless defined $wordA and defined $wordB
1119 0 0 unless defined $wordA and defined $wordB
1124 0 0 unless defined $wordAData
1125 0 0 unless defined $wordBData
1126 0 0 unless defined $wordAData and defined $wordBData
1132 0 0 if @wordAVtr != @wordBVtr
1133 0 0 if @wordAVtr != @wordBVtr
1161 1 0 unless defined $wordA and defined $wordB
1162 1 0 unless defined $wordA and defined $wordB
1168 0 0 if @wordAVtr != @wordBVtr
1169 0 0 if @wordAVtr != @wordBVtr
1193 1 0 unless defined $wordA and defined $wordB
1194 1 0 unless defined $wordA and defined $wordB
1200 0 0 if @wordAVtr != @wordBVtr
1201 0 0 if @wordAVtr != @wordBVtr
1225 1 0 unless defined $wordA and defined $wordB
1226 1 0 unless defined $wordA and defined $wordB
1232 0 0 if @wordAVtr != @wordBVtr
1233 0 0 if @wordAVtr != @wordBVtr
1256 0 5 if defined $returnRawSparseText
1257 5 0 unless defined $returnRawSparseText
1260 5 0 if $self->GetDebugLog == 0 and $self->IsVectorDataInMemory == 0
1261 5 0 if $self->IsVectorDataInMemory == 0
1262 5 0 if $self->IsVectorDataInMemory == 0
1266 0 0 unless defined $wordVectorData
1268 0 0 unless defined $wordVectorData
1273 0 0 if ($self->GetSparseVectorMode == 1) { }
1275 0 0 if ($returnRawSparseText == 1)
1283 0 0 if $vectorSize == 0
1284 0 0 if $vectorSize == 0
1289 0 0 if $vectorSize != 0
1294 0 0 if $i % 2 == 0
1297 0 0 if defined $index
1300 0 0 if defined $index and defined $element
1325 0 52 if $numberOfWordsInMemory > 0
1335 4 0 if $self->IsVectorDataInMemory == 0
1336 4 0 if $self->IsVectorDataInMemory == 0
1352 0 0 if @terms != 2
1355 0 0 if $terms[0] ne ''
1361 0 0 if $terms[1] ne ''
1370 0 0 unless defined $aryRef
1371 0 0 if defined $aryRef
1373 0 0 if keys %{$vocabHashRef;} == 0
1374 0 0 if keys %{$vocabHashRef;} == 0
1379 0 0 if defined $vocabHashRef->{$numOfWords} and $vocabHashRef->{$numOfWords} eq "$vectorLength #\$\@RTED#"
1388 0 3 unless defined $fileDir
1389 0 3 unless defined $fileDir
1391 1 2 unless -e $fileDir
1392 1 2 unless -e $fileDir
1401 0 2 unless open my $fh, '<:', "$fileDir"
1408 2 2 if ($i == 0)
1413 0 2 if @dimensionsAry >= 2
1416 0 2 if @dimensionsAry >= 2
1425 2 0 if length $oldData == length $newData
1426 0 2 if length $oldData != length $newData
1429 0 2 if defined $oldData
1430 0 2 if defined $oldData and @dataAry - 1 != $sizeOfVectors
1434 2 0 if ($fileType eq 'text')
1436 0 2 if $numOfWordVectors > 50
1437 2 0 if $numOfWordVectors < 50
1443 0 0 if defined $data
1444 0 0 if defined $data and @dataAry - 1 != $sizeOfVectors
1447 0 2 if $sparseVectorsFlag == 1
1463 0 4 unless defined $fileDir
1464 0 4 unless defined $fileDir
1466 3 1 unless -e "$fileDir"
1467 3 1 unless -e "$fileDir"
1469 1 0 if -z "$fileDir"
1470 1 0 if -z "$fileDir"
1473 0 0 if $numberOfWordsInMemory > 0
1474 0 0 if $numberOfWordsInMemory > 0
1476 0 0 if defined $searchWord
1477 0 0 if defined $searchWord
1483 0 0 unless defined $fileType
1484 0 0 unless defined $fileType
1486 0 0 if $fileType eq 'text'
1487 0 0 if $fileType eq 'sparsetext'
1488 0 0 if $fileType eq 'binary'
1490 0 0 if $fileType eq 'sparsetext'
1491 0 0 if $fileType eq 'sparsetext'
1492 0 0 if $fileType ne 'sparsetext'
1501 0 0 if ($fileType eq 'text') { }
0 0 elsif ($fileType eq 'sparsetext') { }
0 0 elsif ($fileType eq 'binary') { }
1512 0 0 if $self->GetNumberOfWords > 0
1515 0 0 if length $row == 0
1517 0 0 if ($lineCount == 0)
1522 0 0 if (@data < 2)
1534 0 0 if (defined $searchWord) { }
1538 0 0 if ($data[0] eq $searchWord)
1553 0 0 if $self->GetNumberOfWords > 0
1575 0 0 if $self->GetNumberOfWords > 0
1578 0 0 if length $row == 0
1581 0 0 if ($lineCount == 0) { }
0 0 elsif ($lineCount > 0) { }
1586 0 0 if (@data < 2)
1612 0 0 if (@data > 2 and @data % 2 == 0)
1622 0 0 unless defined $data[0]
1623 0 0 unless defined $data[0]
1630 0 0 if (defined $searchWord) { }
1634 0 0 if ($data[0] eq $searchWord)
1649 0 0 if $self->GetNumberOfWords > 0
1671 0 0 if length $row == 0
1676 0 0 if @strAry < 2
1696 0 0 if $self->GetNumberOfWords > 0
1703 0 0 if $buffer ne ' ' and defined $buffer
1706 0 0 if eof
1707 0 0 if $buffer eq ' '
1708 0 0 if eof
1709 0 0 if eof
1710 0 0 if eof
1711 0 0 if eof
1712 0 0 if eof
1713 0 0 if eof
1714 0 0 if eof
1725 0 0 if not defined $buffer or $buffer eq 0
1726 0 0 if not defined $buffer or $buffer eq 0
1728 0 0 if (defined $buffer and $buffer ne '')
1740 0 0 if (defined $searchWord) { }
1744 0 0 if ($data[0] eq $searchWord)
1756 0 0 if $word ne ''
1767 0 0 if $self->GetNumberOfWords > 0
1773 0 0 if defined $self->GetVocabularyHash
1774 0 0 unless defined $numberOfWords
1782 0 0 if defined $searchWord
1792 0 3 unless defined $savePath
1793 0 3 unless defined $savePath
1795 0 3 unless defined $saveFormat
1801 1 2 if ($saveFormat == 0) { }
1 1 elsif ($saveFormat == 1) { }
1 0 elsif ($saveFormat == 2) { }
1805 0 1 unless open $fileHandle, '>:encoding(utf8)', "$savePath"
1809 0 1 if ($self->GetSparseVectorMode == 1) { }
1817 0 0 if $numOfWords > 0
1822 0 0 if $wordVectorData eq ''
1823 0 0 if $wordVectorData eq ''
1825 0 0 if ($i == 0) { }
1837 0 0 if $vectorSize != 0
1842 0 0 if $j % 2 == 1
1845 0 0 if defined $index
1848 0 0 if defined $index and defined $element
1863 0 0 if $numOfWords > 0
1876 0 0 if $numOfWords > 0
1879 0 0 if $i == 0
1880 0 0 if $i > 0
1883 0 0 if $numOfWords > 0
1902 1 0 if @dataAry == 0
1903 1 0 if @dataAry == 0
1905 0 0 unless open $fileHandle, '>:raw', "$savePath"
1910 0 0 if @headerAry < 2
1924 0 0 if $numOfWords > 0
1929 0 0 if $i == 0
1932 0 0 if ($self->GetSparseVectorMode == 1)
1943 0 0 if @ary < $windowSize
1962 0 0 if $numOfWords > 0
1975 0 1 unless open $fileHandle, '>:encoding(utf8)', "$savePath"
1979 0 1 if ($self->GetSparseVectorMode == 1) { }
1996 0 0 if $numOfWords > 0
1999 0 0 if $i == 0
2001 0 0 if ($i > 0 and defined $data)
2015 0 0 if $value != 0
2022 0 0 if $numOfWords > 0
2045 1 1 if length $strA != length $strB
2046 0 1 if index($strA, $strB) != 0
2056 3 0 unless defined $dataStr
2072 0 1 unless defined $rawSparseText
2073 0 1 unless defined $rawSparseText
2075 0 1 if $rawSparseText eq ''
2076 0 1 if $rawSparseText eq ''
2080 1 0 if $vectorSize == 0
2081 1 0 if $vectorSize == 0
2092 0 0 if $i == 0
2095 0 0 if $i % 2 == 1
2098 0 0 if defined $index
2101 0 0 if defined $index and defined $element
2117 0 0 unless defined $rawSparseText
2118 0 0 unless defined $rawSparseText
2120 0 0 if $rawSparseText eq ''
2121 0 0 if $rawSparseText eq ''
2125 0 0 if $vectorSize == 0
2126 0 0 if $vectorSize == 0
2136 0 0 if $i == 0
2139 0 0 if $i % 2 == 1
2142 0 0 if defined $index
2145 0 0 if defined $index and defined $element
2170 0 64 unless defined $self->{'_debugLog'}
2177 0 54 unless defined $self->{'_writeLog'}
2184 1 0 unless defined $self->{'_fileHandle'}
2191 0 2 unless defined $self->{'_trainFileName'}
2198 0 2 unless defined $self->{'_outputFileName'}
2205 0 2 unless defined $self->{'_wordVecSize'}
2212 0 2 unless defined $self->{'_windowSize'}
2219 0 2 unless defined $self->{'_sample'}
2226 0 2 unless defined $self->{'_hSoftMax'}
2233 0 2 unless defined $self->{'_negative'}
2240 0 2 unless defined $self->{'_numOfThreads'}
2247 0 2 unless defined $self->{'_numOfIterations'}
2254 0 2 unless defined $self->{'_minCount'}
2261 0 3 if not defined $self->{'_alpha'} and $self->GetUseCBOW == 1
2262 0 3 if not defined $self->{'_alpha'} and $self->GetUseCBOW == 0
2269 0 2 unless defined $self->{'_classes'}
2276 0 2 unless defined $self->{'_debug'}
2283 0 2 unless defined $self->{'_binaryOutput'}
2290 0 2 unless defined $self->{'_saveVocab'}
2297 0 2 unless defined $self->{'_readVocab'}
2304 0 2 unless defined $self->{'_useCBOW'}
2311 0 5 unless defined $self->{'_workingDir'}
2318 0 5 unless defined $self->{'_word2VecExeDir'}
2325 0 57 unless defined $self->{'_hashRefOfWordVectors'}
2332 0 4 unless defined $self->{'_overwriteOldFile'}
2339 0 4 unless defined $self->{'_sparseVectorMode'}
2346 0 5 unless defined $self->{'_vectorLength'}
2353 0 4 unless defined $self->{'_numberOfWords'}
2360 0 2 unless defined $self->{'_minimizeMemoryUsage'}
2486 0 1 unless defined $ref
2506 0 0 unless defined $wordVectorStr
2510 0 0 unless defined $self->{'_hashRefOfWordVectors'}
2511 0 0 if @tempAry != 2
2543 1 1 if $temp == 0
2544 1 1 if $temp == 1
2558 1 0 if ($hour < 10)
2563 0 1 if ($min < 10)
2568 1 0 if ($sec < 10)
2593 0 51 unless defined $string
2594 51 0 unless defined $printNewLine
2597 0 51 if ($self->GetDebugLog)
2599 0 0 if (ref $self ne 'Word2vec::Word2vec')
2605 0 0 unless defined $string
2607 0 0 if $printNewLine != 0
2610 0 51 if ($self->GetWriteLog)
2612 0 0 if (ref $self ne 'Word2vec::Word2vec')
2620 0 0 if (defined $fileHandle)
2623 0 0 if $printNewLine != 0