morpho~Morpho

Morphology specific functions such as stemming, conjugation, etc.

Members

readonly Aspect :String

The aspect: Simple, Continuous, Perfect, PerfectContinuous
access: Morpho.Feature.Aspect

readonly Gender :String

The gender: Masculine, Feminine, Neuter.
access: Morpho.Feature.Gender

readonly GNumber :String

The grammatical number: Singular, Dual, Plural
access: Morpho.Feature.Number

readonly lconv

Returns the list of available converting methods
See:
  • listPosConverters

readonly Mood :String

The mood: indicative, subjunctive, conditional, optative, imperative, jussive, potential, hypothetical, inferential
access: Morpho.Feature.Mood
See:

readonly Person :String

The person: First, Second, Third.
access: Morpho.Feature.Person

readonly sstem

Sets the current stemmer

readonly Tense :String

Constant for tenses
access: Morpho.Tense

readonly Voice :String

The voice: Active,Passive, Middle
access: Morpho.Feature.Voice

Methods

protected, static _conj(verb, _opts, _form) → {String}

Parameters:
Name Type Description
verb String the word to be conjugated
_opts Object options for tense, case, voice, aspect, person, number, gender, mood, and other
_form Sring
Returns:
String - Conjugated verb
See:
  • conj

protected, static _gNegName(opts) → {String}

Returns the label of the negation in the current language
Parameters:
Name Type Description
opts Object An object containing the attribute: negated: (0|1)
Returns:
String - the label of the negation in the current language

protected, static _gNegOpts() → {Array.<Object>}

Returns the list of negation options for verb conjugation
Returns:
Array.<Object> - The list of available negation options

protected, static _gPpName(opts) → {String}

Get the personal pronoun using options like: person, gender, etc.
for example, the parameters for the personal pronoun "I":
Parameters:
Name Type Description
opts Object An object containing parameters: person, gender, number.
Returns:
String - the pronoun
Example
{
     person: Morpho.Feature.Person.F, // "first"
     number: Morpho.Feature.Number.S // "singular"
   }

protected, static _gPpOpts() → {Array.<Object>}

Returns a list of options for pronouns in the current language
Returns:
Array.<Object> - List of pronouns options

protected, static _gVoiceName(opts) → {String}

Returns the conjugation voice's name in the current language
Parameters:
Name Type Description
opts Object An object with one attribute: voice
Returns:
String - the label of the voice in the current language

protected, static _gVoiceOpts() → {Array.<Object>}

Returns the list of conjugation voice for the current language
Returns:
Array.<Object> - A list of conjugation voice parameters for the current language

protected, static _nConv(converterName, converterDesc, converterFct)

Add new part of speach converter method
Parameters:
Name Type Description
converterName String the name of the converter
converterDesc String the description of the converter
converterFct function the function convert(word)

protected, static _nStem(stemmerName, stemmerDesc, stemmerFct)

Add new stemmer method
Parameters:
Name Type Description
stemmerName String the name of the stemmer
stemmerDesc String the description of the stemmer
stemmerFct function the function stem(word)

static conj(verb, _opts, _form) → {String}

This function is used for verb conjugation
Parameters:
Name Type Description
verb String the word to be conjugated
_opts Object options for tense, case, voice, aspect, person, number, gender, mood, and other
_form Sring
Returns:
String - Conjugated verb

static conjugate(verb, _opts, _form) → {String}

This function is used for verb conjugation
Parameters:
Name Type Description
verb String the word to be conjugated
_opts Object options for tense, case, voice, aspect, person, number, gender, mood, and other
_form String the form's ID
Returns:
String - Conjugated verb

static conv(word) → {String}

Convert a word: singular to plural; verb to noun; etc
Parameters:
Name Type Description
word String the word to be converted
Returns:
String - converted word
See:
  • convertPoS

static convertPoS(word) → {String}

