comparison src/app/feature-extraction-menu/feature-extraction-menu.component.ts @ 440:8f658642d031

Crude use of the type uris to map to icons representing the feature types. No actual de-referencing of the uris or attempt to understand them.
author Lucas Thompson <dev@lucas.im>
date Mon, 26 Jun 2017 01:55:11 +0100
parents 48904aa87ba3
children 55e17af8a0ee
comparison
equal deleted inserted replaced
439:e609c6d25f40 440:8f658642d031
9 import { 9 import {
10 FeatureExtractionService 10 FeatureExtractionService
11 } from '../services/feature-extraction/feature-extraction.service'; 11 } from '../services/feature-extraction/feature-extraction.service';
12 import {ListResponse} from 'piper'; 12 import {ListResponse} from 'piper';
13 import {Subscription} from 'rxjs/Subscription'; 13 import {Subscription} from 'rxjs/Subscription';
14 import {HigherLevelFeatureShape} from "../visualisations/FeatureUtilities";
14 15
15 export interface ExtractorOutputInfo { 16 export interface ExtractorOutputInfo {
16 extractorKey: string; 17 extractorKey: string;
17 combinedKey: string; 18 combinedKey: string;
18 outputId: string; 19 outputId: string;
19 name: string; 20 name: string;
21 iconName?: string;
20 } 22 }
21 23
22 interface ExtractorInfo { 24 interface ExtractorInfo {
23 name: string; 25 name: string;
24 outputs: ExtractorOutputInfo[]; 26 outputs: ExtractorOutputInfo[];
25 } 27 }
28
29 const crudeTypeUriMap: {[key: string]: HigherLevelFeatureShape} = {
30 'http://purl.org/ontology/af/Beat': 'instants',
31 'http://purl.org/ontology/af/Chromagram': 'matrix',
32 'http://purl.org/ontology/af/Spectrogram': 'matrix',
33 'http://purl.org/ontology/af/KeyChange': 'instants',
34 'http://purl.org/ontology/af/OnsetDetectionFunction': 'vector',
35 'http://purl.org/ontology/af/Onset': 'instants',
36 'http://purl.org/ontology/af/StructuralSegment': 'instants',
37 'http://purl.org/ontology/af/TonalOnset': 'instants',
38 'http://purl.org/ontology/af/Note': 'notes',
39 'http://purl.org/ontology/af/ChordSegment': 'instants',
40 'http://purl.org/ontology/af/MusicSegment': 'instants',
41 'http://purl.org/ontology/af/Pitch': 'tracks'
42 };
43
44 const featureIconMap = {
45 vector: 'show_chart',
46 matrix: 'grid_on',
47 tracks: 'multiline_chart',
48 instants: 'view_week',
49 notes: 'audiotrack',
50 };
26 51
27 @Component({ 52 @Component({
28 selector: 'ugly-feature-extraction-menu', 53 selector: 'ugly-feature-extraction-menu',
29 templateUrl: './feature-extraction-menu.component.html', 54 templateUrl: './feature-extraction-menu.component.html',
30 styleUrls: ['./feature-extraction-menu.component.css'] 55 styleUrls: ['./feature-extraction-menu.component.css']
57 this.extractors = available.available.reduce((acc, staticData) => { 82 this.extractors = available.available.reduce((acc, staticData) => {
58 const name = staticData.basic.name; 83 const name = staticData.basic.name;
59 const outputs: ExtractorOutputInfo[] = 84 const outputs: ExtractorOutputInfo[] =
60 staticData.basicOutputInfo.map(output => { 85 staticData.basicOutputInfo.map(output => {
61 const combinedKey = `${staticData.key}:${output.identifier}`; 86 const combinedKey = `${staticData.key}:${output.identifier}`;
62 return { 87 const hasTypeInfo = staticData.staticOutputInfo &&
63 extractorKey: staticData.key, 88 staticData.staticOutputInfo.get(output.identifier) &&
64 combinedKey: combinedKey, 89 staticData.staticOutputInfo.get(output.identifier).typeURI;
65 name: output.name, 90 const getIcon = () => featureIconMap[crudeTypeUriMap[
66 outputId: output.identifier 91 staticData.staticOutputInfo.get(output.identifier).typeURI
67 }; 92 ]];
93 const hasIcon = hasTypeInfo && getIcon();
94 return Object.assign({
95 extractorKey: staticData.key,
96 combinedKey: combinedKey,
97 name: output.name,
98 outputId: output.identifier
99 },
100 hasIcon ? {iconName: getIcon()} : {}
101 );
68 }); 102 });
69 acc.push({name, outputs}); 103 acc.push({name, outputs});
70 return acc; 104 return acc;
71 }, [] as ExtractorInfo[]); 105 }, [] as ExtractorInfo[]);
72 this.isLoading = false; 106 this.isLoading = false;