protected function weightAttribute(\DOMElement $element, $attribute)
    {
        if (!$element->hasAttribute($attribute)) {
            return 0;
        }
        $weight = 0;

        // $attributeValue = trim($element->getAttribute('class')." ".$element->getAttribute('id'));
        $attributeValue = trim($element->getAttribute($attribute));

        if ('' !== $attributeValue) {
            if (preg_match($this->regexps['negative'], $attributeValue)) {
                $weight -= 25;
            }
            if (preg_match($this->regexps['positive'], $attributeValue)) {
                $weight += 25;
            }
            if (preg_match($this->regexps['unlikelyCandidates'], $attributeValue)) {
                $weight -= 5;
            }
            if (preg_match($this->regexps['okMaybeItsACandidate'], $attributeValue)) {
                $weight += 5;
            }
        }

        return $weight;
    }
protected function weightAttribute(\DOMElement $element, $attribute)
    {
        if (!$element->hasAttribute($attribute)) {
            return 0;
        }
        $weight = 0;

        // $attributeValue = trim($element->getAttribute('class')." ".$element->getAttribute('id'));
        $attributeValue = trim($element->getAttribute($attribute));

        if ('' !== $attributeValue) {
            if (preg_match($this->regexps['negative'], $attributeValue)) {
                $weight -= 25;
            }
            if (preg_match($this->regexps['positive'], $attributeValue)) {
                $weight += 25;
            }
            if (preg_match($this->regexps['unlikelyCandidates'], $attributeValue)) {
                $weight -= 5;
            }
            if (preg_match($this->regexps['okMaybeItsACandidate'], $attributeValue)) {
                $weight += 5;
            }
        }

        return $weight;
    }
protected function weightAttribute ( \ DOMElement $ element , $ attribute ) { if ( ! $ element -> hasAttribute ( $ attribute ) ) { return 0 ; } $ weight = 0 ; // $attributeValue = trim($element->getAttribute('class')." ".$element->getAttribute('id')); $ attributeValue = trim ( $ element -> getAttribute ( $ attribute ) ) ; if ( '' !== $ attributeValue ) { if ( preg_match ( $ this -> regexps [ 'negative' ] , $ attributeValue ) ) { $ weight -= 25 ; } if ( preg_match ( $ this -> regexps [ 'positive' ] , $ attributeValue ) ) { $ weight += 25 ; } if ( preg_match ( $ this -> regexps [ 'unlikelyCandidates' ] , $ attributeValue ) ) { $ weight -= 5 ; } if ( preg_match ( $ this -> regexps [ 'okMaybeItsACandidate' ] , $ attributeValue ) ) { $ weight += 5 ; } } return $ weight ; }
Get an element weight by attribute.
Uses regular expressions to tell if this element looks good or bad.

@param \DOMElement $element
@param string      $attribute

@return int
Get an element weight by attribute . Uses regular expressions to tell if this element looks good or bad .