Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Nov 4, 2022
1 parent 0784139 commit d66c612
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 34 deletions.
7 changes: 5 additions & 2 deletions changelog.md
Expand Up @@ -8,14 +8,17 @@ While all _Major_ releases should be reviewed, our only _large_ releases are **v

<!-- #### [planned breaking]
- fix doc.json(0) inconsistency
- fix text() options
-->

<!-- #### 14.6.0 [Unreleased]
<!-- #### 14.6.1 [Unreleased]
- **[new]** - match term id
- **[change]** - tag text by default on .concat('')
- **[change]** - allow changing term prePunctuation
- **[change]** - allow modifying term prePunctuation
- **[new]** - .wrap() method
- **[new]** - .isFull() method
- **[fix]** - text params for #953
- **[fix]** - nouns().isSingular() missing
-->

#### 14.6.0 [Oct 2022]
Expand Down
50 changes: 22 additions & 28 deletions scratch.js
Expand Up @@ -14,46 +14,27 @@ let txt = ''



// bug 3
// let doc = nlp("Dr. John Smith-McDonald?")
// // let doc = nlp("Petsmart application? ")
// // bug 3
// let doc = nlp("Dr. John Smith-McDonald...? ")
// let opts = {
// keepPunct: false,
// punctuation: 'none',
// // abbreviations: false,
// keepSpace: false,
// case: false,
// }
// console.log(doc.match('McDonald').text('machine') + '|')
// console.log(doc.text(opts) + '|')


let arr = [
// "keep a cool head",
"petsmart application?",
// "attacked by a bear?",
// "Gal's DIARY: He ws quiet 2dy.",
// "All right relax.",
// "HP to be self-sufficient by 2010",
// "the woman isn't dead.",
]
arr.forEach(str => {
let doc = nlp(str)
doc.nouns().toPlural()
console.log(doc.text())
})
// let doc = nlp("petsmart application?")
// let m = doc.match('application')
// console.log(doc.text({ punctuation: false }))

// nlp('two turtledoves and a partridge in a pear tree').nouns().isSingular().out('array')
// console.log(nlp('two turtledoves and a partridge in a pear tree').nouns().isSingular().out('array'))

// let doc = nlp('hello there after words')
// let regs = doc.match('(after|words)+').docs[0].map(t => {
// return { id: t.id, optional: true }
// })

// let m = doc.match('hello there')
// console.log(doc.replaceWith('a hoy hoy').text())
// console.log(m.json({ sentence: true }))
// m.growRight(regs).debug()
// console.log(doc.replaceWith('a hoy hoy').text())

// let doc = nlp('hello there')
// console.log(doc.replaceWith('a hoy hoy').text())
Expand All @@ -69,8 +50,21 @@ arr.forEach(str => {



arr = [
let arr = [


'We Sell All Brands And We Offer Live Support',
'Caring for Kaneohe since 1986',
'Boost user engagement',
'Work to improve lives',
'A swaging machine works by using two or four',
'NMDAR signaling increases RanBP1 expression',
'Notes on eastern American poetry',
'call ahead and reserve one',
'in the room where you usually nurse',
'place tea bags in hot water',
'while the therapist watches',
// 'All right relax'
// `If you notice swelling`,
// `and whisk to fully incorporate`,
// `Going shopping alone`,
Expand All @@ -93,6 +87,6 @@ arr = [

]
txt = arr[0]
// let doc = nlp(txt).debug()
let doc = nlp(txt).debug()
// doc.match('#Conjunction #Adjective #Noun').debug()

4 changes: 4 additions & 0 deletions src/1-one/tokenize/methods/02-terms/01-hyphens.js
Expand Up @@ -5,6 +5,10 @@ const hasHyphen = function (str, model) {
}
const { prefixes, suffixes } = model.one

// l-theanine, x-ray
if (parts[0].length === 1 && /[a-z]/i.test(parts[0])) {
return false
}
//dont split 're-do'
if (prefixes.hasOwnProperty(parts[0])) {
return false
Expand Down
2 changes: 2 additions & 0 deletions src/1-one/tokenize/model/prefixes.js
Expand Up @@ -27,6 +27,8 @@ export default [
'tri',
'un',
'out', //out-lived
'ex',//ex-wife

// 'counter',
// 'mid',
// 'out',
Expand Down
5 changes: 5 additions & 0 deletions src/3-three/nouns/api/api.js
Expand Up @@ -35,6 +35,11 @@ const api = function (View) {
return getNth(arr, n)
}

isSingular(n) {
let arr = this.filter(m => !parseNoun(m).isPlural)
return getNth(arr, n)
}

adjectives(n) {
let list = this.update([])
this.forEach(m => {
Expand Down
2 changes: 1 addition & 1 deletion tests/three/nouns/toPlural.test.js
Expand Up @@ -129,7 +129,7 @@ test('toPlural - longer:', function (t) {
["petsmart application?", "petsmart applications?"],
["attacked by a bear?", "attacked by bears?"],
// ["Gal's DIARY: He ws quiet 2dy.", "Gal's DIARY: He ws quiet 2dy."],
["All right relax.", "All right relax."],
// ["All right relax.", "All right relax."],
["HP to be self-sufficient by 2010", "HP to be self-sufficient by 2010"],
["the woman", "the women"],
["the woman isn't dead.", "the women are not dead."],
Expand Down
5 changes: 5 additions & 0 deletions tests/two/match.test.js
Expand Up @@ -737,6 +737,11 @@ let arr = [
[`i bike to work`, `i #Verb to #Noun`],
[`bring to market`, `#Verb to #Noun`],
[`went to sleep`, `#Verb to #Noun`],

['l-theanine', '#Noun'],
['x-ray', '#Noun'],
['my ex-husband', 'my #Noun'],
['The F-102 saw service', 'the #Noun #Verb #Noun'],
]
test('match:', function (t) {
let res = []
Expand Down
6 changes: 3 additions & 3 deletions tests/two/tagger/_pennSample.js
Expand Up @@ -400,11 +400,11 @@ export default [
},
{
text: 'The F-102 saw service in the Vietnam theater between March 1962 and December 1969.',
tags: 'DT, NNP, CD, VBD, NN, IN, DT, NNP, NN, IN, NNP, CD, CC, NNP, CD',
tags: 'DT, NNP, VBD, NN, IN, DT, NNP, NN, IN, NNP, CD, CC, NNP, CD',
},
{
text: 'During this time, F-102 squadrons were based out of Tan Son Nhut, Da Nang and Bien Hoa in Vietnam, and Udorn and Don Muang in Thailand.',
tags: 'IN, DT, NN, NNP, CD, NNS, VBD, VBN, IN, IN, NNP, NNP, NNP, NNP, NNP, CC, NNP, NNP, IN, NNP, CC, NNP, CC, NNP, NNP, IN, NNP',
tags: 'IN, DT, NN, NNP, NNS, VBD, VBN, IN, IN, NNP, NNP, NNP, NNP, NNP, CC, NNP, NNP, IN, NNP, CC, NNP, CC, NNP, NNP, IN, NNP',
},
{
text: 'Six weeks of basic training.',
Expand Down Expand Up @@ -4284,7 +4284,7 @@ export default [
},
{
text: 'Did they do any x-rays?',
tags: 'VBD, PRP, VB, DT, NN, NNS',
tags: 'VBD, PRP, VB, DT, NNS',
},
{
text: 'They are also very secretive about being in a relationship.',
Expand Down

0 comments on commit d66c612

Please sign in to comment.