detectDocumentStructure () {
    let matchingRulez = []
    let rulez = this.classificationRulez
    let index = 0
    let confidence
    let label = this.label

    if (rulez) {
      rulez.forEach(rule => {
        let found = this.extractFromDataMatrix(rule, this.doc)
        //if (found.length > 0) {
        //  matchingRulez.push({ rule, texts: found })
        //}
        matchingRulez.push({ rule, texts: found, matched: (found.length > 0) })
      })
    }

    if (!rulez || rulez.length === 0) {
      confidence = 0
    } else {
      let matches = matchingRulez.filter(rule => rule.matched === true)
      confidence = ((matches.length * 100) / rulez.length)
    }

    return { label, confidence, matchingRulez }
  }
/**
   *
   * use only a small set of pattern to detect already known document structure
   *
   */
use only a small set of pattern to detect already known document structure
use only a small set of pattern to detect already known document structure
detectDocumentStructure () {
    let matchingRulez = []
    let rulez = this.classificationRulez
    let index = 0
    let confidence
    let label = this.label
    if (rulez) {
      rulez.forEach(rule => {
        let found = this.extractFromDataMatrix(rule, this.doc)
        matchingRulez.push({ rule, texts: found, matched: (found.length > 0) })
      })
    }
    if (!rulez || rulez.length === 0) {
      confidence = 0
    } else {
      let matches = matchingRulez.filter(rule => rule.matched === true)
      confidence = ((matches.length * 100) / rulez.length)
    }
    return { label, confidence, matchingRulez }
  }
detectDocumentStructure ( ) { let matchingRulez = [ ] let rulez = this . classificationRulez let index = 0 let confidence let label = this . label if ( rulez ) { rulez . forEach ( rule => { let found = this . extractFromDataMatrix ( rule , this . doc ) matchingRulez . push ( { rule , texts : found , matched : ( found . length > 0 ) } ) } ) } if ( ! rulez || rulez . length === 0 ) { confidence = 0 } else { let matches = matchingRulez . filter ( rule => rule . matched === true ) confidence = ( ( matches . length * 100 ) / rulez . length ) } return { label , confidence , matchingRulez } }
use only a small set of pattern to detect already known document structure
use only a small set of pattern to detect already known document structure
//if (found.length > 0) { //  matchingRulez.push({ rule, texts: found }) //}