Convert a word: singular to plural; verb to noun; etc
Parameters:
Name Type Description
word String the word to be converted
Returns:
String - converted word
See:
  • conv

static filter(words) → {Array.<String>}

Delete stop words from a list of words
Parameters:
Name Type Description
words Array.<String> list of words
Returns:
Array.<String> - filtered list of words

static filterStopWords(words) → {Array.<String>}

Delete stop words from a list of words
Parameters:
Name Type Description
words Array.<String> list of words
Returns:
Array.<String> - filtered list of words

static gconjmod() → {Object}

Each language has a conjugation table model. For example, in English, Arabic and French, we put pronouns in rows. As for Japanese, the conjugation doesn't follow that pattern.
Returns:
Object - conjugation model with rows and cols

static gconvdesc(converterName) → {string}

Get the description of a PoS converter by its name
Parameters:
Name Type Description
converterName string the name of the converter
Returns:
string - the description of the converter
See:
  • getPosConverterDesc

static getConjugationModel() → {Object}

Each language has a conjugation table model. For example, in English, Arabic and French, we put pronouns in rows. As for Japanese, the conjugation doesn't follow that pattern.
Returns:
Object - conjugation model with rows and cols

static getFormDescription(formName) → {string}

Get the description of a conjugation form
Parameters:
Name Type Description
formName string form's name
Returns:
string - form's description
See:
  • gform

static getOptName(optLabel, opts) → {String}

Returns the name of a conjugation parameter (Pronoun, Negation, Voice) given some options
Parameters:
Name Type Description
optLabel String can be: Pronoun, Negation, Voice
opts Object The parameters
Returns:
String - The label of this parameter in the current language
Example
var opts = {
     person: "first", // Morpho.Feature.Person.F
     number: "singular" // Morpho.Feature.Number.S
   };
   var I = getOptName("Pronoun", opts);
// In English, it will give: "I"
// In Arabic, it will give: "أنا"

static getPosConverterDesc(converterName) → {string}

Get the description of a PoS converter by its name
Parameters:
Name Type Description
converterName string the name of the converter
Returns:
string - the description of the converter
See:
  • gconvdesc

static getStemmerDescription(stemmerName) → {string}

Get the description of a stemmer
Parameters:
Name Type Description
stemmerName string stemmer's name
Returns:
string - stemmer's description
See:
  • gstemdesc

static getTenseName(tense) → {String}

This method is used to recover the name of the tense
Parameters:
Name Type Description
tense String the tense which we want to get the name (See Morpho.Tense)
Returns:
String - the name of the tense in the selected language

static getVerbType(verb) → {String}

Given a verb, it detects its type
Parameters:
Name Type Description
verb String the verbe
Returns:
String - verb's type

static gform(formName) → {object}

Get the form by name
Parameters:
Name Type Description
formName string form's name
Returns:
object - form composition

static gformdesc(formName) → {string}

Get the description of a conjugation form
Parameters:
Name Type Description
formName string form's name
Returns:
string - form's description
See:
  • getFormDescription

static goptname(optLabel, opts) → {String}

Returns the name of a conjugation parameter (Pronoun, Negation, Voice) given some options
Parameters:
Name Type Description
optLabel String can be: Pronoun, Negation, Voice
opts Object The parameters
Returns:
String - The label of this parameter in the current language
Example
var opts = {
     person: "first", // Morpho.Feature.Person.F
     number: "singular" // Morpho.Feature.Number.S
   };
   var I = getOptName("Pronoun", opts);
// In English, it will give: "I"
// In Arabic, it will give: "أنا"

static gsents(text) → {Array.<String>}

Segment a given text
Parameters:
Name Type Description
text String the text to be segmennted into sentences
Returns:
Array.<String> - a list of sentences

static gstemdesc(stemmerName) → {string}

Get the description of a stemmer
Parameters:
Name Type Description
stemmerName string stemmer's name
Returns:
string - stemmer's description
See:
  • getStemmerDescription

