private static float getLinkDensity ( Element e ) { Elements links = getElementsByTag ( e , "a" ) ; int textLength = getInnerText ( e , true ) . length ( ) ; float linkLength = 0.0F ; for ( Element link : links ) { linkLength += getInnerText ( link , true ) . length ( ) ; } return linkLength / textLength ; }
Get the density of links as a percentage of the content . This is the amount of text that is inside a link divided by the total text in the node .