ru-compromise
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published
ru-compromise
скромная обработка естественного языка
npm install ru-compromise
работа в процессе! • work-in-progress!

ru-compromise - это порт compromise для русского языка

Цель этого проекта — предоставить небольшой базовый POS-тегер, основанный на правилах.

(this project is a small, basic, rulru-based POS tagger!)

import nlp from 'ru-compromise'

let doc = nlp('Не забудь и ты эти летние Подмосковные вечера')
doc.match('#Verb').out('array')
// [ 'забудь' ]

или в браузере:

<script src="https://unpkg.com/ru-compromise"></script>
<script>
  let txt = 'В эти тихие вечера'
  let doc = ruCompromise(txt) // window.ruCompromise
  console.log(doc.json())
  // { text:'В эти ...', terms:[ ... ] }
</script>

API

ru-compromise включает все методы из compromise/one:

нажмите здесь, чтобы увидеть API

Output
  • .text() - return the document as text
  • .json() - return the document as data
  • .debug() - pretty-print the interpreted document
  • .out() - a named or custom output
  • .html({}) - output custom html tags for matches
  • .wrap({}) - produce custom output for document matches
Utils
  • .found [getter] - is this document empty?
  • .docs [getter] get term objects as json
  • .length [getter] - count the # of characters in the document (string length)
  • .isView [getter] - identify a compromise object
  • .compute() - run a named analysis on the document
  • .clone() - deep-copy the document, so that no references remain
  • .termList() - return a flat list of all Term objects in match
  • .cache({}) - freeze the current state of the document, for speed-purposes
  • .uncache() - un-freezes the current state of the document, so it may be transformed
Accessors
Match

(match methods use the match-syntax.)

  • .match('') - return a new Doc, with this one as a parent
  • .not('') - return all results except for this
  • .matchOne('') - return only the first match
  • .if('') - return each current phrase, only if it contains this match ('only')
  • .ifNo('') - Filter-out any current phrases that have this match ('notIf')
  • .has('') - Return a boolean if this match exists
  • .before('') - return all terms before a match, in each phrase
  • .after('') - return all terms after a match, in each phrase
  • .union() - return combined matches without duplicates
  • .intersection() - return only duplicate matches
  • .complement() - get everything not in another match
  • .settle() - remove overlaps from matches
  • .growRight('') - add any matching terms immediately after each match
  • .growLeft('') - add any matching terms immediately before each match
  • .grow('') - add any matching terms before or after each match
  • .sweep(net) - apply a series of match objects to the document
  • .splitOn('') - return a Document with three parts for every match ('splitOn')
  • .splitBefore('') - partition a phrase before each matching segment
  • .splitAfter('') - partition a phrase after each matching segment
  • .lookup([]) - quick find for an array of string matches
  • .autoFill() - create type-ahead assumptions on the document
Tag
  • .tag('') - Give all terms the given tag
  • .tagSafe('') - Only apply tag to terms if it is consistent with current tags
  • .unTag('') - Remove this term from the given terms
  • .canBe('') - return only the terms that can be this tag
Case
Whitespace
  • .pre('') - add this punctuation or whitespace before each match
  • .post('') - add this punctuation or whitespace after each match
  • .trim() - remove start and end whitespace
  • .hyphenate() - connect words with hyphen, and remove whitespace
  • .dehyphenate() - remove hyphens between words, and set whitespace
  • .toQuotations() - add quotation marks around these matches
  • .toParentheses() - add brackets around these matches
Loops
  • .map(fn) - run each phrase through a function, and create a new document
  • .forEach(fn) - run a function on each phrase, as an individual document
  • .filter(fn) - return only the phrases that return true
  • .find(fn) - return a document with only the first phrase that matches
  • .some(fn) - return true or false if there is one matching phrase
  • .random(fn) - sample a subset of the results
Insert
Transform
Lib

(these methods are on the main nlp object)

вклад:

пожалуйста, присоединяйтесь, чтобы помочь! - please join to help!

help with first PR1

git clone https://github.com/nlp-compromise/ru-compromise.git
cd ru-compromise
npm install
npm test
npm watch

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i ru-compromise

Weekly Downloads

14

Version

0.0.2

License

MIT

Unpacked Size

2.27 MB

Total Files

46

Last publish

Collaborators

  • spencermountain