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

  • 3487246
  • /
  • src
  • /
  • base.py
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:ab93369e569f9a1a0072592f484aa9bcdbe74abd
directory badge
swh:1:dir:c19368e2f1b862b50dc328121a7cd0826f113bbf

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 ...
base.py
"""Functions for RATA analysis"""
from pathlib import Path

import IPython.display
import pandas as pd
import seaborn as sns


DATA_PATH = Path(__file__).parent.parent / 'data'

FIGURE_PATH = Path(__file__).parent.parent / 'figures'

ODOR_LABEL_LIST = [
u'alcoholic', u'aldehydic', u'alliaceous', u'almond', u'amber', u'animal',
u'anisic', u'apple', u'apricot', u'aromatic', u'balsamic', u'banana',
u'beefy', u'bergamot', u'berry', u'bitter', u'black currant', u'brandy',
u'burnt', u'buttery', u'cabbage', u'camphoreous', u'caramellic', u'cedar',
u'celery', u'chamomile', u'cheesy', u'cherry', u'chocolate', u'cinnamon',
u'citrus', u'clean', u'clove', u'cocoa', u'coconut', u'coffee', u'cognac',
u'cooked', u'cooling', u'cortex', u'coumarinic', u'creamy', u'cucumber',
u'dairy', u'dry', u'earthy', u'ethereal', u'fatty', u'fermented', u'fishy',
u'floral', u'fresh', u'fruit skin', u'fruity', u'garlic', u'gassy',
u'geranium', u'grape', u'grapefruit', u'grassy', u'green', u'hawthorn',
u'hay', u'hazelnut', u'herbal', u'honey', u'hyacinth', u'jasmin', u'juicy',
u'ketonic', u'lactonic', u'lavender', u'leafy', u'leathery', u'lemon',
u'lily', u'malty', u'meaty', u'medicinal', u'melon', u'metallic', u'milky',
u'mint', u'muguet', u'mushroom', u'musk', u'musty', u'natural', u'nutty',
u'odorless', u'oily', u'onion', u'orange', u'orangeflower', u'orris',
u'ozone', u'peach', u'pear', u'phenolic', u'pine', u'pineapple', u'plum',
u'popcorn', u'potato', u'powdery', u'pungent', u'radish', u'raspberry',
u'ripe', u'roasted', u'rose', u'rummy', u'sandalwood', u'savory', u'sharp',
u'smoky', u'soapy', u'solvent', u'sour', u'spicy', u'strawberry',
u'sulfurous', u'sweaty', u'sweet', u'tea', u'terpenic', u'tobacco',
u'tomato', u'tropical', u'vanilla', u'vegetable', u'vetiver', u'violet',
u'warm', u'waxy', u'weedy', u'winey', u'woody'
]

MONELL_CLASS_LIST = [
    'Green', 'Grassy', 'Cucumber', 'Tomato', 'Hay', 'Herbal', 'Mint',
    'Woody', 'Pine', 'Floral', 'Jasmine', 'Rose', 'Honey', 'Fruity',
    'Citrus', 'Lemon', 'Orange', 'Tropical', 'Berry', 'Peach', 'Apple',
    'Sour', 'Fermented', 'Alcoholic', 'Winey', 'Rummy', 'Caramellic',
    'Vanilla', 'Spicy', 'Coffee', 'Smoky', 'Roasted', 'Meaty', 'Nutty',
    'Fatty', 'Coconut', 'Waxy', 'Dairy', 'Buttery', 'Cheesy', 'Sulfurous',
    'Garlic', 'Earthy', 'Musty', 'Animal', 'Musk', 'Powdery', 'Sweet',
    'Cooling', 'Sharp', 'Medicinal', 'Camphoreous', 'Metallic', 'Ozone',
    'Fishy'
]

CLUSTERED_MONELL_CLASS_LIST = ['Fishy',
'Sour', 'Fermented',
'Earthy', 'Musty', 'Metallic', 'Ozone', 'Smoky', 'Animal',
'Mint', 'Cooling', 'Medicinal', 'Camphoreous', 'Alcoholic', 'Sharp',
'Cucumber', 'Spicy', 'Green', 'Grassy', 'Pine', 'Herbal', 'Hay', 'Woody',
'Coconut', 'Coffee', 'Caramellic', 'Vanilla',
'Buttery', 'Dairy', 'Cheesy', 'Tomato', 'Garlic',
'Fatty', 'Meaty', 'Sulfurous', 'Roasted', 'Nutty',
'Lemon', 'Citrus', 'Orange',
'Sweet', 'Peach', 'Tropical', 'Apple', 'Fruity', 'Berry', 'Honey', 'Winey', 'Rummy',
'Floral', 'Jasmine', 'Rose', 'Musk', 'Powdery', 'Waxy',
]

import collections
assert set(MONELL_CLASS_LIST) == set(CLUSTERED_MONELL_CLASS_LIST), "Missing labels {}".format(set(MONELL_CLASS_LIST) ^ CLUSTERED_MONELL_CLASS_LIST)
assert len(MONELL_CLASS_LIST) == len(CLUSTERED_MONELL_CLASS_LIST), "Duplicate labels {} {}".format(collections.Counter(MONELL_CLASS_LIST).most_common(3),
                                                                                                   collections.Counter(CLUSTERED_MONELL_CLASS_LIST).most_common(3))

def translate_monell_google_odor(odor_name):
    return {'Jasmine': 'jasmin'}.get(odor_name, odor_name).lower()

CLASS_LIST = [translate_monell_google_odor(c) for c in MONELL_CLASS_LIST]

def set_visual_settings(dpi: int = 75, usetex: bool = False, font: str = 'Fira Sans') -> None:
    """"Change matplotlib settings."""
    sns.set(font_scale=1.25)
    sns.set_style('whitegrid')
    IPython.display.set_matplotlib_formats('retina')
    pd.set_option('display.precision', 3)

def print_module_versions(module_list):
    """Print module versions"""
    for module in module_list:
        print(f'{module.__name__:<10s}: {module.__version__}')

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