Skip to content

Instantly share code, notes, and snippets.

class FS {
root = {
type:'directory',
name:'/',
children:[],
}
sort(node) {
node.children.sort((a, b) => {
if (a.type == b.type) return a.name.localeCompare(b.name);
@khtdr
khtdr / summarizer.ts
Created October 3, 2022 00:30
Text summarizer using NLP (compromise)
import nlp from "compromise";
export function summarize(text: string, approx_word_count = 75): string {
const terms = rankTextTerms(text);
const ranked = reorderSentences(text, terms);
const summary = extractSummary(ranked, approx_word_count);
return summary;
}
function rankTextTerms(text: string): Record<string, number> {