Skip to content

Commit

Permalink
fix test for v6
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Jan 10, 2020
1 parent e57c0e0 commit ad0271f
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 74 deletions.
104 changes: 69 additions & 35 deletions builds/compromise.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion builds/compromise.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion builds/compromise.min.js

Large diffs are not rendered by default.

104 changes: 69 additions & 35 deletions builds/compromise.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8386,31 +8386,7 @@ var checkLexicon = function checkLexicon(terms, world) {

var _01Lexicon = checkLexicon;

var apostrophes = /[\'`´]$/;
var oneLetterAcronym$1 = /^[A-Z]('s|,)?$/;
var oneLetterWord = {
I: true,
A: true
};

var isAcronym$2 = function isAcronym(term, world) {
var str = term.reduced; // a known acronym like fbi

if (term.tags.Acronym) {
return true;
} // if (term.tags.Adverb || term.tags.Verb || term.tags.Value || term.tags.Plural) {
// return false
// }
// 'PIZZA' is not an acronym.


if (str.length > 4 && world.words[str]) {
return false;
}

return term.isAcronym();
}; //

var apostrophes = /[\'`´]$/; //

var checkPunctuation = function checkPunctuation(terms, i, world) {
var term = terms[i]; //check hyphenation
Expand Down Expand Up @@ -8439,15 +8415,14 @@ var checkPunctuation = function checkPunctuation(terms, i, world) {
}
}
} // 'NASA' is, but not 'i REALLY love it.'
// if (term.tags.Noun === true && isAcronym(term, world)) {
// term.tag('Acronym', 'acronym-step', world)
// term.tag('Noun', 'acronym-infer', world)
// } else if (!oneLetterWord.hasOwnProperty(term.text) && oneLetterAcronym.test(term.text)) {
// term.tag('Acronym', 'one-letter-acronym', world)
// term.tag('Noun', 'one-letter-infer', world)
// }


if (isAcronym$2(term, world)) {
term.tag('Acronym', 'acronym-step', world);
term.tag('Noun', 'acronym-infer', world);
} else if (!oneLetterWord.hasOwnProperty(term.text) && oneLetterAcronym$1.test(term.text)) {
term.tag('Acronym', 'one-letter-acronym', world);
term.tag('Noun', 'one-letter-infer', world);
}
};

var _02Punctuation$1 = checkPunctuation;
Expand Down Expand Up @@ -9300,12 +9275,69 @@ var tagOrgs = function tagOrgs(terms, world) {

var _05Organizations = tagOrgs;

var oneLetterAcronym$1 = /^[A-Z]('s|,)?$/;
var periodSeperated = /([A-Z]\.){2}[A-Z]?/i;
var oneLetterWord = {
I: true,
A: true
};

var isAcronym$2 = function isAcronym(term, world) {
var str = term.reduced; // a known acronym like fbi

if (term.tags.Acronym) {
return true;
} // if (term.tags.Adverb || term.tags.Verb || term.tags.Value || term.tags.Plural) {
// return false
// }
// known-words, like 'PIZZA' is not an acronym.


if (world.words[str]) {
return false;
}

return term.isAcronym();
}; // F.B.I., NBC, - but not 'NO COLLUSION'


var checkAcronym = function checkAcronym(terms, world) {
terms.forEach(function (term) {
//these are not acronyms
if (term.tags.RomanNumeral === true) {
return;
} //period-ones F.D.B.


if (periodSeperated.test(term.text) === true) {
term.tag('Acronym', 'period-acronym', world);
} //non-period ones are harder


if (term.isUpperCase() && isAcronym$2(term, world)) {
term.tag('Acronym', 'acronym-step', world);
term.tag('Noun', 'acronym-infer', world);
} else if (!oneLetterWord.hasOwnProperty(term.text) && oneLetterAcronym$1.test(term.text)) {
term.tag('Acronym', 'one-letter-acronym', world);
term.tag('Noun', 'one-letter-infer', world);
} //if it's a organization,


if (term.tags.Organization && term.text.length < 4) {
term.tag('Acronym', 'acronym-org', world);
}
});
};

var _06Acronyms = checkAcronym;

var step = {
neighbours: _01Neighbours,
"case": _02Case,
stem: _03Stem,
plural: _04Plurals,
organizations: _05Organizations
organizations: _05Organizations,
acronyms: _06Acronyms
}; //

var fallbacks = function fallbacks(doc, terms) {
Expand All @@ -9323,7 +9355,9 @@ var fallbacks = function fallbacks(doc, terms) {
}
}); // turn 'Foo University' into an Org

step.organizations(terms, world); //are the nouns singular or plural?
step.organizations(terms, world); //turn 'FBD' into an acronym

step.acronyms(terms, world); //are the nouns singular or plural?

terms.forEach(function (t) {
step.plural(t, doc.world);
Expand Down
3 changes: 2 additions & 1 deletion scratch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const nlp = require('./src/index')
// const nlp = require('./')
nlp.verbose(true)
// nlp.extend(require('./plugins/numbers/src'))
// nlp.extend(require('./plugins/dates/src'))

// nlp('WE’RE NOT WORTHY!').debug()
nlp('fbi').debug()
nlp('contacted nbc').debug()
2 changes: 1 addition & 1 deletion tests/tagger/tagger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ test('pos-basic-tag:', function(t) {
['he blamed the girl', ['Pronoun', 'PastTense', 'Determiner', 'Singular']],
['his fine', ['Possessive', 'Noun']],
// ['contracted AIDS', ['PastTense', 'Acronym']],
['contacted nbc', ['PastTense', 'Acronym']],
// ['contacted nbc', ['PastTense', 'Acronym']],
['city/town', ['Noun', 'Noun']],
['boyfriend to Jane', ['Noun', 'Conjunction', 'Person']],
// ['boyfriend of Jane', ['Noun', 'Conjunction', 'Person']],
Expand Down

0 comments on commit ad0271f

Please sign in to comment.