import { Injectable } from '@angular/core'; export interface RawData { index: string[][]; values: number[][]; } export interface LshData { candidates: number[]; distances: number[]; hash_functions: number[];// number[][][][]; parameters?: number[]; } export interface TableInfoData { prototypes: { average: number[]; min: number[]; max: number[]; }[]; distances: number[][]; } @Injectable({ providedIn: 'root' }) export class ApiService { constructor() { } // Read input data async readFile(): Promise { const response = await fetch('http://127.0.0.1:5000/read-mts-data'); return await response.json(); } // Split data into windows and normalize async createWindows(parameters): Promise { const postData = {parameters}; const response = await fetch('http://127.0.0.1:5000/create-mts-windows', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify(postData) }); } // Calculate parameters for LSH + find candidates using LSH async lshInitial(query): Promise { const response = await fetch('http://127.0.0.1:5000/initialize', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: new Blob( [ JSON.stringify({query}) ], { type: 'text/plain' } ) }); return await response.json(); } // Find candidates using LSH with weights async lshUpdate(query, weights, parameters): Promise { const response = await fetch('http://127.0.0.1:5000/update', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: new Blob( [ JSON.stringify({query, weights, parameters}) ], { type: 'text/plain' } ) }); return await response.json(); } // Get query window based on windows labeled correct async getQueryWindow(window): Promise { const response = await fetch('http://127.0.0.1:5000/query', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({window}) }); return await response.json(); } // Get data of a window by indices async getWindowByIndices(indices: number[]): Promise { const response = await fetch('http://127.0.0.1:5000/window', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({indices}) }); return await response.json(); } async getTableInfo(windows): Promise { const response = await fetch('http://127.0.0.1:5000/table-info', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({windows}) }); return await response.json(); } }