<commit_before>function createNuGetAsText(nugetSpec: any): any {
    // r is Result object
    let r = {}

    if (nugetSpec.package && nugetSpec.package.metadata && nugetSpec.package.metadata[0]) {
        let metadata = nugetSpec.package.metadata[0] || [];
        let metadataKeys = Object.keys(metadata).filter(m => m !== 'dependencies') || [];
        let dependencies = metadata.dependencies && metadata.dependencies[0] && metadata.dependencies[0].group ? metadata.dependencies[0].group : [];
        let references = metadata.references && metadata.references[0] && metadata.references[0].reference ? metadata.references[0].reference : []
        let dependencyKeys = Object.keys(dependencies) || [];
        let frameworkAssemblies = metadata.frameworkAssemblies && metadata.frameworkAssemblies[0] && metadata.frameworkAssemblies[0].frameworkAssembly ? metadata.frameworkAssemblies[0].frameworkAssembly : [];
        let frameworkAssembliesKeys = Object.keys(frameworkAssemblies) || [];

        // Metadata
        if (metadataKeys.length) r['Metadata'] = {};
        metadataKeys.forEach(k => r['Metadata'][k] = metadata[k].toString())

        // References
        if (references.length) {
            r['References'] = references.map(r => r.$)
        }

        // Dependencies
        if (dependencyKeys.length) r['Dependencies'] = {};
        dependencyKeys.forEach(k => {
            let framework = dependencies[k];
            let frameworkName = framework.$ && framework.$.targetFramework ? framework.$.targetFramework : 'All Frameworks'
            r['Dependencies'][frameworkName] = {}
            let dependency = r['Dependencies'][frameworkName]

            if (framework.dependency) {
                framework.dependency.forEach(d => dependency[d.$.id] = d.$.version)
            } else {
                dependency = `No dependencies.`
            }
        })

        // frameworkAssemblies
        if (frameworkAssembliesKeys.length) r['Framework Assemblies'] = {};
        frameworkAssembliesKeys.forEach(k => r['Framework Assemblies'][frameworkAssemblies[k].$.targetFramework || 'All'] = frameworkAssemblies[k].$.assemblyName);
    }

    return r;
}

export function getTextForNuPkgContents(filePath): Promise<string> {
    return new Promise<string>((resolve, reject) => {
        var nupkgReader = require('smart-nupkg-metadata-reader');
        var yaml = require('js-yaml');
        nupkgReader.readMetadata(filePath, function (result, error) {
            if (error) {
                return reject();<commit_msg>Fix bug with dependencies without group<commit_after>function getDependenciesWithoutFramework(metadata) {
    return metadata.dependencies && metadata.dependencies[0] && metadata.dependencies[0].dependency ? metadata.dependencies[0].dependency : [];
}

function getDependenciesByFramework(metadata) {
    return metadata.dependencies && metadata.dependencies[0] && metadata.dependencies[0].group ? metadata.dependencies[0].group : [];
}

function createNuGetAsText(nugetSpec: any): any {
    // r is Result object
    let r = {}

    if (nugetSpec.package && nugetSpec.package.metadata && nugetSpec.package.metadata[0]) {
        let metadata = nugetSpec.package.metadata[0] || [];
        let metadataKeys = Object.keys(metadata).filter(m => m !== 'dependencies') || [];
        let dependenciesByFramework = getDependenciesByFramework(metadata);
        let dependenciesWithoutFramework = getDependenciesWithoutFramework(metadata);
        let references = metadata.references && metadata.references[0] && metadata.references[0].reference ? metadata.references[0].reference : []
        let dependencyByFrameworkKeys = Object.keys(dependenciesByFramework) || [];
        let frameworkAssemblies = metadata.frameworkAssemblies && metadata.frameworkAssemblies[0] && metadata.frameworkAssemblies[0].frameworkAssembly ? metadata.frameworkAssemblies[0].frameworkAssembly : [];
        let frameworkAssembliesKeys = Object.keys(frameworkAssemblies) || [];

        // Metadata
        if (metadataKeys.length) r['Metadata'] = {};
        metadataKeys.forEach(k => r['Metadata'][k] = metadata[k].toString())

        // References
        if (references.length) {
            r['References'] = references.map(r => r.$)
        }

        // Dependencies by Framework
        if (dependencyByFrameworkKeys.length) r['Dependencies'] = r['Dependencies'] || {};
        dependencyByFrameworkKeys.forEach(k => {
            let framework = dependenciesByFramework[k];
            let frameworkName = framework.$ && framework.$.targetFramework ? framework.$.targetFramework : 'All Frameworks'
            r['Dependencies'][frameworkName] = {}
            let dependency = r['Dependencies'][frameworkName]

            if (framework.dependency) {
                framework.dependency.forEach(d => dependency[d.$.id] = d.$.version)
            } else {
                dependency = `No dependencies.`
            }
        })

        // Dependencies without Framework
        if (dependenciesWithoutFramework.length) r['Dependencies'] = r['Dependencies'] || {};
        dependenciesWithoutFramework.forEach(k => {
            r['Dependencies'][k.$.id] = k.$.version
        })

        // frameworkAssemblies
        if (frameworkAssembliesKeys.length) r['Framework Assemblies'] = {};
        frameworkAssembliesKeys.forEach(k => r['Framework Assemblies'][frameworkAssemblies[k].$.targetFramework || 'All'] = frameworkAssemblies[k].$.assemblyName);
    }

    return r;
}

export function getTextForNuPkgContents(filePath): Promise<string> {
    return new Promise<string>((resolve, reject) => {
        var nupkgReader = require('smart-nupkg-metadata-reader');
        var yaml = require('js-yaml');
        nupkgReader.readMetadata(filePath, function (result, error) {
            if (error) {
                return reject();
{'fraction_non_alphanumeric': 0.13513974096796183, 'fraction_numerical': 0.004260395364689844, 'mean_word_length': 3.1185964912280704, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4468426', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1482, 'n_words': 273}