flashtext.js:Python包FlashText @ httpsJavaScript端口

  • m0_483613
    了解作者
  • 51.1KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-11 02:59
    上传日期
Flashtext.js 令人惊叹的Python软件包JavaScript(ES6 +源和零依赖项)端口 此模块可用于替换句子中的关键字或从句子中提取关键字。 注意-这是一个快速的实验端口。 请发布以解决所有无法解决或可以改进的问题 安装 $ npm install flashtext . js -- save 或者 $ yarn add flashtext . js 用法 提取关键词 const processor = new KeywordProcessor ( ) ; processor . addKeyword ( 'Big Apple' , 'New York' ) ; processor . addKeyword ( 'Bay Area' ) ; const keywordsFound = processor . extractKeywords ( 'I love Bi
flashtext_js-master.zip
  • flashtext.js-master
  • src
  • index.js
    11.9KB
  • build
  • index.js
    3.8KB
  • test
  • index.test.js
    3.2KB
  • .coveralls.yml
    45B
  • .eslintrc.js
    495B
  • .babelrc
    27B
  • .npmignore
    20B
  • .travis.yml
    127B
  • LICENSE
    1KB
  • README.md
    3.7KB
  • .gitignore
    35B
  • .eslintignore
    31B
  • package-lock.json
    198.8KB
  • package.json
    1010B
内容介绍
# Flashtext.js [![Build Status](https://travis-ci.org/drenther/flashtext.js.svg?branch=master)](https://travis-ci.org/drenther/flashtext.js) [![Coverage Status](https://coveralls.io/repos/github/drenther/flashtext.js/badge.svg?branch=master)](https://coveralls.io/github/drenther/flashtext.js?branch=master) ### JavaScript (ES6+ source and zero dependencies) port of the amazing Python package [flashtext](https://github.com/vi3k6i5/flashtext) This module can be used to replace keywords in sentences or extract keywords from sentences. #### Note - This is a quick experimental port. Please post [issues](https://github.com/drenther/flashtext.js/issues) for anything that doesn't work or can be improved ## Installation ```javascript $ npm install flashtext.js --save ``` #### or ```javascript $ yarn add flashtext.js ``` ## Usage ### Extract Keywords ```javascript const processor = new KeywordProcessor(); processor.addKeyword('Big Apple', 'New York'); processor.addKeyword('Bay Area'); const keywordsFound = processor.extractKeywords( 'I love Big Apple and Bay Area.' ); console.log(keywordsFound); // output - ['New York', 'Bay Area'] ``` ### Replace Keywords ```javascript const processor = new KeywordProcessor(); processor.addKeyword('Big Apple', 'New York'); processor.addKeyword('New Delhi', 'NCR Region'); const newSentence = processor.replaceKeywords( 'I love Big Apple and new delhi.' ); console.log(newSentence); // output - 'I love New York and NCR Region.' ``` ### Case Sensitive Example ```javascript const processor = new KeywordProcessor(true); processor.addKeyword('Big Apple', 'New York'); processor.addKeyword('Bay Area'); const keywordsFound = processor.extractKeywords( 'I love big Apple and Bay Area.' ); console.log(keywordsFound); // output - ['Bay Area'] ``` ### Multiple Keywords Entry using Object ```javascript const processor = new KeywordProcessor(); processor.addKeywordsFromObject({ java: ['java_2e', 'java programming'], python: ['python2.7', 'python programming'], }); const keywordsFound = processor.extractKeywords( 'I love java_2e and python programming.' ); console.log(keywordsFound); // output - ['java', 'python'] const newSentence = processor.replaceKeywords( 'I prefer python over java programming.' ); console.log(newSentence); // output - 'I prefer python over java.' ``` ### Multiple Keywords Entry using Arrays ```javascript const processor = new KeywordProcessor(); processor.addKeywordsFromArray(['java', 'product manager']); const keywordsFound = processor.extractKeywords( 'I am a product manager for a java platform' ); console.log(keywordsFound); // output - ['product manager', 'java'] ``` ### Remove Keywords (One/Multiple) ```javascript const processor = new KeywordProcessor(); processor.addKeywordsFromArray(['react', 'angular', 'vue', 'javascript']); processor.removeKeywordsFromArray(['angular', 'vue']); processor.removeKeyword('javascript'); const keywordsFound = processor.extractKeywords( 'I know React, Angular and Vue. I love JavaScript.' ); console.log(keywordsFound); // output - ['react']; ``` ### Add characters as a part of word ```javascript const processor = new KeywordProcessor(); processor.addKeyword('Big Apple'); const before = processor.extractKeywords('I love Big Apple/Bay Area.'); console.log(before); // output - ['Big Apple'] processor.addNonWordBoundaries('/'); const after = processor.extractKeywords('I love Big Apple/Bay Area.'); console.log(after); // output - [] ``` ## References The original paper published on [FlashText algorithm](https://arxiv.org/abs/1711.00046) The article published on [Medium freeCodeCamp](https://medium.freecodecamp.org/regex-was-taking-5-days-flashtext-does-it-in-15-minutes-55f04411025f) ## License This code is under MIT license.
评论
    相关推荐
    • Flash报表
      NULL 博文链接:https://lixue150.iteye.com/blog/1454134
    • Flash优化
      NULL 博文链接:https://412599526-qq-com.iteye.com/blog/1189144
    • Flash机制
      NULL 博文链接:https://as3.iteye.com/blog/941209
    • Flash优化
      NULL 博文链接:https://412599526-qq-com.iteye.com/blog/1189144
    • flash 视频
      NULL 博文链接:https://wuzijingaip.iteye.com/blog/587535
    • flash camera
      NULL 博文链接:https://marlgl.iteye.com/blog/1563674
    • Flash优化
      NULL 博文链接:https://412599526-qq-com.iteye.com/blog/1189144
    • flash 时钟
      NULL 博文链接:https://wuzijingaip.iteye.com/blog/628405
    • flash 视频
      NULL 博文链接:https://wuzijingaip.iteye.com/blog/587535
    • flash camera
      NULL 博文链接:https://marlgl.iteye.com/blog/1563674