forked from muraken720/parse-japanese
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse-japanese.min.js
1 lines (1 loc) · 88.1 KB
/
parse-japanese.min.js
1
!function(b,a){typeof exports==='object'&&typeof module!=='undefined'?module.exports=b():typeof define==='function'&&define.amd?define([],b):(typeof window!=='undefined'?a=window:typeof global!=='undefined'?a=global:typeof self!=='undefined'?a=self:a=this,a.ParseJapanese=b())}(function(){var a;return function a(b,c,e){function f(d,k){if(!c[d]){if(!b[d]){var i=typeof require=='function'&&require;if(!k&&i)return i(d,!0);if(g)return g(d,!0);var j=new Error("Cannot find module '"+d+"'");throw j.code='MODULE_NOT_FOUND',j}var h=c[d]={exports:{}};b[d][0].call(h.exports,function(c){var a=b[d][1][c];return f(a?a:c)},h,h.exports,a,b,c,e)}return c[d].exports}var g=typeof require=='function'&&require;for(var d=0;d<e.length;d++)f(e[d]);return f}({1:[function(a,b,c){'use strict';b.exports=a('./lib/parse-japanese')},{'./lib/parse-japanese':2}],2:[function(a,b,c){(function(o){'use strict';function q(a){return a.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}function p(c,t,v){function p(){return{line:r,column:o,offset:j}}function x(b){var a=q(b).length;return j+=a,o+=a,p()}function u(a){return{start:p(),end:x(a)}}function d(b){var a={type:b+'Node',children:[]};return c.position&&(a.position={}),a}function b(d,b){var a={type:d+'Node',value:b.surface_form};return c.position&&(a.position=u(b.surface_form)),c.pos&&(a.data=b),a}function a(b,a){a.children.push(b),c.position&&(a.position={start:a.children[0].position.start,end:b.position.end})}function w(t,u,w){r=u+1,o=1;var p=d('Paragraph'),l=d('Sentence'),h=d('Word');if(t===''){u!==w.length-1&&(a(b('WhiteSpace',{surface_form:'\n',pos:'記号',pos_detail_1:'空白'}),p),a(p,g));return}var v=new i(t).toWideJapneseSymbol().toString(),s=c.tokenizer.tokenize(v);for(var q=0;q<s.length;q++){var j=s[q];q===0&&a(l,p),j.pos_detail_1===f?e?a(b('WhiteSpace',j),h):(h.children.length&&(a(h,l),h=d('Word')),a(b('WhiteSpace',j),l)):j.pos_detail_1===m?(e++,a(b('Punctuation',j),h)):j.pos_detail_1===n?(e--,a(b('Punctuation',j),h)):j.pos_detail_1===k?(a(b('Punctuation',j),h),e||(a(h,l),h=d('Word'),q!==s.length-1&&(l=d('Sentence'),a(l,p)))):a(b('Text',j),h),q===s.length-1&&(h.children.length&&a(h,l),a(b('WhiteSpace',{surface_form:'\n',pos:'記号',pos_detail_1:'空白'}),p),a(p,g))}}var e=0,j=0,r,o,s=t.split(l),g=d('Root');h.builder({dicPath:c.dicDir}).build(function(a,b){a?console.log(a):(c.tokenizer=b,s.forEach(w),v(g))})}function d(b,a){var c,e,f;if(!(this instanceof d))return new d(b,a);b&&b instanceof j?this.file=b:a=b,c=a&&a.position,c!==null&&c!==undefined&&(this.position=Boolean(c)),e=a&&a.pos,e!==null&&e!==undefined&&(this.pos=Boolean(e)),f=a&&a.dicDir,f!==null&&f!==undefined&&(this.dicDir=f)}var h=a('kuromoji'),i=a('jaco').Jaco,j=a('vfile'),e=a('path'),l=/\r?\n/g,m='括弧開',n='括弧閉',k='句点',f='空白',c=d.prototype;c.position=!0,c.pos=!1;const g=function(){o.kuromoji={};const b=e.dirname(a.resolve('kuromoji'));return e.join(b,'..','dict')};c.dicDir=g(),c.parse=function(a,b){p(this,this.file?this.file.toString():a,b)},b.exports=d}.call(this,typeof global!=='undefined'?global:typeof self!=='undefined'?self:typeof window!=='undefined'?window:{}))},{jaco:5,kuromoji:19,path:29,vfile:33}],3:[function(b,a,c){!function(i,h,b,c,j,k,l,o,r,m,f,q,g,p,n){"use strict";function e(a){this.bc=m(a),this.keys=[]}function d(a){this.bc=a,this.bc.shrink()}i='