Code Monkey home page Code Monkey logo

xtracta's Introduction

Exercise: Extract supplier name from invoice

This repository contains the program to extract the supplier name from an invoice.

To execute it straight away, clone the repository, start python in the cloned folder and execute the following commands in python:

import exercise
invoice = exercise.read_invoice()
supplier_names = exercise.read_supplier_names()
supplier = exercise.get_supplier_from_invoice(invoice, supplier_names)

supplier will contain the name of the supplier that appears in the invoice.

If you don't want to start python in the cloned folder, you can also start python anywhere and then execute at the beginning:

import os
os.chdir(path_to_cloned_repository)

The exercise module

The file that solves the exercise is exercise.py. It's a python module with three functions:

  • read_invoice(invoice_path) reads the file containing the information about the invoice given by the input. If no input is given, the function will read the file given for the exercise.
  • read_supplier_names(suppliers_path) reads the file containing the information about the supplier names given by the input. If no input is given, the function will read the file given for the exercise.
  • get_supplier_from_invoice(invoice, supplier_names) returns the supplier from the list of suppliers that appears in the invoice.

Other files

  • test.py contains a unit test that tests the correctness of get_supplier_from_invoice.
  • The folder original_files contains the two .txt files that were originally provided for solving the exercise.
  • The folder preprocessed_files contains the two preprocessed original files, that I slightly modified in order for them to be read properly by the functions in the exercise module. In particular, invoice is a csv file and supplier_names is a jsonl file. I also added an extra file, fake_suppliers.csv, that I generated in order to test how the algorithm performed with hundreds of thousands of suppliers.
  • requirements.txt includes the requirements for the module to work as expected.

xtracta's People

Contributors

alejandrodemiquel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.