compromise

2019-05-15 admin

compromise是什么

什么是compromise,natural language processing in the browser

compromise使用教程帮助文档

<div align=“center”></div>

<div align=“center”>

<div>modest natural-language processing in javascript</div>

<sub>by Spencer Kelly and many contributors</sub></div>

| | |

save yourself from regex-whackamole<g-emoji class=“g-emoji” alias=“crossed_fingers” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f91e.png”>🤞</g-emoji>:

nlp(entireNovel).sentences().if('the #Adjective of times').out()
// "it was the blurst of times??"

move things around:

nlp('she sells seashells by the seashore.').sentences().toFutureTense().out()
// 'she will sell seashells...'

respond to text input:

if( doc.has('^simon says (shoot|fire) #Determiner lazer') ){
  fireLazer()
} else {
  dontFire()
}

<div align=“center”>compromise is not the cleverest. but it is small, quick, and good-enough for a bunch of stuff.</div>


<div align=“center”>

| <script src>

<div>        one javascript file        </div>

| <g-emoji class=“g-emoji” alias=“pray” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f64f.png”>🙏</g-emoji>

<div>    <kbd>npm install compromise</kbd>    </div>

|

<div>86%

<div>    on the Penn treebank    </div>

</div>

| IE9+

<div>      caniuse, youbetcha      </div>

|

</div>

<g-emoji class=“g-emoji” alias=“zap” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/26a1.png”>⚡️</g-emoji> on the Client-side

<script src="https://unpkg.com/compromise@latest/builds/compromise.min.js"></script>
<script>
  var doc = nlp('dinosaur')

  var str = doc.nouns().toPlural().out('text')
  console.log(str)
  // 'dinosaurs'
</script>

<g-emoji class=“g-emoji” alias=“volcano” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f30b.png”>🌋</g-emoji> Server-side!

var nlp = require('compromise')

var doc = nlp('London is calling')
doc.sentences().toNegative()
// 'London is not calling'

<div align=“center”>Get the hang of things:</div>

|

<div align=“center”>          Tutorial #1          </div>

<div align=“center”><sub>Input → output</sub></div>

|

<div align=“center”>          Tutorial #2          </div>

<div align=“center”><sub>Match & transform</sub></div>

|

<div align=“center”>          Tutorial #3          </div>

<div align=“center”><sub>Making a bot</sub></div>

|

<div align=“center”>Detailed docs:</div>

|

<div align=“center”>          API          </div>

|

<div align=“center”>          Full Tagset          </div>

|

<div align=“center”>          Plugins          </div>

|

<div align=“center”>          Outputs          </div>

|

<div align=“center”>          Match Syntax          </div>

|

Examples:

|

<div align=“center”>          Part-of-Speech tagging          </div>

<div align=“center”><sub>nouns! verbs! adjectives!</sub></div>

|

<div align=“center”>                Named-entities                </div>

<div align=“center”><sub>people, places, organizations</sub></div>

|

<div align=“center”>                Number parsing                </div>

<div align=“center”><sub>seven hundred and fifty == 750</sub></div>

| |

<div align=“center”>        Grammar-match        </div>

<div align=“center”><sub>like a regex for a sentence</sub></div>

|

<div align=“center”>          Verb conjugation          </div>

<div align=“center”><sub>all your base are belong</sub></div>

|

<div align=“center”>          Normalization          </div>

<div align=“center”><sub>case, whitespace, contractions…</sub></div>

|

doc = nlp('a bottle of beer on the wall.')
doc.nouns(0).toPlural()
doc.out('text')
//'The bottles of beer on the wall.'
doc = nlp('ninety five thousand and fifty two')
doc.values().toNumber().out()
// '95052'

doc = nlp('the 23rd of December')
doc.values().add(2).toText()
doc.out('text')
// 'the twenty fifth of December'
doc = nlp("the guest-singer's björk   at seven thirty.").normalize().out('text')
// 'The guest singer is Bjork at 7:30.'
  • Tense: - switch to/from conjugations of any verb
let doc = nlp('she sells seashells by the seashore.')
doc.sentences().toFutureTense().out('text')
//'she will sell seashells...'

doc.verbs().conjugate()
// [{ PastTense: 'sold',
//    Infinitive: 'sell',
//    Gerund: 'selling', ...
// }]
doc = nlp("we're not gonna take it, no we ain't gonna take it.")
doc.has('going') // true
doc.match('are not').length // == 2
doc.contractions().expand().out()
//'we are not going to take it, no we are not going to take it'
doc = nlp('the opera about richard nixon visiting china')
doc.topics().data()
// [
//   { text: 'richard nixon' },
//   { text: 'china' }
// ]
var lexicon={
  'boston': 'MusicalGroup'
}
doc = nlp('i heard Boston\'s set in Chicago', lexicon)

//alternatively, fix it 'in-post':
doc.match('heard #Possessive set').terms(1).tag('MusicalGroup')
doc = nlp('We like Roy! We like Roy!').sentences().out('array')
// ['We like Roy!', 'We like Roy!']

doc = nlp('Tony Hawk').out('html')
/*
<span>
  <span class="nl-Person nl-FirstName">Tony</span>
  <span>&nbsp;</span>
  <span class="nl-Person nl-LastName">Hawk</span>
</span>
*/
  • Plugins: - allow adding vocabulary, fixing errors, and setting context quickly:
var plugin = {
  tags:{
    Character:{
      isA: 'Noun'
    }
  },
  words:{
    itchy: 'Character',
    scratchy: 'Character'
  }
}
nlp.plugin(plugin)
nlp(`Couldn't Itchy share his pie with Scratchy?`).debug()
/*
   couldn't   - #Modal, #Verb
   itchy      - #Character, #Noun
   share      - #Infinitive, #Verb
   ...
*/

of course, there’s a lot more stuff.

Join in - we’re fun, using semver, and moving fast:

| [

<div>        Twitter        </div>](https://twitter.com/nlp_compromise) | [

<div>      Slack group      </div>](http://slack.compromise.cool/) | [

<div>      Mailing-list      </div>](http://nlpcompromise.us12.list-manage2.com/subscribe?u=d5bd9bcc36c4bef0fd5f6e75f&id=8738c1f5ef) | [

<div>        Projects        </div>](https://github.com/nlp-compromise/nlp_compromise/wiki/Projects) | [

<div>      Pull-requests      </div>](https://github.com/spencermountain/compromise/wiki/Contributing) |

<div align=“left”> </div>

<details><summary><g-emoji class=“g-emoji” alias=“open_umbrella” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/2602.png”>☂️</g-emoji> Isn’t javascript too…</summary>

here

here></details>

<details><summary><g-emoji class=“g-emoji” alias=“dancer” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f483.png”>💃</g-emoji> Can it run on my arduino-watch?</summary>

quickStart</details>

<details><summary><g-emoji class=“g-emoji” alias=“earth_americas” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f30e.png”>🌎</g-emoji> Other Languages?</summary>

German

French</details>

<details><summary><g-emoji class=“g-emoji” alias=“sparkles” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/2728.png”>✨</g-emoji> Partial builds?</summary>

this gif</details>


Also:

For the former promise-library, see jnewman/compromise (Thanks Joshua!)

<div align=“right”>(and don’t forget <g-emoji class=“g-emoji” alias=“bowing_man” fallback-src=“https://github.githubassets.com/images/icons/emoji/unicode/1f647.png”>🙇</g-emoji> NLTK, GATE, Stanford, and Illinois libs )</div>

你可能感兴趣的文章:

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-65030.html

文章标题:compromise

回到顶部