Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

morpheme-match-all

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

morpheme-match-all - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

CHANGELOG.md

53

lib/Expector.js
// MIT © 2016 azu
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var createTokenMatcher = require("morpheme-match");
var assert = require("assert");
var Expector = function () {
/**
* @param {ExpectedDictionary} dict
*/
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var assert = __importStar(require("assert"));
var morpheme_match_1 = require("morpheme-match");
var Expector = /** @class */ (function () {
function Expector(dict) {
_classCallCheck(this, Expector);
assert(Array.isArray(dict["tokens"]), "\"tokens\" property is required. " + dict);
this.matcher = createTokenMatcher(dict["tokens"]);
this.dict = dict;
assert.ok(Array.isArray(dict["tokens"]), "\"tokens\" property is required. " + dict);
this.matcher = morpheme_match_1.createTokenMatcher(dict.tokens);
}
/**
* match and return results
* @param {Object} actualToken
* @returns {{match: boolean, tokens: Object[]}}
*/
_createClass(Expector, [{
key: "match",
value: function match(actualToken) {
return this.matcher(actualToken);
}
}]);
Expector.prototype.match = function (actualToken) {
return this.matcher(actualToken);
};
return Expector;
}();
exports.default = Expector;
}());
exports.Expector = Expector;
//# sourceMappingURL=Expector.js.map
// MIT © 2016 azu
"use strict";
var _Expector = require("./Expector");
var _Expector2 = _interopRequireDefault(_Expector);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var assert = require("assert");
Object.defineProperty(exports, "__esModule", { value: true });
var Expector_1 = require("./Expector");
/**
* @typedef {Object} ExpectedDictionary
* @property {Object[]} tokens kuromoji's token list
* @property {string} [message]
* @property {string} [expected]
* @public
* Create Matcher function for match all multiple tokens
*/
/**
* @typedef {Object} MatchResult
* @property {Object[]} tokens match tokens,
* @property {number} index index of first match token
* @property {boolean[]} skipped skipped values for tokens
* @property {ExpectedDictionary[]} dict dictionary defined by you
* @public
*/
/**
* @param {ExpectedDictionary[]} dictionaries
* @return {morphemeMatchAll}
* @public
*/
function createMatcher(dictionaries) {
var expectors = dictionaries.map(function (dict) {
return new _Expector2.default(dict);
return new Expector_1.Expector(dict);
});

@@ -44,13 +20,6 @@ /**

return function morphemeMatchAll(actualTokens) {
/**
* @type {MatchResult[]}
*/
var matchResults = [];
actualTokens.forEach(function (actualToken) {
expectors.forEach(function (expector) {
var _expector$match = expector.match(actualToken),
match = _expector$match.match,
tokens = _expector$match.tokens,
skipped = _expector$match.skipped;
var _a = expector.match(actualToken), match = _a.match, tokens = _a.tokens, skipped = _a.skipped;
if (!match) {

@@ -75,3 +44,3 @@ return;

}
module.exports = createMatcher;
exports.createMatcher = createMatcher;
//# sourceMappingURL=morpheme-match-all.js.map
{
"directories": {
"test": "test"
"name": "morpheme-match-all",
"version": "2.0.0",
"description": "A wrapper of morpheme-match API. Match all kuromoji's tokens.",
"keywords": [
"japanese",
"kuromoji",
"morphological"
],
"homepage": "https://github.com/azu/morpheme-match-all",
"bugs": {
"url": "https://github.com/azu/morpheme-match-all/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/azu/morpheme-match-all.git"
},
"license": "MIT",
"author": "azu",
"license": "MIT",
"files": [

@@ -12,42 +25,30 @@ "bin/",

],
"name": "morpheme-match-all",
"version": "1.2.0",
"description": "A wrapper of morpheme-match API. Match all kuromoji's tokens.",
"main": "lib/morpheme-match-all.js",
"types": "lib/morpheme-match-all.d.ts",
"directories": {
"test": "test"
},
"scripts": {
"test": "mocha test/",
"build": "NODE_ENV=production babel src --out-dir lib --source-maps",
"watch": "babel src --out-dir lib --watch --source-maps",
"build": "cross-env NODE_ENV=production tsc -p .",
"docs": "documentation build --access public -f md l -o out.md src/morpheme-match-all.js && cat out.md | add-text-to-markdown README.md --section \"Usage\" --write; rm out.md",
"prepublish": "npm run docs && npm run --if-present build"
"prepublish": "npm run --if-present build",
"test": "mocha \"test/**/*.{js,ts}\"",
"watch": "tsc -p . --watch"
},
"keywords": [
"kuromoji",
"morphological",
"japanese"
],
"repository": {
"type": "git",
"url": "https://github.com/azu/morpheme-match-all.git"
"dependencies": {
"morpheme-match": "^2.0.0"
},
"bugs": {
"url": "https://github.com/azu/morpheme-match-all/issues"
},
"homepage": "https://github.com/azu/morpheme-match-all",
"devDependencies": {
"add-text-to-markdown": "^2.0.0",
"babel-cli": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-jsdoc-to-assert": "^4.0.0",
"babel-preset-power-assert": "^1.0.0",
"babel-register": "^6.18.0",
"@types/mocha": "^5.2.7",
"@types/node": "^12.0.7",
"cross-env": "^5.2.0",
"documentation": "^9.1.1",
"documentation-markdown-api-theme": "^1.0.2",
"kuromojin": "^1.3.2",
"mocha": "^5.2.0",
"power-assert": "^1.4.2"
"mocha": "^6.1.4",
"power-assert": "^1.4.2",
"ts-node": "^8.2.0",
"ts-node-test-register": "^8.0.1",
"typescript": "^3.5.1"
},
"dependencies": {
"morpheme-match": "^1.2.1"
}
"gitHead": "3c3aa522a214e319eac7bfd7817dbd23b7a56cb0"
}

@@ -83,3 +83,3 @@ # morpheme-match-all

const kuromojin = require("kuromojin");
const createMatcher = require("morpheme-match-all");
const {createMatcher} = require("morpheme-match-all");
const dictionaries = require("./fixtures/dictionary");

@@ -86,0 +86,0 @@ const matchAll = createMatcher(dictionaries);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc