gustavomazzoni / cordova-plugin-tesseract

Cordova Plugin for OCR process using Tesseract
77 stars 34 forks source link

Throwing errors when calling TesseractPlugin.loadLanguage #30

Open gianlazz opened 7 years ago

gianlazz commented 7 years ago

Here's what I've got

import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';

/**
 * Generated class for the MainPage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */

@Component({
  selector: 'page-main',
  templateUrl: 'main.html',
})
export class MainPage {

  constructor(public navCtrl: NavController, public navParams: NavParams) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad MainPage');
  }

    TesseractPlugin.loadLanguage(language, function(response) {
  deferred.resolve(response);
}, function(reason) {
  deferred.reject('Error on loading OCR file for your language. ' + reason);
});
}

Error Produced:

[22:30:38]  typescript: src/pages/main/main.ts, line: 24
            ';' expected.

      L24:      TesseractPlugin.loadLanguage(language, function(response) {
      L25:    deferred.resolve(response);

[22:30:38]  typescript: src/pages/main/main.ts, line: 24
            Parameter declaration expected.

      L24:      TesseractPlugin.loadLanguage(language, function(response) {
      L25:    deferred.resolve(response);

[22:30:38]  typescript: src/pages/main/main.ts, line: 26
            Unexpected token. A constructor, method, accessor, or property was expected.

      L25:    deferred.resolve(response);
      L26:  }, function(reason) {
      L27:    deferred.reject('Error on loading OCR file for your language. ' + reason);

[22:30:38]  typescript: src/pages/main/main.ts, line: 28
            Unexpected token. A constructor, method, accessor, or property was expected.

      L27:    deferred.reject('Error on loading OCR file for your language. ' + reason);
      L28:  });

[22:30:38]  typescript: src/pages/main/main.ts, line: 24
            Duplicate function implementation.

      L24:      TesseractPlugin.loadLanguage(language, function(response) {
      L25:    deferred.resolve(response);

[22:30:38]  typescript: src/pages/main/main.ts, line: 25
            Cannot find name 'deferred'.

      L24:      TesseractPlugin.loadLanguage(language, function(response) {
      L25:    deferred.resolve(response);
      L26:  }, function(reason) {

[22:30:38]  typescript: src/pages/main/main.ts, line: 26
            Duplicate function implementation.

      L25:    deferred.resolve(response);
      L26:  }, function(reason) {
      L27:    deferred.reject('Error on loading OCR file for your language. ' + reason);

[22:30:38]  typescript: src/pages/main/main.ts, line: 27
            Cannot find name 'deferred'.

      L26:  }, function(reason) {
      L27:    deferred.reject('Error on loading OCR file for your language. ' + reason);
      L28:  });

[22:30:38]  build finished in 9.67 s

[22:30:38]  build started ...
[22:30:38]  transpile update started ...
[22:30:38]  transpile update finished in 83 ms
[22:30:38]  deeplinks update started ...
[22:30:38]  deeplinks update finished in 56 ms
[22:30:38]  webpack update started ...
[22:30:40]  webpack update finished in 1.32 s
[22:30:44]  typescript: src/pages/main/main.ts, line: 24
            ';' expected.

      L24:      TesseractPlugin.loadLanguage(language, function(response) {
      L25:    deferred.resolve(response);

[22:30:44]  typescript: src/pages/main/main.ts, line: 24
            Parameter declaration expected.

      L24:      TesseractPlugin.loadLanguage(language, function(response) {
      L25:    deferred.resolve(response);

[22:30:44]  typescript: src/pages/main/main.ts, line: 26
            Unexpected token. A constructor, method, accessor, or property was expected.

      L25:    deferred.resolve(response);
      L26:  }, function(reason) {
      L27:    deferred.reject('Error on loading OCR file for your language. ' + reason);

[22:30:44]  typescript: src/pages/main/main.ts, line: 28
            Unexpected token. A constructor, method, accessor, or property was expected.

      L27:    deferred.reject('Error on loading OCR file for your language. ' + reason);
      L28:  });

[22:30:44]  typescript: src/pages/main/main.ts, line: 24
            Duplicate function implementation.

      L24:      TesseractPlugin.loadLanguage(language, function(response) {
      L25:    deferred.resolve(response);

[22:30:44]  typescript: src/pages/main/main.ts, line: 25
            Cannot find name 'deferred'.

      L24:      TesseractPlugin.loadLanguage(language, function(response) {
      L25:    deferred.resolve(response);
      L26:  }, function(reason) {

[22:30:44]  typescript: src/pages/main/main.ts, line: 26
            Duplicate function implementation.

      L25:    deferred.resolve(response);
      L26:  }, function(reason) {
      L27:    deferred.reject('Error on loading OCR file for your language. ' + reason);

[22:30:44]  typescript: src/pages/main/main.ts, line: 27
            Cannot find name 'deferred'.

      L26:  }, function(reason) {
      L27:    deferred.reject('Error on loading OCR file for your language. ' + reason);
      L28:  });
gianlazz commented 7 years ago

I suspect I'm probably being a total noob and just missing some assumed knowledge since I followed along with the instructions just fine until reaching this point.