<commit_before><?php
/**
 * Finds X code that doesn't have corresponding Y code. This helps us
 * to know what Y code still needs implementing.
 *
 * This script needs ack to run. See http://beyondgrep.com/ .
 */
$x = 'googlePlusOne';
$y = 'linkedInSharing';
// Case-sensitive X-Y pairs that are considered to be equivalent.
$equivalentPairs = [
    'GooglePlusOne' => 'LinkedInSharing',
    'googlePlusOne' => 'linkedInSharing',
    'google-plusone' => 'linkedin-sharing',
];
// Filename and string patterns to ignore. Empty this list when you are starting.
$ignore = ['instances/main/widget-configuration.xml',
           'lib/XG_App.php',
           'lib/XG_ConfigHelper.php',
           'lib/Migration/NetworkSetting.php',
           'afterContent.php',
           'googlePlusOneButton.php',
           'XG_JsMetadata.php',
           'LikeController.php',
           'googlePlusOne.js',
           'GooglePlusOneApi'];
$ignore = implode('|', $ignore);
$baseDirectory = realpath(dirname(__FILE__) . "/../webapp");
$xMatches = shell_exec("cd $baseDirectory; ack -i $x | ack -v '$ignore' | ack -vi $y");
$yMatches = shell_exec("cd $baseDirectory; ack -i $y | ack -v '$ignore'");
$xMatches = preg_replace('/:\d+:/', '::: ', $xMatches);
$yMatches = preg_replace('/:\d+:/', '::: ', $yMatches);
$replacedXMatches = str_replace(array_keys($equivalentPairs), array_values($equivalentPairs), $xMatches);
$xLines = explode("\n", $xMatches);
$replacedXLines = explode("\n", $replacedXMatches);
$replacedXLineNumbers = array_flip($replacedXLines);
$yLines = explode("\n", $yMatches);
$unmatchedReplacedXLines = array_diff($replacedXLines, $yLines);
$ignore = '@:::\\s*/
           |:::\\s*\*
           @xi';
foreach ($unmatchedReplacedXLines as $unmatchedReplacedXLine) {
    if (preg_match($ignore, $unmatchedReplacedXLine)) {
        continue;
    }
    $replacedXLineNumber = $replacedXLineNumbers[$unmatchedReplacedXLine];
    $xLine = $xLines[$replacedXLineNumber];
    echo "$xLine\n";
}<commit_msg>Made script actually work in a different project.<commit_after><?php
/**
 * Finds X code that doesn't have corresponding Y code. This helps us
 * to know what Y code still needs implementing.
 *
 * This script needs ack to run. See http://beyondgrep.com/ .
 */
// Case-insensitive patterns for initial search.
$x = 'contentInboundEmailPrefix';
$y = 'extendedAttributes';
// Case-sensitive X-Y pairs that are considered to be equivalent.
$equivalentPairs = [
    'contentInboundEmailPrefix' => 'extendedAttributes',
    'ContentInboundEmailPrefix' => 'ExtendedAttributes',
];
// Filename and string patterns to ignore. Empty this list when you are starting.
$ignore = [];
$ignore = implode('|', $ignore);
$baseDirectory = dirname(__FILE__);
$xMatches = shell_exec("cd $baseDirectory; ack -i $x" . ($ignore ? " | ack -v '$ignore'" : ''));
$yMatches = shell_exec("cd $baseDirectory; ack -i $y" . ($ignore ? " | ack -v '$ignore'" : ''));
$xMatches = preg_replace('/:\d+:/', '::: ', $xMatches);
$yMatches = preg_replace('/:\d+:/', '::: ', $yMatches);
$replacedXMatches = str_replace(array_keys($equivalentPairs), array_values($equivalentPairs), $xMatches);
$xLines = explode("\n", $xMatches);
$replacedXLines = explode("\n", $replacedXMatches);
$replacedXLineNumbers = array_flip($replacedXLines);
$yLines = explode("\n", $yMatches);
$unmatchedReplacedXLines = array_diff($replacedXLines, $yLines);
// Ignore comments.
$ignore = '@:::\\s*/
           |:::\\s*\*
           @xi';
foreach ($unmatchedReplacedXLines as $unmatchedReplacedXLine) {
    if (preg_match($ignore, $unmatchedReplacedXLine)) {
        continue;
    }
    $replacedXLineNumber = $replacedXLineNumbers[$unmatchedReplacedXLine];
    $xLine = $xLines[$replacedXLineNumber];
    echo "$xLine\n";
}
{'fraction_non_alphanumeric': 0.16981634282672345, 'fraction_numerical': 0.0, 'mean_word_length': 4.19060773480663, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '7572944', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1225, 'n_words': 284}