static gtensename(tense) → {String}

This method is used to recover the name of the tense
Parameters:
Name Type Description
tense String the tense which we want to get the name (See Morpho.Tense)
Returns:
String - the name of the tense in the selected language

abstract, static gvtype(verb) → {String}

Given a verb, it detects its type
Parameters:
Name Type Description
verb String the verbe
Returns:
String - verb's type

static lconjopt(optLabel) → {Array.<Object>}

Returns the available options for conjugation such as pronouns, negation, voice, etc.
Parameters:
Name Type Description
optLabel String Can be: "Pronoun", "Negation", "Voice"
Returns:
Array.<Object> - A list of parameters related to optLabel and the processed language

static lform() → {Array.<Object>}

This function returns an object of available conjugation forms for the current language
Returns:
Array.<Object> - Array of conjugation forms available for the language
Example
{
 "form_name": {opts}
}

static listConjugationOptions(optLabel) → {Array.<Object>}

Returns the available options for conjugation such as pronouns, negation, voice, etc.
Parameters:
Name Type Description
optLabel String Can be: "Pronoun", "Negation", "Voice"
Returns:
Array.<Object> - A list of parameters related to optLabel and the processed language

static listForms() → {Array.<Object>}

This function returns an object of available conjugation forms for the current language
Returns:
Array.<Object> - Array of conjugation forms available for the language
See:
  • lform
Example
{
 "form_name": {opts}
}

static listPosConverters() → {Array.<String>}

Returns the list of available converting methods
Returns:
Array.<String> - Array of Strings containing converters names
See:
  • lconv

static listStemmers() → {Array.<String>}

Returns the list of available stemming methods
Returns:
Array.<String> - Array of Strings containing stemmers names

abstract, static listVerbTypes() → {Array.<String>}

Returns a list of verb types
Returns:
Array.<String> - list of verb types

static lstem() → {Array.<String>}

Returns the list of available stemming methods
Returns:
Array.<String> - Array of Strings containing stemmers names

abstract, static lvtype() → {Array.<String>}

Returns a list of verb types
Returns:
Array.<String> - list of verb types

static norm(word, opts) → {String}

Normalization method, used to delete non used chars or to replace some with others, etc.
Parameters:
Name Type Description
word String the word to be normalized
opts String some options (optional) where each language defines its own normalization options
Returns:
String - normalized word

static normalize(word, opts) → {String}

Normalization method, used to delete non used chars or to replace some with others, etc.
Parameters:
Name Type Description
word String the word to be normalized
opts String some options (optional) where each language defines its own normalization options
Returns:
String - normalized word

static parseConjModel(morpho) → {Object}

This method is a helper for presenting conjugation tables. It takes a Morpho object of a certain language, then creates rows labels and columns labels for this language
Parameters:
Name Type Description
morpho Morpho A Morpho object specified for a given language
Returns:
Object - - Information about columns and rows in conjugation

static sconv(converterName)

Sets the current PoS converter
Parameters:
Name Type Description
converterName String converter method's name
See:
  • setCurrentPosConverter

static setCurrentPosConverter(converterName)

Sets the current PoS converter
Parameters:
Name Type Description
converterName String converter method's name
See:
  • sconv

static setCurrentStemmer(StemmerName)

Sets the current stemmer
Parameters:
Name Type Description
StemmerName String stemmer method's name

static splitToSentences(text) → {Array.<String>}

Segment a given text
Parameters:
Name Type Description
text String the text to be segmennted into sentences
Returns:
Array.<String> - a list of sentences

static stem(word) → {String}

Stem a word: delete prefixes, suffixes and infixes
Parameters:
Name Type Description
word String the word to be stemmed
Returns:
String - stemmed word

static tokenize(text) → {Array.<String>}

Tokenize a given text (mostly, a sentence)
Parameters:
Name Type Description
text String the sentence to be tokenized
Returns:
Array.<String> - a list of words