1.0.0 • Published 5 years ago

isidore v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Isidore: A grammar utility for the internet

An experimental, potentially multilingual, highly configurable part-of-speech tagger.

This is still somewhat experimental.. Verb identification, in particular, is still limited. Please monitor the issuer tracker for progress on feature development.

dev dependency status License Downloads

API

PartsOfSpeech

There is a class per part of speech. All parts of speech inherit from the word class:

Word Class

MemberTypeDescription
partOfSpeechstringone of the eight parts of speech
wordstringthe word (token)
typestringa high-level classification for this partOfSpeech
typesarrayall possible types for this partOfSpeech

Parts of Speech:

  • Noun
  • Pronoun
  • Verb
  • Adjective
  • Adverb
  • Conjunction
  • Interjection
  • Preposition

    These may all have additional members.

Dictionaries

There is a dictionary class per part-of-speech. All dictionaries inherit from the Dictionary class. Any rules about how words can vary (inflections) are stored in the Dictionary for that part of speech (e.g. NounDictionary has rules about how to recognize plurals and possessives);

This is so that Isidore could have potential to scale into other languages without requiring massive rewrites.

Dictionary

MemberTypeDescription
listarraysorted list of words
languagestringLanguage for the dictionary
findWord()methodfinds a word in the dictionary
partOfSpeechstringthe part of speech that dictionary has
GrammarModelclassThe type that the dictionary contains

NounDictionary class:

MemberTypeDescription
listarrayNouns with types and wordCategories
languagestringtwo-letter abbreviation of language
inflectionsobjectinflections that can be applied to all nouns
findWord(word)methodSearches for word in dictionary (returns Noun if successful)
getInflections(word)methodword (string), returns all possible inflections for the word
guessInflection(word)method(string), returns a single inflection (object)
removeInflection(word, inflection)methodword(string), inflection (object). returns string

Languages

All languages within the utility. Right now we just have En, which is a Language;

Language class

MemberTypeDescription
grammarDictionariesObjectNounDictionary, PronounDictionary, VerbDictionary, AdjectiveDictionary, AdverbDictionary, ConjunctionDictionary, InterjectionDictionary, PrepositionDictionary
languagestringtwo-letter description of language
findWord()methodaccepts a string, returns an array containing partOfSpeech or a word if no word is found

Sentence

The sentence is where the parsing magic starts.

Sentence Class

MemberTypeDescription
textstringraw text of the sentence
typestringdeclarative, interrogative, imperative, exclamatory
languagestringLanguage (En) is default
rawWordListarrayonly the words in the sentence
wordListarrayeach word in the sentence classified as either a or word
typesarraythe possible types that a sentence could have
getSentenceType()methodreturns string, the type of sentence. Guesses what the sentence type is based on punctuation

Example

const { Sentence } = isidore
const mySentence = new Sentence('He gives her a car.');
const { wordList } = mySentence;

console.log(mySentence);
/*
Sentence {
    text: 'He gives him a car.',
    language: 'En',
    rawWordList: [ 'he', 'gives', 'him', 'a', 'car' ],
    wordList:
    [
        Pronoun {
            partOfSpeech: 'pronoun',
            word: 'he',
            referent: 'animate',
            gender: 'masculine',
            type: 'subject',
            person: 3,
            quantity: 'singular'
        },
        Verb {
            partOfSpeech: 'verb',
            word: 'give',
            type: 'transitive',
            valence: 2
        },
        Pronoun {
            partOfSpeech: 'pronoun',
            word: 'him',
            referent: 'animate',
            gender: 'masculine',
            type: 'object',
            person: 3,
            quantity: 'singular',
        },
        Adjective {
            partOfSpeech: 'adjective',
            word: 'a',
            type: 'article',
            degree: undefined
        },
        Noun {
            partOfSpeech: 'noun',
            word: 'car',
            type: 'entityClass',
            subType: 'common',
            inflection: undefined
        }
    ],
    type: 'declarative'
}
    */
1.0.0

5 years ago

0.0.4

5 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago