Skip to content

Commit

Permalink
fix pri formula
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDev committed Nov 2, 2023
1 parent 751c3c1 commit 79d9b28
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .phpunit.cache/test-results
@@ -1 +1 @@
{"version":1,"defects":{"GoogleSerpTest::testPuphpeteerMobile":8,"GoogleSerpTest::testCurlMobile":8,"GoogleSerpTest::testExtractionPositionZero":8,"GoogleSerpTest::testExtractMaps":7,"GlobalTest::testTextDataExtractor":7,"GoogleSerpTest::testExtractMapsB":8,"GoogleTrendsTest::testTrendsPuppet":7,"GoogleSuggesterTest::testGoogleSuggester":8,"GoogleTrendsTest::testTrendsCurl":8,"PiedWeb\\MethodDocBlockGenerator\\Test\\MethodDocBlockGeneratorTest::testIt":7},"times":{"PiedWeb\\Crawler\\Test\\CrawlerTest::testIt":1.496,"PiedWeb\\Crawler\\Test\\CrawlerTest::testCommand":0.668,"PiedWeb\\Crawler\\Test\\CrawlerTest::testWitchCachId":0.762,"PiedWeb\\Curl\\Test\\HelperTest::testSchemeFromProxy":0.001,"PiedWeb\\Curl\\Test\\HelperTest::testCheckContentType":0,"PiedWeb\\Curl\\Test\\HelperTest::testCheckStatusCode":0,"PiedWeb\\Curl\\Test\\RequestTest::testDownloadIfHtml":0.304,"PiedWeb\\Curl\\Test\\RequestTest::testNotDownload":0.204,"PiedWeb\\Curl\\Test\\RequestTest::testEffectiveUrl":20.478,"PiedWeb\\Curl\\Test\\RequestTest::testCurlError":0.042,"PiedWeb\\Curl\\Test\\RequestTest::test404":0.229,"PiedWeb\\Curl\\Test\\RequestTest::testAllMethods":1.499,"PiedWeb\\Curl\\Test\\RequestTest::testMultipleCheckInHeaders":0.103,"PiedWeb\\Curl\\Test\\RequestTest::testProxy":1.002,"PiedWeb\\Curl\\Test\\RequestTest::testAbortIfTooBig":0.223,"PiedWeb\\Curl\\Test\\RequestTest::testDownloadOnlyFirstBytes":0.233,"PiedWeb\\Curl\\Test\\RequestTest::testResponseFromCache":0.002,"PiedWeb\\Curl\\Test\\StaticWrapperTest::testStaticGet":0.059,"GlobalTest::testEncoding":0.004,"GlobalTest::testCanonical":0.669,"GlobalTest::testTextDataExtractor":0.405,"GlobalTest::testHrefLangExtractor":0.367,"GoogleSerpTest::testPuphpeteerMobile":9.054,"GoogleSerpTest::testCurlMobile":0.873,"GoogleSerpTest::testExtractionPositionZero":0.784,"GoogleSerpTest::testExtractMaps":1.427,"GoogleSuggesterTest::testGoogleSuggester":1.373,"GoogleTrendsTest::testTrendsCurl":2.809,"GoogleTrendsTest::testTrendsPuppet":34.619,"PiedWeb\\TextAnalyzer\\Test\\AnalyzerTest::testMultiAnalyzer":0.009,"PiedWeb\\TextAnalyzer\\Test\\AnalyzerTest::testTextAnalyzer":0.003,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testSimpleSentences":0,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testRemoveExtremityStopWords":0,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testRemoveExtremityStopWords2":0,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testRemoveStopWords":0,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testStripTags":0.001,"GoogleSerpTest::testRelatedSearches":0.658,"GoogleSerpTest::testExtractMapsB":0.704,"PiedWeb\\MethodDocBlockGenerator\\Test\\MethodDocBlockGeneratorTest::testIt":0.001}}
{"version":1,"defects":{"GoogleSerpTest::testPuphpeteerMobile":8,"GoogleSerpTest::testCurlMobile":8,"GoogleSerpTest::testExtractionPositionZero":8,"GoogleSerpTest::testExtractMaps":7,"GlobalTest::testTextDataExtractor":7,"GoogleSerpTest::testExtractMapsB":8,"GoogleTrendsTest::testTrendsPuppet":7,"GoogleSuggesterTest::testGoogleSuggester":8,"GoogleTrendsTest::testTrendsCurl":8,"PiedWeb\\MethodDocBlockGenerator\\Test\\MethodDocBlockGeneratorTest::testIt":7},"times":{"PiedWeb\\Crawler\\Test\\CrawlerTest::testIt":1.496,"PiedWeb\\Crawler\\Test\\CrawlerTest::testCommand":0.668,"PiedWeb\\Crawler\\Test\\CrawlerTest::testWitchCachId":0.762,"PiedWeb\\Curl\\Test\\HelperTest::testSchemeFromProxy":0.001,"PiedWeb\\Curl\\Test\\HelperTest::testCheckContentType":0,"PiedWeb\\Curl\\Test\\HelperTest::testCheckStatusCode":0,"PiedWeb\\Curl\\Test\\RequestTest::testDownloadIfHtml":0.304,"PiedWeb\\Curl\\Test\\RequestTest::testNotDownload":0.204,"PiedWeb\\Curl\\Test\\RequestTest::testEffectiveUrl":20.478,"PiedWeb\\Curl\\Test\\RequestTest::testCurlError":0.042,"PiedWeb\\Curl\\Test\\RequestTest::test404":0.229,"PiedWeb\\Curl\\Test\\RequestTest::testAllMethods":1.499,"PiedWeb\\Curl\\Test\\RequestTest::testMultipleCheckInHeaders":0.103,"PiedWeb\\Curl\\Test\\RequestTest::testProxy":1.002,"PiedWeb\\Curl\\Test\\RequestTest::testAbortIfTooBig":0.223,"PiedWeb\\Curl\\Test\\RequestTest::testDownloadOnlyFirstBytes":0.233,"PiedWeb\\Curl\\Test\\RequestTest::testResponseFromCache":0.002,"PiedWeb\\Curl\\Test\\StaticWrapperTest::testStaticGet":0.059,"GlobalTest::testEncoding":0.004,"GlobalTest::testCanonical":0.669,"GlobalTest::testTextDataExtractor":0.405,"GlobalTest::testHrefLangExtractor":0.367,"GoogleSerpTest::testPuphpeteerMobile":9.054,"GoogleSerpTest::testCurlMobile":0.873,"GoogleSerpTest::testExtractionPositionZero":0.784,"GoogleSerpTest::testExtractMaps":3.312,"GoogleSuggesterTest::testGoogleSuggester":1.373,"GoogleTrendsTest::testTrendsCurl":2.809,"GoogleTrendsTest::testTrendsPuppet":34.619,"PiedWeb\\TextAnalyzer\\Test\\AnalyzerTest::testMultiAnalyzer":0.009,"PiedWeb\\TextAnalyzer\\Test\\AnalyzerTest::testTextAnalyzer":0.003,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testSimpleSentences":0,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testRemoveExtremityStopWords":0,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testRemoveExtremityStopWords2":0,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testRemoveStopWords":0,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testStripTags":0.001,"GoogleSerpTest::testRelatedSearches":0.658,"GoogleSerpTest::testExtractMapsB":0.704,"PiedWeb\\MethodDocBlockGenerator\\Test\\MethodDocBlockGeneratorTest::testIt":0.001}}
2 changes: 1 addition & 1 deletion packages/crawler/src/AbstractPageRankCalculator.php
Expand Up @@ -35,7 +35,7 @@ protected function calcul(): void
foreach ($ids as $id) {
$sumPR = 0;
foreach ($this->getLinksTo($id) as $link) {
$sumPR += $this->results[$link] ?? 0 / $this->getNbrLinksFrom($link);
$sumPR += ($this->results[$link] ?? 0) / $this->getNbrLinksFrom($link);
}

$this->results[$id] = $this->dampingFactor * $sumPR + (1 - $this->dampingFactor) / $this->getPagesNbr();
Expand Down
11 changes: 7 additions & 4 deletions packages/google/tests/GoogleSerpTest.php
Expand Up @@ -83,22 +83,25 @@ public function testExtractionPositionZero(): void

public function testExtractMaps(): void
{
foreach (['altimood', 'lac bleu valgaudemar altitude', 'accompagnateur montagne'] as $kw) {
// 'lac bleu valgaudemar altitude',
// 'plombier paris'
foreach (['altimood', 'accompagnateur montagne'] as $kw) {
$extractor = $this->getExtractor($kw);

$extractor->getBrowserPage()->screenshot(['path' => 'debug.png']);
$extractor->getBrowserPage()->screenshot(['path' => './debug/debugExtractMaps - '.$kw.'.png', 'fullPage' => true]);
file_put_contents('./debug/debugExtractMaps - '.$kw.'.html', $extractor->getBrowserPage()->content());

$mapsResults = $extractor->extractBusinessResults();
dump($mapsResults[0] ?? null);
$this->assertArrayHasKey(0, $mapsResults);
$this->assertArrayHasKey(0, $mapsResults, $kw);
}
}

public function testRelatedSearches(): void
{
$extractor = $this->getExtractor('randonnée valgaudemar');

$extractor->getBrowserPage()->screenshot(['path' => 'debug.png']);
$extractor->getBrowserPage()->screenshot(['path' => '/debug/debug-relatedSearches.png']);

$relatedSearches = $extractor->getRelatedSearches();
$this->assertContains('Rando Valgaudemar 3 jours', $relatedSearches);
Expand Down

0 comments on commit 79d9b28

Please sign in to comment.