mirror of
https://github.com/jzillmann/pdf-to-markdown.git
synced 2025-06-24 19:41:24 +02:00
No unused locals
This commit is contained in:
parent
17290cf746
commit
f5a180113d
@ -20,8 +20,8 @@ const config = {
|
|||||||
// Max number of lines at top/bottom (per page) which are getting evaluated for eviction
|
// Max number of lines at top/bottom (per page) which are getting evaluated for eviction
|
||||||
maxNumberOffTopOrBottomLines: 3,
|
maxNumberOffTopOrBottomLines: 3,
|
||||||
|
|
||||||
// From the absolute fringe elements (min/max y) how much y can item deviate before beeing disregarded.
|
// From the absolute fringe elements (min/max y) how much y can item deviate before beeing disregarded.
|
||||||
maxDistanceFromFringeElements:30,
|
maxDistanceFromFringeElements: 30,
|
||||||
|
|
||||||
// Max neighbour taken (in one direction) for detecting neighbour similarity.
|
// Max neighbour taken (in one direction) for detecting neighbour similarity.
|
||||||
// Choosen number might be more effectful for PDFs with a strong odd/evan page differernce.
|
// Choosen number might be more effectful for PDFs with a strong odd/evan page differernce.
|
||||||
@ -54,7 +54,7 @@ export default class RemoveRepetitiveItems extends ItemTransformer {
|
|||||||
const yLines = pageExtracts
|
const yLines = pageExtracts
|
||||||
.map((page) => page.lineByY(y))
|
.map((page) => page.lineByY(y))
|
||||||
.filter((line) => typeof line !== 'undefined') as Line[];
|
.filter((line) => typeof line !== 'undefined') as Line[];
|
||||||
const texts = yLines.map((line) => line.text());
|
|
||||||
const similarities = flatMap(yLines, (line, idx) =>
|
const similarities = flatMap(yLines, (line, idx) =>
|
||||||
adiacentLines(yLines, idx).map((adiacentLine) => calculateSimilarity(line, adiacentLine)),
|
adiacentLines(yLines, idx).map((adiacentLine) => calculateSimilarity(line, adiacentLine)),
|
||||||
);
|
);
|
||||||
@ -66,6 +66,7 @@ export default class RemoveRepetitiveItems extends ItemTransformer {
|
|||||||
// - contain chapter highlights
|
// - contain chapter highlights
|
||||||
// - contains rising number
|
// - contains rising number
|
||||||
|
|
||||||
|
// const texts = yLines.map((line) => line.text());
|
||||||
// console.log('y' + y, texts, similarities, median(similarities));
|
// console.log('y' + y, texts, similarities, median(similarities));
|
||||||
return median(similarities) >= config.minSimilarity;
|
return median(similarities) >= config.minSimilarity;
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,6 @@ import { toMatchFile } from 'jest-file-snapshot';
|
|||||||
|
|
||||||
import * as pdfjs from 'pdfjs-dist/es5/build/pdf';
|
import * as pdfjs from 'pdfjs-dist/es5/build/pdf';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
import PdfParser from 'src/PdfParser';
|
import PdfParser from 'src/PdfParser';
|
||||||
import PdfPipeline from 'src/PdfPipeline';
|
import PdfPipeline from 'src/PdfPipeline';
|
||||||
|
@ -92,7 +92,6 @@ function expectTotalProgress(progress: Progress, expected: number) {
|
|||||||
|
|
||||||
function expectStageInProgress(progress: Progress, stageIndex: number) {
|
function expectStageInProgress(progress: Progress, stageIndex: number) {
|
||||||
for (let index = 0; index < progress.stageProgress.length; index++) {
|
for (let index = 0; index < progress.stageProgress.length; index++) {
|
||||||
const stageProgress = progress.stageProgress[index];
|
|
||||||
if (index < stageIndex) {
|
if (index < stageIndex) {
|
||||||
expect(progress.isProgressing(index)).toBe(false);
|
expect(progress.isProgressing(index)).toBe(false);
|
||||||
expect(progress.isComplete(index)).toBe(true);
|
expect(progress.isComplete(index)).toBe(true);
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import ChangeTracker from 'src/debug/ChangeTracker';
|
import ChangeTracker from 'src/debug/ChangeTracker';
|
||||||
import { detectChanges } from 'src/debug/detectChanges';
|
import { detectChanges } from 'src/debug/detectChanges';
|
||||||
import { PositionChange, Direction, Addition, Removal } from 'src/debug/ChangeIndex';
|
import { PositionChange, Direction, Addition, Removal } from 'src/debug/ChangeIndex';
|
||||||
import { idItem, idItems, items } from 'test/testItems';
|
import { idItem, idItems } from 'test/testItems';
|
||||||
import Item from 'src/Item';
|
|
||||||
|
|
||||||
test('No changes', async () => {
|
test('No changes', async () => {
|
||||||
const items = idItems(0, ['A', 'B', 'C']);
|
const items = idItems(0, ['A', 'B', 'C']);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
|
"noUnusedLocals": true,
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"paths": {
|
"paths": {
|
||||||
"src/*": ["src/*"],
|
"src/*": ["src/*"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user