npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

afta

v1.0.2

Published

**AFTA** is a powerful, open-source JavaScript library for analyzing, indexing, and searching documents. It provides support for different kinds of document parsers (currently PDF and HTML), various query types, and leverages an SQL database for storing a

Downloads

4

Readme

AFTA

AFTA is a powerful, open-source JavaScript library for analyzing, indexing, and searching documents. It provides support for different kinds of document parsers (currently PDF and HTML), various query types, and leverages an SQL database for storing and retrieving indexed documents.

This project is ideal for applications that require efficient and advanced search functionality over a collection of documents.

Key Features

  • Supports multiple types of document parsers
  • Built-in document analyzer and indexer
  • Cache system for optimizing search operations
  • Multiple query types supported (Term, Boolean, Phrase)
  • Uses SQLite database for persisting index and document data

In this section, we will guide you through the process of setting up and using the Indexer. This will include the following steps:

Setup Environment

Make sure you have Node.js installed. If you don't, you can download it from the official website. Also, ensure that you have a running instance of an Analyzer server. You will need to specify its address when creating an instance of the Analyzer class.

Install Dependencies

As this library is meant to be used with a node environment, ensure all dependencies are installed. Run the command npm install in your terminal at the root of your project directory.

Install Pacakge afta

npm install afta

Create an Instance of Analyzer

import { Analyzer } from "afta";

const analyzer = new Analyzer("link_to_analyzer");

Create an Instance of Database

import { SQLiteDatabase } from "afta";

const database = new SQLiteDatabase("indexer.db");
await database.connect();

Create an Instance of Indexer

import { Indexer } from "afta";

const indexer = new Indexer(analyzer, database);

Add Documents to Indexer

import { Document, Field } from "../../src";

const document = new Document(1);
const field1 = new Field(
  "title",
  "My Title",
  "My Analyzed Title",
  true,
  true,
  true
);
const field2 = new Field(
  "body",
  "My Body",
  "My Analyzed Body",
  true,
  true,
  true
);

document.add(field1);
document.add(field2);

await indexer.addDocument(document);

Create and Execute Queries

import { TermQuery, Term, BuilderQuery } from "afta";

const termQuery = new TermQuery(new Term("title", "My Title"));
const builderQuery = new BuilderQuery();
builderQuery.build(termQuery);

const result = await builderQuery.execute(indexer, analyzer);
console.log(`Total Hits: ${result.totalHits}`);
console.log(`Matching Documents: ${JSON.stringify(result.documents)}`);

Closing the Database Connection

await database.close();

This is a basic guide on how to use the Indexer. Depending on your specific use case, you may need to use additional features or techniques.

The complete code for these steps is:

import {
  Analyzer,
  SQLiteDatabase,
  Indexer,
  Document,
  Field,
  TermQuery,
  Term,
  BuilderQuery,
} from "afta";

// Instantiate Analyzer
const analyzer = new Analyzer("link_to_analyzer");

// Instantiate SQLiteDatabase
const database = new SQLiteDatabase("indexer.db");
await database.connect();

// Instantiate Indexer
const indexer = new Indexer(analyzer, database);

// Create and Add Document to Indexer
const document = new Document(1);
const field1 = new Field(
  "title",
  "My Title",
  "My Analyzed Title",
  true,
  true,
  true
);
const field2 = new Field(
  "body",
  "My Body",
  "My Analyzed Body",
  true,
  true,
  true
);

document.add(field1);
document.add(field2);

await indexer.addDocument(document);

// Create and Execute Queries
const termQuery = new TermQuery(new Term("title", "My Title"));
const builderQuery = new BuilderQuery();
builderQuery.build(termQuery);

const result = await builderQuery.execute(indexer, analyzer);
console.log(`Total Hits: ${result.totalHits}`);
console.log(`Matching Documents: ${JSON.stringify(result.documents)}`);

// Close the database connection
await db.close();