<commit_before>/*************************************************************************/
/* Copyright (c) 2004                                                    */
/* <NAME>, <NAME>, and <NAME>                    */
/* Copyright (c) 2009 <NAME>                                      */
/* All rights reserved                                                   */
/*                                                                       */
/* Use of the link grammar parsing system is subject to the terms of the */
/* license set forth in the LICENSE file included with this software.   */ 
/* This license allows free redistribution and use in source and binary  */
/* forms, with or without modification, subject to certain conditions.   */
/*                                                                       */
/*************************************************************************/
#ifndef _LINK_GRAMMAR_ERROR_H_
#define _LINK_GRAMMAR_ERROR_H_

#include "link-includes.h"

typedef struct
{
	Sentence sent;
} err_ctxt;

typedef enum
{
	Fatal = 1,
	Error,
	Warn,
	Info,
	Debug
} severity;

void err_msg(err_ctxt *, severity, const char *fmt, ...) GNUC_PRINTF(3,4);
const char *feature_enabled(const char *, const char *);

#ifdef _WIN32
# define __func__ __FUNCTION__
#endif

/**
 * Print a debug message at verbosity >= level.
 * Preceding the level number by a + (+level) adds printing of the
 * function name.
 * The !debug variable can be set to a comma-separated list of functions
 * in order to restrict the debug messages to these functions only.
 */
#define lgdebug(level, ...) \
(((verbosity >= (level)) && \
	(('\0' == debug[0]) || feature_enabled(debug, __func__))) \
	? ((STRINGIFY(level)[0] == '+' ? (void)printf("%s: ", __func__) : (void)0), \
	(void)printf(__VA_ARGS__)) : (void)0)

/**
 * Return TRUE if the given feature (a string) is set in the !test variable
 * (a comma-separated feature list).
 */
#define test_enabled(feature) \
	(('\0' != test) ? feature_enabled(test, feature) : NULL)

#endif
<commit_msg>Add a macro for debug-messages block at a desired verbosity<commit_after>/*************************************************************************/
/* Copyright (c) 2004                                                    */
/* <NAME>, <NAME>, and <NAME>                    */
/* Copyright (c) 2009 <NAME>                                      */
/* All rights reserved                                                   */
/*                                                                       */
/* Use of the link grammar parsing system is subject to the terms of the */
/* license set forth in the LICENSE file included with this software.   */ 
/* This license allows free redistribution and use in source and binary  */
/* forms, with or without modification, subject to certain conditions.   */
/*                                                                       */
/*************************************************************************/
#ifndef _LINK_GRAMMAR_ERROR_H_
#define _LINK_GRAMMAR_ERROR_H_

#include "link-includes.h"

typedef struct
{
	Sentence sent;
} err_ctxt;

typedef enum
{
	Fatal = 1,
	Error,
	Warn,
	Info,
	Debug
} severity;

void err_msg(err_ctxt *, severity, const char *fmt, ...) GNUC_PRINTF(3,4);
const char *feature_enabled(const char *, const char *);

#ifdef _WIN32
# define __func__ __FUNCTION__
#endif

/**
 * Print a debug message at verbosity >= level.
 * Preceding the level number by a + (+level) adds printing of the
 * function name.
 * The !debug variable can be set to a comma-separated list of functions
 * in order to restrict the debug messages to these functions only.
 */
#define lgdebug(level, ...) \
(((verbosity >= (level)) && \
	(('\0' == debug[0]) || feature_enabled(debug, __func__))) \
	? ((STRINGIFY(level)[0] == '+' ? (void)printf("%s: ", __func__) : (void)0), \
	(void)printf(__VA_ARGS__)) : (void)0)

/**
 * Wrap-up a debug-messages block.
 * Preceding the level number by a + (+level) adds printing of the
 * function name.
 * The !debug variable can be set to a comma-separated list of functions
 * in order to restrict the debug messages to these functions only.
 *
 * Return true if the debug-messages block should be executed, else false.
 *
 * Usage example, for debug messages at verbosity V:
 * if (debug_level(V))
 * {
 * 	print_disjunct(d);
 * }
 */
#define debug_level(level) \
(((verbosity >= (level)) && \
	(('\0' == debug[0]) || feature_enabled(debug, __func__))) \
	? ((STRINGIFY(level)[0] == '+' ? printf("%s: ", __func__) : 0), true)  \
	: false)

/**
 * Return TRUE if the given feature (a string) is set in the !test variable
 * (a comma-separated feature list).
 */
#define test_enabled(feature) \
	(('\0' != test) ? feature_enabled(test, feature) : NULL)

#endif

{'fraction_non_alphanumeric': 0.18113522537562604, 'fraction_numerical': 0.008764607679465776, 'mean_word_length': 2.4017033356990773, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7618755', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1254, 'n_words': 449}