Skip to content

Commit

Permalink
fix aps name extraction on pdf with missing fields
Browse files Browse the repository at this point in the history
  • Loading branch information
andobolocco committed Jun 19, 2020
1 parent 666ffcc commit c6148fe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/documentTypes/apsBill.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ module.exports = {

extractor: (keyValues, rawText) => {
const keys = Object.keys(keyValues);
let fullName;
// first name & last name (WARNING splitting full name by space potential inconsistency)

const first3Lines = rawText.slice(0, 3);
let fullName = first3Lines.find((line) => (
fullName = first3Lines.find((line) => (
line !== 'aps'
&& line !== 'Your electricity bill'
&& !line.match(/Bill? date/gi)
Expand All @@ -45,6 +47,11 @@ module.exports = {
&& line.length >= 6
));
}
if (!fullName) {
const index = rawText.findIndex((line) => line.match(/^[A-Z\s]+ [A-Z]{2} \d+-\d+$/g)) - 2;
fullName = rawText[index];
}

let first_name;
let last_name;
let street_address_line_1;
Expand Down

0 comments on commit c6148fe

Please sign in to comment.