Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

language_classifier binding #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jtara1
Copy link

@jtara1 jtara1 commented Jul 1, 2023

Build

node-gyp configure
node-gyp build

There shouldn't be any errors.

Test

test.js

const postal = require('./build/Release/language_classifier');

const simpleInputs = [
  'street',
  'calle',
];

// from libpostal address expansion
const inputs = [
  "200 santa monica pier santa monica coahuila 90401 usa",
  "200 santa monica pier santa monica compania 90401 usa",
  "200 santa monica pier santa monica compania anonima 90401 usa",
  "200 santa monica pier santa monica calle 90401 usa",
  "200 santa monica pier santa monica ca 90401 usa",
  "200 santa monica pier santa monica casa 90401 usa",
  "200 santa monica pier santa monica cagliari 90401 usa",
  "200 santa monica pier santa monica california 90401 usa",
  "200 santa monica pier santa monica companhia anonima 90401 usa"
];

for (const input of simpleInputs.concat(inputs)) {
  const result = postal.language_classifier(input);
  console.log(input, result);  
}

const address = "200 santa monica pier santa monica california 90401 usa";
const addressWords = address
  .split(' ')
  // .filter(str => isNaN(parseFloat(str)));

for (const word of addressWords) {
  const result = postal.language_classifier(word);
  console.log(word, result);
}

Test Output Sample

street [ { language: 'en', probability: 0.9975550392228959 } ]
calle [ { language: 'es', probability: 0.9948278315613933 } ]
200 santa monica pier santa monica coahuila 90401 usa [ { language: 'es', probability: 0.9889375382113144 } ]


ERR   Language classification returned NULL
   at libpostal_classify_language (libpostal.c:209) errno: Inappropriate ioctl for device
90401 undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant