Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contract Note Parser

This project provides two implementations of a contract note parser that uses OpenAI's GPT-4 to extract structured data from PDF contract notes:

  1. A Node.js implementation for local processing
  2. A Google Apps Script implementation for Google Sheets integration

Prerequisites

For Node.js Implementation

  • Node.js (v14 or higher)
  • Yarn package manager
  • OpenAI API key

For Google Apps Script Implementation

  • Google account
  • Google Drive access
  • OpenAI API key

Setup Instructions

Node.js Implementation

  1. Clone the repository:
git clone <repository-url>
cd docparse
  1. Install dependencies:
yarn install
  1. Create a .env file in the root directory:
OPENAI_API_KEY=your_api_key_here
  1. Place your PDF contract note in the project directory or update the path in src/main.ts

  2. Run the parser:

yarn start

The extracted data will be saved to extracted_data.json in the project directory.

Google Apps Script Implementation

  1. Create a new Google Sheet

  2. Go to Extensions > Apps Script

  3. Delete any code in the script editor and paste the contents of src/contractParser.gs

  4. Replace the API key in the script:

const OPENAI_API_KEY = 'your_api_key_here';
  1. Save the script (File > Save)

  2. Enable required services:

    • Click on "Services" (+ icon)
    • Add the following services:
      • Drive API
      • Google Sheets API
  3. Authorize the script:

    • Click the "Run" button
    • Grant necessary permissions when prompted

Usage

Node.js Implementation

Simply run the script and it will process the PDF file specified in the code:

yarn start

Google Apps Script Implementation

  1. Open your Google Sheet
  2. Look for the "Contract Parser" menu in the toolbar
  3. Click "Contract Parser" > "Process PDF"
  4. Select your PDF file from Google Drive
  5. Wait for the processing to complete
  6. The extracted data will appear in a new sheet named "Extracted Data"

Output Format

The parser extracts the following information from contract notes:

  • Trade details
  • Quantities
  • Prices
  • Other relevant table data

The data is structured in a JSON format and, in the Google Sheets version, is presented in a two-column format:

  • Column A: Field names
  • Column B: Extracted values

Troubleshooting

Common Issues

  1. PDF Text Extraction Issues

    • Ensure the PDF is not scanned as an image
    • Check if the PDF is not password protected
    • Verify the PDF is readable and not corrupted
  2. API Key Issues

    • Verify your OpenAI API key is correct
    • Check if you have sufficient credits in your OpenAI account
    • Ensure the API key has not expired
  3. Google Apps Script Issues

    • Make sure all required services are enabled
    • Check if you have necessary permissions for the Google Sheet
    • Verify the PDF is accessible to the script

Error Messages

  • "No PDF file uploaded" - Make sure you've selected a PDF file
  • "Error processing PDF" - Check the PDF format and accessibility
  • "API Error" - Verify your OpenAI API key and internet connection

Security Notes

  • Never commit your .env file or API keys to version control
  • Keep your OpenAI API key secure and don't share it
  • Regularly rotate your API keys
  • Be cautious when sharing Google Sheets with the script

Contributing

Feel free to submit issues and enhancement requests!

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

AI document parser for financial services

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages