The evidence service
Let's start by creating an empty service and creating a very basic structure for its functions. Create a new TypeScript file inside the evidence/
folder and add the following contents to it:
// src/app/evidence/evidenc.service.ts import {Injectable} from "@angular/core"; @Injectable() export class EvidenceService { private words = [ {key:"w1",value:1}, {key:"w2",value:2} ]; wordCounts(url) { // ToDo: get a url subscribe to its response and call other // functions to count the words and their occurrence in it. // Ideally it will return an array of objects. return words; } }
So the draft version of our service is very simple. It gets a URL which contains the article of our interest and then finds and returns all unique words and number of their instances.
Before implementing these functions, we need to get the URL and find a way to extract useful content out of it. The important question here is how we distinguish between HTML tags and...