Spaces:
Running
Running
fix(scrape parser): Cannot read properties of 'undefined' during page parsing (#1274)
Browse filesfix(scrape parser): Cannot read properties of undefined (reading percentageTextShare) during page parsing
Co-authored-by: Nathan Sarrazin <[email protected]>
src/lib/server/websearch/scrape/parser.ts
CHANGED
@@ -432,7 +432,7 @@ export function spatialParser() {
|
|
432 |
});
|
433 |
|
434 |
// if there is a dominant cluster with more than 60% text share, return that
|
435 |
-
const dominantCluster = clusterWithMetrics[0]
|
436 |
if (dominantCluster) return [clusterWithMetrics[0].cluster];
|
437 |
|
438 |
// clusters are sorted by text share after applying a penalty for centrality
|
@@ -448,7 +448,7 @@ export function spatialParser() {
|
|
448 |
// find all clusters that are similar to the largest cluster in terms of text share
|
449 |
// and see if they are enough to cover at least 60% of the text share
|
450 |
const largeTextShareClusters = sortedClusters.filter((c) =>
|
451 |
-
approximatelyEqual(c.percentageTextShare, sortedClusters[0]
|
452 |
);
|
453 |
|
454 |
const totalTextShareOfLargeClusters = largeTextShareClusters.reduce(
|
|
|
432 |
});
|
433 |
|
434 |
// if there is a dominant cluster with more than 60% text share, return that
|
435 |
+
const dominantCluster = clusterWithMetrics[0]?.percentageTextShare > 60;
|
436 |
if (dominantCluster) return [clusterWithMetrics[0].cluster];
|
437 |
|
438 |
// clusters are sorted by text share after applying a penalty for centrality
|
|
|
448 |
// find all clusters that are similar to the largest cluster in terms of text share
|
449 |
// and see if they are enough to cover at least 60% of the text share
|
450 |
const largeTextShareClusters = sortedClusters.filter((c) =>
|
451 |
+
approximatelyEqual(c.percentageTextShare, sortedClusters[0]?.percentageTextShare, 10)
|
452 |
);
|
453 |
|
454 |
const totalTextShareOfLargeClusters = largeTextShareClusters.reduce(
|