0.2.37 • Published 4 days ago

@fabilab/atlasapprox-nlp v0.2.37

Weekly downloads
-
License
MIT
Repository
github
Last release
4 days ago

npm version

Cell Atlas Approximations - Natural Language Processing

Cell atlases are single cell data sets on the scale of whole organisms. There are many ways for humans to query these atlases using natural language (e.g. English), however human-atlas interactions are currently limited to Python or R programmers.

This project enables biologists, doctors, and anyone else to ask questions in their natural language (starting from English) and convert the question into a formalised query for an atlas approximation. This functionality is used internally in our Human Interface web application. Intents understood via NLP in this library are then forwarded to our JavaScript API contained in the @fabilab/atlasapprox npm package.

Installation

npm install @fabilab/atlasapprox-nlp

If you want to use query the JavaScript API based on the answers you received here, you'll need to install that package as well:

npm install @fabilab/atlasapprox

Usage

// ES6 (e.g. in React development)
import { AtlasApproxNlp } from '@fabilab/atlasapprox-nlp';
// CommonJS variant
//let { AtlasApproxNlp } = require('@fabilab/atlasapprox-nlp');

let nlp = new AtlasApproxNlp();

(async () => {
  await nlp.initialise();

  // NOTE: Multiple initalisations are unnecessary but tolerated

  // Ask a question
  let response = await nlp.ask("What measurement types are available?");
  console.log(response);

  // Reset context to a virgin state
  nlp.reset();

})();

AtlasapproxNlp is the main object wrapping the excellent nlpjs library. Object instantiation is synchronous, but initialisation of the nlpjs library is async.

Architechture

  • src/corpus.json is the training corpus containing utterances (questions), entities, etc.
  • src/app.js contains most of the wrapper code, including the buildAPIParams, buildAnswer, and ask functions.
  • src/tail_node.js contains the object constructor and initalisation methods to be exported in CommonJS format.
  • src/tail_window.js is an older version that relies on a global window.nlp object (deprecated).

Development

  • Add utterances etc. to the corpus.
  • Test with npm run testCorpus, adding test questions to test/trainAndTest.js if needed.
  • Once this works, you can pre-train the production model using npm run train. npm run train saves the model in gists/model/model.nlp which is a git submodule, and pushed a new commit to the gist repo.
  • Get the URL of the raw file on gist and substitute it on top of src/app.js.
  • Run npm run testNpm to test a webpack-like app that loads the module using CommonJS.

(deprecated):

  • npm run testBrowser creates a browser-compatible index.js and an index.html into build and opens it in Firefox. Opening the inspector shows an example call and exposes a function called answerFun to probe the model by hand.
0.2.37

4 days ago

0.2.36

11 days ago

0.2.35

24 days ago

0.2.34

26 days ago

0.2.33

2 months ago

0.2.32

2 months ago

0.2.30

5 months ago

0.2.31

5 months ago

0.2.29

5 months ago

0.2.28

5 months ago

0.2.27

5 months ago

0.2.26

5 months ago

0.2.25

5 months ago

0.2.24

5 months ago

0.2.23

5 months ago

0.2.22

5 months ago

0.2.21

5 months ago

0.2.20

6 months ago

0.2.19

6 months ago

0.2.18

7 months ago

0.2.17

7 months ago

0.2.16

7 months ago

0.2.15

7 months ago

0.2.13

7 months ago

0.2.12

7 months ago

0.2.11

7 months ago

0.2.10

7 months ago

0.2.9

7 months ago

0.2.8

7 months ago

0.2.7

7 months ago

0.2.6

7 months ago

0.2.5

7 months ago

0.2.4

7 months ago

0.2.3

7 months ago

0.2.2

7 months ago

0.2.1

7 months ago

0.2.0

7 months ago

0.1.31

7 months ago

0.1.30

7 months ago

0.1.29

7 months ago

0.1.28

8 months ago

0.1.27

8 months ago

0.1.26

8 months ago

0.1.25

8 months ago

0.1.24

8 months ago

0.1.23

9 months ago

0.1.22

9 months ago

0.1.21

9 months ago

0.1.20

9 months ago

0.1.19

9 months ago

0.1.18

9 months ago

0.1.17

9 months ago

0.1.16

9 months ago

0.1.15

9 months ago

0.1.14

9 months ago

0.1.13

9 months ago

0.1.12

10 months ago

0.1.11

10 months ago

0.1.10

10 months ago

0.1.8

10 months ago

0.1.7

10 months ago

0.1.6

10 months ago

0.1.9

10 months ago