repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/DictionaryFactory.java | DictionaryFactory.createDefaultDictionary | public static ADictionary createDefaultDictionary(JcsegTaskConfig config, boolean loadDic)
{
return createDefaultDictionary(config, config.isAutoload(), loadDic);
} | java | public static ADictionary createDefaultDictionary(JcsegTaskConfig config, boolean loadDic)
{
return createDefaultDictionary(config, config.isAutoload(), loadDic);
} | [
"public",
"static",
"ADictionary",
"createDefaultDictionary",
"(",
"JcsegTaskConfig",
"config",
",",
"boolean",
"loadDic",
")",
"{",
"return",
"createDefaultDictionary",
"(",
"config",
",",
"config",
".",
"isAutoload",
"(",
")",
",",
"loadDic",
")",
";",
"}"
] | create the ADictionary according to the JcsegTaskConfig
@param config
@param loadDic
@return ADictionary | [
"create",
"the",
"ADictionary",
"according",
"to",
"the",
"JcsegTaskConfig"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/DictionaryFactory.java#L123-L126 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/DictionaryFactory.java | DictionaryFactory.createSingletonDictionary | public static ADictionary createSingletonDictionary(JcsegTaskConfig config, boolean loadDic)
{
synchronized (LOCK) {
if ( singletonDic == null ) {
singletonDic = createDefaultDictionary(config, loadDic);
}
}
return singletonDic;
} | java | public static ADictionary createSingletonDictionary(JcsegTaskConfig config, boolean loadDic)
{
synchronized (LOCK) {
if ( singletonDic == null ) {
singletonDic = createDefaultDictionary(config, loadDic);
}
}
return singletonDic;
} | [
"public",
"static",
"ADictionary",
"createSingletonDictionary",
"(",
"JcsegTaskConfig",
"config",
",",
"boolean",
"loadDic",
")",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"if",
"(",
"singletonDic",
"==",
"null",
")",
"{",
"singletonDic",
"=",
"createDefaultDict... | create a singleton ADictionary object according to the JcsegTaskConfig
@param config
@param loadDic
@return ADictionary | [
"create",
"a",
"singleton",
"ADictionary",
"object",
"according",
"to",
"the",
"JcsegTaskConfig"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/DictionaryFactory.java#L147-L156 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/STConverter.java | STConverter.TraToSimplified | public static String TraToSimplified( String str )
{
StringBuffer sb = new StringBuffer();
int idx;
for ( int j = 0; j < str.length(); j++ ) {
if ( (idx = TRASTR.indexOf(str.charAt(j))) != -1 ) {
sb.append(SIMSTR.charAt(idx));
} else {
sb.append(str.charAt(j));
}
}
return sb.toString();
} | java | public static String TraToSimplified( String str )
{
StringBuffer sb = new StringBuffer();
int idx;
for ( int j = 0; j < str.length(); j++ ) {
if ( (idx = TRASTR.indexOf(str.charAt(j))) != -1 ) {
sb.append(SIMSTR.charAt(idx));
} else {
sb.append(str.charAt(j));
}
}
return sb.toString();
} | [
"public",
"static",
"String",
"TraToSimplified",
"(",
"String",
"str",
")",
"{",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"int",
"idx",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"str",
".",
"length",
"(",
")",
";... | convert the traditional words to simplified words
of the specified string.
@param str
@return String | [
"convert",
"the",
"traditional",
"words",
"to",
"simplified",
"words",
"of",
"the",
"specified",
"string",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/STConverter.java#L62-L74 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/SegmentFactory.java | SegmentFactory.createSegment | public static ISegment createSegment( Class<? extends ISegment> _class,
Class<?> paramtypes[], Object args[] )
{
ISegment seg = null;
try {
Constructor<?> cons = _class.getConstructor(paramtypes);
seg = (ISegment) cons.newInstance(args);
} catch (Exception e) {
e.printStackTrace();
System.out.println("can't load the ISegment implements class " +
"with path ["+_class.getName()+"] ");
}
return seg;
} | java | public static ISegment createSegment( Class<? extends ISegment> _class,
Class<?> paramtypes[], Object args[] )
{
ISegment seg = null;
try {
Constructor<?> cons = _class.getConstructor(paramtypes);
seg = (ISegment) cons.newInstance(args);
} catch (Exception e) {
e.printStackTrace();
System.out.println("can't load the ISegment implements class " +
"with path ["+_class.getName()+"] ");
}
return seg;
} | [
"public",
"static",
"ISegment",
"createSegment",
"(",
"Class",
"<",
"?",
"extends",
"ISegment",
">",
"_class",
",",
"Class",
"<",
"?",
">",
"paramtypes",
"[",
"]",
",",
"Object",
"args",
"[",
"]",
")",
"{",
"ISegment",
"seg",
"=",
"null",
";",
"try",
... | load the ISegment class with the given path
@param _class
@return ISegment | [
"load",
"the",
"ISegment",
"class",
"with",
"the",
"given",
"path"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/SegmentFactory.java#L32-L46 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/SegmentFactory.java | SegmentFactory.createJcseg | public static ISegment createJcseg( int mode, Object...args ) throws JcsegException
{
Class<? extends ISegment> _clsname;
switch ( mode ) {
case JcsegTaskConfig.SIMPLE_MODE:
_clsname = SimpleSeg.class;
break;
case JcsegTaskConfig.COMPLEX_MODE:
_clsname = ComplexSeg.class;
break;
case JcsegTaskConfig.DETECT_MODE:
_clsname = DetectSeg.class;
break;
case JcsegTaskConfig.SEARCH_MODE:
_clsname = SearchSeg.class;
break;
case JcsegTaskConfig.DELIMITER_MODE:
_clsname = DelimiterSeg.class;
break;
case JcsegTaskConfig.NLP_MODE:
_clsname = NLPSeg.class;
break;
default:
throw new JcsegException("No Such Algorithm Excpetion");
}
Class<?>[] _paramtype = null;
if ( args.length == 2 ) {
_paramtype = new Class[]{JcsegTaskConfig.class, ADictionary.class};
} else if ( args.length == 3 ) {
_paramtype = new Class[]{Reader.class, JcsegTaskConfig.class, ADictionary.class};
} else {
throw new JcsegException("length of the arguments should be 2 or 3");
}
return createSegment(_clsname, _paramtype, args);
} | java | public static ISegment createJcseg( int mode, Object...args ) throws JcsegException
{
Class<? extends ISegment> _clsname;
switch ( mode ) {
case JcsegTaskConfig.SIMPLE_MODE:
_clsname = SimpleSeg.class;
break;
case JcsegTaskConfig.COMPLEX_MODE:
_clsname = ComplexSeg.class;
break;
case JcsegTaskConfig.DETECT_MODE:
_clsname = DetectSeg.class;
break;
case JcsegTaskConfig.SEARCH_MODE:
_clsname = SearchSeg.class;
break;
case JcsegTaskConfig.DELIMITER_MODE:
_clsname = DelimiterSeg.class;
break;
case JcsegTaskConfig.NLP_MODE:
_clsname = NLPSeg.class;
break;
default:
throw new JcsegException("No Such Algorithm Excpetion");
}
Class<?>[] _paramtype = null;
if ( args.length == 2 ) {
_paramtype = new Class[]{JcsegTaskConfig.class, ADictionary.class};
} else if ( args.length == 3 ) {
_paramtype = new Class[]{Reader.class, JcsegTaskConfig.class, ADictionary.class};
} else {
throw new JcsegException("length of the arguments should be 2 or 3");
}
return createSegment(_clsname, _paramtype, args);
} | [
"public",
"static",
"ISegment",
"createJcseg",
"(",
"int",
"mode",
",",
"Object",
"...",
"args",
")",
"throws",
"JcsegException",
"{",
"Class",
"<",
"?",
"extends",
"ISegment",
">",
"_clsname",
";",
"switch",
"(",
"mode",
")",
"{",
"case",
"JcsegTaskConfig",... | create the specified mode Jcseg instance
@param mode
@return ISegment
@throws JcsegException | [
"create",
"the",
"specified",
"mode",
"Jcseg",
"instance"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/SegmentFactory.java#L55-L91 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/JcsegServer.java | JcsegServer.init | private void init()
{
//setup thread pool
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(config.getMaxThreadPoolSize());
threadPool.setIdleTimeout(config.getThreadIdleTimeout());
server = new Server(threadPool);
//setup the http configuration
HttpConfiguration http_config = new HttpConfiguration();
http_config.setOutputBufferSize(config.getOutputBufferSize());
http_config.setRequestHeaderSize(config.getRequestHeaderSize());
http_config.setResponseHeaderSize(config.getResponseHeaderSize());
http_config.setSendServerVersion(false);
http_config.setSendDateHeader(false);
//setup the connector
ServerConnector connector = new ServerConnector(
server,
new HttpConnectionFactory(http_config)
);
connector.setPort(config.getPort());
connector.setHost(config.getHost());
connector.setIdleTimeout(config.getHttpIdleTimeout());
server.addConnector(connector);
} | java | private void init()
{
//setup thread pool
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(config.getMaxThreadPoolSize());
threadPool.setIdleTimeout(config.getThreadIdleTimeout());
server = new Server(threadPool);
//setup the http configuration
HttpConfiguration http_config = new HttpConfiguration();
http_config.setOutputBufferSize(config.getOutputBufferSize());
http_config.setRequestHeaderSize(config.getRequestHeaderSize());
http_config.setResponseHeaderSize(config.getResponseHeaderSize());
http_config.setSendServerVersion(false);
http_config.setSendDateHeader(false);
//setup the connector
ServerConnector connector = new ServerConnector(
server,
new HttpConnectionFactory(http_config)
);
connector.setPort(config.getPort());
connector.setHost(config.getHost());
connector.setIdleTimeout(config.getHttpIdleTimeout());
server.addConnector(connector);
} | [
"private",
"void",
"init",
"(",
")",
"{",
"//setup thread pool",
"QueuedThreadPool",
"threadPool",
"=",
"new",
"QueuedThreadPool",
"(",
")",
";",
"threadPool",
".",
"setMaxThreads",
"(",
"config",
".",
"getMaxThreadPoolSize",
"(",
")",
")",
";",
"threadPool",
".... | initialize the server and register the basic context handler | [
"initialize",
"the",
"server",
"and",
"register",
"the",
"basic",
"context",
"handler"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/JcsegServer.java#L68-L94 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/JcsegServer.java | JcsegServer.registerHandler | public JcsegServer registerHandler()
{
String basePath = this.getClass().getPackage().getName()+".controller";
AbstractRouter router = new DynamicRestRouter(basePath, MainController.class);
router.addMapping("/extractor/keywords", KeywordsController.class);
router.addMapping("/extractor/keyphrase", KeyphraseController.class);
router.addMapping("/extractor/sentence", SentenceController.class);
router.addMapping("/extractor/summary", SummaryController.class);
router.addMapping("/tokenizer/default", TokenizerController.class);
/*
* the rest of path and dynamic rest checking will handler it
*/
//router.addMapping("/tokenizer/default", TokenizerController.class);
/*
* prepare standard handler
*/
StandardHandler stdHandler = new StandardHandler(config, resourcePool, router);
/*
* prepare the resource handler
*/
JcsegResourceHandler resourceHandler = new JcsegResourceHandler();
/*
* i am going to rewrite the path to handler mapping mechanism
* check the Router handler for more info
*/
GzipHandler gzipHandler = new GzipHandler();
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{stdHandler, resourceHandler});
gzipHandler.setHandler(handlers);
server.setHandler(gzipHandler);
return this;
} | java | public JcsegServer registerHandler()
{
String basePath = this.getClass().getPackage().getName()+".controller";
AbstractRouter router = new DynamicRestRouter(basePath, MainController.class);
router.addMapping("/extractor/keywords", KeywordsController.class);
router.addMapping("/extractor/keyphrase", KeyphraseController.class);
router.addMapping("/extractor/sentence", SentenceController.class);
router.addMapping("/extractor/summary", SummaryController.class);
router.addMapping("/tokenizer/default", TokenizerController.class);
/*
* the rest of path and dynamic rest checking will handler it
*/
//router.addMapping("/tokenizer/default", TokenizerController.class);
/*
* prepare standard handler
*/
StandardHandler stdHandler = new StandardHandler(config, resourcePool, router);
/*
* prepare the resource handler
*/
JcsegResourceHandler resourceHandler = new JcsegResourceHandler();
/*
* i am going to rewrite the path to handler mapping mechanism
* check the Router handler for more info
*/
GzipHandler gzipHandler = new GzipHandler();
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{stdHandler, resourceHandler});
gzipHandler.setHandler(handlers);
server.setHandler(gzipHandler);
return this;
} | [
"public",
"JcsegServer",
"registerHandler",
"(",
")",
"{",
"String",
"basePath",
"=",
"this",
".",
"getClass",
"(",
")",
".",
"getPackage",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".controller\"",
";",
"AbstractRouter",
"router",
"=",
"new",
"DynamicRestR... | register handler service | [
"register",
"handler",
"service"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/JcsegServer.java#L99-L135 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/JcsegServer.java | JcsegServer.resetJcsegTaskConfig | private void resetJcsegTaskConfig(JcsegTaskConfig config, JSONObject json)
{
if ( json.has("jcseg_maxlen") ) {
config.setMaxLength(json.getInt("jcseg_maxlen"));
}
if ( json.has("jcseg_icnname") ) {
config.setICnName(json.getBoolean("jcseg_icnname"));
}
if ( json.has("jcseg_pptmaxlen") ) {
config.setPPT_MAX_LENGTH(json.getInt("jcseg_pptmaxlen"));
}
if ( json.has("jcseg_cnmaxlnadron") ) {
config.setMaxCnLnadron(json.getInt("jcseg_cnmaxlnadron"));
}
if ( json.has("jcseg_clearstopword") ) {
config.setClearStopwords(json.getBoolean("jcseg_clearstopword"));
}
if ( json.has("jcseg_cnnumtoarabic") ) {
config.setCnNumToArabic(json.getBoolean("jcseg_cnnumtoarabic"));
}
if ( json.has("jcseg_cnfratoarabic") ) {
config.setCnFactionToArabic(json.getBoolean("jcseg_cnfratoarabic"));
}
if ( json.has("jcseg_keepunregword") ) {
config.setKeepUnregWords(json.getBoolean("jcseg_keepunregword"));
}
if ( json.has("jcseg_ensencondseg") ) {
config.setEnSecondSeg(json.getBoolean("jcseg_ensencondseg"));
}
if ( json.has("jcseg_stokenminlen") ) {
config.setSTokenMinLen(json.getInt("jcseg_stokenminlen"));
}
if ( json.has("jcseg_nsthreshold") ) {
config.setNameSingleThreshold(json.getInt("jcseg_nsthreshold"));
}
if ( json.has("jcseg_keeppunctuations") ) {
config.setKeepPunctuations(json.getString("jcseg_keeppunctuations"));
}
} | java | private void resetJcsegTaskConfig(JcsegTaskConfig config, JSONObject json)
{
if ( json.has("jcseg_maxlen") ) {
config.setMaxLength(json.getInt("jcseg_maxlen"));
}
if ( json.has("jcseg_icnname") ) {
config.setICnName(json.getBoolean("jcseg_icnname"));
}
if ( json.has("jcseg_pptmaxlen") ) {
config.setPPT_MAX_LENGTH(json.getInt("jcseg_pptmaxlen"));
}
if ( json.has("jcseg_cnmaxlnadron") ) {
config.setMaxCnLnadron(json.getInt("jcseg_cnmaxlnadron"));
}
if ( json.has("jcseg_clearstopword") ) {
config.setClearStopwords(json.getBoolean("jcseg_clearstopword"));
}
if ( json.has("jcseg_cnnumtoarabic") ) {
config.setCnNumToArabic(json.getBoolean("jcseg_cnnumtoarabic"));
}
if ( json.has("jcseg_cnfratoarabic") ) {
config.setCnFactionToArabic(json.getBoolean("jcseg_cnfratoarabic"));
}
if ( json.has("jcseg_keepunregword") ) {
config.setKeepUnregWords(json.getBoolean("jcseg_keepunregword"));
}
if ( json.has("jcseg_ensencondseg") ) {
config.setEnSecondSeg(json.getBoolean("jcseg_ensencondseg"));
}
if ( json.has("jcseg_stokenminlen") ) {
config.setSTokenMinLen(json.getInt("jcseg_stokenminlen"));
}
if ( json.has("jcseg_nsthreshold") ) {
config.setNameSingleThreshold(json.getInt("jcseg_nsthreshold"));
}
if ( json.has("jcseg_keeppunctuations") ) {
config.setKeepPunctuations(json.getString("jcseg_keeppunctuations"));
}
} | [
"private",
"void",
"resetJcsegTaskConfig",
"(",
"JcsegTaskConfig",
"config",
",",
"JSONObject",
"json",
")",
"{",
"if",
"(",
"json",
".",
"has",
"(",
"\"jcseg_maxlen\"",
")",
")",
"{",
"config",
".",
"setMaxLength",
"(",
"json",
".",
"getInt",
"(",
"\"jcseg_... | reset a JcsegTaskConfig from a JSONObject
@param config
@param json | [
"reset",
"a",
"JcsegTaskConfig",
"from",
"a",
"JSONObject"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/JcsegServer.java#L321-L359 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Keep.java | Keep.compact | private void compact() {
int from = 0;
int to = 0;
while (from < this.capacity) {
Object key = this.list[from];
long usage = age(this.ticks[from]);
if (usage > 0) {
this.ticks[to] = usage;
this.list[to] = key;
this.map.put(key, to);
to += 1;
} else {
this.map.remove(key);
}
from += 1;
}
if (to < this.capacity) {
this.length = to;
} else {
this.map.clear();
this.length = 0;
}
this.power = 0;
} | java | private void compact() {
int from = 0;
int to = 0;
while (from < this.capacity) {
Object key = this.list[from];
long usage = age(this.ticks[from]);
if (usage > 0) {
this.ticks[to] = usage;
this.list[to] = key;
this.map.put(key, to);
to += 1;
} else {
this.map.remove(key);
}
from += 1;
}
if (to < this.capacity) {
this.length = to;
} else {
this.map.clear();
this.length = 0;
}
this.power = 0;
} | [
"private",
"void",
"compact",
"(",
")",
"{",
"int",
"from",
"=",
"0",
";",
"int",
"to",
"=",
"0",
";",
"while",
"(",
"from",
"<",
"this",
".",
"capacity",
")",
"{",
"Object",
"key",
"=",
"this",
".",
"list",
"[",
"from",
"]",
";",
"long",
"usag... | Compact the keep. A keep may contain at most this.capacity elements.
The keep contents can be reduced by deleting all elements with low use
counts, and by reducing the use counts of the survivors. | [
"Compact",
"the",
"keep",
".",
"A",
"keep",
"may",
"contain",
"at",
"most",
"this",
".",
"capacity",
"elements",
".",
"The",
"keep",
"contents",
"can",
"be",
"reduced",
"by",
"deleting",
"all",
"elements",
"with",
"low",
"use",
"counts",
"and",
"by",
"re... | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Keep.java#L90-L113 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Keep.java | Keep.find | public int find(Object key) {
Object o = this.map.get(key);
return o instanceof Integer ? ((Integer) o).intValue() : none;
} | java | public int find(Object key) {
Object o = this.map.get(key);
return o instanceof Integer ? ((Integer) o).intValue() : none;
} | [
"public",
"int",
"find",
"(",
"Object",
"key",
")",
"{",
"Object",
"o",
"=",
"this",
".",
"map",
".",
"get",
"(",
"key",
")",
";",
"return",
"o",
"instanceof",
"Integer",
"?",
"(",
"(",
"Integer",
")",
"o",
")",
".",
"intValue",
"(",
")",
":",
... | Find the integer value associated with this key, or nothing if this key
is not in the keep.
@param key
An object.
@return An integer | [
"Find",
"the",
"integer",
"value",
"associated",
"with",
"this",
"key",
"or",
"nothing",
"if",
"this",
"key",
"is",
"not",
"in",
"the",
"keep",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Keep.java#L123-L126 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Keep.java | Keep.register | public void register(Object value) {
if (JSONzip.probe) {
int integer = find(value);
if (integer >= 0) {
JSONzip.log("\nDuplicate key " + value);
}
}
if (this.length >= this.capacity) {
compact();
}
this.list[this.length] = value;
this.map.put(value, this.length);
this.ticks[this.length] = 1;
if (JSONzip.probe) {
JSONzip.log("<" + this.length + " " + value + "> ");
}
this.length += 1;
} | java | public void register(Object value) {
if (JSONzip.probe) {
int integer = find(value);
if (integer >= 0) {
JSONzip.log("\nDuplicate key " + value);
}
}
if (this.length >= this.capacity) {
compact();
}
this.list[this.length] = value;
this.map.put(value, this.length);
this.ticks[this.length] = 1;
if (JSONzip.probe) {
JSONzip.log("<" + this.length + " " + value + "> ");
}
this.length += 1;
} | [
"public",
"void",
"register",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"JSONzip",
".",
"probe",
")",
"{",
"int",
"integer",
"=",
"find",
"(",
"value",
")",
";",
"if",
"(",
"integer",
">=",
"0",
")",
"{",
"JSONzip",
".",
"log",
"(",
"\"\\nDuplic... | Register a value in the keep. Compact the keep if it is full. The next
time this value is encountered, its integer can be sent instead.
@param value A value. | [
"Register",
"a",
"value",
"in",
"the",
"keep",
".",
"Compact",
"the",
"keep",
"if",
"it",
"is",
"full",
".",
"The",
"next",
"time",
"this",
"value",
"is",
"encountered",
"its",
"integer",
"can",
"be",
"sent",
"instead",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Keep.java#L164-L181 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/MMSegFilter.java | MMSegFilter.getMaximumMatchChunks | public static IChunk[] getMaximumMatchChunks(IChunk[] chunks)
{
int maxLength = chunks[0].getLength();
int j;
//find the maximum word length
for ( j = 1; j < chunks.length; j++ ) {
if ( chunks[j].getLength() > maxLength )
maxLength = chunks[j].getLength();
}
//get the items that the word length equals to
//the max's length.
ArrayList<IChunk> chunkArr = new ArrayList<IChunk>(chunks.length);
for ( j = 0; j < chunks.length; j++ ) {
if ( chunks[j].getLength() == maxLength) {
chunkArr.add(chunks[j]);
}
}
IChunk[] lchunk = new IChunk[chunkArr.size()];
chunkArr.toArray(lchunk);
chunkArr.clear();
return lchunk;
} | java | public static IChunk[] getMaximumMatchChunks(IChunk[] chunks)
{
int maxLength = chunks[0].getLength();
int j;
//find the maximum word length
for ( j = 1; j < chunks.length; j++ ) {
if ( chunks[j].getLength() > maxLength )
maxLength = chunks[j].getLength();
}
//get the items that the word length equals to
//the max's length.
ArrayList<IChunk> chunkArr = new ArrayList<IChunk>(chunks.length);
for ( j = 0; j < chunks.length; j++ ) {
if ( chunks[j].getLength() == maxLength) {
chunkArr.add(chunks[j]);
}
}
IChunk[] lchunk = new IChunk[chunkArr.size()];
chunkArr.toArray(lchunk);
chunkArr.clear();
return lchunk;
} | [
"public",
"static",
"IChunk",
"[",
"]",
"getMaximumMatchChunks",
"(",
"IChunk",
"[",
"]",
"chunks",
")",
"{",
"int",
"maxLength",
"=",
"chunks",
"[",
"0",
"]",
".",
"getLength",
"(",
")",
";",
"int",
"j",
";",
"//find the maximum word length",
"for",
"(",
... | 1. the maximum match rule
this rule will return the chunks that own the largest word length | [
"1",
".",
"the",
"maximum",
"match",
"rule",
"this",
"rule",
"will",
"return",
"the",
"chunks",
"that",
"own",
"the",
"largest",
"word",
"length"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/MMSegFilter.java#L16-L40 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/MMSegFilter.java | MMSegFilter.getLargestAverageWordLengthChunks | public static IChunk[] getLargestAverageWordLengthChunks(IChunk[] chunks)
{
double largetAverage = chunks[0].getAverageWordsLength();
int j;
//find the largest average word length
for ( j = 1; j < chunks.length; j++ ) {
if ( chunks[j].getAverageWordsLength() > largetAverage ) {
largetAverage = chunks[j].getAverageWordsLength();
}
}
//get the items that the average word length equals to
//the max's.
ArrayList<IChunk> chunkArr = new ArrayList<IChunk>(chunks.length);
for ( j = 0; j < chunks.length; j++ ) {
if ( chunks[j].getAverageWordsLength() == largetAverage) {
chunkArr.add(chunks[j]);
}
}
IChunk[] lchunk = new IChunk[chunkArr.size()];
chunkArr.toArray(lchunk);
chunkArr.clear();
return lchunk;
} | java | public static IChunk[] getLargestAverageWordLengthChunks(IChunk[] chunks)
{
double largetAverage = chunks[0].getAverageWordsLength();
int j;
//find the largest average word length
for ( j = 1; j < chunks.length; j++ ) {
if ( chunks[j].getAverageWordsLength() > largetAverage ) {
largetAverage = chunks[j].getAverageWordsLength();
}
}
//get the items that the average word length equals to
//the max's.
ArrayList<IChunk> chunkArr = new ArrayList<IChunk>(chunks.length);
for ( j = 0; j < chunks.length; j++ ) {
if ( chunks[j].getAverageWordsLength() == largetAverage) {
chunkArr.add(chunks[j]);
}
}
IChunk[] lchunk = new IChunk[chunkArr.size()];
chunkArr.toArray(lchunk);
chunkArr.clear();
return lchunk;
} | [
"public",
"static",
"IChunk",
"[",
"]",
"getLargestAverageWordLengthChunks",
"(",
"IChunk",
"[",
"]",
"chunks",
")",
"{",
"double",
"largetAverage",
"=",
"chunks",
"[",
"0",
"]",
".",
"getAverageWordsLength",
"(",
")",
";",
"int",
"j",
";",
"//find the largest... | 2. largest average word length
this rule will return the chunks that own the largest average word length | [
"2",
".",
"largest",
"average",
"word",
"length",
"this",
"rule",
"will",
"return",
"the",
"chunks",
"that",
"own",
"the",
"largest",
"average",
"word",
"length"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/MMSegFilter.java#L47-L73 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/MMSegFilter.java | MMSegFilter.getSmallestVarianceWordLengthChunks | public static IChunk[] getSmallestVarianceWordLengthChunks(IChunk[] chunks)
{
double smallestVariance = chunks[0].getWordsVariance();
int j;
//find the smallest variance word length
for ( j = 1; j < chunks.length; j++ ) {
if ( chunks[j].getWordsVariance() < smallestVariance ) {
smallestVariance = chunks[j].getWordsVariance();
}
}
//get the items that the variance word length equals to
//the max's.
ArrayList<IChunk> chunkArr = new ArrayList<IChunk>(chunks.length);
for ( j = 0; j < chunks.length; j++ ) {
if ( chunks[j].getWordsVariance() == smallestVariance) {
chunkArr.add(chunks[j]);
}
}
IChunk[] lchunk = new IChunk[chunkArr.size()];
chunkArr.toArray(lchunk);
chunkArr.clear();
return lchunk;
} | java | public static IChunk[] getSmallestVarianceWordLengthChunks(IChunk[] chunks)
{
double smallestVariance = chunks[0].getWordsVariance();
int j;
//find the smallest variance word length
for ( j = 1; j < chunks.length; j++ ) {
if ( chunks[j].getWordsVariance() < smallestVariance ) {
smallestVariance = chunks[j].getWordsVariance();
}
}
//get the items that the variance word length equals to
//the max's.
ArrayList<IChunk> chunkArr = new ArrayList<IChunk>(chunks.length);
for ( j = 0; j < chunks.length; j++ ) {
if ( chunks[j].getWordsVariance() == smallestVariance) {
chunkArr.add(chunks[j]);
}
}
IChunk[] lchunk = new IChunk[chunkArr.size()];
chunkArr.toArray(lchunk);
chunkArr.clear();
return lchunk;
} | [
"public",
"static",
"IChunk",
"[",
"]",
"getSmallestVarianceWordLengthChunks",
"(",
"IChunk",
"[",
"]",
"chunks",
")",
"{",
"double",
"smallestVariance",
"=",
"chunks",
"[",
"0",
"]",
".",
"getWordsVariance",
"(",
")",
";",
"int",
"j",
";",
"//find the smalles... | the smallest variance word length
this rule will the chunks that one the smallest variance word length | [
"the",
"smallest",
"variance",
"word",
"length",
"this",
"rule",
"will",
"the",
"chunks",
"that",
"one",
"the",
"smallest",
"variance",
"word",
"length"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/MMSegFilter.java#L79-L105 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/MMSegFilter.java | MMSegFilter.getLargestSingleMorphemicFreedomChunks | public static IChunk[] getLargestSingleMorphemicFreedomChunks(IChunk[] chunks)
{
double largestFreedom = chunks[0].getSingleWordsMorphemicFreedom();
int j;
//find the maximum sum of single morphemic freedom
for ( j = 1; j < chunks.length; j++ ) {
if ( chunks[j].getSingleWordsMorphemicFreedom() > largestFreedom ) {
largestFreedom = chunks[j].getSingleWordsMorphemicFreedom();
}
}
//get the items that the word length equals to
//the max's length.
ArrayList<IChunk> chunkArr = new ArrayList<IChunk>(chunks.length);
for ( j = 0; j < chunks.length; j++ ) {
if ( chunks[j].getSingleWordsMorphemicFreedom() == largestFreedom) {
chunkArr.add(chunks[j]);
}
}
IChunk[] lchunk = new IChunk[chunkArr.size()];
chunkArr.toArray(lchunk);
chunkArr.clear();
return lchunk;
} | java | public static IChunk[] getLargestSingleMorphemicFreedomChunks(IChunk[] chunks)
{
double largestFreedom = chunks[0].getSingleWordsMorphemicFreedom();
int j;
//find the maximum sum of single morphemic freedom
for ( j = 1; j < chunks.length; j++ ) {
if ( chunks[j].getSingleWordsMorphemicFreedom() > largestFreedom ) {
largestFreedom = chunks[j].getSingleWordsMorphemicFreedom();
}
}
//get the items that the word length equals to
//the max's length.
ArrayList<IChunk> chunkArr = new ArrayList<IChunk>(chunks.length);
for ( j = 0; j < chunks.length; j++ ) {
if ( chunks[j].getSingleWordsMorphemicFreedom() == largestFreedom) {
chunkArr.add(chunks[j]);
}
}
IChunk[] lchunk = new IChunk[chunkArr.size()];
chunkArr.toArray(lchunk);
chunkArr.clear();
return lchunk;
} | [
"public",
"static",
"IChunk",
"[",
"]",
"getLargestSingleMorphemicFreedomChunks",
"(",
"IChunk",
"[",
"]",
"chunks",
")",
"{",
"double",
"largestFreedom",
"=",
"chunks",
"[",
"0",
"]",
".",
"getSingleWordsMorphemicFreedom",
"(",
")",
";",
"int",
"j",
";",
"//f... | the largest sum of degree of morphemic freedom of one-character words
this rule will return the chunks that own the largest sum of degree of morphemic freedom
of one-character | [
"the",
"largest",
"sum",
"of",
"degree",
"of",
"morphemic",
"freedom",
"of",
"one",
"-",
"character",
"words",
"this",
"rule",
"will",
"return",
"the",
"chunks",
"that",
"own",
"the",
"largest",
"sum",
"of",
"degree",
"of",
"morphemic",
"freedom",
"of",
"o... | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/core/MMSegFilter.java#L113-L139 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/ArrayUtil.java | ArrayUtil.implode | public static String implode(String glue, Object[] pieces)
{
if ( pieces == null ) {
return null;
}
StringBuffer sb = new StringBuffer();
for ( Object o : pieces ) {
if ( sb.length() > 0 ) {
sb.append(glue);
}
sb.append(o.toString());
}
return sb.toString();
} | java | public static String implode(String glue, Object[] pieces)
{
if ( pieces == null ) {
return null;
}
StringBuffer sb = new StringBuffer();
for ( Object o : pieces ) {
if ( sb.length() > 0 ) {
sb.append(glue);
}
sb.append(o.toString());
}
return sb.toString();
} | [
"public",
"static",
"String",
"implode",
"(",
"String",
"glue",
",",
"Object",
"[",
"]",
"pieces",
")",
"{",
"if",
"(",
"pieces",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"fo... | String array implode internal method
@param glue
@param pieces
@return String | [
"String",
"array",
"implode",
"internal",
"method"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/ArrayUtil.java#L17-L33 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/ArrayUtil.java | ArrayUtil.indexOf | public static int indexOf(String ele, String[] arr)
{
if ( arr == null ) {
return -1;
}
for ( int i = 0; i < arr.length; i++ ) {
if ( arr[i].equals(ele) ) {
return i;
}
}
return -1;
} | java | public static int indexOf(String ele, String[] arr)
{
if ( arr == null ) {
return -1;
}
for ( int i = 0; i < arr.length; i++ ) {
if ( arr[i].equals(ele) ) {
return i;
}
}
return -1;
} | [
"public",
"static",
"int",
"indexOf",
"(",
"String",
"ele",
",",
"String",
"[",
"]",
"arr",
")",
"{",
"if",
"(",
"arr",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"length... | check and search the specified element in the Array
@param ele
@param arr
@return int | [
"check",
"and",
"search",
"the",
"specified",
"element",
"in",
"the",
"Array"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/ArrayUtil.java#L42-L55 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/ArrayUtil.java | ArrayUtil.startsWith | public static int startsWith(String str, String[] arr)
{
if ( arr == null ) {
return -1;
}
for ( int i = 0; i < arr.length; i++ ) {
if ( arr[i].startsWith(str) ) {
return i;
}
}
return -1;
} | java | public static int startsWith(String str, String[] arr)
{
if ( arr == null ) {
return -1;
}
for ( int i = 0; i < arr.length; i++ ) {
if ( arr[i].startsWith(str) ) {
return i;
}
}
return -1;
} | [
"public",
"static",
"int",
"startsWith",
"(",
"String",
"str",
",",
"String",
"[",
"]",
"arr",
")",
"{",
"if",
"(",
"arr",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"len... | check if there is an element that starts with the specified string
@param str
@return int | [
"check",
"if",
"there",
"is",
"an",
"element",
"that",
"starts",
"with",
"the",
"specified",
"string"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/ArrayUtil.java#L63-L76 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/ArrayUtil.java | ArrayUtil.endsWith | public static int endsWith(String str, String[] arr)
{
if ( arr == null ) {
return -1;
}
for ( int i = 0; i < arr.length; i++ ) {
if ( arr[i].endsWith(str) ) {
return i;
}
}
return -1;
} | java | public static int endsWith(String str, String[] arr)
{
if ( arr == null ) {
return -1;
}
for ( int i = 0; i < arr.length; i++ ) {
if ( arr[i].endsWith(str) ) {
return i;
}
}
return -1;
} | [
"public",
"static",
"int",
"endsWith",
"(",
"String",
"str",
",",
"String",
"[",
"]",
"arr",
")",
"{",
"if",
"(",
"arr",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"lengt... | check if there is an element that ends with the specified string
@param str
@return int | [
"check",
"if",
"there",
"is",
"an",
"element",
"that",
"ends",
"with",
"the",
"specified",
"string"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/ArrayUtil.java#L84-L97 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/ArrayUtil.java | ArrayUtil.contains | public static int contains(String str, String[] arr)
{
if ( arr == null ) {
return -1;
}
for ( int i = 0; i < arr.length; i++ ) {
if ( arr[i].contains(str) ) {
return i;
}
}
return -1;
} | java | public static int contains(String str, String[] arr)
{
if ( arr == null ) {
return -1;
}
for ( int i = 0; i < arr.length; i++ ) {
if ( arr[i].contains(str) ) {
return i;
}
}
return -1;
} | [
"public",
"static",
"int",
"contains",
"(",
"String",
"str",
",",
"String",
"[",
"]",
"arr",
")",
"{",
"if",
"(",
"arr",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"lengt... | check if there is an element that contains the specified string
@param str
@return int | [
"check",
"if",
"there",
"is",
"an",
"element",
"that",
"contains",
"the",
"specified",
"string"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/ArrayUtil.java#L105-L118 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/ArrayUtil.java | ArrayUtil.toJsonObject | public static String toJsonObject(String[] arr)
{
if ( arr == null ) {
return null;
}
StringBuffer sb = new StringBuffer();
sb.append('{');
for ( String ele : arr ) {
if ( sb.length() == 1 ) {
sb.append('"').append(ele).append("\":true");
} else {
sb.append(",\"").append(ele).append("\":true");
}
}
sb.append('}');
return sb.toString();
} | java | public static String toJsonObject(String[] arr)
{
if ( arr == null ) {
return null;
}
StringBuffer sb = new StringBuffer();
sb.append('{');
for ( String ele : arr ) {
if ( sb.length() == 1 ) {
sb.append('"').append(ele).append("\":true");
} else {
sb.append(",\"").append(ele).append("\":true");
}
}
sb.append('}');
return sb.toString();
} | [
"public",
"static",
"String",
"toJsonObject",
"(",
"String",
"[",
"]",
"arr",
")",
"{",
"if",
"(",
"arr",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"sb",
".",
"append",
"(",
... | implode the array elements as a Json array string
@param arr
@return String | [
"implode",
"the",
"array",
"elements",
"as",
"a",
"Json",
"array",
"string"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/ArrayUtil.java#L126-L144 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/extractor/impl/TextRankSummaryExtractor.java | TextRankSummaryExtractor.textToSentence | List<Sentence> textToSentence(Reader reader) throws IOException
{
List<Sentence> sentence = new ArrayList<Sentence>();
Sentence sen = null;
sentenceSeg.reset(reader);
while ( (sen = sentenceSeg.next()) != null ) {
sentence.add(sen);
}
return sentence;
} | java | List<Sentence> textToSentence(Reader reader) throws IOException
{
List<Sentence> sentence = new ArrayList<Sentence>();
Sentence sen = null;
sentenceSeg.reset(reader);
while ( (sen = sentenceSeg.next()) != null ) {
sentence.add(sen);
}
return sentence;
} | [
"List",
"<",
"Sentence",
">",
"textToSentence",
"(",
"Reader",
"reader",
")",
"throws",
"IOException",
"{",
"List",
"<",
"Sentence",
">",
"sentence",
"=",
"new",
"ArrayList",
"<",
"Sentence",
">",
"(",
")",
";",
"Sentence",
"sen",
"=",
"null",
";",
"sent... | text doc to sentence
@param reader
@return List<Sentence>
@throws IOException | [
"text",
"doc",
"to",
"sentence"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/extractor/impl/TextRankSummaryExtractor.java#L50-L61 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/extractor/impl/TextRankSummaryExtractor.java | TextRankSummaryExtractor.sentenceTokenize | List<List<IWord>> sentenceTokenize(List<Sentence> sentence) throws IOException
{
List<List<IWord>> senWords = new ArrayList<List<IWord>>();
for ( Sentence sen : sentence ) {
List<IWord> words = new ArrayList<IWord>();
wordSeg.reset(new StringReader(sen.getValue()));
IWord word = null;
while ( (word = wordSeg.next()) != null ) {
words.add(word);
}
senWords.add(words);
}
return senWords;
} | java | List<List<IWord>> sentenceTokenize(List<Sentence> sentence) throws IOException
{
List<List<IWord>> senWords = new ArrayList<List<IWord>>();
for ( Sentence sen : sentence ) {
List<IWord> words = new ArrayList<IWord>();
wordSeg.reset(new StringReader(sen.getValue()));
IWord word = null;
while ( (word = wordSeg.next()) != null ) {
words.add(word);
}
senWords.add(words);
}
return senWords;
} | [
"List",
"<",
"List",
"<",
"IWord",
">",
">",
"sentenceTokenize",
"(",
"List",
"<",
"Sentence",
">",
"sentence",
")",
"throws",
"IOException",
"{",
"List",
"<",
"List",
"<",
"IWord",
">>",
"senWords",
"=",
"new",
"ArrayList",
"<",
"List",
"<",
"IWord",
... | sentence to words
@param sentence
@return List<List<IWord>>
@throws IOException | [
"sentence",
"to",
"words"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/extractor/impl/TextRankSummaryExtractor.java#L70-L85 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/extractor/impl/TextRankSummaryExtractor.java | TextRankSummaryExtractor.textRankSortedDocuments | protected Document[] textRankSortedDocuments(
List<Sentence> sentence, List<List<IWord>> senWords) throws IOException
{
int docNum = sentence.size();
//documents relevance matrix build
double[][] relevance = BM25RelevanceMatixBuild(sentence, senWords);
//org.lionsoul.jcseg.util.Util.printMatrix(relevance);
double[] score = new double[docNum];
double[] weight_sum = new double[docNum];
for ( int i = 0; i < docNum; i++ ) {
weight_sum[i] = sum(relevance[i]) - relevance[i][i];
score[i] = 0;
}
//do the textrank score iteration
for ( int c = 0; c < maxIterateNum; c++ ) {
for ( int i = 0; i < docNum; i++ ) {
double sigema = 0D;
for ( int j = 0; j < docNum; j++ ) {
if ( i == j || weight_sum[j] == 0 ) continue;
/*
* ws(vj) * wji / sigma(wjk) with k in Out(Vj)
* ws(vj): score[j] the score of document[j]
* wji: relevance score bettween document[j] and document[i]
* sigema(wjk): weight sum for document[j]
*/
sigema += relevance[j][i] / weight_sum[j] * score[j];
}
score[i] = 1 - D + D * sigema;
}
}
//build the document set
//and sort the documents by scores
Document[] docs = new Document[docNum];
for ( int i = 0; i < docNum; i++ ) {
docs[i] = new Document(i, sentence.get(i), senWords.get(i), score[i]);
}
Sort.shellSort(docs);
//let gc do its works
relevance = null;
score = null;
weight_sum = null;
return docs;
} | java | protected Document[] textRankSortedDocuments(
List<Sentence> sentence, List<List<IWord>> senWords) throws IOException
{
int docNum = sentence.size();
//documents relevance matrix build
double[][] relevance = BM25RelevanceMatixBuild(sentence, senWords);
//org.lionsoul.jcseg.util.Util.printMatrix(relevance);
double[] score = new double[docNum];
double[] weight_sum = new double[docNum];
for ( int i = 0; i < docNum; i++ ) {
weight_sum[i] = sum(relevance[i]) - relevance[i][i];
score[i] = 0;
}
//do the textrank score iteration
for ( int c = 0; c < maxIterateNum; c++ ) {
for ( int i = 0; i < docNum; i++ ) {
double sigema = 0D;
for ( int j = 0; j < docNum; j++ ) {
if ( i == j || weight_sum[j] == 0 ) continue;
/*
* ws(vj) * wji / sigma(wjk) with k in Out(Vj)
* ws(vj): score[j] the score of document[j]
* wji: relevance score bettween document[j] and document[i]
* sigema(wjk): weight sum for document[j]
*/
sigema += relevance[j][i] / weight_sum[j] * score[j];
}
score[i] = 1 - D + D * sigema;
}
}
//build the document set
//and sort the documents by scores
Document[] docs = new Document[docNum];
for ( int i = 0; i < docNum; i++ ) {
docs[i] = new Document(i, sentence.get(i), senWords.get(i), score[i]);
}
Sort.shellSort(docs);
//let gc do its works
relevance = null;
score = null;
weight_sum = null;
return docs;
} | [
"protected",
"Document",
"[",
"]",
"textRankSortedDocuments",
"(",
"List",
"<",
"Sentence",
">",
"sentence",
",",
"List",
"<",
"List",
"<",
"IWord",
">",
">",
"senWords",
")",
"throws",
"IOException",
"{",
"int",
"docNum",
"=",
"sentence",
".",
"size",
"("... | get the documents order by relevance score.
@param sentence
@param senWords
@throws IOException | [
"get",
"the",
"documents",
"order",
"by",
"relevance",
"score",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/extractor/impl/TextRankSummaryExtractor.java#L202-L253 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/TimeUtil.java | TimeUtil.createDateTimePool | public static final IWord[] createDateTimePool()
{
return new IWord[]{
null, //year
null, //month
null, //day
null, //timing method
null, //hour
null, //minute
null, //seconds
};
} | java | public static final IWord[] createDateTimePool()
{
return new IWord[]{
null, //year
null, //month
null, //day
null, //timing method
null, //hour
null, //minute
null, //seconds
};
} | [
"public",
"static",
"final",
"IWord",
"[",
"]",
"createDateTimePool",
"(",
")",
"{",
"return",
"new",
"IWord",
"[",
"]",
"{",
"null",
",",
"//year",
"null",
",",
"//month",
"null",
",",
"//day",
"null",
",",
"//timing method",
"null",
",",
"//hour",
"nul... | create and return a date-time pool
@return IWord[] | [
"create",
"and",
"return",
"a",
"date",
"-",
"time",
"pool"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/TimeUtil.java#L79-L90 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/TimeUtil.java | TimeUtil.fillDateTimePool | public static final int fillDateTimePool(IWord[] wPool, IWord word)
{
int pIdx = getDateTimeIndex(word.getEntity(0));
if ( pIdx == DATETIME_NONE ) {
return DATETIME_NONE;
}
if ( wPool[pIdx] == null ) {
wPool[pIdx] = word;
return pIdx;
}
return DATETIME_NONE;
} | java | public static final int fillDateTimePool(IWord[] wPool, IWord word)
{
int pIdx = getDateTimeIndex(word.getEntity(0));
if ( pIdx == DATETIME_NONE ) {
return DATETIME_NONE;
}
if ( wPool[pIdx] == null ) {
wPool[pIdx] = word;
return pIdx;
}
return DATETIME_NONE;
} | [
"public",
"static",
"final",
"int",
"fillDateTimePool",
"(",
"IWord",
"[",
"]",
"wPool",
",",
"IWord",
"word",
")",
"{",
"int",
"pIdx",
"=",
"getDateTimeIndex",
"(",
"word",
".",
"getEntity",
"(",
"0",
")",
")",
";",
"if",
"(",
"pIdx",
"==",
"DATETIME_... | fill the date-time pool specified part through the specified
time entity string.
@param wPool
@param word
@return int | [
"fill",
"the",
"date",
"-",
"time",
"pool",
"specified",
"part",
"through",
"the",
"specified",
"time",
"entity",
"string",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/TimeUtil.java#L100-L113 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/TimeUtil.java | TimeUtil.fillDateTimePool | public static final void fillDateTimePool(
IWord[] wPool, int pIdx, IWord word)
{
if ( wPool[pIdx] == null ) {
wPool[pIdx] = word;
}
} | java | public static final void fillDateTimePool(
IWord[] wPool, int pIdx, IWord word)
{
if ( wPool[pIdx] == null ) {
wPool[pIdx] = word;
}
} | [
"public",
"static",
"final",
"void",
"fillDateTimePool",
"(",
"IWord",
"[",
"]",
"wPool",
",",
"int",
"pIdx",
",",
"IWord",
"word",
")",
"{",
"if",
"(",
"wPool",
"[",
"pIdx",
"]",
"==",
"null",
")",
"{",
"wPool",
"[",
"pIdx",
"]",
"=",
"word",
";",... | fill the date-time pool specified part with part index constant
@param wPool
@param pIdx
@param word | [
"fill",
"the",
"date",
"-",
"time",
"pool",
"specified",
"part",
"with",
"part",
"index",
"constant"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/TimeUtil.java#L122-L128 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/TimeUtil.java | TimeUtil.getTimeKey | public static final String getTimeKey(String entity)
{
if ( entity == null ) {
return null;
}
int sIdx = entity.indexOf('.');
if ( sIdx == -1 ) {
return null;
}
return entity.substring(sIdx + 1);
} | java | public static final String getTimeKey(String entity)
{
if ( entity == null ) {
return null;
}
int sIdx = entity.indexOf('.');
if ( sIdx == -1 ) {
return null;
}
return entity.substring(sIdx + 1);
} | [
"public",
"static",
"final",
"String",
"getTimeKey",
"(",
"String",
"entity",
")",
"{",
"if",
"(",
"entity",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"int",
"sIdx",
"=",
"entity",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"sIdx... | get and return the time key part of the specified entity string
@param entity
@return String | [
"get",
"and",
"return",
"the",
"time",
"key",
"part",
"of",
"the",
"specified",
"entity",
"string"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/TimeUtil.java#L136-L148 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/sentence/SentenceSeg.java | SentenceSeg.readUntil | protected void readUntil(char echar) throws IOException
{
int ch, i = 0;
IStringBuffer sb = new IStringBuffer();
while ( (ch = readNext()) != -1 ) {
if ( ++i >= MAX_QUOTE_LENGTH ) {
/*
* push back the readed chars
* and reset the global idx value.
*/
for ( int j = sb.length() - 1; j >= 0; j-- ) {
reader.unread(sb.charAt(j));
}
idx -= sb.length();
break;
}
sb.append((char)ch);
if ( ch == echar ) {
gisb.append(sb.toString());
break;
}
}
sb = null;
} | java | protected void readUntil(char echar) throws IOException
{
int ch, i = 0;
IStringBuffer sb = new IStringBuffer();
while ( (ch = readNext()) != -1 ) {
if ( ++i >= MAX_QUOTE_LENGTH ) {
/*
* push back the readed chars
* and reset the global idx value.
*/
for ( int j = sb.length() - 1; j >= 0; j-- ) {
reader.unread(sb.charAt(j));
}
idx -= sb.length();
break;
}
sb.append((char)ch);
if ( ch == echar ) {
gisb.append(sb.toString());
break;
}
}
sb = null;
} | [
"protected",
"void",
"readUntil",
"(",
"char",
"echar",
")",
"throws",
"IOException",
"{",
"int",
"ch",
",",
"i",
"=",
"0",
";",
"IStringBuffer",
"sb",
"=",
"new",
"IStringBuffer",
"(",
")",
";",
"while",
"(",
"(",
"ch",
"=",
"readNext",
"(",
")",
")... | loop the reader until the specifield char is found.
@param echar
@throws IOException | [
"loop",
"the",
"reader",
"until",
"the",
"specifield",
"char",
"is",
"found",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/sentence/SentenceSeg.java#L186-L211 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/IIntQueue.java | IIntQueue.enQueue | public boolean enQueue( int data )
{
Entry o = new Entry(data, tail.prev, tail);
tail.prev.next = o;
tail.prev = o;
//set the size
size++;
return true;
} | java | public boolean enQueue( int data )
{
Entry o = new Entry(data, tail.prev, tail);
tail.prev.next = o;
tail.prev = o;
//set the size
size++;
return true;
} | [
"public",
"boolean",
"enQueue",
"(",
"int",
"data",
")",
"{",
"Entry",
"o",
"=",
"new",
"Entry",
"(",
"data",
",",
"tail",
".",
"prev",
",",
"tail",
")",
";",
"tail",
".",
"prev",
".",
"next",
"=",
"o",
";",
"tail",
".",
"prev",
"=",
"o",
";",
... | append a int from the tail
@param data
@return boolean | [
"append",
"a",
"int",
"from",
"the",
"tail"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/IIntQueue.java#L30-L40 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/IHashQueue.java | IHashQueue.add | public boolean add( T word )
{
Entry<T> o = new Entry<T>(word, tail.prev, tail);
tail.prev.next = o;
tail.prev = o;
//set the size and set the index
size++;
index.put(word.getValue(), word);
return true;
} | java | public boolean add( T word )
{
Entry<T> o = new Entry<T>(word, tail.prev, tail);
tail.prev.next = o;
tail.prev = o;
//set the size and set the index
size++;
index.put(word.getValue(), word);
return true;
} | [
"public",
"boolean",
"add",
"(",
"T",
"word",
")",
"{",
"Entry",
"<",
"T",
">",
"o",
"=",
"new",
"Entry",
"<",
"T",
">",
"(",
"word",
",",
"tail",
".",
"prev",
",",
"tail",
")",
";",
"tail",
".",
"prev",
".",
"next",
"=",
"o",
";",
"tail",
... | append a item from the tail
@param word
@return boolean | [
"append",
"a",
"item",
"from",
"the",
"tail"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/IHashQueue.java#L49-L60 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/extractor/SummaryExtractor.java | SummaryExtractor.getSummaryFromString | public String getSummaryFromString(String doc, int length) throws IOException
{
return getSummary(new StringReader(doc), length);
} | java | public String getSummaryFromString(String doc, int length) throws IOException
{
return getSummary(new StringReader(doc), length);
} | [
"public",
"String",
"getSummaryFromString",
"(",
"String",
"doc",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"return",
"getSummary",
"(",
"new",
"StringReader",
"(",
"doc",
")",
",",
"length",
")",
";",
"}"
] | get document summary from a string
@param doc
@param length
@return String
@throws IOException | [
"get",
"document",
"summary",
"from",
"a",
"string"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/extractor/SummaryExtractor.java#L83-L86 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/extractor/SummaryExtractor.java | SummaryExtractor.getSummaryFromFile | public String getSummaryFromFile(String file, int length) throws IOException
{
return getSummary(new FileReader(file), length);
} | java | public String getSummaryFromFile(String file, int length) throws IOException
{
return getSummary(new FileReader(file), length);
} | [
"public",
"String",
"getSummaryFromFile",
"(",
"String",
"file",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"return",
"getSummary",
"(",
"new",
"FileReader",
"(",
"file",
")",
",",
"length",
")",
";",
"}"
] | get document summary from a file
@param file
@param length
@return String
@throws IOException | [
"get",
"document",
"summary",
"from",
"a",
"file"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/extractor/SummaryExtractor.java#L97-L100 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/EntityFormat.java | EntityFormat.isMailAddress | public final static boolean isMailAddress(String str)
{
int atIndex = str.indexOf('@');
if ( atIndex == -1 ) {
return false;
}
if ( ! StringUtil.isLetterOrNumeric(str, 0, atIndex) ) {
return false;
}
int ptIndex, ptStart = atIndex + 1;
while ( (ptIndex = str.indexOf('.', ptStart)) > 0 ) {
if ( ptIndex == ptStart ) {
return false;
}
if ( ! StringUtil.isLetterOrNumeric(str, ptStart, ptIndex) ) {
return false;
}
ptStart = ptIndex + 1;
}
if ( ptStart < str.length()
&& ! StringUtil.isLetterOrNumeric(str, ptStart, str.length()) ) {
return false;
}
return true;
} | java | public final static boolean isMailAddress(String str)
{
int atIndex = str.indexOf('@');
if ( atIndex == -1 ) {
return false;
}
if ( ! StringUtil.isLetterOrNumeric(str, 0, atIndex) ) {
return false;
}
int ptIndex, ptStart = atIndex + 1;
while ( (ptIndex = str.indexOf('.', ptStart)) > 0 ) {
if ( ptIndex == ptStart ) {
return false;
}
if ( ! StringUtil.isLetterOrNumeric(str, ptStart, ptIndex) ) {
return false;
}
ptStart = ptIndex + 1;
}
if ( ptStart < str.length()
&& ! StringUtil.isLetterOrNumeric(str, ptStart, str.length()) ) {
return false;
}
return true;
} | [
"public",
"final",
"static",
"boolean",
"isMailAddress",
"(",
"String",
"str",
")",
"{",
"int",
"atIndex",
"=",
"str",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"atIndex",
"==",
"-",
"1",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
... | check if the specified string is an email address or not
@param str
@return boolean | [
"check",
"if",
"the",
"specified",
"string",
"is",
"an",
"email",
"address",
"or",
"not"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/EntityFormat.java#L19-L49 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/EntityFormat.java | EntityFormat.isUrlAddress | public final static boolean isUrlAddress(String str, ADictionary dic)
{
int prIndex = str.indexOf("://");
if ( prIndex > -1 && ! StringUtil.isLatin(str, 0, prIndex) ) {
return false;
}
int sIdx = prIndex > -1 ? prIndex + 3 : 0;
int slIndex = str.indexOf('/', sIdx), sgIndex = str.indexOf('?', sIdx);
int eIdx = slIndex > -1 ? slIndex : (sgIndex > -1 ? sgIndex : str.length());
int lpIndex = -1;
for ( int i = sIdx; i < eIdx; i++ ) {
char chr = str.charAt(i);
if ( chr == '.' ) {
if ( lpIndex == -1 ) {
lpIndex = i;
continue;
}
if ( (i - lpIndex) == 1 || i == (eIdx - 1)) {
return false;
}
lpIndex = i;
} else if ( ! StringUtil.isEnLetter(chr)
&& ! StringUtil.isEnNumeric(chr) ) {
return false;
}
}
if ( dic != null && ! dic.match(ILexicon.DOMAIN_SUFFIX,
str.substring(lpIndex+1, eIdx)) ) {
return false;
}
//check the path part
if ( slIndex > -1 ) {
sIdx = slIndex;
eIdx = sgIndex > -1 ? sgIndex : str.length();
lpIndex = -1;
for ( int i = sIdx; i < eIdx; i++ ) {
char chr = str.charAt(i);
if ( "./-_".indexOf(chr) > -1 ) {
if ( lpIndex == -1 ) {
lpIndex = i;
continue;
}
if ( i - lpIndex == 1 || (chr == '.' && i == (eIdx - 1)) ) {
return false;
}
lpIndex = i;
} else if ( ! StringUtil.isEnLetter(chr)
&& ! StringUtil.isEnNumeric(chr) ) {
return false;
}
}
}
return true;
} | java | public final static boolean isUrlAddress(String str, ADictionary dic)
{
int prIndex = str.indexOf("://");
if ( prIndex > -1 && ! StringUtil.isLatin(str, 0, prIndex) ) {
return false;
}
int sIdx = prIndex > -1 ? prIndex + 3 : 0;
int slIndex = str.indexOf('/', sIdx), sgIndex = str.indexOf('?', sIdx);
int eIdx = slIndex > -1 ? slIndex : (sgIndex > -1 ? sgIndex : str.length());
int lpIndex = -1;
for ( int i = sIdx; i < eIdx; i++ ) {
char chr = str.charAt(i);
if ( chr == '.' ) {
if ( lpIndex == -1 ) {
lpIndex = i;
continue;
}
if ( (i - lpIndex) == 1 || i == (eIdx - 1)) {
return false;
}
lpIndex = i;
} else if ( ! StringUtil.isEnLetter(chr)
&& ! StringUtil.isEnNumeric(chr) ) {
return false;
}
}
if ( dic != null && ! dic.match(ILexicon.DOMAIN_SUFFIX,
str.substring(lpIndex+1, eIdx)) ) {
return false;
}
//check the path part
if ( slIndex > -1 ) {
sIdx = slIndex;
eIdx = sgIndex > -1 ? sgIndex : str.length();
lpIndex = -1;
for ( int i = sIdx; i < eIdx; i++ ) {
char chr = str.charAt(i);
if ( "./-_".indexOf(chr) > -1 ) {
if ( lpIndex == -1 ) {
lpIndex = i;
continue;
}
if ( i - lpIndex == 1 || (chr == '.' && i == (eIdx - 1)) ) {
return false;
}
lpIndex = i;
} else if ( ! StringUtil.isEnLetter(chr)
&& ! StringUtil.isEnNumeric(chr) ) {
return false;
}
}
}
return true;
} | [
"public",
"final",
"static",
"boolean",
"isUrlAddress",
"(",
"String",
"str",
",",
"ADictionary",
"dic",
")",
"{",
"int",
"prIndex",
"=",
"str",
".",
"indexOf",
"(",
"\"://\"",
")",
";",
"if",
"(",
"prIndex",
">",
"-",
"1",
"&&",
"!",
"StringUtil",
"."... | check if the specified string is an URL address or not
@param str
@param dic optional dictionary object
@return boolean | [
"check",
"if",
"the",
"specified",
"string",
"is",
"an",
"URL",
"address",
"or",
"not"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/EntityFormat.java#L58-L119 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/EntityFormat.java | EntityFormat.isMobileNumber | public static final boolean isMobileNumber(String str)
{
if ( str.length() != 11 ) {
return false;
}
if ( str.charAt(0) != '1' ) {
return false;
}
if ( "34578".indexOf(str.charAt(1)) == -1 ) {
return false;
}
return StringUtil.isNumeric(str, 2, str.length());
} | java | public static final boolean isMobileNumber(String str)
{
if ( str.length() != 11 ) {
return false;
}
if ( str.charAt(0) != '1' ) {
return false;
}
if ( "34578".indexOf(str.charAt(1)) == -1 ) {
return false;
}
return StringUtil.isNumeric(str, 2, str.length());
} | [
"public",
"static",
"final",
"boolean",
"isMobileNumber",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
".",
"length",
"(",
")",
"!=",
"11",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"str",
".",
"charAt",
"(",
"0",
")",
"!=",
"'",
"'"... | check if the specified string is a mobile number
@param str
@return boolean | [
"check",
"if",
"the",
"specified",
"string",
"is",
"a",
"mobile",
"number"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/EntityFormat.java#L127-L142 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java | StringUtil.isCJKChar | public static boolean isCJKChar( int c )
{
/*
* @Note: added at 2015-11-25
* for foreign country translated name recognize
* add '·' as CJK chars
*/
if ( c == 183
|| Character.getType(c) == Character.OTHER_LETTER )
return true;
return false;
} | java | public static boolean isCJKChar( int c )
{
/*
* @Note: added at 2015-11-25
* for foreign country translated name recognize
* add '·' as CJK chars
*/
if ( c == 183
|| Character.getType(c) == Character.OTHER_LETTER )
return true;
return false;
} | [
"public",
"static",
"boolean",
"isCJKChar",
"(",
"int",
"c",
")",
"{",
"/*\n * @Note: added at 2015-11-25\n * for foreign country translated name recognize\n * add '·' as CJK chars\n */",
"if",
"(",
"c",
"==",
"183",
"||",
"Character",
".",
"getType... | check the specified char is CJK, Thai... char
true will be return if it is or return false
@param c
@return boolean | [
"check",
"the",
"specified",
"char",
"is",
"CJK",
"Thai",
"...",
"char",
"true",
"will",
"be",
"return",
"if",
"it",
"is",
"or",
"return",
"false"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java#L37-L48 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java | StringUtil.isEnPunctuation | public static boolean isEnPunctuation( int c )
{
return ( (c > 32 && c < 48)
|| ( c > 57 && c < 65 )
|| ( c > 90 && c < 97 )
|| ( c > 122 && c < 127 )
);
} | java | public static boolean isEnPunctuation( int c )
{
return ( (c > 32 && c < 48)
|| ( c > 57 && c < 65 )
|| ( c > 90 && c < 97 )
|| ( c > 122 && c < 127 )
);
} | [
"public",
"static",
"boolean",
"isEnPunctuation",
"(",
"int",
"c",
")",
"{",
"return",
"(",
"(",
"c",
">",
"32",
"&&",
"c",
"<",
"48",
")",
"||",
"(",
"c",
">",
"57",
"&&",
"c",
"<",
"65",
")",
"||",
"(",
"c",
">",
"90",
"&&",
"c",
"<",
"97... | check the given char is half-width punctuation
@param c
@return boolean | [
"check",
"the",
"given",
"char",
"is",
"half",
"-",
"width",
"punctuation"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java#L231-L238 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java | StringUtil.isDigit | public static boolean isDigit(String str, int beginIndex, int endIndex)
{
char c;
for ( int j = beginIndex; j < endIndex; j++ ) {
c = str.charAt(j);
//make full-width char half-width
if ( c > 65280 ) c -= 65248;
if ( c < 48 || c > 57 ) {
return false;
}
}
return true;
} | java | public static boolean isDigit(String str, int beginIndex, int endIndex)
{
char c;
for ( int j = beginIndex; j < endIndex; j++ ) {
c = str.charAt(j);
//make full-width char half-width
if ( c > 65280 ) c -= 65248;
if ( c < 48 || c > 57 ) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isDigit",
"(",
"String",
"str",
",",
"int",
"beginIndex",
",",
"int",
"endIndex",
")",
"{",
"char",
"c",
";",
"for",
"(",
"int",
"j",
"=",
"beginIndex",
";",
"j",
"<",
"endIndex",
";",
"j",
"++",
")",
"{",
"c",
"=",
... | check the specified char is a digit or not
true will return if it is or return false this method can recognize full-with char
@param str
@param beginIndex
@param endIndex
@return boolean | [
"check",
"the",
"specified",
"char",
"is",
"a",
"digit",
"or",
"not",
"true",
"will",
"return",
"if",
"it",
"is",
"or",
"return",
"false",
"this",
"method",
"can",
"recognize",
"full",
"-",
"with",
"char"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java#L272-L285 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java | StringUtil.isDecimal | public static boolean isDecimal(String str, int beginIndex, int endIndex)
{
if ( str.charAt(str.length() - 1) == '.'
|| str.charAt(0) == '.' ) {
return false;
}
char c;
int p= 0; //number of point
for ( int j = 1; j < str.length(); j++ ) {
c = str.charAt(j);
if ( c == '.' ) {
p++;
} else {
//make full-width half-width
if ( c > 65280 ) c -= 65248;
if ( c < 48 || c > 57 ) return false;
}
}
return (p==1);
} | java | public static boolean isDecimal(String str, int beginIndex, int endIndex)
{
if ( str.charAt(str.length() - 1) == '.'
|| str.charAt(0) == '.' ) {
return false;
}
char c;
int p= 0; //number of point
for ( int j = 1; j < str.length(); j++ ) {
c = str.charAt(j);
if ( c == '.' ) {
p++;
} else {
//make full-width half-width
if ( c > 65280 ) c -= 65248;
if ( c < 48 || c > 57 ) return false;
}
}
return (p==1);
} | [
"public",
"static",
"boolean",
"isDecimal",
"(",
"String",
"str",
",",
"int",
"beginIndex",
",",
"int",
"endIndex",
")",
"{",
"if",
"(",
"str",
".",
"charAt",
"(",
"str",
".",
"length",
"(",
")",
"-",
"1",
")",
"==",
"'",
"'",
"||",
"str",
".",
"... | check the specified char is a decimal including the full-width char
@param str
@param beginIndex
@param endIndex
@return boolean | [
"check",
"the",
"specified",
"char",
"is",
"a",
"decimal",
"including",
"the",
"full",
"-",
"width",
"char"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java#L298-L319 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java | StringUtil.isLatin | public static boolean isLatin(String str, int beginIndex, int endIndex)
{
for ( int j = beginIndex; j < endIndex; j++ ) {
if ( ! isEnChar(str.charAt(j)) ) {
return false;
}
}
return true;
} | java | public static boolean isLatin(String str, int beginIndex, int endIndex)
{
for ( int j = beginIndex; j < endIndex; j++ ) {
if ( ! isEnChar(str.charAt(j)) ) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isLatin",
"(",
"String",
"str",
",",
"int",
"beginIndex",
",",
"int",
"endIndex",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"beginIndex",
";",
"j",
"<",
"endIndex",
";",
"j",
"++",
")",
"{",
"if",
"(",
"!",
"isEnChar",
... | check if the specified string is all Latin chars
@param str
@param beginIndex
@param endIndex
@return boolean | [
"check",
"if",
"the",
"specified",
"string",
"is",
"all",
"Latin",
"chars"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java#L332-L341 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java | StringUtil.isCJK | public static boolean isCJK(String str, int beginIndex, int endIndex)
{
for ( int j = beginIndex; j < endIndex; j++ ) {
if ( ! isCJKChar(str.charAt(j)) ) {
return false;
}
}
return true;
} | java | public static boolean isCJK(String str, int beginIndex, int endIndex)
{
for ( int j = beginIndex; j < endIndex; j++ ) {
if ( ! isCJKChar(str.charAt(j)) ) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isCJK",
"(",
"String",
"str",
",",
"int",
"beginIndex",
",",
"int",
"endIndex",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"beginIndex",
";",
"j",
"<",
"endIndex",
";",
"j",
"++",
")",
"{",
"if",
"(",
"!",
"isCJKChar",
"... | check if the specified string is all CJK chars
@param str
@param beginIndex
@param endIndex
@return boolean | [
"check",
"if",
"the",
"specified",
"string",
"is",
"all",
"CJK",
"chars"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java#L353-L362 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java | StringUtil.isLetterOrNumeric | public static boolean isLetterOrNumeric(String str, int beginIndex, int endIndex)
{
for ( int i = beginIndex; i < endIndex; i++ ) {
char chr = str.charAt(i);
if ( ! StringUtil.isEnLetter(chr)
&& ! StringUtil.isEnNumeric(chr) ) {
return false;
}
}
return true;
} | java | public static boolean isLetterOrNumeric(String str, int beginIndex, int endIndex)
{
for ( int i = beginIndex; i < endIndex; i++ ) {
char chr = str.charAt(i);
if ( ! StringUtil.isEnLetter(chr)
&& ! StringUtil.isEnNumeric(chr) ) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isLetterOrNumeric",
"(",
"String",
"str",
",",
"int",
"beginIndex",
",",
"int",
"endIndex",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"beginIndex",
";",
"i",
"<",
"endIndex",
";",
"i",
"++",
")",
"{",
"char",
"chr",
"=",
... | check if the specified string is Latin numeric or letter
@param str
@param beginIndex
@param endIndex
@return boolean | [
"check",
"if",
"the",
"specified",
"string",
"is",
"Latin",
"numeric",
"or",
"letter"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java#L374-L385 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java | StringUtil.isLetter | public static boolean isLetter(String str, int beginIndex, int endIndex)
{
for ( int i = beginIndex; i < endIndex; i++ ) {
char chr = str.charAt(i);
if ( ! StringUtil.isEnLetter(chr) ) {
return false;
}
}
return true;
} | java | public static boolean isLetter(String str, int beginIndex, int endIndex)
{
for ( int i = beginIndex; i < endIndex; i++ ) {
char chr = str.charAt(i);
if ( ! StringUtil.isEnLetter(chr) ) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isLetter",
"(",
"String",
"str",
",",
"int",
"beginIndex",
",",
"int",
"endIndex",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"beginIndex",
";",
"i",
"<",
"endIndex",
";",
"i",
"++",
")",
"{",
"char",
"chr",
"=",
"str",
... | check if the specified string is Latin letter
@param str
@param beginIndex
@param endIndex
@return boolean | [
"check",
"if",
"the",
"specified",
"string",
"is",
"Latin",
"letter"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java#L397-L407 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java | StringUtil.isNumeric | public static boolean isNumeric(String str, int beginIndex, int endIndex)
{
for ( int i = beginIndex; i < endIndex; i++ ) {
char chr = str.charAt(i);
if ( ! StringUtil.isEnNumeric(chr) ) {
return false;
}
}
return true;
} | java | public static boolean isNumeric(String str, int beginIndex, int endIndex)
{
for ( int i = beginIndex; i < endIndex; i++ ) {
char chr = str.charAt(i);
if ( ! StringUtil.isEnNumeric(chr) ) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isNumeric",
"(",
"String",
"str",
",",
"int",
"beginIndex",
",",
"int",
"endIndex",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"beginIndex",
";",
"i",
"<",
"endIndex",
";",
"i",
"++",
")",
"{",
"char",
"chr",
"=",
"str",
... | check if the specified string it Latin numeric
@param str
@param beginIndex
@param endIndex
@return boolean | [
"check",
"if",
"the",
"specified",
"string",
"it",
"Latin",
"numeric"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java#L419-L429 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java | StringUtil.latinIndexOf | public static int latinIndexOf(String str, int offset)
{
for ( int j = offset; j < str.length(); j++ ) {
if ( isEnChar(str.charAt(j)) ) {
return j;
}
}
return -1;
} | java | public static int latinIndexOf(String str, int offset)
{
for ( int j = offset; j < str.length(); j++ ) {
if ( isEnChar(str.charAt(j)) ) {
return j;
}
}
return -1;
} | [
"public",
"static",
"int",
"latinIndexOf",
"(",
"String",
"str",
",",
"int",
"offset",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"offset",
";",
"j",
"<",
"str",
".",
"length",
"(",
")",
";",
"j",
"++",
")",
"{",
"if",
"(",
"isEnChar",
"(",
"str",
... | get the index of the first Latin char of the specified string
@param str
@param offset
@return integer | [
"get",
"the",
"index",
"of",
"the",
"first",
"Latin",
"char",
"of",
"the",
"specified",
"string"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java#L440-L449 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java | StringUtil.CJKIndexOf | public static int CJKIndexOf(String str, int offset)
{
for ( int j = offset; j < str.length(); j++ ) {
if ( isCJKChar(str.charAt(j)) ) {
return j;
}
}
return -1;
} | java | public static int CJKIndexOf(String str, int offset)
{
for ( int j = offset; j < str.length(); j++ ) {
if ( isCJKChar(str.charAt(j)) ) {
return j;
}
}
return -1;
} | [
"public",
"static",
"int",
"CJKIndexOf",
"(",
"String",
"str",
",",
"int",
"offset",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"offset",
";",
"j",
"<",
"str",
".",
"length",
"(",
")",
";",
"j",
"++",
")",
"{",
"if",
"(",
"isCJKChar",
"(",
"str",
"... | get the index of the first CJK char of the specified string
@param str
@param offset
@return integer | [
"get",
"the",
"index",
"of",
"the",
"first",
"CJK",
"char",
"of",
"the",
"specified",
"string"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java#L463-L472 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java | StringUtil.hwsTofws | public static String hwsTofws( String str )
{
char[] chars = str.toCharArray();
for ( int j = 0; j < chars.length; j++ ) {
if ( chars[j] == '\u0020' ) {
chars[j] = '\u3000';
} else if ( chars[j] < '\177' ) {
chars[j] = (char)(chars[j] + 65248);
}
}
return new String(chars);
} | java | public static String hwsTofws( String str )
{
char[] chars = str.toCharArray();
for ( int j = 0; j < chars.length; j++ ) {
if ( chars[j] == '\u0020' ) {
chars[j] = '\u3000';
} else if ( chars[j] < '\177' ) {
chars[j] = (char)(chars[j] + 65248);
}
}
return new String(chars);
} | [
"public",
"static",
"String",
"hwsTofws",
"(",
"String",
"str",
")",
"{",
"char",
"[",
"]",
"chars",
"=",
"str",
".",
"toCharArray",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"chars",
".",
"length",
";",
"j",
"++",
")",
"{... | a static method to replace the half-width char to the full-width char in a given string
@param str
@return String the new String after the replace | [
"a",
"static",
"method",
"to",
"replace",
"the",
"half",
"-",
"width",
"char",
"to",
"the",
"full",
"-",
"width",
"char",
"in",
"a",
"given",
"string"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/StringUtil.java#L507-L519 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java | Zipper.pad | public void pad(int width) throws JSONException {
try {
this.bitwriter.pad(width);
} catch (Throwable e) {
throw new JSONException(e);
}
} | java | public void pad(int width) throws JSONException {
try {
this.bitwriter.pad(width);
} catch (Throwable e) {
throw new JSONException(e);
}
} | [
"public",
"void",
"pad",
"(",
"int",
"width",
")",
"throws",
"JSONException",
"{",
"try",
"{",
"this",
".",
"bitwriter",
".",
"pad",
"(",
"width",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"throw",
"new",
"JSONException",
"(",
"e",
")"... | Pad the output to fill an allotment of bits.
@param width
The size of the bit allotment. A value of 8 will complete and
flush the current byte. If you don't pad, then some of the
last bits might not be sent to the Output Stream.
@throws JSONException | [
"Pad",
"the",
"output",
"to",
"fill",
"an",
"allotment",
"of",
"bits",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java#L124-L130 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java | Zipper.write | private void write(int integer, int width) throws JSONException {
try {
this.bitwriter.write(integer, width);
if (probe) {
log(integer, width);
}
} catch (Throwable e) {
throw new JSONException(e);
}
} | java | private void write(int integer, int width) throws JSONException {
try {
this.bitwriter.write(integer, width);
if (probe) {
log(integer, width);
}
} catch (Throwable e) {
throw new JSONException(e);
}
} | [
"private",
"void",
"write",
"(",
"int",
"integer",
",",
"int",
"width",
")",
"throws",
"JSONException",
"{",
"try",
"{",
"this",
".",
"bitwriter",
".",
"write",
"(",
"integer",
",",
"width",
")",
";",
"if",
"(",
"probe",
")",
"{",
"log",
"(",
"intege... | Write a number, using the number of bits necessary to hold the number.
@param integer
The value to be encoded.
@param width
The number of bits to encode the value, between 0 and 32.
@throws JSONException | [
"Write",
"a",
"number",
"using",
"the",
"number",
"of",
"bits",
"necessary",
"to",
"hold",
"the",
"number",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java#L141-L150 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java | Zipper.write | private void write(Kim kim, Huff huff, Huff ext) throws JSONException {
for (int at = 0; at < kim.length; at += 1) {
int c = kim.get(at);
write(c, huff);
while ((c & 128) == 128) {
at += 1;
c = kim.get(at);
write(c, ext);
}
}
} | java | private void write(Kim kim, Huff huff, Huff ext) throws JSONException {
for (int at = 0; at < kim.length; at += 1) {
int c = kim.get(at);
write(c, huff);
while ((c & 128) == 128) {
at += 1;
c = kim.get(at);
write(c, ext);
}
}
} | [
"private",
"void",
"write",
"(",
"Kim",
"kim",
",",
"Huff",
"huff",
",",
"Huff",
"ext",
")",
"throws",
"JSONException",
"{",
"for",
"(",
"int",
"at",
"=",
"0",
";",
"at",
"<",
"kim",
".",
"length",
";",
"at",
"+=",
"1",
")",
"{",
"int",
"c",
"=... | Write each of the bytes in a kim with Huffman encoding.
@param kim
A kim containing the bytes to be written.
@param huff
The Huffman encoder.
@param ext
The Huffman encoder for the extended bytes.
@throws JSONException | [
"Write",
"each",
"of",
"the",
"bytes",
"in",
"a",
"kim",
"with",
"Huffman",
"encoding",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java#L177-L187 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java | Zipper.write | private void write(int integer, Keep keep) throws JSONException {
int width = keep.bitsize();
keep.tick(integer);
if (probe) {
log("\"" + keep.value(integer) + "\"");
}
write(integer, width);
} | java | private void write(int integer, Keep keep) throws JSONException {
int width = keep.bitsize();
keep.tick(integer);
if (probe) {
log("\"" + keep.value(integer) + "\"");
}
write(integer, width);
} | [
"private",
"void",
"write",
"(",
"int",
"integer",
",",
"Keep",
"keep",
")",
"throws",
"JSONException",
"{",
"int",
"width",
"=",
"keep",
".",
"bitsize",
"(",
")",
";",
"keep",
".",
"tick",
"(",
"integer",
")",
";",
"if",
"(",
"probe",
")",
"{",
"l... | Write an integer, using the number of bits necessary to hold the number
as determined by its keep, and increment its usage count in the keep.
@param integer
The value to be encoded.
@param keep
The Keep that the integer is one of.
@throws JSONException | [
"Write",
"an",
"integer",
"using",
"the",
"number",
"of",
"bits",
"necessary",
"to",
"hold",
"the",
"number",
"as",
"determined",
"by",
"its",
"keep",
"and",
"increment",
"its",
"usage",
"count",
"in",
"the",
"keep",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java#L199-L206 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java | Zipper.write | private void write(JSONArray jsonarray) throws JSONException {
// JSONzip has three encodings for arrays:
// The array is empty (zipEmptyArray).
// First value in the array is a string (zipArrayString).
// First value in the array is not a string (zipArrayValue).
boolean stringy = false;
int length = jsonarray.length();
if (length == 0) {
write(zipEmptyArray, 3);
} else {
Object value = jsonarray.get(0);
if (value == null) {
value = JSONObject.NULL;
}
if (value instanceof String) {
stringy = true;
write(zipArrayString, 3);
writeString((String) value);
} else {
write(zipArrayValue, 3);
writeValue(value);
}
for (int i = 1; i < length; i += 1) {
if (probe) {
log();
}
value = jsonarray.get(i);
if (value == null) {
value = JSONObject.NULL;
}
if (value instanceof String != stringy) {
zero();
}
one();
if (value instanceof String) {
writeString((String) value);
} else {
writeValue(value);
}
}
zero();
zero();
}
} | java | private void write(JSONArray jsonarray) throws JSONException {
// JSONzip has three encodings for arrays:
// The array is empty (zipEmptyArray).
// First value in the array is a string (zipArrayString).
// First value in the array is not a string (zipArrayValue).
boolean stringy = false;
int length = jsonarray.length();
if (length == 0) {
write(zipEmptyArray, 3);
} else {
Object value = jsonarray.get(0);
if (value == null) {
value = JSONObject.NULL;
}
if (value instanceof String) {
stringy = true;
write(zipArrayString, 3);
writeString((String) value);
} else {
write(zipArrayValue, 3);
writeValue(value);
}
for (int i = 1; i < length; i += 1) {
if (probe) {
log();
}
value = jsonarray.get(i);
if (value == null) {
value = JSONObject.NULL;
}
if (value instanceof String != stringy) {
zero();
}
one();
if (value instanceof String) {
writeString((String) value);
} else {
writeValue(value);
}
}
zero();
zero();
}
} | [
"private",
"void",
"write",
"(",
"JSONArray",
"jsonarray",
")",
"throws",
"JSONException",
"{",
"// JSONzip has three encodings for arrays:",
"// The array is empty (zipEmptyArray).",
"// First value in the array is a string (zipArrayString).",
"// First value in the array is not a string ... | Write a JSON Array.
@param jsonarray The JSONArray to write.
@throws JSONException If the write fails. | [
"Write",
"a",
"JSON",
"Array",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java#L214-L260 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java | Zipper.writeJSON | @SuppressWarnings({ "rawtypes", "unchecked" })
private void writeJSON(Object value) throws JSONException {
if (JSONObject.NULL.equals(value)) {
write(zipNull, 3);
} else if (Boolean.FALSE.equals(value)) {
write(zipFalse, 3);
} else if (Boolean.TRUE.equals(value)) {
write(zipTrue, 3);
} else {
if (value instanceof Map) {
value = new JSONObject((Map) value);
} else if (value instanceof Collection) {
value = new JSONArray((Collection) value);
} else if (value.getClass().isArray()) {
value = new JSONArray(value);
}
if (value instanceof JSONObject) {
write((JSONObject) value);
} else if (value instanceof JSONArray) {
write((JSONArray) value);
} else {
throw new JSONException("Unrecognized object");
}
}
} | java | @SuppressWarnings({ "rawtypes", "unchecked" })
private void writeJSON(Object value) throws JSONException {
if (JSONObject.NULL.equals(value)) {
write(zipNull, 3);
} else if (Boolean.FALSE.equals(value)) {
write(zipFalse, 3);
} else if (Boolean.TRUE.equals(value)) {
write(zipTrue, 3);
} else {
if (value instanceof Map) {
value = new JSONObject((Map) value);
} else if (value instanceof Collection) {
value = new JSONArray((Collection) value);
} else if (value.getClass().isArray()) {
value = new JSONArray(value);
}
if (value instanceof JSONObject) {
write((JSONObject) value);
} else if (value instanceof JSONArray) {
write((JSONArray) value);
} else {
throw new JSONException("Unrecognized object");
}
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"rawtypes\"",
",",
"\"unchecked\"",
"}",
")",
"private",
"void",
"writeJSON",
"(",
"Object",
"value",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"JSONObject",
".",
"NULL",
".",
"equals",
"(",
"value",
")",
")",
"{"... | Write a JSON value.
@param value
One of these types: JSONObject, JSONArray (or Map or
Collection or array), Number (or Integer or Long or Double),
or String, or Boolean, or JSONObject.NULL, or null.
@throws JSONException | [
"Write",
"a",
"JSON",
"value",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java#L271-L295 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java | Zipper.writeName | private void writeName(String name) throws JSONException {
// If this name has already been registered, then emit its integer and
// increment its usage count.
Kim kim = new Kim(name);
int integer = this.namekeep.find(kim);
if (integer != none) {
one();
write(integer, this.namekeep);
} else {
// Otherwise, emit the string with Huffman encoding, and register it.
zero();
write(kim, this.namehuff, this.namehuffext);
write(end, namehuff);
this.namekeep.register(kim);
}
} | java | private void writeName(String name) throws JSONException {
// If this name has already been registered, then emit its integer and
// increment its usage count.
Kim kim = new Kim(name);
int integer = this.namekeep.find(kim);
if (integer != none) {
one();
write(integer, this.namekeep);
} else {
// Otherwise, emit the string with Huffman encoding, and register it.
zero();
write(kim, this.namehuff, this.namehuffext);
write(end, namehuff);
this.namekeep.register(kim);
}
} | [
"private",
"void",
"writeName",
"(",
"String",
"name",
")",
"throws",
"JSONException",
"{",
"// If this name has already been registered, then emit its integer and",
"// increment its usage count.",
"Kim",
"kim",
"=",
"new",
"Kim",
"(",
"name",
")",
";",
"int",
"integer",... | Write the name of an object property. Names have their own Keep and
Huffman encoder because they are expected to be a more restricted set.
@param name The name string.
@throws JSONException | [
"Write",
"the",
"name",
"of",
"an",
"object",
"property",
".",
"Names",
"have",
"their",
"own",
"Keep",
"and",
"Huffman",
"encoder",
"because",
"they",
"are",
"expected",
"to",
"be",
"a",
"more",
"restricted",
"set",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java#L304-L323 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java | Zipper.write | private void write(JSONObject jsonobject) throws JSONException {
// JSONzip has two encodings for objects: Empty Objects (zipEmptyObject) and
// non-empty objects (zipObject).
boolean first = true;
Iterator<String> keys = jsonobject.keys();
while (keys.hasNext()) {
if (probe) {
log();
}
Object key = keys.next();
if (key instanceof String) {
if (first) {
first = false;
write(zipObject, 3);
} else {
one();
}
writeName((String) key);
Object value = jsonobject.get((String) key);
if (value instanceof String) {
zero();
writeString((String) value);
} else {
one();
writeValue(value);
}
}
}
if (first) {
write(zipEmptyObject, 3);
} else {
zero();
}
} | java | private void write(JSONObject jsonobject) throws JSONException {
// JSONzip has two encodings for objects: Empty Objects (zipEmptyObject) and
// non-empty objects (zipObject).
boolean first = true;
Iterator<String> keys = jsonobject.keys();
while (keys.hasNext()) {
if (probe) {
log();
}
Object key = keys.next();
if (key instanceof String) {
if (first) {
first = false;
write(zipObject, 3);
} else {
one();
}
writeName((String) key);
Object value = jsonobject.get((String) key);
if (value instanceof String) {
zero();
writeString((String) value);
} else {
one();
writeValue(value);
}
}
}
if (first) {
write(zipEmptyObject, 3);
} else {
zero();
}
} | [
"private",
"void",
"write",
"(",
"JSONObject",
"jsonobject",
")",
"throws",
"JSONException",
"{",
"// JSONzip has two encodings for objects: Empty Objects (zipEmptyObject) and",
"// non-empty objects (zipObject).",
"boolean",
"first",
"=",
"true",
";",
"Iterator",
"<",
"String"... | Write a JSON object.
@param jsonobject The JSONObject to be written.
@throws JSONException | [
"Write",
"a",
"JSON",
"object",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java#L331-L366 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java | Zipper.writeValue | private void writeValue(Object value) throws JSONException {
if (value instanceof Number) {
String string = JSONObject.numberToString((Number) value);
int integer = this.valuekeep.find(string);
if (integer != none) {
write(2, 2);
write(integer, this.valuekeep);
return;
}
if (value instanceof Integer || value instanceof Long) {
long longer = ((Number) value).longValue();
if (longer >= 0 && longer < int14) {
write(0, 2);
if (longer < int4) {
zero();
write((int) longer, 4);
return;
}
one();
if (longer < int7) {
zero();
write((int)(longer - int4), 7);
return;
}
one();
write((int)(longer - int7), 14);
return;
}
}
write(1, 2);
for (int i = 0; i < string.length(); i += 1) {
write(bcd(string.charAt(i)), 4);
}
write(endOfNumber, 4);
this.valuekeep.register(string);
} else {
write(3, 2);
writeJSON(value);
}
} | java | private void writeValue(Object value) throws JSONException {
if (value instanceof Number) {
String string = JSONObject.numberToString((Number) value);
int integer = this.valuekeep.find(string);
if (integer != none) {
write(2, 2);
write(integer, this.valuekeep);
return;
}
if (value instanceof Integer || value instanceof Long) {
long longer = ((Number) value).longValue();
if (longer >= 0 && longer < int14) {
write(0, 2);
if (longer < int4) {
zero();
write((int) longer, 4);
return;
}
one();
if (longer < int7) {
zero();
write((int)(longer - int4), 7);
return;
}
one();
write((int)(longer - int7), 14);
return;
}
}
write(1, 2);
for (int i = 0; i < string.length(); i += 1) {
write(bcd(string.charAt(i)), 4);
}
write(endOfNumber, 4);
this.valuekeep.register(string);
} else {
write(3, 2);
writeJSON(value);
}
} | [
"private",
"void",
"writeValue",
"(",
"Object",
"value",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"value",
"instanceof",
"Number",
")",
"{",
"String",
"string",
"=",
"JSONObject",
".",
"numberToString",
"(",
"(",
"Number",
")",
"value",
")",
";",
"i... | Write a value.
@param value
One of these types: Boolean, Number, etc.
@throws JSONException | [
"Write",
"a",
"value",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Zipper.java#L411-L450 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/extractor/KeywordsExtractor.java | KeywordsExtractor.filter | protected boolean filter(IWord word)
{
/*
* normally word with length less than 2 will
* be something, well could be ignored
*/
if ( word.getValue().length() < 2 ) {
return false;
}
//type check
switch ( word.getType() ) {
//case IWord.T_BASIC_LATIN:
case IWord.T_LETTER_NUMBER:
case IWord.T_OTHER_NUMBER:
case IWord.T_CJK_PINYIN:
case IWord.T_PUNCTUATION:
case IWord.T_UNRECOGNIZE_WORD: {
return false;
}
}
//part of speech check
String[] poss = word.getPartSpeech();
if ( poss == null ) return true;
char pos = poss[0].charAt(0);
switch ( pos ) {
case 'e': {
if ( poss[0].equals("en") ) return true;
return false;
}
case 'm': {
if ( poss[0].equals("mix") ) return true;
return false;
}
case 'q':
case 'b':
case 'r':
case 'z':
case 'p':
case 'c':
case 'u':
case 'y':
case 'd': //@date 2015-11-23
case 'o':
case 'h':
case 'k':
case 'g':
case 'x':
case 'w': {
return false;
}
/*case 'n':
case 'v':
case 'a':
case 't':
case 's':
case 'f':
{
return true;
}*/
}
return true;
} | java | protected boolean filter(IWord word)
{
/*
* normally word with length less than 2 will
* be something, well could be ignored
*/
if ( word.getValue().length() < 2 ) {
return false;
}
//type check
switch ( word.getType() ) {
//case IWord.T_BASIC_LATIN:
case IWord.T_LETTER_NUMBER:
case IWord.T_OTHER_NUMBER:
case IWord.T_CJK_PINYIN:
case IWord.T_PUNCTUATION:
case IWord.T_UNRECOGNIZE_WORD: {
return false;
}
}
//part of speech check
String[] poss = word.getPartSpeech();
if ( poss == null ) return true;
char pos = poss[0].charAt(0);
switch ( pos ) {
case 'e': {
if ( poss[0].equals("en") ) return true;
return false;
}
case 'm': {
if ( poss[0].equals("mix") ) return true;
return false;
}
case 'q':
case 'b':
case 'r':
case 'z':
case 'p':
case 'c':
case 'u':
case 'y':
case 'd': //@date 2015-11-23
case 'o':
case 'h':
case 'k':
case 'g':
case 'x':
case 'w': {
return false;
}
/*case 'n':
case 'v':
case 'a':
case 't':
case 's':
case 'f':
{
return true;
}*/
}
return true;
} | [
"protected",
"boolean",
"filter",
"(",
"IWord",
"word",
")",
"{",
"/*\n * normally word with length less than 2 will\n * be something, well could be ignored \n */",
"if",
"(",
"word",
".",
"getValue",
"(",
")",
".",
"length",
"(",
")",
"<",
"2",
")"... | word item filter
@param word | [
"word",
"item",
"filter"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/extractor/KeywordsExtractor.java#L39-L105 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java | Controller.init | private void init()
{
//request.setCharacterEncoding(setting.getCharset());
response.setCharacterEncoding(config.getCharset());
response.setContentType("text/html;charset="+config.getCharset());
response.setStatus(HttpServletResponse.SC_OK);
} | java | private void init()
{
//request.setCharacterEncoding(setting.getCharset());
response.setCharacterEncoding(config.getCharset());
response.setContentType("text/html;charset="+config.getCharset());
response.setStatus(HttpServletResponse.SC_OK);
} | [
"private",
"void",
"init",
"(",
")",
"{",
"//request.setCharacterEncoding(setting.getCharset());",
"response",
".",
"setCharacterEncoding",
"(",
"config",
".",
"getCharset",
"(",
")",
")",
";",
"response",
".",
"setContentType",
"(",
"\"text/html;charset=\"",
"+",
"co... | request initialize work | [
"request",
"initialize",
"work"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java#L93-L99 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java | Controller.getInt | public int getInt(String name)
{
int val = 0;
try {
val = Integer.valueOf(request.getParameter(name));
} catch (NumberFormatException e) {}
return val;
} | java | public int getInt(String name)
{
int val = 0;
try {
val = Integer.valueOf(request.getParameter(name));
} catch (NumberFormatException e) {}
return val;
} | [
"public",
"int",
"getInt",
"(",
"String",
"name",
")",
"{",
"int",
"val",
"=",
"0",
";",
"try",
"{",
"val",
"=",
"Integer",
".",
"valueOf",
"(",
"request",
".",
"getParameter",
"(",
"name",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"... | get a integer arguments
@param name
@return int | [
"get",
"a",
"integer",
"arguments"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java#L146-L154 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java | Controller.getFloat | public float getFloat(String name)
{
float fval = 0F;
try {
fval = Float.valueOf(request.getParameter(name));
} catch (NumberFormatException e) {}
return fval;
} | java | public float getFloat(String name)
{
float fval = 0F;
try {
fval = Float.valueOf(request.getParameter(name));
} catch (NumberFormatException e) {}
return fval;
} | [
"public",
"float",
"getFloat",
"(",
"String",
"name",
")",
"{",
"float",
"fval",
"=",
"0F",
";",
"try",
"{",
"fval",
"=",
"Float",
".",
"valueOf",
"(",
"request",
".",
"getParameter",
"(",
"name",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatExceptio... | get a float arguments
@param name
@return float | [
"get",
"a",
"float",
"arguments"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java#L169-L177 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java | Controller.getLong | public long getLong(String name)
{
long val = 0;
try {
val = Long.valueOf(request.getParameter(name));
} catch (NumberFormatException e) {}
return val;
} | java | public long getLong(String name)
{
long val = 0;
try {
val = Long.valueOf(request.getParameter(name));
} catch (NumberFormatException e) {}
return val;
} | [
"public",
"long",
"getLong",
"(",
"String",
"name",
")",
"{",
"long",
"val",
"=",
"0",
";",
"try",
"{",
"val",
"=",
"Long",
".",
"valueOf",
"(",
"request",
".",
"getParameter",
"(",
"name",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"... | get a long argument
@param name
@return long | [
"get",
"a",
"long",
"argument"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java#L192-L200 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java | Controller.getDouble | public double getDouble(String name)
{
double val = 0;
try {
val = Double.valueOf(request.getParameter(name));
} catch (NumberFormatException e) {}
return val;
} | java | public double getDouble(String name)
{
double val = 0;
try {
val = Double.valueOf(request.getParameter(name));
} catch (NumberFormatException e) {}
return val;
} | [
"public",
"double",
"getDouble",
"(",
"String",
"name",
")",
"{",
"double",
"val",
"=",
"0",
";",
"try",
"{",
"val",
"=",
"Double",
".",
"valueOf",
"(",
"request",
".",
"getParameter",
"(",
"name",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatExcepti... | get a double argument
@param name
@return double | [
"get",
"a",
"double",
"argument"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java#L215-L223 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java | Controller.getBoolean | public boolean getBoolean(String name)
{
boolean val = false;
try {
val = Boolean.valueOf(request.getParameter(name));
} catch (NumberFormatException e) {}
return val;
} | java | public boolean getBoolean(String name)
{
boolean val = false;
try {
val = Boolean.valueOf(request.getParameter(name));
} catch (NumberFormatException e) {}
return val;
} | [
"public",
"boolean",
"getBoolean",
"(",
"String",
"name",
")",
"{",
"boolean",
"val",
"=",
"false",
";",
"try",
"{",
"val",
"=",
"Boolean",
".",
"valueOf",
"(",
"request",
".",
"getParameter",
"(",
"name",
")",
")",
";",
"}",
"catch",
"(",
"NumberForma... | get a boolean argument
@param name
@return boolean | [
"get",
"a",
"boolean",
"argument"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java#L238-L246 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java | Controller.getRawData | public byte[] getRawData() throws IOException
{
int contentLength = request.getContentLength();
if( contentLength<0 ) {
return null;
}
byte[] buffer = new byte[contentLength];
ServletInputStream is = request.getInputStream();
for (int i = 0; i < contentLength; ) {
int rLen = is.read(buffer, i, contentLength - i);
if ( rLen == -1 ) {
break;
}
i += rLen;
}
return buffer;
} | java | public byte[] getRawData() throws IOException
{
int contentLength = request.getContentLength();
if( contentLength<0 ) {
return null;
}
byte[] buffer = new byte[contentLength];
ServletInputStream is = request.getInputStream();
for (int i = 0; i < contentLength; ) {
int rLen = is.read(buffer, i, contentLength - i);
if ( rLen == -1 ) {
break;
}
i += rLen;
}
return buffer;
} | [
"public",
"byte",
"[",
"]",
"getRawData",
"(",
")",
"throws",
"IOException",
"{",
"int",
"contentLength",
"=",
"request",
".",
"getContentLength",
"(",
")",
";",
"if",
"(",
"contentLength",
"<",
"0",
")",
"{",
"return",
"null",
";",
"}",
"byte",
"[",
"... | get the original raw data
@return byte[]
@throws IOException | [
"get",
"the",
"original",
"raw",
"data"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java#L274-L293 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java | Controller.getRawDataAsString | public String getRawDataAsString() throws IOException
{
byte[] buffer = getRawData();
if ( buffer == null ) {
return null;
}
String encoding = request.getCharacterEncoding();
if ( encoding == null ) {
encoding = "utf-8";
}
return new String(buffer, encoding);
} | java | public String getRawDataAsString() throws IOException
{
byte[] buffer = getRawData();
if ( buffer == null ) {
return null;
}
String encoding = request.getCharacterEncoding();
if ( encoding == null ) {
encoding = "utf-8";
}
return new String(buffer, encoding);
} | [
"public",
"String",
"getRawDataAsString",
"(",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"getRawData",
"(",
")",
";",
"if",
"(",
"buffer",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"String",
"encoding",
"=",
"request",... | get the original request raw data as String
@return String
@throws IOException | [
"get",
"the",
"original",
"request",
"raw",
"data",
"as",
"String"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java#L301-L314 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java | Controller.getRawDataAsJson | public JSONObject getRawDataAsJson() throws IOException
{
String input = getRawDataAsString();
if ( input == null ) {
return null;
}
return new JSONObject(input);
} | java | public JSONObject getRawDataAsJson() throws IOException
{
String input = getRawDataAsString();
if ( input == null ) {
return null;
}
return new JSONObject(input);
} | [
"public",
"JSONObject",
"getRawDataAsJson",
"(",
")",
"throws",
"IOException",
"{",
"String",
"input",
"=",
"getRawDataAsString",
"(",
")",
";",
"if",
"(",
"input",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"JSONObject",
"(",
"in... | get the original request raw data as json
@return JSONObject
@throws IOException | [
"get",
"the",
"original",
"request",
"raw",
"data",
"as",
"json"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/Controller.java#L322-L330 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/JSONzip.java | JSONzip.logchar | static void logchar(int integer, int width) {
if (integer > ' ' && integer <= '}') {
log("'" + (char) integer + "':" + width + " ");
} else {
log(integer, width);
}
} | java | static void logchar(int integer, int width) {
if (integer > ' ' && integer <= '}') {
log("'" + (char) integer + "':" + width + " ");
} else {
log(integer, width);
}
} | [
"static",
"void",
"logchar",
"(",
"int",
"integer",
",",
"int",
"width",
")",
"{",
"if",
"(",
"integer",
">",
"'",
"'",
"&&",
"integer",
"<=",
"'",
"'",
")",
"{",
"log",
"(",
"\"'\"",
"+",
"(",
"char",
")",
"integer",
"+",
"\"':\"",
"+",
"width",... | Write a character or its code to the console.
@param integer The charcode to be written to the log.
@param width The width of the charcode in bits. | [
"Write",
"a",
"character",
"or",
"its",
"code",
"to",
"the",
"console",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/JSONzip.java#L231-L237 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/JSONzip.java | JSONzip.postMortem | public boolean postMortem(PostMortem pm) {
JSONzip that = (JSONzip) pm;
return this.namehuff.postMortem(that.namehuff)
&& this.namekeep.postMortem(that.namekeep)
&& this.stringkeep.postMortem(that.stringkeep)
&& this.stringhuff.postMortem(that.stringhuff)
&& this.valuekeep.postMortem(that.valuekeep);
} | java | public boolean postMortem(PostMortem pm) {
JSONzip that = (JSONzip) pm;
return this.namehuff.postMortem(that.namehuff)
&& this.namekeep.postMortem(that.namekeep)
&& this.stringkeep.postMortem(that.stringkeep)
&& this.stringhuff.postMortem(that.stringhuff)
&& this.valuekeep.postMortem(that.valuekeep);
} | [
"public",
"boolean",
"postMortem",
"(",
"PostMortem",
"pm",
")",
"{",
"JSONzip",
"that",
"=",
"(",
"JSONzip",
")",
"pm",
";",
"return",
"this",
".",
"namehuff",
".",
"postMortem",
"(",
"that",
".",
"namehuff",
")",
"&&",
"this",
".",
"namekeep",
".",
"... | This method is used for testing the implementation of JSONzip. It is not
suitable for any other purpose. It is used to compare a Compressor and a
Decompressor, verifying that the data structures that were built during
zipping and unzipping were the same.
@return true if the structures match. | [
"This",
"method",
"is",
"used",
"for",
"testing",
"the",
"implementation",
"of",
"JSONzip",
".",
"It",
"is",
"not",
"suitable",
"for",
"any",
"other",
"purpose",
".",
"It",
"is",
"used",
"to",
"compare",
"a",
"Compressor",
"and",
"a",
"Decompressor",
"veri... | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/JSONzip.java#L247-L254 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Huff.java | Huff.postMortem | public boolean postMortem(PostMortem pm) {
// Go through every integer in the domain, generating its bit sequence, and
// then prove that that bit sequence produces the same integer.
for (int integer = 0; integer < this.domain; integer += 1) {
if (!postMortem(integer)) {
JSONzip.log("\nBad huff ");
JSONzip.logchar(integer, integer);
return false;
}
}
return this.table.postMortem(((Huff) pm).table);
} | java | public boolean postMortem(PostMortem pm) {
// Go through every integer in the domain, generating its bit sequence, and
// then prove that that bit sequence produces the same integer.
for (int integer = 0; integer < this.domain; integer += 1) {
if (!postMortem(integer)) {
JSONzip.log("\nBad huff ");
JSONzip.logchar(integer, integer);
return false;
}
}
return this.table.postMortem(((Huff) pm).table);
} | [
"public",
"boolean",
"postMortem",
"(",
"PostMortem",
"pm",
")",
"{",
"// Go through every integer in the domain, generating its bit sequence, and",
"// then prove that that bit sequence produces the same integer.",
"for",
"(",
"int",
"integer",
"=",
"0",
";",
"integer",
"<",
"... | Compare two Huffman tables. | [
"Compare",
"two",
"Huffman",
"tables",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Huff.java#L302-L315 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Huff.java | Huff.read | public int read(BitReader bitreader) throws JSONException {
try {
this.width = 0;
Symbol symbol = this.table;
while (symbol.integer == none) {
this.width += 1;
symbol = bitreader.bit() ? symbol.one : symbol.zero;
}
tick(symbol.integer);
if (JSONzip.probe) {
JSONzip.logchar(symbol.integer, this.width);
}
return symbol.integer;
} catch (Throwable e) {
throw new JSONException(e);
}
} | java | public int read(BitReader bitreader) throws JSONException {
try {
this.width = 0;
Symbol symbol = this.table;
while (symbol.integer == none) {
this.width += 1;
symbol = bitreader.bit() ? symbol.one : symbol.zero;
}
tick(symbol.integer);
if (JSONzip.probe) {
JSONzip.logchar(symbol.integer, this.width);
}
return symbol.integer;
} catch (Throwable e) {
throw new JSONException(e);
}
} | [
"public",
"int",
"read",
"(",
"BitReader",
"bitreader",
")",
"throws",
"JSONException",
"{",
"try",
"{",
"this",
".",
"width",
"=",
"0",
";",
"Symbol",
"symbol",
"=",
"this",
".",
"table",
";",
"while",
"(",
"symbol",
".",
"integer",
"==",
"none",
")",... | Read bits until a symbol can be identified. The weight of the read
symbol will be incremented.
@param bitreader
The source of bits.
@return The integer value of the symbol.
@throws JSONException | [
"Read",
"bits",
"until",
"a",
"symbol",
"can",
"be",
"identified",
".",
"The",
"weight",
"of",
"the",
"read",
"symbol",
"will",
"be",
"incremented",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Huff.java#L326-L342 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Huff.java | Huff.write | private void write(Symbol symbol, BitWriter bitwriter)
throws JSONException {
try {
Symbol back = symbol.back;
if (back != null) {
this.width += 1;
write(back, bitwriter);
if (back.zero == symbol) {
bitwriter.zero();
} else {
bitwriter.one();
}
}
} catch (Throwable e) {
throw new JSONException(e);
}
} | java | private void write(Symbol symbol, BitWriter bitwriter)
throws JSONException {
try {
Symbol back = symbol.back;
if (back != null) {
this.width += 1;
write(back, bitwriter);
if (back.zero == symbol) {
bitwriter.zero();
} else {
bitwriter.one();
}
}
} catch (Throwable e) {
throw new JSONException(e);
}
} | [
"private",
"void",
"write",
"(",
"Symbol",
"symbol",
",",
"BitWriter",
"bitwriter",
")",
"throws",
"JSONException",
"{",
"try",
"{",
"Symbol",
"back",
"=",
"symbol",
".",
"back",
";",
"if",
"(",
"back",
"!=",
"null",
")",
"{",
"this",
".",
"width",
"+=... | Recur from a symbol back, emitting bits. We recur before emitting to
make the bits come out in the right order.
@param symbol
The symbol to write.
@param bitwriter
The bitwriter to write it to.
@throws JSONException | [
"Recur",
"from",
"a",
"symbol",
"back",
"emitting",
"bits",
".",
"We",
"recur",
"before",
"emitting",
"to",
"make",
"the",
"bits",
"come",
"out",
"in",
"the",
"right",
"order",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Huff.java#L368-L384 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Huff.java | Huff.write | public void write(int value, BitWriter bitwriter) throws JSONException {
this.width = 0;
write(this.symbols[value], bitwriter);
tick(value);
if (JSONzip.probe) {
JSONzip.logchar(value, this.width);
}
} | java | public void write(int value, BitWriter bitwriter) throws JSONException {
this.width = 0;
write(this.symbols[value], bitwriter);
tick(value);
if (JSONzip.probe) {
JSONzip.logchar(value, this.width);
}
} | [
"public",
"void",
"write",
"(",
"int",
"value",
",",
"BitWriter",
"bitwriter",
")",
"throws",
"JSONException",
"{",
"this",
".",
"width",
"=",
"0",
";",
"write",
"(",
"this",
".",
"symbols",
"[",
"value",
"]",
",",
"bitwriter",
")",
";",
"tick",
"(",
... | Write the bits corresponding to a symbol. The weight of the symbol will
be incremented.
@param value
The number of the symbol to write
@param bitwriter
The destination of the bits.
@throws JSONException | [
"Write",
"the",
"bits",
"corresponding",
"to",
"a",
"symbol",
".",
"The",
"weight",
"of",
"the",
"symbol",
"will",
"be",
"incremented",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Huff.java#L396-L403 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Unzipper.java | Unzipper.bit | private boolean bit() throws JSONException {
boolean value;
try {
value = this.bitreader.bit();
if (probe) {
log(value ? 1 : 0);
}
return value;
} catch (Throwable e) {
throw new JSONException(e);
}
} | java | private boolean bit() throws JSONException {
boolean value;
try {
value = this.bitreader.bit();
if (probe) {
log(value ? 1 : 0);
}
return value;
} catch (Throwable e) {
throw new JSONException(e);
}
} | [
"private",
"boolean",
"bit",
"(",
")",
"throws",
"JSONException",
"{",
"boolean",
"value",
";",
"try",
"{",
"value",
"=",
"this",
".",
"bitreader",
".",
"bit",
"(",
")",
";",
"if",
"(",
"probe",
")",
"{",
"log",
"(",
"value",
"?",
"1",
":",
"0",
... | Read one bit.
@return true if 1, false if 0.
@throws JSONException | [
"Read",
"one",
"bit",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Unzipper.java#L64-L76 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Unzipper.java | Unzipper.getAndTick | private Object getAndTick(Keep keep, BitReader bitreader)
throws JSONException {
try {
int width = keep.bitsize();
int integer = bitreader.read(width);
Object value = keep.value(integer);
if (JSONzip.probe) {
JSONzip.log("\"" + value + "\"");
JSONzip.log(integer, width);
}
if (integer >= keep.length) {
throw new JSONException("Deep error.");
}
keep.tick(integer);
return value;
} catch (Throwable e) {
throw new JSONException(e);
}
} | java | private Object getAndTick(Keep keep, BitReader bitreader)
throws JSONException {
try {
int width = keep.bitsize();
int integer = bitreader.read(width);
Object value = keep.value(integer);
if (JSONzip.probe) {
JSONzip.log("\"" + value + "\"");
JSONzip.log(integer, width);
}
if (integer >= keep.length) {
throw new JSONException("Deep error.");
}
keep.tick(integer);
return value;
} catch (Throwable e) {
throw new JSONException(e);
}
} | [
"private",
"Object",
"getAndTick",
"(",
"Keep",
"keep",
",",
"BitReader",
"bitreader",
")",
"throws",
"JSONException",
"{",
"try",
"{",
"int",
"width",
"=",
"keep",
".",
"bitsize",
"(",
")",
";",
"int",
"integer",
"=",
"bitreader",
".",
"read",
"(",
"wid... | Read enough bits to obtain an integer from the keep, and increase that
integer's weight.
@param keep The keep providing the context.
@param bitreader The bitreader that is the source of bits.
@return The value associated with the number.
@throws JSONException | [
"Read",
"enough",
"bits",
"to",
"obtain",
"an",
"integer",
"from",
"the",
"keep",
"and",
"increase",
"that",
"integer",
"s",
"weight",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Unzipper.java#L87-L105 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Unzipper.java | Unzipper.read | private int read(int width) throws JSONException {
try {
int value = this.bitreader.read(width);
if (probe) {
log(value, width);
}
return value;
} catch (Throwable e) {
throw new JSONException(e);
}
} | java | private int read(int width) throws JSONException {
try {
int value = this.bitreader.read(width);
if (probe) {
log(value, width);
}
return value;
} catch (Throwable e) {
throw new JSONException(e);
}
} | [
"private",
"int",
"read",
"(",
"int",
"width",
")",
"throws",
"JSONException",
"{",
"try",
"{",
"int",
"value",
"=",
"this",
".",
"bitreader",
".",
"read",
"(",
"width",
")",
";",
"if",
"(",
"probe",
")",
"{",
"log",
"(",
"value",
",",
"width",
")"... | Read an integer, specifying its width in bits.
@param width
0 to 32.
@return An unsigned integer.
@throws JSONException | [
"Read",
"an",
"integer",
"specifying",
"its",
"width",
"in",
"bits",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Unzipper.java#L131-L141 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Unzipper.java | Unzipper.read | private String read(Huff huff, Huff ext, Keep keep) throws JSONException {
Kim kim;
int at = 0;
int allocation = 256;
byte[] bytes = new byte[allocation];
if (bit()) {
return getAndTick(keep, this.bitreader).toString();
}
while (true) {
if (at >= allocation) {
allocation *= 2;
bytes = java.util.Arrays.copyOf(bytes, allocation);
}
int c = huff.read(this.bitreader);
if (c == end) {
break;
}
while ((c & 128) == 128) {
bytes[at] = (byte) c;
at += 1;
c = ext.read(this.bitreader);
}
bytes[at] = (byte) c;
at += 1;
}
if (at == 0) {
return "";
}
kim = new Kim(bytes, at);
keep.register(kim);
return kim.toString();
} | java | private String read(Huff huff, Huff ext, Keep keep) throws JSONException {
Kim kim;
int at = 0;
int allocation = 256;
byte[] bytes = new byte[allocation];
if (bit()) {
return getAndTick(keep, this.bitreader).toString();
}
while (true) {
if (at >= allocation) {
allocation *= 2;
bytes = java.util.Arrays.copyOf(bytes, allocation);
}
int c = huff.read(this.bitreader);
if (c == end) {
break;
}
while ((c & 128) == 128) {
bytes[at] = (byte) c;
at += 1;
c = ext.read(this.bitreader);
}
bytes[at] = (byte) c;
at += 1;
}
if (at == 0) {
return "";
}
kim = new Kim(bytes, at);
keep.register(kim);
return kim.toString();
} | [
"private",
"String",
"read",
"(",
"Huff",
"huff",
",",
"Huff",
"ext",
",",
"Keep",
"keep",
")",
"throws",
"JSONException",
"{",
"Kim",
"kim",
";",
"int",
"at",
"=",
"0",
";",
"int",
"allocation",
"=",
"256",
";",
"byte",
"[",
"]",
"bytes",
"=",
"ne... | Read Huffman encoded characters into a keep.
@param huff A Huffman decoder.
@param ext A Huffman decoder for the extended bytes.
@param keep The keep that will receive the kim.
@return The string that was read.
@throws JSONException | [
"Read",
"Huffman",
"encoded",
"characters",
"into",
"a",
"keep",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Unzipper.java#L151-L182 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Unzipper.java | Unzipper.readArray | private JSONArray readArray(boolean stringy) throws JSONException {
JSONArray jsonarray = new JSONArray();
jsonarray.put(stringy
? read(this.stringhuff, this.stringhuffext, this.stringkeep)
: readValue());
while (true) {
if (probe) {
log();
}
if (!bit()) {
if (!bit()) {
return jsonarray;
}
jsonarray.put(stringy
? readValue()
: read(this.stringhuff, this.stringhuffext,
this.stringkeep));
} else {
jsonarray.put(stringy
? read(this.stringhuff, this.stringhuffext,
this.stringkeep)
: readValue());
}
}
} | java | private JSONArray readArray(boolean stringy) throws JSONException {
JSONArray jsonarray = new JSONArray();
jsonarray.put(stringy
? read(this.stringhuff, this.stringhuffext, this.stringkeep)
: readValue());
while (true) {
if (probe) {
log();
}
if (!bit()) {
if (!bit()) {
return jsonarray;
}
jsonarray.put(stringy
? readValue()
: read(this.stringhuff, this.stringhuffext,
this.stringkeep));
} else {
jsonarray.put(stringy
? read(this.stringhuff, this.stringhuffext,
this.stringkeep)
: readValue());
}
}
} | [
"private",
"JSONArray",
"readArray",
"(",
"boolean",
"stringy",
")",
"throws",
"JSONException",
"{",
"JSONArray",
"jsonarray",
"=",
"new",
"JSONArray",
"(",
")",
";",
"jsonarray",
".",
"put",
"(",
"stringy",
"?",
"read",
"(",
"this",
".",
"stringhuff",
",",
... | Read a JSONArray.
@param stringy
true if the first element is a string.
@throws JSONException | [
"Read",
"a",
"JSONArray",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Unzipper.java#L191-L215 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Unzipper.java | Unzipper.readJSON | private Object readJSON() throws JSONException {
switch (read(3)) {
case zipObject:
return readObject();
case zipArrayString:
return readArray(true);
case zipArrayValue:
return readArray(false);
case zipEmptyObject:
return new JSONObject();
case zipEmptyArray:
return new JSONArray();
case zipTrue:
return Boolean.TRUE;
case zipFalse:
return Boolean.FALSE;
default:
return JSONObject.NULL;
}
} | java | private Object readJSON() throws JSONException {
switch (read(3)) {
case zipObject:
return readObject();
case zipArrayString:
return readArray(true);
case zipArrayValue:
return readArray(false);
case zipEmptyObject:
return new JSONObject();
case zipEmptyArray:
return new JSONArray();
case zipTrue:
return Boolean.TRUE;
case zipFalse:
return Boolean.FALSE;
default:
return JSONObject.NULL;
}
} | [
"private",
"Object",
"readJSON",
"(",
")",
"throws",
"JSONException",
"{",
"switch",
"(",
"read",
"(",
"3",
")",
")",
"{",
"case",
"zipObject",
":",
"return",
"readObject",
"(",
")",
";",
"case",
"zipArrayString",
":",
"return",
"readArray",
"(",
"true",
... | Read a JSON value. The type of value is determined by the next 3 bits.
@return The read value.
@throws JSONException | [
"Read",
"a",
"JSON",
"value",
".",
"The",
"type",
"of",
"value",
"is",
"determined",
"by",
"the",
"next",
"3",
"bits",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/zip/Unzipper.java#L223-L242 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/IntArrayList.java | IntArrayList.add | public void add( int val )
{
if ( size == items.length )
resize( items.length * 2 + 1 );
items[size++] = val;
} | java | public void add( int val )
{
if ( size == items.length )
resize( items.length * 2 + 1 );
items[size++] = val;
} | [
"public",
"void",
"add",
"(",
"int",
"val",
")",
"{",
"if",
"(",
"size",
"==",
"items",
".",
"length",
")",
"resize",
"(",
"items",
".",
"length",
"*",
"2",
"+",
"1",
")",
";",
"items",
"[",
"size",
"++",
"]",
"=",
"val",
";",
"}"
] | Append a new Integer to the end.
@param val | [
"Append",
"a",
"new",
"Integer",
"to",
"the",
"end",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/IntArrayList.java#L45-L50 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/IntArrayList.java | IntArrayList.remove | public void remove( int idx )
{
if ( idx < 0 || idx > size )
throw new IndexOutOfBoundsException();
int numMove = size - idx - 1;
if ( numMove > 0 )
System.arraycopy(items, idx + 1, items, idx, numMove);
size--;
} | java | public void remove( int idx )
{
if ( idx < 0 || idx > size )
throw new IndexOutOfBoundsException();
int numMove = size - idx - 1;
if ( numMove > 0 )
System.arraycopy(items, idx + 1, items, idx, numMove);
size--;
} | [
"public",
"void",
"remove",
"(",
"int",
"idx",
")",
"{",
"if",
"(",
"idx",
"<",
"0",
"||",
"idx",
">",
"size",
")",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"int",
"numMove",
"=",
"size",
"-",
"idx",
"-",
"1",
";",
"if",
"(",
"... | remove the element at the specified position
use System.arraycopy instead of a loop may be more efficient
@param idx | [
"remove",
"the",
"element",
"at",
"the",
"specified",
"position",
"use",
"System",
".",
"arraycopy",
"instead",
"of",
"a",
"loop",
"may",
"be",
"more",
"efficient"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/IntArrayList.java#L72-L80 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/JSONArray.java | JSONArray.put | public JSONArray put(int index, Map<String, Object> value) throws JSONException {
this.put(index, new JSONObject(value));
return this;
} | java | public JSONArray put(int index, Map<String, Object> value) throws JSONException {
this.put(index, new JSONObject(value));
return this;
} | [
"public",
"JSONArray",
"put",
"(",
"int",
"index",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"value",
")",
"throws",
"JSONException",
"{",
"this",
".",
"put",
"(",
"index",
",",
"new",
"JSONObject",
"(",
"value",
")",
")",
";",
"return",
"this",
... | Put a value in the JSONArray, where the value will be a JSONObject that
is produced from a Map.
@param index
The subscript.
@param value
The Map value.
@return this.
@throws JSONException
If the index is negative or if the the value is an invalid
number. | [
"Put",
"a",
"value",
"in",
"the",
"JSONArray",
"where",
"the",
"value",
"will",
"be",
"a",
"JSONObject",
"that",
"is",
"produced",
"from",
"a",
"Map",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/JSONArray.java#L770-L773 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/JSONArray.java | JSONArray.similar | public boolean similar(Object other) {
if (!(other instanceof JSONArray)) {
return false;
}
int len = this.length();
if (len != ((JSONArray)other).length()) {
return false;
}
for (int i = 0; i < len; i += 1) {
Object valueThis = this.get(i);
Object valueOther = ((JSONArray)other).get(i);
if (valueThis instanceof JSONObject) {
if (!((JSONObject)valueThis).similar(valueOther)) {
return false;
}
} else if (valueThis instanceof JSONArray) {
if (!((JSONArray)valueThis).similar(valueOther)) {
return false;
}
} else if (!valueThis.equals(valueOther)) {
return false;
}
}
return true;
} | java | public boolean similar(Object other) {
if (!(other instanceof JSONArray)) {
return false;
}
int len = this.length();
if (len != ((JSONArray)other).length()) {
return false;
}
for (int i = 0; i < len; i += 1) {
Object valueThis = this.get(i);
Object valueOther = ((JSONArray)other).get(i);
if (valueThis instanceof JSONObject) {
if (!((JSONObject)valueThis).similar(valueOther)) {
return false;
}
} else if (valueThis instanceof JSONArray) {
if (!((JSONArray)valueThis).similar(valueOther)) {
return false;
}
} else if (!valueThis.equals(valueOther)) {
return false;
}
}
return true;
} | [
"public",
"boolean",
"similar",
"(",
"Object",
"other",
")",
"{",
"if",
"(",
"!",
"(",
"other",
"instanceof",
"JSONArray",
")",
")",
"{",
"return",
"false",
";",
"}",
"int",
"len",
"=",
"this",
".",
"length",
"(",
")",
";",
"if",
"(",
"len",
"!=",
... | Determine if two JSONArrays are similar.
They must contain similar sequences.
@param other The other JSONArray
@return true if they are equal | [
"Determine",
"if",
"two",
"JSONArrays",
"are",
"similar",
".",
"They",
"must",
"contain",
"similar",
"sequences",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/JSONArray.java#L828-L852 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/Kim.java | Kim.copy | public int copy(byte[] bytes, int at) {
System.arraycopy(this.bytes, 0, bytes, at, this.length);
return at + this.length;
} | java | public int copy(byte[] bytes, int at) {
System.arraycopy(this.bytes, 0, bytes, at, this.length);
return at + this.length;
} | [
"public",
"int",
"copy",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"at",
")",
"{",
"System",
".",
"arraycopy",
"(",
"this",
".",
"bytes",
",",
"0",
",",
"bytes",
",",
"at",
",",
"this",
".",
"length",
")",
";",
"return",
"at",
"+",
"this",
".... | Copy the contents of this kim to a byte array.
@param bytes
A byte array of sufficient size.
@param at
The position within the byte array to take the byes.
@return The position immediately after the copy. | [
"Copy",
"the",
"contents",
"of",
"this",
"kim",
"to",
"a",
"byte",
"array",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/Kim.java#L292-L295 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/json/Kim.java | Kim.get | public int get(int at) throws JSONException {
if (at < 0 || at > this.length) {
throw new JSONException("Bad character at " + at);
}
return ((int) this.bytes[at]) & 0xFF;
} | java | public int get(int at) throws JSONException {
if (at < 0 || at > this.length) {
throw new JSONException("Bad character at " + at);
}
return ((int) this.bytes[at]) & 0xFF;
} | [
"public",
"int",
"get",
"(",
"int",
"at",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"at",
"<",
"0",
"||",
"at",
">",
"this",
".",
"length",
")",
"{",
"throw",
"new",
"JSONException",
"(",
"\"Bad character at \"",
"+",
"at",
")",
";",
"}",
"retu... | Get a byte from a kim.
@param at
The position of the byte. The first byte is at 0.
@return The byte.
@throws JSONException
if there is no byte at that position. | [
"Get",
"a",
"byte",
"from",
"a",
"kim",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/json/Kim.java#L328-L333 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.reset | public void reset( Reader input ) throws IOException
{
if ( input != null ) {
reader = new IPushbackReader(new BufferedReader(input));
}
idx = -1;
} | java | public void reset( Reader input ) throws IOException
{
if ( input != null ) {
reader = new IPushbackReader(new BufferedReader(input));
}
idx = -1;
} | [
"public",
"void",
"reset",
"(",
"Reader",
"input",
")",
"throws",
"IOException",
"{",
"if",
"(",
"input",
"!=",
"null",
")",
"{",
"reader",
"=",
"new",
"IPushbackReader",
"(",
"new",
"BufferedReader",
"(",
"input",
")",
")",
";",
"}",
"idx",
"=",
"-",
... | input stream and reader reset.
@param input
@throws IOException | [
"input",
"stream",
"and",
"reader",
"reset",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L99-L106 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.pushBack | protected void pushBack(String str)
{
char[] chars = str.toCharArray();
for ( int j = chars.length - 1; j >= 0; j-- ) {
reader.unread(chars[j]);
}
idx -= chars.length;
} | java | protected void pushBack(String str)
{
char[] chars = str.toCharArray();
for ( int j = chars.length - 1; j >= 0; j-- ) {
reader.unread(chars[j]);
}
idx -= chars.length;
} | [
"protected",
"void",
"pushBack",
"(",
"String",
"str",
")",
"{",
"char",
"[",
"]",
"chars",
"=",
"str",
".",
"toCharArray",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"chars",
".",
"length",
"-",
"1",
";",
"j",
">=",
"0",
";",
"j",
"--",
")",
... | push back a string to the stream
@param str | [
"push",
"back",
"a",
"string",
"to",
"the",
"stream"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L137-L144 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.getNextLatinWord | protected IWord getNextLatinWord(int c, int pos) throws IOException
{
/*
* clear or just return the English punctuation as
* a single word with PUNCTUATION type and part of speech
*/
if ( StringUtil.isEnPunctuation( c ) ) {
String str = String.valueOf((char)c);
if ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, str) ) {
return null;
}
IWord w = new Word(str, IWord.T_PUNCTUATION);
w.setPosition(pos);
w.setPartSpeech(IWord.PUNCTUATION);
return w;
}
IWord w = nextLatinWord(c, pos);
w.setPosition(pos);
/* @added: 2013-12-16
* check and do the secondary segmentation work.
* This will split 'qq2013' to 'qq, 2013'.
*/
if ( config.EN_SECOND_SEG
&& (ctrlMask & ISegment.START_SS_MASK) != 0 ) {
enSecondSeg(w, false);
}
if ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, w.getValue()) ) {
w = null; //Let gc do its work
return null;
}
if ( config.APPEND_CJK_SYN ) {
appendLatinSyn(w);
}
return w;
} | java | protected IWord getNextLatinWord(int c, int pos) throws IOException
{
/*
* clear or just return the English punctuation as
* a single word with PUNCTUATION type and part of speech
*/
if ( StringUtil.isEnPunctuation( c ) ) {
String str = String.valueOf((char)c);
if ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, str) ) {
return null;
}
IWord w = new Word(str, IWord.T_PUNCTUATION);
w.setPosition(pos);
w.setPartSpeech(IWord.PUNCTUATION);
return w;
}
IWord w = nextLatinWord(c, pos);
w.setPosition(pos);
/* @added: 2013-12-16
* check and do the secondary segmentation work.
* This will split 'qq2013' to 'qq, 2013'.
*/
if ( config.EN_SECOND_SEG
&& (ctrlMask & ISegment.START_SS_MASK) != 0 ) {
enSecondSeg(w, false);
}
if ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, w.getValue()) ) {
w = null; //Let gc do its work
return null;
}
if ( config.APPEND_CJK_SYN ) {
appendLatinSyn(w);
}
return w;
} | [
"protected",
"IWord",
"getNextLatinWord",
"(",
"int",
"c",
",",
"int",
"pos",
")",
"throws",
"IOException",
"{",
"/*\n * clear or just return the English punctuation as\n * a single word with PUNCTUATION type and part of speech \n */",
"if",
"(",
"StringUtil",
... | get the next Latin word from the current position of the input stream
@param c
@param pos
@return IWord could be null and that mean we reached a stop word
@throws IOException | [
"get",
"the",
"next",
"Latin",
"word",
"from",
"the",
"current",
"position",
"of",
"the",
"input",
"stream"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L587-L629 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.getNextMixedWord | protected IWord getNextMixedWord(char[] chars, int cjkidx) throws IOException
{
IStringBuffer buff = new IStringBuffer();
buff.clear().append(chars, cjkidx);
String tstring = buff.toString();
if ( ! dic.match(ILexicon.MIX_ASSIST_WORD, tstring) ) {
return null;
}
/*
* check and append the behind Latin string
*/
if ( behindLatin == null ) {
behindLatin = nextLatinString(readNext());
}
IWord wd = null;
buff.append(behindLatin);
tstring = buff.toString();
if ( dic.match(ILexicon.CJK_WORD, tstring) ) {
wd = dic.get(ILexicon.CJK_WORD, tstring);
}
if ( (ctrlMask & ISegment.CHECK_EC_MASK) != 0
|| dic.match(ILexicon.MIX_ASSIST_WORD, tstring) ) {
ialist.clear();
int chr = -1, j, mc = 0;
for ( j = 0; j < dic.mixSuffixLength && (chr = readNext()) != -1; j++ ) {
buff.append((char)chr);
ialist.add(chr);
tstring = buff.toString();
if ( dic.match(ILexicon.CJK_WORD, tstring) ) {
wd = dic.get(ILexicon.CJK_WORD, tstring);
mc = j + 1;
}
}
//push back the read chars.
for ( int i = j - 1; i >= mc; i-- ) {
pushBack(ialist.get(i));
}
}
buff.clear();
buff = null;
if ( wd != null ) {
behindLatin = null;
}
return wd;
} | java | protected IWord getNextMixedWord(char[] chars, int cjkidx) throws IOException
{
IStringBuffer buff = new IStringBuffer();
buff.clear().append(chars, cjkidx);
String tstring = buff.toString();
if ( ! dic.match(ILexicon.MIX_ASSIST_WORD, tstring) ) {
return null;
}
/*
* check and append the behind Latin string
*/
if ( behindLatin == null ) {
behindLatin = nextLatinString(readNext());
}
IWord wd = null;
buff.append(behindLatin);
tstring = buff.toString();
if ( dic.match(ILexicon.CJK_WORD, tstring) ) {
wd = dic.get(ILexicon.CJK_WORD, tstring);
}
if ( (ctrlMask & ISegment.CHECK_EC_MASK) != 0
|| dic.match(ILexicon.MIX_ASSIST_WORD, tstring) ) {
ialist.clear();
int chr = -1, j, mc = 0;
for ( j = 0; j < dic.mixSuffixLength && (chr = readNext()) != -1; j++ ) {
buff.append((char)chr);
ialist.add(chr);
tstring = buff.toString();
if ( dic.match(ILexicon.CJK_WORD, tstring) ) {
wd = dic.get(ILexicon.CJK_WORD, tstring);
mc = j + 1;
}
}
//push back the read chars.
for ( int i = j - 1; i >= mc; i-- ) {
pushBack(ialist.get(i));
}
}
buff.clear();
buff = null;
if ( wd != null ) {
behindLatin = null;
}
return wd;
} | [
"protected",
"IWord",
"getNextMixedWord",
"(",
"char",
"[",
"]",
"chars",
",",
"int",
"cjkidx",
")",
"throws",
"IOException",
"{",
"IStringBuffer",
"buff",
"=",
"new",
"IStringBuffer",
"(",
")",
";",
"buff",
".",
"clear",
"(",
")",
".",
"append",
"(",
"c... | get the next mixed word, CJK-English or CJK-English-CJK or whatever
@param chars
@param cjkidx
@return IWord or null for nothing found
@throws IOException | [
"get",
"the",
"next",
"mixed",
"word",
"CJK",
"-",
"English",
"or",
"CJK",
"-",
"English",
"-",
"CJK",
"or",
"whatever"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L639-L689 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.getNextPunctuationPairWord | protected IWord getNextPunctuationPairWord(int c, int pos) throws IOException
{
IWord w = null, w2 = null;
String text = getPairPunctuationText(c);
//handle the punctuation.
String str = String.valueOf((char)c);
if ( ! ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, str) ) ) {
w = new Word(str, IWord.T_PUNCTUATION);
w.setPartSpeech(IWord.PUNCTUATION);
w.setPosition(pos);
}
//handle the pair text.
if ( text != null && text.length() > 0
&& ! ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, text) ) ) {
w2 = new Word( text, ILexicon.CJK_WORD );
w2.setPartSpeech(IWord.PPT_POSPEECH);
w2.setPosition(pos+1);
if ( w == null ) w = w2;
else wordPool.add(w2);
}
/* here:
* 1. the punctuation is clear.
* 2. the pair text is null or being cleared.
* @date 2013-09-06
*/
if ( w == null && w2 == null ) {
return null;
}
return w;
} | java | protected IWord getNextPunctuationPairWord(int c, int pos) throws IOException
{
IWord w = null, w2 = null;
String text = getPairPunctuationText(c);
//handle the punctuation.
String str = String.valueOf((char)c);
if ( ! ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, str) ) ) {
w = new Word(str, IWord.T_PUNCTUATION);
w.setPartSpeech(IWord.PUNCTUATION);
w.setPosition(pos);
}
//handle the pair text.
if ( text != null && text.length() > 0
&& ! ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, text) ) ) {
w2 = new Word( text, ILexicon.CJK_WORD );
w2.setPartSpeech(IWord.PPT_POSPEECH);
w2.setPosition(pos+1);
if ( w == null ) w = w2;
else wordPool.add(w2);
}
/* here:
* 1. the punctuation is clear.
* 2. the pair text is null or being cleared.
* @date 2013-09-06
*/
if ( w == null && w2 == null ) {
return null;
}
return w;
} | [
"protected",
"IWord",
"getNextPunctuationPairWord",
"(",
"int",
"c",
",",
"int",
"pos",
")",
"throws",
"IOException",
"{",
"IWord",
"w",
"=",
"null",
",",
"w2",
"=",
"null",
";",
"String",
"text",
"=",
"getPairPunctuationText",
"(",
"c",
")",
";",
"//handl... | get the next punctuation pair word from the current position
of the input stream.
@param c
@param pos
@return IWord could be null and that mean we reached a stop word
@throws IOException | [
"get",
"the",
"next",
"punctuation",
"pair",
"word",
"from",
"the",
"current",
"position",
"of",
"the",
"input",
"stream",
"."
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L700-L736 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.appendWordFeatures | protected void appendWordFeatures( IWord word )
{
//add the pinyin to the pool
if ( config.APPEND_CJK_PINYIN
&& config.LOAD_CJK_PINYIN && word.getPinyin() != null ) {
IWord pinyin = new Word(word.getPinyin(), IWord.T_CJK_PINYIN);
pinyin.setPosition(word.getPosition());
pinyin.setEntity(word.getEntity());
wordPool.add(pinyin);
}
//add the synonyms words to the pool
if ( config.APPEND_CJK_SYN
&& config.LOAD_CJK_SYN && word.getSyn() != null ) {
SegKit.appendSynonyms(wordPool, word);
}
} | java | protected void appendWordFeatures( IWord word )
{
//add the pinyin to the pool
if ( config.APPEND_CJK_PINYIN
&& config.LOAD_CJK_PINYIN && word.getPinyin() != null ) {
IWord pinyin = new Word(word.getPinyin(), IWord.T_CJK_PINYIN);
pinyin.setPosition(word.getPosition());
pinyin.setEntity(word.getEntity());
wordPool.add(pinyin);
}
//add the synonyms words to the pool
if ( config.APPEND_CJK_SYN
&& config.LOAD_CJK_SYN && word.getSyn() != null ) {
SegKit.appendSynonyms(wordPool, word);
}
} | [
"protected",
"void",
"appendWordFeatures",
"(",
"IWord",
"word",
")",
"{",
"//add the pinyin to the pool",
"if",
"(",
"config",
".",
"APPEND_CJK_PINYIN",
"&&",
"config",
".",
"LOAD_CJK_PINYIN",
"&&",
"word",
".",
"getPinyin",
"(",
")",
"!=",
"null",
")",
"{",
... | check and append the pinyin and the synonyms words of the specified word
@param word | [
"check",
"and",
"append",
"the",
"pinyin",
"and",
"the",
"synonyms",
"words",
"of",
"the",
"specified",
"word"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L743-L759 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.appendLatinSyn | protected void appendLatinSyn( IWord w )
{
IWord ew;
/*
* @added 2014-07-07
* w maybe EC_MIX_WORD, so check its syn first
* and make sure it is not a EC_MIX_WORD then check the EN_WORD
*/
if ( w.getSyn() == null ) {
ew = dic.get(ILexicon.CJK_WORD, w.getValue());
} else {
ew = w;
}
if ( ew != null && ew.getSyn() != null ) {
ew.setPosition(w.getPosition());
SegKit.appendSynonyms(wordPool, ew);
}
} | java | protected void appendLatinSyn( IWord w )
{
IWord ew;
/*
* @added 2014-07-07
* w maybe EC_MIX_WORD, so check its syn first
* and make sure it is not a EC_MIX_WORD then check the EN_WORD
*/
if ( w.getSyn() == null ) {
ew = dic.get(ILexicon.CJK_WORD, w.getValue());
} else {
ew = w;
}
if ( ew != null && ew.getSyn() != null ) {
ew.setPosition(w.getPosition());
SegKit.appendSynonyms(wordPool, ew);
}
} | [
"protected",
"void",
"appendLatinSyn",
"(",
"IWord",
"w",
")",
"{",
"IWord",
"ew",
";",
"/*\n * @added 2014-07-07\n * w maybe EC_MIX_WORD, so check its syn first\n * and make sure it is not a EC_MIX_WORD then check the EN_WORD \n */",
"if",
"(",
"w",
".",... | Check and append the synonyms words of specified word included the CJK and basic Latin words
All the synonyms words share the same position part of speech, word type with the primitive word
@param w | [
"Check",
"and",
"append",
"the",
"synonyms",
"words",
"of",
"specified",
"word",
"included",
"the",
"CJK",
"and",
"basic",
"Latin",
"words",
"All",
"the",
"synonyms",
"words",
"share",
"the",
"same",
"position",
"part",
"of",
"speech",
"word",
"type",
"with"... | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L767-L786 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.getNextMatch | protected IWord[] getNextMatch(char[] chars, int index)
{
ArrayList<IWord> mList = new ArrayList<IWord>(8);
//StringBuilder isb = new StringBuilder();
isb.clear();
char c = chars[index];
isb.append(c);
String temp = isb.toString();
if ( dic.match(ILexicon.CJK_WORD, temp) ) {
mList.add(dic.get(ILexicon.CJK_WORD, temp));
}
String _key = null;
for ( int j = 1;
j < config.MAX_LENGTH && ((j+index) < chars.length); j++ ) {
isb.append(chars[j+index]);
_key = isb.toString();
if ( dic.match(ILexicon.CJK_WORD, _key) ) {
mList.add(dic.get(ILexicon.CJK_WORD, _key));
}
}
/*
* if match no words from the current position
* to idx+Config.MAX_LENGTH, just return the Word with
* a value of temp as a unrecognited word.
*/
if ( mList.isEmpty() ) {
mList.add(new Word(temp, ILexicon.UNMATCH_CJK_WORD));
}
/* for ( int j = 0; j < mList.size(); j++ ) {
System.out.println(mList.get(j));
}*/
IWord[] words = new IWord[mList.size()];
mList.toArray(words);
mList.clear();
return words;
} | java | protected IWord[] getNextMatch(char[] chars, int index)
{
ArrayList<IWord> mList = new ArrayList<IWord>(8);
//StringBuilder isb = new StringBuilder();
isb.clear();
char c = chars[index];
isb.append(c);
String temp = isb.toString();
if ( dic.match(ILexicon.CJK_WORD, temp) ) {
mList.add(dic.get(ILexicon.CJK_WORD, temp));
}
String _key = null;
for ( int j = 1;
j < config.MAX_LENGTH && ((j+index) < chars.length); j++ ) {
isb.append(chars[j+index]);
_key = isb.toString();
if ( dic.match(ILexicon.CJK_WORD, _key) ) {
mList.add(dic.get(ILexicon.CJK_WORD, _key));
}
}
/*
* if match no words from the current position
* to idx+Config.MAX_LENGTH, just return the Word with
* a value of temp as a unrecognited word.
*/
if ( mList.isEmpty() ) {
mList.add(new Word(temp, ILexicon.UNMATCH_CJK_WORD));
}
/* for ( int j = 0; j < mList.size(); j++ ) {
System.out.println(mList.get(j));
}*/
IWord[] words = new IWord[mList.size()];
mList.toArray(words);
mList.clear();
return words;
} | [
"protected",
"IWord",
"[",
"]",
"getNextMatch",
"(",
"char",
"[",
"]",
"chars",
",",
"int",
"index",
")",
"{",
"ArrayList",
"<",
"IWord",
">",
"mList",
"=",
"new",
"ArrayList",
"<",
"IWord",
">",
"(",
"8",
")",
";",
"//StringBuilder isb = new StringBuilder... | match the next CJK word in the dictionary
@param chars
@param index
@return IWord[] | [
"match",
"the",
"next",
"CJK",
"word",
"in",
"the",
"dictionary"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L882-L923 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.nextCJKSentence | protected char[] nextCJKSentence( int c ) throws IOException
{
isb.clear();
int ch;
isb.append((char)c);
//reset the CE check mask.
ctrlMask &= ~ISegment.CHECK_CE_MASk;
while ( (ch = readNext()) != -1 ) {
if ( StringUtil.isWhitespace(ch) ) {
pushBack(ch);
break;
}
if ( ! StringUtil.isCJKChar(ch) ) {
pushBack(ch);
/*check Chinese English mixed word*/
if ( StringUtil.isEnLetter(ch)
|| StringUtil.isEnNumeric(ch) ) {
ctrlMask |= ISegment.CHECK_CE_MASk;
}
break;
}
isb.append((char)ch);
}
return isb.toString().toCharArray();
} | java | protected char[] nextCJKSentence( int c ) throws IOException
{
isb.clear();
int ch;
isb.append((char)c);
//reset the CE check mask.
ctrlMask &= ~ISegment.CHECK_CE_MASk;
while ( (ch = readNext()) != -1 ) {
if ( StringUtil.isWhitespace(ch) ) {
pushBack(ch);
break;
}
if ( ! StringUtil.isCJKChar(ch) ) {
pushBack(ch);
/*check Chinese English mixed word*/
if ( StringUtil.isEnLetter(ch)
|| StringUtil.isEnNumeric(ch) ) {
ctrlMask |= ISegment.CHECK_CE_MASk;
}
break;
}
isb.append((char)ch);
}
return isb.toString().toCharArray();
} | [
"protected",
"char",
"[",
"]",
"nextCJKSentence",
"(",
"int",
"c",
")",
"throws",
"IOException",
"{",
"isb",
".",
"clear",
"(",
")",
";",
"int",
"ch",
";",
"isb",
".",
"append",
"(",
"(",
"char",
")",
"c",
")",
";",
"//reset the CE check mask.",
"ctrlM... | load a CJK char list from the stream start from the
current position till the char is not a CJK char
@param c
@return char[]
@throws IOException | [
"load",
"a",
"CJK",
"char",
"list",
"from",
"the",
"stream",
"start",
"from",
"the",
"current",
"position",
"till",
"the",
"char",
"is",
"not",
"a",
"CJK",
"char"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L1129-L1158 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.nextLatinString | protected String nextLatinString(int c) throws IOException
{
isb.clear();
if ( c > 65280 ) c -= 65248;
if ( c >= 65 && c <= 90 ) c += 32;
isb.append((char)c);
int ch;
int _ctype = 0;
ctrlMask &= ~ISegment.CHECK_EC_MASK;
while ( (ch = readNext()) != -1 ) {
//Covert the full-width char to half-width char.
if ( ch > 65280 ) ch -= 65248;
_ctype = StringUtil.getEnCharType(ch);
//Whitespace check.
if ( _ctype == StringUtil.EN_WHITESPACE ) {
break;
}
//English punctuation check.
if ( _ctype == StringUtil.EN_PUNCTUATION ) {
if ( ! config.isKeepPunctuation((char)ch) ) {
pushBack(ch);
break;
}
}
//Not EN_KNOW, and it could be letter, numeric.
if ( _ctype == StringUtil.EN_UNKNOW ) {
pushBack(ch);
if ( StringUtil.isCJKChar( ch ) ) {
ctrlMask |= ISegment.CHECK_EC_MASK;
}
break;
}
//covert the lower case letter to upper case.
if ( ch >= 65 && ch <= 90 ) ch += 32;
isb.append((char)ch);
/*
* global English word length limitation
*/
if ( isb.length() > config.MAX_LATIN_LENGTH ) {
break;
}
}
/*
* check and remove the dot punctuation after it
*/
for ( int j = isb.length() - 1; j > 0; j-- ) {
if ( isb.charAt(j) == '.' ) {
isb.deleteCharAt(j);
}
}
return isb.toString();
} | java | protected String nextLatinString(int c) throws IOException
{
isb.clear();
if ( c > 65280 ) c -= 65248;
if ( c >= 65 && c <= 90 ) c += 32;
isb.append((char)c);
int ch;
int _ctype = 0;
ctrlMask &= ~ISegment.CHECK_EC_MASK;
while ( (ch = readNext()) != -1 ) {
//Covert the full-width char to half-width char.
if ( ch > 65280 ) ch -= 65248;
_ctype = StringUtil.getEnCharType(ch);
//Whitespace check.
if ( _ctype == StringUtil.EN_WHITESPACE ) {
break;
}
//English punctuation check.
if ( _ctype == StringUtil.EN_PUNCTUATION ) {
if ( ! config.isKeepPunctuation((char)ch) ) {
pushBack(ch);
break;
}
}
//Not EN_KNOW, and it could be letter, numeric.
if ( _ctype == StringUtil.EN_UNKNOW ) {
pushBack(ch);
if ( StringUtil.isCJKChar( ch ) ) {
ctrlMask |= ISegment.CHECK_EC_MASK;
}
break;
}
//covert the lower case letter to upper case.
if ( ch >= 65 && ch <= 90 ) ch += 32;
isb.append((char)ch);
/*
* global English word length limitation
*/
if ( isb.length() > config.MAX_LATIN_LENGTH ) {
break;
}
}
/*
* check and remove the dot punctuation after it
*/
for ( int j = isb.length() - 1; j > 0; j-- ) {
if ( isb.charAt(j) == '.' ) {
isb.deleteCharAt(j);
}
}
return isb.toString();
} | [
"protected",
"String",
"nextLatinString",
"(",
"int",
"c",
")",
"throws",
"IOException",
"{",
"isb",
".",
"clear",
"(",
")",
";",
"if",
"(",
"c",
">",
"65280",
")",
"c",
"-=",
"65248",
";",
"if",
"(",
"c",
">=",
"65",
"&&",
"c",
"<=",
"90",
")",
... | the simple version of the next basic Latin fetch logic
Just return the next Latin string with the keep punctuation after it
@param c
@return String
@throws IOException | [
"the",
"simple",
"version",
"of",
"the",
"next",
"basic",
"Latin",
"fetch",
"logic",
"Just",
"return",
"the",
"next",
"Latin",
"string",
"with",
"the",
"keep",
"punctuation",
"after",
"it"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L1425-L1486 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.nextLetterNumber | protected String nextLetterNumber( int c ) throws IOException
{
//StringBuilder isb = new StringBuilder();
isb.clear();
isb.append((char)c);
int ch;
while ( (ch = readNext()) != -1 ) {
if ( StringUtil.isWhitespace(ch) ) {
pushBack(ch);
break;
}
if ( ! StringUtil.isLetterNumber( ch ) ) {
pushBack(ch);
break;
}
isb.append((char)ch);
}
return isb.toString();
} | java | protected String nextLetterNumber( int c ) throws IOException
{
//StringBuilder isb = new StringBuilder();
isb.clear();
isb.append((char)c);
int ch;
while ( (ch = readNext()) != -1 ) {
if ( StringUtil.isWhitespace(ch) ) {
pushBack(ch);
break;
}
if ( ! StringUtil.isLetterNumber( ch ) ) {
pushBack(ch);
break;
}
isb.append((char)ch);
}
return isb.toString();
} | [
"protected",
"String",
"nextLetterNumber",
"(",
"int",
"c",
")",
"throws",
"IOException",
"{",
"//StringBuilder isb = new StringBuilder();",
"isb",
".",
"clear",
"(",
")",
";",
"isb",
".",
"append",
"(",
"(",
"char",
")",
"c",
")",
";",
"int",
"ch",
";",
"... | find the next other letter from the current position
find the letter number from the current position
count until the char in the specified position is not a letter number or whitespace
@param c
@return String
@throws IOException | [
"find",
"the",
"next",
"other",
"letter",
"from",
"the",
"current",
"position",
"find",
"the",
"letter",
"number",
"from",
"the",
"current",
"position",
"count",
"until",
"the",
"char",
"in",
"the",
"specified",
"position",
"is",
"not",
"a",
"letter",
"numbe... | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L1497-L1518 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.nextOtherNumber | protected String nextOtherNumber( int c ) throws IOException
{
//StringBuilder isb = new StringBuilder();
isb.clear();
isb.append((char)c);
int ch;
while ( (ch = readNext()) != -1 ) {
if ( StringUtil.isWhitespace(ch) ) {
pushBack(ch);
break;
}
if ( ! StringUtil.isOtherNumber(ch) ) {
pushBack(ch);
break;
}
isb.append((char)ch);
}
return isb.toString();
} | java | protected String nextOtherNumber( int c ) throws IOException
{
//StringBuilder isb = new StringBuilder();
isb.clear();
isb.append((char)c);
int ch;
while ( (ch = readNext()) != -1 ) {
if ( StringUtil.isWhitespace(ch) ) {
pushBack(ch);
break;
}
if ( ! StringUtil.isOtherNumber(ch) ) {
pushBack(ch);
break;
}
isb.append((char)ch);
}
return isb.toString();
} | [
"protected",
"String",
"nextOtherNumber",
"(",
"int",
"c",
")",
"throws",
"IOException",
"{",
"//StringBuilder isb = new StringBuilder();",
"isb",
".",
"clear",
"(",
")",
";",
"isb",
".",
"append",
"(",
"(",
"char",
")",
"c",
")",
";",
"int",
"ch",
";",
"w... | find the other number from the current position
count until the char in the specified position is not a other number or whitespace
@param c
@return String
@throws IOException | [
"find",
"the",
"other",
"number",
"from",
"the",
"current",
"position",
"count",
"until",
"the",
"char",
"in",
"the",
"specified",
"position",
"is",
"not",
"a",
"other",
"number",
"or",
"whitespace"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L1528-L1549 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.nextCNNumeric | protected String nextCNNumeric( char[] chars, int index ) throws IOException
{
//StringBuilder isb = new StringBuilder();
isb.clear();
isb.append( chars[ index ]);
ctrlMask &= ~ISegment.CHECK_CF_MASK; //reset the fraction check mask.
for ( int j = index + 1; j < chars.length; j++ ) {
/*
* check and deal with '分之' if the
* current char is not a Chinese numeric.
* (try to recognize a Chinese fraction)
*
* @added 2013-12-14
*/
if ( NumericUtil.isCNNumeric(chars[j]) == -1 ) {
if ( j + 2 < chars.length
&& chars[j ] == '分'
&& chars[j+1] == '之'
/* check and make sure chars[j+2] is a chinese numeric.
* or error will happen on situation like '四六分之' .
* @added 2013-12-14 */
&& NumericUtil.isCNNumeric(chars[j+2]) != -1 ) {
isb.append(chars[j++]);
isb.append(chars[j++]);
isb.append(chars[j ]);
//set the chinese fraction check mask.
ctrlMask |= ISegment.CHECK_CF_MASK;
continue;
} else {
break;
}
}
//append the buffer.
isb.append( chars[j] );
}
return isb.toString();
} | java | protected String nextCNNumeric( char[] chars, int index ) throws IOException
{
//StringBuilder isb = new StringBuilder();
isb.clear();
isb.append( chars[ index ]);
ctrlMask &= ~ISegment.CHECK_CF_MASK; //reset the fraction check mask.
for ( int j = index + 1; j < chars.length; j++ ) {
/*
* check and deal with '分之' if the
* current char is not a Chinese numeric.
* (try to recognize a Chinese fraction)
*
* @added 2013-12-14
*/
if ( NumericUtil.isCNNumeric(chars[j]) == -1 ) {
if ( j + 2 < chars.length
&& chars[j ] == '分'
&& chars[j+1] == '之'
/* check and make sure chars[j+2] is a chinese numeric.
* or error will happen on situation like '四六分之' .
* @added 2013-12-14 */
&& NumericUtil.isCNNumeric(chars[j+2]) != -1 ) {
isb.append(chars[j++]);
isb.append(chars[j++]);
isb.append(chars[j ]);
//set the chinese fraction check mask.
ctrlMask |= ISegment.CHECK_CF_MASK;
continue;
} else {
break;
}
}
//append the buffer.
isb.append( chars[j] );
}
return isb.toString();
} | [
"protected",
"String",
"nextCNNumeric",
"(",
"char",
"[",
"]",
"chars",
",",
"int",
"index",
")",
"throws",
"IOException",
"{",
"//StringBuilder isb = new StringBuilder();",
"isb",
".",
"clear",
"(",
")",
";",
"isb",
".",
"append",
"(",
"chars",
"[",
"index",
... | find the Chinese number from the current position
count until the char in the specified position is not a other number or whitespace
@param chars char array of CJK items
@param index
@return String[] | [
"find",
"the",
"Chinese",
"number",
"from",
"the",
"current",
"position",
"count",
"until",
"the",
"char",
"in",
"the",
"specified",
"position",
"is",
"not",
"a",
"other",
"number",
"or",
"whitespace"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L1559-L1598 | train |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/SearchSeg.java | SearchSeg.getNextCJKWord | @Override
protected IWord getNextCJKWord(int c, int pos) throws IOException
{
String key = null;
char[] chars = nextCJKSentence(c);
int cjkidx = 0, ignidx = 0, mnum = 0;
IWord word = null;
ArrayList<IWord> mList = new ArrayList<IWord>(8);
while ( cjkidx < chars.length ) {
/// @Note added at 2017/04/29
/// check and append the single char word
String sstr = String.valueOf(chars[cjkidx]);
if ( dic.match(ILexicon.CJK_WORD, sstr) ) {
IWord sWord = dic.get(ILexicon.CJK_WORD, sstr).clone();
sWord.setPosition(pos+cjkidx);
mList.add(sWord);
}
mnum = 0;
isb.clear().append(chars[cjkidx]);
//System.out.println("ignore idx: " + ignidx);
for ( int j = 1; j < config.MAX_LENGTH
&& (cjkidx+j) < chars.length; j++ ) {
isb.append(chars[cjkidx+j]);
key = isb.toString();
if ( dic.match(ILexicon.CJK_WORD, key) ) {
mnum = 1;
ignidx = Math.max(ignidx, cjkidx + j);
word = dic.get(ILexicon.CJK_WORD, key).clone();
word.setPosition(pos+cjkidx);
mList.add(word);
}
}
/*
* no matches here:
* should the current character chars[cjkidx] be a single word ?
* lets do the current check
*/
if ( mnum == 0 && (cjkidx == 0 || cjkidx > ignidx) ) {
String temp = String.valueOf(chars[cjkidx]);
if ( ! dic.match(ILexicon.CJK_WORD, temp) ) {
word = new Word(temp, ILexicon.UNMATCH_CJK_WORD);
word.setPosition(pos+cjkidx);
mList.add(word);
}
}
cjkidx++;
}
/*
* do all the words analysis
* 1, clear the stop words
* 1, check and append the pinyin or synonyms words
*/
for ( IWord w : mList ) {
key = w.getValue();
if ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, key) ) {
continue;
}
wordPool.add(w);
appendWordFeatures(w);
}
//let gc do its work
mList.clear();
mList = null;
return wordPool.size()==0 ? null : wordPool.remove();
} | java | @Override
protected IWord getNextCJKWord(int c, int pos) throws IOException
{
String key = null;
char[] chars = nextCJKSentence(c);
int cjkidx = 0, ignidx = 0, mnum = 0;
IWord word = null;
ArrayList<IWord> mList = new ArrayList<IWord>(8);
while ( cjkidx < chars.length ) {
/// @Note added at 2017/04/29
/// check and append the single char word
String sstr = String.valueOf(chars[cjkidx]);
if ( dic.match(ILexicon.CJK_WORD, sstr) ) {
IWord sWord = dic.get(ILexicon.CJK_WORD, sstr).clone();
sWord.setPosition(pos+cjkidx);
mList.add(sWord);
}
mnum = 0;
isb.clear().append(chars[cjkidx]);
//System.out.println("ignore idx: " + ignidx);
for ( int j = 1; j < config.MAX_LENGTH
&& (cjkidx+j) < chars.length; j++ ) {
isb.append(chars[cjkidx+j]);
key = isb.toString();
if ( dic.match(ILexicon.CJK_WORD, key) ) {
mnum = 1;
ignidx = Math.max(ignidx, cjkidx + j);
word = dic.get(ILexicon.CJK_WORD, key).clone();
word.setPosition(pos+cjkidx);
mList.add(word);
}
}
/*
* no matches here:
* should the current character chars[cjkidx] be a single word ?
* lets do the current check
*/
if ( mnum == 0 && (cjkidx == 0 || cjkidx > ignidx) ) {
String temp = String.valueOf(chars[cjkidx]);
if ( ! dic.match(ILexicon.CJK_WORD, temp) ) {
word = new Word(temp, ILexicon.UNMATCH_CJK_WORD);
word.setPosition(pos+cjkidx);
mList.add(word);
}
}
cjkidx++;
}
/*
* do all the words analysis
* 1, clear the stop words
* 1, check and append the pinyin or synonyms words
*/
for ( IWord w : mList ) {
key = w.getValue();
if ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, key) ) {
continue;
}
wordPool.add(w);
appendWordFeatures(w);
}
//let gc do its work
mList.clear();
mList = null;
return wordPool.size()==0 ? null : wordPool.remove();
} | [
"@",
"Override",
"protected",
"IWord",
"getNextCJKWord",
"(",
"int",
"c",
",",
"int",
"pos",
")",
"throws",
"IOException",
"{",
"String",
"key",
"=",
"null",
";",
"char",
"[",
"]",
"chars",
"=",
"nextCJKSentence",
"(",
"c",
")",
";",
"int",
"cjkidx",
"... | get the next CJK word from the current position of the input stream
and this function is the core part the most segmentation implements
@see ASegment#getNextCJKWord(int, int)
@throws IOException | [
"get",
"the",
"next",
"CJK",
"word",
"from",
"the",
"current",
"position",
"of",
"the",
"input",
"stream",
"and",
"this",
"function",
"is",
"the",
"core",
"part",
"the",
"most",
"segmentation",
"implements"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/SearchSeg.java#L40-L113 | train |
lionsoul2014/jcseg | jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/UriEntry.java | UriEntry.process | private void process()
{
if (requestUri.length() > 1) {
parts = new ArrayList<String>(10);
for ( int i = 1; i < requestUri.length(); ) {
int sIdx = i;
int eIdx = requestUri.indexOf('/', sIdx + 1);
//not matched or reach the end
if ( eIdx == -1 ) {
parts.add(requestUri.substring(sIdx));
break;
}
parts.add(requestUri.substring(sIdx, eIdx));
i = eIdx + 1;
}
/*
* check and add a empty method name
* with request style like /tokenizer/
*/
if ( requestUri.charAt(requestUri.length()-1) == '/' ) {
parts.add("");
}
int length = parts.size();
if ( length > 1 ) {
IStringBuffer sb = new IStringBuffer();
for ( int i = 0; i < length - 1; i++ ) {
int l = sb.length();
sb.append(parts.get(i));
//make sure the first letter is uppercase
char chr = sb.charAt(l);
if ( chr >= 90 ) {
chr -= 32;
sb.set(l, chr);
}
}
controller = sb.toString();
}
method = parts.get(length-1);
}
} | java | private void process()
{
if (requestUri.length() > 1) {
parts = new ArrayList<String>(10);
for ( int i = 1; i < requestUri.length(); ) {
int sIdx = i;
int eIdx = requestUri.indexOf('/', sIdx + 1);
//not matched or reach the end
if ( eIdx == -1 ) {
parts.add(requestUri.substring(sIdx));
break;
}
parts.add(requestUri.substring(sIdx, eIdx));
i = eIdx + 1;
}
/*
* check and add a empty method name
* with request style like /tokenizer/
*/
if ( requestUri.charAt(requestUri.length()-1) == '/' ) {
parts.add("");
}
int length = parts.size();
if ( length > 1 ) {
IStringBuffer sb = new IStringBuffer();
for ( int i = 0; i < length - 1; i++ ) {
int l = sb.length();
sb.append(parts.get(i));
//make sure the first letter is uppercase
char chr = sb.charAt(l);
if ( chr >= 90 ) {
chr -= 32;
sb.set(l, chr);
}
}
controller = sb.toString();
}
method = parts.get(length-1);
}
} | [
"private",
"void",
"process",
"(",
")",
"{",
"if",
"(",
"requestUri",
".",
"length",
"(",
")",
">",
"1",
")",
"{",
"parts",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"10",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"re... | do the request uri process | [
"do",
"the",
"request",
"uri",
"process"
] | 7c8a912e3bbcaf4f8de701180b9c24e2e444a94b | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/UriEntry.java#L56-L102 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.