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

Revision 140655049e939e0ae0070fff192de4e1d0eff5a7 authored by lauragarrison on 04 February 2021, 11:49:20 UTC, committed by lauragarrison on 04 February 2021, 11:49:20 UTC
add plant image for replicability process
1 parent f707e6b
  • Files
  • Changes
  • 1bf1e1d
  • /
  • templates
  • /
  • model
  • /
  • model_get_initial_datatypes.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.

  • revision
  • directory
  • content
revision badge
swh:1:rev:140655049e939e0ae0070fff192de4e1d0eff5a7
directory badge
swh:1:dir:afc4d6d3ec61f1e72dacbe98843f2f249093a47d
content badge
swh:1:cnt:698561c9128a1017c2e239bb5ebf85fe0f424886

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.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
model_get_initial_datatypes.js
function replace_spaces_with_underscore(value) {
    value = value.split(" ").join("_");
    value = value.split(")").join("_");
    value = value.split("(").join("_");
    value = value.split("/").join("_");
    value = value.split("-").join("_");
    value = value.split("[").join("_");
    value = value.split("]").join("_");
    value = value.split(".").join("_");
    value = value.split("?").join("_");
    value = value.split("!").join("_");
    value = value.split("@").join("_");
    value = value.split("*").join("_");

    value = value.split("ä").join("ae");
    value = value.split("ü").join("ue");
    value = value.split("ö").join("oe");
    value = value.split("ß").join("ss");

    value = "id_qualitative_rectangle" + value;


    return value;
}

/**
 * This function identifies the initial datatypes
 * @param data
 * @returns {*}
 */
function identify_initial_datatypes(data) {

    let headerNames = d3.keys(data[0]);

    let headerNames_underscore = headerNames.map(replace_spaces_with_underscore);

    let columns = [];

 //   for (let i = 0; i < 91; i++) {
    for (let i = 0; i < headerNames.length; i++) {
        let obj = {};
        obj[key_header] = headerNames[i];
        obj[key_id] = headerNames_underscore[i];
        obj[key_column_values] = data.map(function (d) {

            if (d !== undefined) {
                return d[headerNames[i]];
            }

        });
        obj[key_data_type] = check_data_types(obj[key_column_values]);

        columns.push(obj);
    }

    /**
     * This function identifies the data types
     * @param x
     * @returns {string}
     */
    function check_data_types(x) {

        const regExp_date = /^(0?[1-9]|[12][0-9]|3[01])[\.\-](0?[1-9]|1[012])[\.\-]\d{4}$/; // regular Expression for dd.mm.yyyy

        if (x.every(function(i){ return !isNaN(i)})) {
            if (x.every(function(i){ return Number.isInteger(i)})) {
                return id_data_type__categorical;
            }
            return id_data_type__numerical;
        } else if (x.every(function(i){ return i === undefined || i === "" || regExp_date.test(i)})) {
            return id_data_type__date;
        } else if (x.every(function(i){ return typeof i === "string" })) {
            return id_data_type__categorical;
        }
    }

    return columns;
}
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2025, 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