Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 5b23d0f
  • /
  • src
  • /
  • plugins
  • /
  • tree_data_helper.js
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:33286d300c27e6211b61db51f7941f904618a2a7
directory badge
swh:1:dir:d810d13a526521471406fb682b82d7b4a0267eab

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
tree_data_helper.js

const tree_process = function(text_tree) {
    
    text_tree.eachAfter(element => {
        if(element.all_children) element.all_children.forEach((d,i) => d.siblings_id = i);
        element.children = element.all_children;
        // if (!element.data.precision){
        //     let s = element.all_children.map(d=>d.data.precision);
        //     if (s) element.data.precision = s.reduce((a,c)=>{return a+c}, 0) / s.length;
        // }
        // if (!element.data.recall){
        //     let s = element.all_children.map(d=>d.data.recall);
        //     if (s) element.data.recall = s.reduce((a,c)=>{return a+c}, 0) / s.length;
        // }
        // if (!element.data.mismatch){
        //     let s = element.all_children.map(d=>d.data.mismatch);
        //     if (s) element.data.mismatch = s.reduce((a,c)=>{return a+c}, 0);
        // }
        if (!element.data.descendants_idx){
            if (!element.all_children){
                element.data.descendants_idx = [element.data.id];
            }
            else{
                let idxs = [];
                for (let i = 0; i < element.all_children.length; i++){
                    idxs = idxs.concat(element.all_children[i].data.descendants_idx);
                }
                element.data.descendants_idx = idxs;
            }
        }
        element.f1_api = 2 - (element.data.precision * 2 + element.data.recall) / 2;
        element.mm_api = element.data.mismatch / 20000;
        // element.api = element.f1_api;
    });

    // text_tree.eachBefore((d, i) => d.order = i);

    // text_tree.all_descendants = text_tree.descendants();
    text_tree.all_descendants.forEach(d => d.children = []);
    return tree_process;
};

export {
    tree_process,
}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API