<commit_before>/**
 * DOM transformation shared with app. Let's keep this in sync with the app.
 * Last sync: Android repo 3d5b441 www/js/transforms/relocateFirstParagraph.js
 *
 * The main changes from the original Android app file are:
 * 1) Checking for heading tags since now we're dealing not just with the first
 *    section but the whole page content.
 * 2) No need to check for is main page since that is now done before this
 *    function is called.
 * 3) We cannot use the trick using element height to skip P tags because
 *    on the server we don't know the pixel height of an element.
 * 4) Use content.createElement() instead of document.createElement()
 * 5) On the service side we don't have #content_block_0 yet. That element
 *    gets created by the app when it pulls in the content over the JS bridge.
 */

'use strict';

function findFirstGoodParagraphIn( nodes ) {
    var minLength = 80;
    var firstGoodParagraphIndex;
    var i;

    for ( i = 0; i < nodes.length; i++ ) {
        if ( nodes[i].tagName && nodes[i].tagName.indexOf('H') === 0 ) {
            // Don't go past the first heading tag (since that would be the next section)
            break;

        } else if (nodes[i].tagName === 'P' ) {
            // Ensure the P being pulled up has at least a couple lines of text.
            // Otherwise silly things like a empty P or P which only contains a
            // BR tag will get pulled up (see articles on "Chemical Reaction" and
            // "Hawaii").
            // We cannot use the trick using element height because on the server
            // we don't know the pixel height of an element.
            if ( nodes[i].textContent.length < minLength ) {
                continue;
            }<commit_msg>Reduce minimum lead paragraph length<commit_after>/**
 * DOM transformation shared with app. Let's keep this in sync with the app.
 * Last sync: Android repo 3d5b441 www/js/transforms/relocateFirstParagraph.js
 *
 * The main changes from the original Android app file are:
 * 1) Checking for heading tags since now we're dealing not just with the first
 *    section but the whole page content.
 * 2) No need to check for is main page since that is now done before this
 *    function is called.
 * 3) We cannot use the trick using element height to skip P tags because
 *    on the server we don't know the pixel height of an element.
 * 4) Use content.createElement() instead of document.createElement()
 * 5) On the service side we don't have #content_block_0 yet. That element
 *    gets created by the app when it pulls in the content over the JS bridge.
 */

'use strict';

function findFirstGoodParagraphIn( nodes ) {
    var minLength = 40;
    var firstGoodParagraphIndex;
    var i;

    for ( i = 0; i < nodes.length; i++ ) {
        if ( nodes[i].tagName && nodes[i].tagName.indexOf('H') === 0 ) {
            // Don't go past the first heading tag (since that would be the next section)
            break;

        } else if (nodes[i].tagName === 'P' ) {
            // Ensure the P being pulled up has at least a couple lines of text.
            // Otherwise silly things like a empty P or P which only contains a
            // BR tag will get pulled up (see articles on "Chemical Reaction" and
            // "Hawaii").
            // We cannot use the trick using element height because on the server
            // we don't know the pixel height of an element.
            if ( nodes[i].textContent.length < minLength ) {
                continue;
            }
{'fraction_non_alphanumeric': 0.07859768165111676, 'fraction_numerical': 0.008481764206955046, 'mean_word_length': 2.431619786614937, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2641668', 'n_tokens_mistral': 968, 'n_tokens_neox': 918, 'n_words': 476}