Skip to content

Better in-page search using natural queries, implemented client-side with a Porter-stemmer, part of speech tagger and naive tokenizer. Reads current/specified page content and identifies passages that contain answers to user queries.

Notifications You must be signed in to change notification settings

ryhan/answer.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

answer.js

Better in-page search, created by Ryhan Hassan.

Usage

Include the following libraries

<script src="lib/jquery.js"></script>
<script src="lib/underscore.js"></script>
<script src="lib/natural.js"></script>
<script src="lib/jspos/lexer.js"></script>
<script src="lib/jspos/lexicon.js_"></script>
<script src="lib/jspos/POSTagger.js"></script>
<script src="answer.js"></script>

Preprocess the article

Create a new answer object, and run read() on any text.

reader = new answer();
reader.read($('article').text());

Query with questions

Running match( text ) will return an array of sentences in descending rank with their rank.

var answers = reader.match("What is the longevity of a soap bubble limited by?");

// Log the top answer, formatted as [score, text]
console.log(answers[0]);

Demos

  • demo.html logs the top answer to the console
  • search.html is a demo with a styled search field.

About

Better in-page search using natural queries, implemented client-side with a Porter-stemmer, part of speech tagger and naive tokenizer. Reads current/specified page content and identifies passages that contain answers to user queries.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published