original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: 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
docstring_tokens: Get an element weight by attribute . Uses regular expressions to tell if this element looks good or bad .