1234567891011121314151617181920212223242526272829 |
- /// <reference path="ContentDifferential.ts" />
- class ContentUnit {
- public categories : Array<ContentDifferential> = [];
- public addCategory (...nouns : Array<Thing | typeof Thing | ContentDifferential>) {
- this.categories.push(new ContentDifferential(...nouns));
- }
- public isMatch (cu : ContentUnit) {
- return ContentDifferential.isMatch(this.categories, cu.categories);
- }
- public getScore () {
- let score = 0;
- this.categories.forEach(diff => {
- score += diff.score;
- });
- return score / this.categories.length;
- }
- public matchAgainst (a : Array<ContentUnit>) : Array<number> {
- for (let i = 0; i < a.length; i++) {
- if (a[i].isMatch(this)) {
- return [i];
- }
- }
- }
- }
|