text:
#ifndef __fann_train_h__
#define __fann_train_h__

/* Section: FANN Training

 	There are many different ways of training neural networks and the FANN library supports
 	a number of different approaches.

 	Two fundamentally different approaches are the most commonly used:

 		Fixed topology training - The size and topology of the ANN is determined in advance
 			and the training alters the weights in order to minimize the difference between
 			the desired output values and the actual output values. This kind of training is
 			supported by <fann_train_on_data>.

 		Evolving topology training - The training start out with an empty ANN, only consisting
 			of input and output neurons. Hidden neurons and connections are added during training,
 			in order to reach the same goal as for fixed topology training. This kind of training
 			is supported by <FANN Cascade Training>.
 */

/* Struct: struct fann_train_data
	Structure used to store data, for use with training.

	The data inside this structure should never be manipulated directly, but should use some
	of the supplied functions in <Training Data Manipulation>.

	The training data structure is very usefull for storing data during training and testing of a
	neural network.

	See also:
	<fann_read_train_from_file>, <fann_train_on_data>, <fann_destroy_train>
*/
struct fann_train_data
{
	enum fann_errno_enum errno_f;
	FILE *error_log;
	char *errstr;

	unsigned int num_data;
	unsigned int num_input;
	unsigned int num_output;
	fann_type **input;
	fann_type **output;
};

/* Section: FANN Training */

/* Group: Training */

#ifndef FIXEDFANN
/* Function: fann_train

   Train one iteration with a set of inputs, and a set of desired outputs.
   This training is always incremental training (see <fann_train_enum>), since
   only one pattern is presented.

   Parameters:
   	ann - The neural network structure
   	input - an array of inputs. This array must be exactly <fann_get_num_input> long.
   	desired_output - an array of desired outputs. This array must be exactly <fann_get_num_output> long.

   	See also:
   		<fann_train_on_data>, <fann_train_epoch>

   	This function appears in FANN >= 1.0.0.
 */
FANN_EXTERNAL void FANN_API fann_train(struct fann *ann, fann_type * input,
									   fann_type * desired_output);

#endif	/* NOT FIXEDFANN */

/* Function: fann_test
   Test with a set of inputs, and a set of desired outputs.
   This operation updates the mean square error, but does not
   change the network in any way.

   See also:
   		<fann_test_data>, <fann_train>

   This function appears in FANN >= 1.0.0.
*/
FANN_EXTERNAL fann_type * FANN_API fann_test(struct fann *ann, fann_type * input,
												 fann_type * desired_output);

/* Function: fann_get_MSE
   Reads the mean square error from the network.

   Reads the mean square error from the network. This value is calculated during
   training or testing, and can therefore sometimes be a bit off if the weights
   have been changed since the last calculation of the value.

   See also:
   	<fann_test_data>

	This function appears in FANN >= 1.1.0.
 */
FANN_EXTERNAL float FANN_API fann_get_MSE(struct fann *ann);

/* Function: fann_get_bit_fail

	The number of fail bits; means the number of output neurons which differ more
	than the bit fail limit (see <fann_get_bit_fail_limit>, <fann_set_bit_fail_limit>).
	The bits are counted in all of the training data, so this number can be higher than
	the number of training data.

	This value is reset by <fann_reset_MSE> and updated by all the same functions which also
	update the MSE value (e.g. <fann_test_data>, <fann_train_epoch>)

	See also:
		<fann_stopfunc_enum>, <fann_get_MSE>

	This function appears in FANN >= 2.0.0
*/
FANN_EXTERNAL unsigned int FANN_API fann_get_bit_fail(struct fann *ann);

/* Function: fann_reset_MSE
   Resets the mean square error from the network.

   This function also resets the number of bits that fail.

   See also:
   	<fann_get_MSE>, <fann_get_bit_fail_limit>

    This function appears in FANN >= 1.1.0
 */
FANN_EXTERNAL void FANN_API fann_reset_MSE(struct fann *ann);

/* Group: Training Data Training */

#ifndef FIXEDFANN

/* Function: fann_train_on_data

   Trains on an entire dataset, for a period of time.

   This training uses the training algorithm chosen by <fann_set_training_algorithm>,
   and the parameters set for these training algorithms.

   Parameters:
   		ann - The neural network
   		data - The data, which should be used during training
   		max_epochs - The maximum number of epochs the training should continue
   		epochs_between_reports - The number of epochs between printing a status report to stdout.
   			A value of zero means no reports should be printed.
   		desired_error - The desired <fann_get_MSE> or <fann_get_bit_fail>, depending on which stop function
   			is chosen by <fann_set_train_stop_function>.

	Instead of printing out reports every epochs_between_reports, a callback function can be called
	(see <fann_set_callback>).

	See also:
		<fann_train_on_file>, <fann_train_epoch>, <Parameters>

	This function appears in FANN >= 1.0.0.
*/
FANN_EXTERNAL void FANN_API fann_train_on_data(struct fann *ann, struct fann_train_data *data,
											   unsigned int max_epochs,
											   unsigned int epochs_between_reports,
											   float desired_error);

/* Function: fann_train_on_file

   Does the same as <fann_train_on_data>, but reads the training data directly from a file.

   See also:
   		<fann_train_on_data>

	This function appears in FANN >= 1.0.0.
*/
FANN_EXTERNAL void FANN_API fann_train_on_file(struct fann *ann, const char *filename,
											   unsigned int max_epochs,
											   unsigned int epochs_between_reports,
											   float desired_error);

/* Function: fann_train_epoch
   Train one epoch with a set of training data.

    Train one epoch with the training data stored in data. One epoch is where all of
    the training data is considered exactly once.

	This function returns the MSE error as it is calculated either before or during
	the actual training. This is not the actual MSE after the training epoch, but since
	calculating this will require to go through the entire training set once more, it is
	more than adequate to use this value during training.

	The training algorithm used by this function is chosen by the <fann_set_training_algorithm>
	function.

	See also:
		<fann_train_on_data>, <fann_test_data>

	This function appears in FANN >= 1.2.0.
 */
FANN_EXTERNAL float FANN_API fann_train_epoch(struct fann *ann, struct fann_train_data *data);
#endif	/* NOT FIXEDFANN */

/* Function: fann_test_data

   Test a set of training data and calculates the MSE for the training data.

   This function updates the MSE and the bit fail values.

   See also:
 	<fann_test>, <fann_get_MSE>, <fann_get_bit_fail>

	This function appears in FANN >= 1.2.0.
 */
FANN_EXTERNAL float FANN_API fann_test_data(struct fann *ann, struct fann_train_data *data);

/* Group: Training Data Manipulation */

/* Function: fann_read_train_from_file
   Reads a file that stores training data.

   The file must be formatted like:
   >num_train_data num_input num_output
   >inputdata separated by space
   >outputdata separated by space
   >
   >.
   >.
   >.
   >
   >inputdata separated by space
   >outputdata separated by space

   See also:
   	<fann_train_on_data>, <fann_destroy_train>, <fann_save_train>

    This function appears in FANN >= 1.0.0
*/
FANN_EXTERNAL struct fann_train_data *FANN_API fann_read_train_from_file(const char *filename);

/* Function: fann_create_train
   Creates an empty training data struct.

   See also:
     <fann_read_train_from_file>, <fann_train_on_data>, <fann_destroy_train>,
     <fann_save_train>, <fann_create_train_array>

    This function appears in FANN >= 2.2.0
*/
FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train(unsigned int num_data, unsigned int num_input, unsigned int num_output);

/* Function: fann_create_train_pointer_array
   Creates an training data struct and fills it with data from provided arrays of pointer.

   A copy of the data is made so there are no restrictions on the
   allocation of the input/output data and the caller is responsible
   for the deallocation of the data pointed to by input and output.

   See also:
     <fann_read_train_from_file>, <fann_train_on_data>, <fann_destroy_train>,
     <fann_save_train>, <fann_create_train>, <fann_create_train_array>

    This function appears in FANN >= 2.3.0
*/
FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_pointer_array(unsigned int num_data, unsigned int num_input, fann_type **input, unsigned int num_output, fann_type **output);

/* Function: fann_create_train_array
   Creates an training data struct and fills it with data from provided arrays, where the arrays must have the dimensions:
   input[num_data*num_input]
   output[num_data*num_output]

   A copy of the data is made so there are no restrictions on the
   allocation of the input/output data and the caller is responsible
   for the deallocation of the data pointed to by input and output.

   See also:
     <fann_read_train_from_file>, <fann_train_on_data>, <fann_destroy_train>,
     <fann_save_train>, <fann_create_train>, <fann_create_train_pointer_array>

    This function appears in FANN >= 2.3.0
*/
FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_array(unsigned int num_data, unsigned int num_input, fann_type *input, unsigned int num_output, fann_type *output);

/* Function: fann_create_train_from_callback
   Creates the training data struct from a user supplied function.
   As the training data are numerable (data 1, data 2...), the user must write
   a function that receives the number of the training data set (input,output)
   and returns the set.  fann_create_train_from_callback will call the user
   supplied function 'num_data' times, one input-output pair each time. Each
   time the user supplied function is called, the time of the call will be passed
   as the 'num' parameter and the user supplied function must write the input
   and output to the corresponding parameters.

   Parameters:
     num_data      - The number of training data
     num_input     - The number of inputs per training data
     num_output    - The number of ouputs per training data
     user_function - The user supplied function

   Parameters for the user function:
     num        - The number of the training data set
     num_input  - The number of inputs per training data
     num_output - The number of ouputs per training data
     input      - The set of inputs
     output     - The set of desired outputs

   See also:
     <fann_read_train_from_file>, <fann_train_on_data>, <fann_destroy_train>,
     <fann_save_train>

    This function appears in FANN >= 2.1.0
*/
FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_callback(unsigned int num_data,
                                          unsigned int num_input,
                                          unsigned int num_output,
                                          void (FANN_API *user_function)( unsigned int,
                                                                 unsigned int,
                                                                 unsigned int,
                                                                 fann_type * ,
                                                                 fann_type * ));

/* Function: fann_destroy_train
   Destructs the training data and properly deallocates all of the associated data.
   Be sure to call this function when finished using the training data.

    This function appears in FANN >= 1.0.0
 */
FANN_EXTERNAL void FANN_API fann_destroy_train(struct fann_train_data *train_data);

/* Function: fann_get_train_input
   Gets the training input data at the given position

   See also:
     <fann_get_train_output>

   This function appears in FANN >= 2.3.0
 */
FANN_EXTERNAL fann_type * FANN_API fann_get_train_input(struct fann_train_data * data, unsigned int position);

/* Function: fann_get_train_output
   Gets the training output data at the given position

   See also:
     <fann_get_train_output>

   This function appears in FANN >= 2.3.0
 */
FANN_EXTERNAL fann_type * FANN_API fann_get_train_output(struct fann_train_data * data, unsigned int position);

/* Function: fann_shuffle_train_data

   Shuffles training data, randomizing the order.
   This is recommended for incremental training, while it has no influence during batch training.

   This function appears in FANN >= 1.1.0.
 */
FANN_EXTERNAL void FANN_API fann_shuffle_train_data(struct fann_train_data *train_data);

#ifndef FIXEDFANN

/* Function: fann_get_min_train_input

   Get the minimum value of all in the input data

   This function appears in FANN >= 2.3.0
*/
FANN_EXTERNAL fann_type FANN_API fann_get_min_train_input(struct fann_train_data *train_data);

/* Function: fann_get_max_train_input

   Get the maximum value of all in the input data

   This function appears in FANN >= 2.3.0
*/
FANN_EXTERNAL fann_type FANN_API fann_get_max_train_input(struct fann_train_data *train_data);

/* Function: fann_get_min_train_output

   Get the minimum value of all in the output data

   This function appears in FANN >= 2.3.0
*/
FANN_EXTERNAL fann_type FANN_API fann_get_min_train_output(struct fann_train_data *train_data);

/* Function: fann_get_max_train_output

   Get the maximum value of all in the output data

   This function appears in FANN >= 2.3.0
*/
FANN_EXTERNAL fann_type FANN_API fann_get_max_train_output(struct fann_train_data *train_data);

/* Function: fann_scale_train

   Scale input and output data based on previously calculated parameters.

   Parameters:
     ann      - ann for which trained parameters were calculated before
     data     - training data that needs to be scaled

   See also:
   	<fann_descale_train>, <fann_set_scaling_params>

    This function appears in FANN >= 2.1.0
*/
FANN_EXTERNAL void FANN_API fann_scale_train( struct fann *ann, struct fann_train_data *data );

/* Function: fann_descale_train

   Descale input and output data based on previously calculated parameters.

   Parameters:
     ann      - ann for which trained parameters were calculated before
     data     - training data that needs to be descaled

   See also:
   	<fann_scale_train>, <fann_set_scaling_params>

    This function appears in FANN >= 2.1.0
 */
FANN_EXTERNAL void FANN_API fann_descale_train( struct fann *ann, struct fann_train_data *data );

/* Function: fann_set_input_scaling_params

   Calculate input scaling parameters for future use based on training data.

   Parameters:
   	 ann           - ann for which parameters need to be calculated
   	 data          - training data that will be used to calculate scaling parameters
   	 new_input_min - desired lower bound in input data after scaling (not strictly followed)
   	 new_input_max - desired upper bound in input data after scaling (not strictly followed)

   See also:
   	 <fann_set_output_scaling_params>

    This function appears in FANN >= 2.1.0
 */
FANN_EXTERNAL int FANN_API fann_set_input_scaling_params(
	struct fann *ann,
	const struct fann_train_data *data,
	float new_input_min,
	float new_input_max);

/* Function: fann_set_output_scaling_params

   Calculate output scaling parameters for future use based on training data.

   Parameters:
   	 ann            - ann for which parameters need to be calculated
   	 data           - training data that will be used to calculate scaling parameters
   	 new_output_min - desired lower bound in output data after scaling (not strictly followed)
   	 new_output_max - desired upper bound in output data after scaling (not strictly followed)

   See also:
   	 <fann_set_input_scaling_params>

    This function appears in FANN >= 2.1.0
 */
FANN_EXTERNAL int FANN_API fann_set_output_scaling_params(
	struct fann *ann,
	const struct fann_train_data *data,
	float new_output_min,
	float new_output_max);

/* Function: fann_set_scaling_params

   Calculate input and output scaling parameters for future use based on training data.

   Parameters:
   	 ann            - ann for which parameters need to be calculated
   	 data           - training data that will be used to calculate scaling parameters
   	 new_input_min  - desired lower bound in input data after scaling (not strictly followed)
   	 new_input_max  - desired upper bound in input data after scaling (not strictly followed)
   	 new_output_min - desired lower bound in output data after scaling (not strictly followed)
   	 new_output_max - desired upper bound in output data after scaling (not strictly followed)

   See also:
   	 <fann_set_input_scaling_params>, <fann_set_output_scaling_params>

    This function appears in FANN >= 2.1.0
 */
FANN_EXTERNAL int FANN_API fann_set_scaling_params(
	struct fann *ann,
	const struct fann_train_data *data,
	float new_input_min,
	float new_input_max,
	float new_output_min,
	float new_output_max);

/* Function: fann_clear_scaling_params

   Clears scaling parameters.

   Parameters:
     ann - ann for which to clear scaling parameters

    This function appears in FANN >= 2.1.0
 */
FANN_EXTERNAL int FANN_API fann_clear_scaling_params(struct fann *ann);

/* Function: fann_scale_input

   Scale data in input vector before feeding it to ann based on previously calculated parameters.

   Parameters:
     ann          - for which scaling parameters were calculated
     input_vector - input vector that will be scaled

   See also:
     <fann_descale_input>, <fann_scale_output>

    This function appears in FANN >= 2.1.0
*/
FANN_EXTERNAL void FANN_API fann_scale_input( struct fann *ann, fann_type *input_vector );

/* Function: fann_scale_output

   Scale data in output vector before feeding it to ann based on previously calculated parameters.

   Parameters:
     ann           - for which scaling parameters were calculated
     output_vector - output vector that will be scaled

   See also:
     <fann_descale_output>, <fann_scale_input>

    This function appears in FANN >= 2.1.0
 */
FANN_EXTERNAL void FANN_API fann_scale_output( struct fann *ann, fann_type *output_vector );

/* Function: fann_descale_input

   Scale data in input vector after getting it from ann based on previously calculated parameters.

   Parameters:
     ann          - for which scaling parameters were calculated
     input_vector - input vector that will be descaled

   See also:
     <fann_scale_input>, <fann_descale_output>

    This function appears in FANN >= 2.1.0
 */
FANN_EXTERNAL void FANN_API fann_descale_input( struct fann *ann, fann_type *input_vector );

/* Function: fann_descale_output

   Scale data in output vector after getting it from ann based on previously calculated parameters.

   Parameters:
     ann           - for which scaling parameters were calculated
     output_vector - output vector that will be descaled

   See also:
     <fann_scale_output>, <fann_descale_input>

    This function appears in FANN >= 2.1.0
 */
FANN_EXTERNAL void FANN_API fann_descale_output( struct fann *ann, fann_type *output_vector );

#endif

/* Function: fann_scale_input_train_data

   Scales the inputs in the training data to the specified range.

   A simplified scaling method, which is mostly useful in examples where it's known that all the
   data will be in one range and it should be transformed to another range.

   It is not recommended to use this on subsets of data as the complete input range might not be
   available in that subset.

   For more powerful scaling, please consider <fann_scale_train>

   See also:
   	<fann_scale_output_train_data>, <fann_scale_train_data>, <fann_scala_input>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL void FANN_API fann_scale_input_train_data(struct fann_train_data *train_data,
														fann_type new_min, fann_type new_max);

/* Function: fann_scale_output_train_data

   Scales the outputs in the training data to the specified range.

   A simplified scaling method, which is mostly useful in examples where it's known that all the
   data will be in one range and it should be transformed to another range.

   It is not recommended to use this on subsets of data as the complete input range might not be
   available in that subset.

   For more powerful scaling, please consider <fann_scale_train>

   See also:
   	<fann_scale_input_train_data>, <fann_scale_train_data>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL void FANN_API fann_scale_output_train_data(struct fann_train_data *train_data,
														 fann_type new_min, fann_type new_max);

/* Function: fann_scale_train_data

   Scales the inputs and outputs in the training data to the specified range.

   A simplified scaling method, which is mostly useful in examples where it's known that all the
   data will be in one range and it should be transformed to another range.

   It is not recommended to use this on subsets of data as the complete input range might not be
   available in that subset.

   For more powerful scaling, please consider <fann_scale_train>

   See also:
   	<fann_scale_output_train_data>, <fann_scale_input_train_data>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL void FANN_API fann_scale_train_data(struct fann_train_data *train_data,
												  fann_type new_min, fann_type new_max);

/* Function: fann_merge_train_data

   Merges the data from *data1* and *data2* into a new <struct fann_train_data>.

   This function appears in FANN >= 1.1.0.
 */
FANN_EXTERNAL struct fann_train_data *FANN_API fann_merge_train_data(struct fann_train_data *data1,
																	 struct fann_train_data *data2);

/* Function: fann_duplicate_train_data

   Returns an exact copy of a <struct fann_train_data>.

   This function appears in FANN >= 1.1.0.
 */
FANN_EXTERNAL struct fann_train_data *FANN_API fann_duplicate_train_data(struct fann_train_data
																		 *data);

/* Function: fann_subset_train_data

   Returns an copy of a subset of the <struct fann_train_data>, starting at position *pos*
   and *length* elements forward.

   >fann_subset_train_data(train_data, 0, fann_length_train_data(train_data))

   Will do the same as <fann_duplicate_train_data>.

   See also:
   	<fann_length_train_data>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL struct fann_train_data *FANN_API fann_subset_train_data(struct fann_train_data
																		 *data, unsigned int pos,
																		 unsigned int length);

/* Function: fann_length_train_data

   Returns the number of training patterns in the <struct fann_train_data>.

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL unsigned int FANN_API fann_length_train_data(struct fann_train_data *data);

/* Function: fann_num_input_train_data

   Returns the number of inputs in each of the training patterns in the <struct fann_train_data>.

   See also:
   	<fann_num_train_data>, <fann_num_output_train_data>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL unsigned int FANN_API fann_num_input_train_data(struct fann_train_data *data);

/* Function: fann_num_output_train_data

   Returns the number of outputs in each of the training patterns in the <struct fann_train_data>.

   See also:
   	<fann_num_train_data>, <fann_num_input_train_data>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL unsigned int FANN_API fann_num_output_train_data(struct fann_train_data *data);

/* Function: fann_save_train

   Save the training structure to a file, with the format as specified in <fann_read_train_from_file>

   Return:
   The function returns 0 on success and -1 on failure.

   See also:
   	<fann_read_train_from_file>, <fann_save_train_to_fixed>

   This function appears in FANN >= 1.0.0.
 */
FANN_EXTERNAL int FANN_API fann_save_train(struct fann_train_data *data, const char *filename);

/* Function: fann_save_train_to_fixed

   Saves the training structure to a fixed point data file.

   This function is very useful for testing the quality of a fixed point network.

   Return:
   The function returns 0 on success and -1 on failure.

   See also:
   	<fann_save_train>

   This function appears in FANN >= 1.0.0.
 */
FANN_EXTERNAL int FANN_API fann_save_train_to_fixed(struct fann_train_data *data, const char *filename,
													 unsigned int decimal_point);

/* Group: Parameters */

/* Function: fann_get_training_algorithm

   Return the training algorithm as described by <fann_train_enum>. This training algorithm
   is used by <fann_train_on_data> and associated functions.

   Note that this algorithm is also used during <fann_cascadetrain_on_data>, although only
   FANN_TRAIN_RPROP and FANN_TRAIN_QUICKPROP is allowed during cascade training.

   The default training algorithm is FANN_TRAIN_RPROP.

   See also:
    <fann_set_training_algorithm>, <fann_train_enum>

   This function appears in FANN >= 1.0.0.
 */
FANN_EXTERNAL enum fann_train_enum FANN_API fann_get_training_algorithm(struct fann *ann);

/* Function: fann_set_training_algorithm

   Set the training algorithm.

   More info available in <fann_get_training_algorithm>

   This function appears in FANN >= 1.0.0.
 */
FANN_EXTERNAL void FANN_API fann_set_training_algorithm(struct fann *ann,
														enum fann_train_enum training_algorithm);

/* Function: fann_get_learning_rate

   Return the learning rate.

   The learning rate is used to determine how aggressive training should be for some of the
   training algorithms (FANN_TRAIN_INCREMENTAL, FANN_TRAIN_BATCH, FANN_TRAIN_QUICKPROP).
   Do however note that it is not used in FANN_TRAIN_RPROP.

   The default learning rate is 0.7.

   See also:
   	<fann_set_learning_rate>, <fann_set_training_algorithm>

   This function appears in FANN >= 1.0.0.
 */
FANN_EXTERNAL float FANN_API fann_get_learning_rate(struct fann *ann);

/* Function: fann_set_learning_rate

   Set the learning rate.

   More info available in <fann_get_learning_rate>

   This function appears in FANN >= 1.0.0.
 */
FANN_EXTERNAL void FANN_API fann_set_learning_rate(struct fann *ann, float learning_rate);

/* Function: fann_get_learning_momentum

   Get the learning momentum.

   The learning momentum can be used to speed up FANN_TRAIN_INCREMENTAL training.
   A too high momentum will however not benefit training. Setting momentum to 0 will
   be the same as not using the momentum parameter. The recommended value of this parameter
   is between 0.0 and 1.0.

   The default momentum is 0.

   See also:
   <fann_set_learning_momentum>, <fann_set_training_algorithm>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL float FANN_API fann_get_learning_momentum(struct fann *ann);

/* Function: fann_set_learning_momentum

   Set the learning momentum.

   More info available in <fann_get_learning_momentum>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL void FANN_API fann_set_learning_momentum(struct fann *ann, float learning_momentum);

/* Function: fann_get_activation_function

   Get the activation function for neuron number *neuron* in layer number *layer*,
   counting the input layer as layer 0.

   It is not possible to get activation functions for the neurons in the input layer.

   Information about the individual activation functions is available at <fann_activationfunc_enum>.

   Returns:
    The activation function for the neuron or -1 if the neuron is not defined in the neural network.

   See also:
   	<fann_set_activation_function_layer>, <fann_set_activation_function_hidden>,
   	<fann_set_activation_function_output>, <fann_set_activation_steepness>,
    <fann_set_activation_function>

   This function appears in FANN >= 2.1.0
 */
FANN_EXTERNAL enum fann_activationfunc_enum FANN_API fann_get_activation_function(struct fann *ann,
																int layer,
																int neuron);

/* Function: fann_set_activation_function

   Set the activation function for neuron number *neuron* in layer number *layer*,
   counting the input layer as layer 0.

   It is not possible to set activation functions for the neurons in the input layer.

   When choosing an activation function it is important to note that the activation
   functions have different range. FANN_SIGMOID is e.g. in the 0 - 1 range while
   FANN_SIGMOID_SYMMETRIC is in the -1 - 1 range and FANN_LINEAR is unbounded.

   Information about the individual activation functions is available at <fann_activationfunc_enum>.

   The default activation function is FANN_SIGMOID_STEPWISE.

   See also:
   	<fann_set_activation_function_layer>, <fann_set_activation_function_hidden>,
   	<fann_set_activation_function_output>, <fann_set_activation_steepness>,
    <fann_get_activation_function>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL void FANN_API fann_set_activation_function(struct fann *ann,
																enum fann_activationfunc_enum
																activation_function,
																int layer,
																int neuron);

/* Function: fann_set_activation_function_layer

   Set the activation function for all the neurons in the layer number *layer*,
   counting the input layer as layer 0.

   It is not possible to set activation functions for the neurons in the input layer.

   See also:
   	<fann_set_activation_function>, <fann_set_activation_function_hidden>,
   	<fann_set_activation_function_output>, <fann_set_activation_steepness_layer>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL void FANN_API fann_set_activation_function_layer(struct fann *ann,
																enum fann_activationfunc_enum
																activation_function,
																int layer);

/* Function: fann_set_activation_function_hidden

   Set the activation function for all of the hidden layers.

   See also:
   	<fann_set_activation_function>, <fann_set_activation_function_layer>,
   	<fann_set_activation_function_output>, <fann_set_activation_steepness_hidden>

   This function appears in FANN >= 1.0.0.
 */
FANN_EXTERNAL void FANN_API fann_set_activation_function_hidden(struct fann *ann,
																enum fann_activationfunc_enum
																activation_function);

/* Function: fann_set_activation_function_output

   Set the activation function for the output layer.

   See also:
   	<fann_set_activation_function>, <fann_set_activation_function_layer>,
   	<fann_set_activation_function_hidden>, <fann_set_activation_steepness_output>

   This function appears in FANN >= 1.0.0.
 */
FANN_EXTERNAL void FANN_API fann_set_activation_function_output(struct fann *ann,
																enum fann_activationfunc_enum
																activation_function);

/* Function: fann_get_activation_steepness

   Get the activation steepness for neuron number *neuron* in layer number *layer*,
   counting the input layer as layer 0.

   It is not possible to get activation steepness for the neurons in the input layer.

   The steepness of an activation function says something about how fast the activation function
   goes from the minimum to the maximum. A high value for the activation function will also
   give a more aggressive training.

   When training neural networks where the output values should be at the extremes (usually 0 and 1,
   depending on the activation function), a steep activation function can be used (e.g. 1.0).

   The default activation steepness is 0.5.

   Returns:
    The activation steepness for the neuron or -1 if the neuron is not defined in the neural network.

   See also:
   	<fann_set_activation_steepness_layer>, <fann_set_activation_steepness_hidden>,
   	<fann_set_activation_steepness_output>, <fann_set_activation_function>,
    <fann_set_activation_steepness>

   This function appears in FANN >= 2.1.0
 */
FANN_EXTERNAL fann_type FANN_API fann_get_activation_steepness(struct fann *ann,
																int layer,
																int neuron);

/* Function: fann_set_activation_steepness

   Set the activation steepness for neuron number *neuron* in layer number *layer*,
   counting the input layer as layer 0.

   It is not possible to set activation steepness for the neurons in the input layer.

   The steepness of an activation function says something about how fast the activation function
   goes from the minimum to the maximum. A high value for the activation function will also
   give a more aggressive training.

   When training neural networks where the output values should be at the extremes (usually 0 and 1,
   depending on the activation function), a steep activation function can be used (e.g. 1.0).

   The default activation steepness is 0.5.

   See also:
   	<fann_set_activation_steepness_layer>, <fann_set_activation_steepness_hidden>,
   	<fann_set_activation_steepness_output>, <fann_set_activation_function>,
    <fann_get_activation_steepness>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL void FANN_API fann_set_activation_steepness(struct fann *ann,
																fann_type steepness,
																int layer,
																int neuron);

/* Function: fann_set_activation_steepness_layer

   Set the activation steepness for all of the neurons in layer number *layer*,
   counting the input layer as layer 0.

   It is not possible to set activation steepness for the neurons in the input layer.

   See also:
   	<fann_set_activation_steepness>, <fann_set_activation_steepness_hidden>,
   	<fann_set_activation_steepness_output>, <fann_set_activation_function_layer>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL void FANN_API fann_set_activation_steepness_layer(struct fann *ann,
																fann_type steepness,
																int layer);

/* Function: fann_set_activation_steepness_hidden

   Set the steepness of the activation steepness in all of the hidden layers.

   See also:
   	<fann_set_activation_steepness>, <fann_set_activation_steepness_layer>,
   	<fann_set_activation_steepness_output>, <fann_set_activation_function_hidden>

   This function appears in FANN >= 1.2.0.
 */
FANN_EXTERNAL void FANN_API fann_set_activation_steepness_hidden(struct fann *ann,
																 fann_type steepness);

/* Function: fann_set_activation_steepness_output

   Set the steepness of the activation steepness in the output layer.

   See also:
   	<fann_set_activation_steepness>, <fann_set_activation_steepness_layer>,
   	<fann_set_activation_steepness_hidden>, <fann_set_activation_function_output>

   This function appears in FANN >= 1.2.0.
 */
FANN_EXTERNAL void FANN_API fann_set_activation_steepness_output(struct fann *ann,
																 fann_type steepness);

/* Function: fann_get_train_error_function

   Returns the error function used during training.

   The error functions are described further in <fann_errorfunc_enum>

   The default error function is FANN_ERRORFUNC_TANH

   See also:
   	<fann_set_train_error_function>

   This function appears in FANN >= 1.2.0.
  */
FANN_EXTERNAL enum fann_errorfunc_enum FANN_API fann_get_train_error_function(struct fann *ann);

/* Function: fann_set_train_error_function

   Set the error function used during training.

   The error functions are described further in <fann_errorfunc_enum>

   See also:
   	<fann_get_train_error_function>

   This function appears in FANN >= 1.2.0.
 */
FANN_EXTERNAL void FANN_API fann_set_train_error_function(struct fann *ann,
														  enum fann_errorfunc_enum
														  train_error_function);

/* Function: fann_get_train_stop_function

   Returns the the stop function used during training.

   The stop function is described further in <fann_stopfunc_enum>

   The default stop function is FANN_STOPFUNC_MSE

   See also:
   	<fann_get_train_stop_function>, <fann_get_bit_fail_limit>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL enum fann_stopfunc_enum FANN_API fann_get_train_stop_function(struct fann *ann);

/* Function: fann_set_train_stop_function

   Set the stop function used during training.

   Returns the the stop function used during training.

   The stop function is described further in <fann_stopfunc_enum>

   See also:
   	<fann_get_train_stop_function>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL void FANN_API fann_set_train_stop_function(struct fann *ann,
														 enum fann_stopfunc_enum train_stop_function);

/* Function: fann_get_bit_fail_limit

   Returns the bit fail limit used during training.

   The bit fail limit is used during training where the <fann_stopfunc_enum> is set to FANN_STOPFUNC_BIT.

   The limit is the maximum accepted difference between the desired output and the actual output during
   training. Each output that diverges more than this limit is counted as an error bit.
   This difference is divided by two when dealing with symmetric activation functions,
   so that symmetric and not symmetric activation functions can use the same limit.

   The default bit fail limit is 0.35.

   See also:
   	<fann_set_bit_fail_limit>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL fann_type FANN_API fann_get_bit_fail_limit(struct fann *ann);

/* Function: fann_set_bit_fail_limit

   Set the bit fail limit used during training.

   See also:
   	<fann_get_bit_fail_limit>

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL void FANN_API fann_set_bit_fail_limit(struct fann *ann, fann_type bit_fail_limit);

/* Function: fann_set_callback

   Sets the callback function for use during training.

   See <fann_callback_type> for more information about the callback function.

   The default callback function simply prints out some status information.

   This function appears in FANN >= 2.0.0.
 */
FANN_EXTERNAL void FANN_API fann_set_callback(struct fann *ann, fann_callback_type callback);

/* Function: fann_get_quickprop_decay

   The decay is a small negative valued number which is the factor that the weights
   should become smaller in each iteration during quickprop training. This is used
   to make sure that the weights do not become too high during training.

   The default decay is -0.0001.

   See also:
   	<fann_set_quickprop_decay>

   This function appears in FANN >= 1.2.0.
 */
FANN_EXTERNAL float FANN_API fann_get_quickprop_decay(struct fann *ann);

/* Function: fann_set_quickprop_decay

   Sets the quickprop decay factor.

   See also:
   	<fann_get_quickprop_decay>

   This function appears in FANN >= 1.2.0.
*/
FANN_EXTERNAL void FANN_API fann_set_quickprop_decay(struct fann *ann, float quickprop_decay);

/* Function: fann_get_quickprop_mu

   The mu factor is used to increase and decrease the step-size during quickprop training.
   The mu factor should always be above 1, since it would otherwise decrease the step-size
   when it was supposed to increase it.

   The default mu factor is 1.75.

   See also:
   	<fann_set_quickprop_mu>

   This function appears in FANN >= 1.2.0.
*/
FANN_EXTERNAL float FANN_API fann_get_quickprop_mu(struct fann *ann);

/* Function: fann_set_quickprop_mu

    Sets the quickprop mu factor.

   See also:
   	<fann_get_quickprop_mu>

   This function appears in FANN >= 1.2.0.
*/
FANN_EXTERNAL void FANN_API fann_set_quickprop_mu(struct fann *ann, float quickprop_mu);

/* Function: fann_get_rprop_increase_factor

   The increase factor is a value larger than 1, which is used to
   increase the step-size during RPROP training.

   The default increase factor is 1.2.

   See also:
   	<fann_set_rprop_increase_factor>

   This function appears in FANN >= 1.2.0.
*/
FANN_EXTERNAL float FANN_API fann_get_rprop_increase_factor(struct fann *ann);

/* Function: fann_set_rprop_increase_factor

   The increase factor used during RPROP training.

   See also:
   	<fann_get_rprop_increase_factor>

   This function appears in FANN >= 1.2.0.
*/
FANN_EXTERNAL void FANN_API fann_set_rprop_increase_factor(struct fann *ann,
														   float rprop_increase_factor);

/* Function: fann_get_rprop_decrease_factor

   The decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.

   The default decrease factor is 0.5.

   See also:
    <fann_set_rprop_decrease_factor>

   This function appears in FANN >= 1.2.0.
*/
FANN_EXTERNAL float FANN_API fann_get_rprop_decrease_factor(struct fann *ann);

/* Function: fann_set_rprop_decrease_factor

   The decrease factor is a value smaller than 1, which is used to decrease the step-size during RPROP training.

   See also:
    <fann_get_rprop_decrease_factor>

   This function appears in FANN >= 1.2.0.
*/
FANN_EXTERNAL void FANN_API fann_set_rprop_decrease_factor(struct fann *ann,
														   float rprop_decrease_factor);

/* Function: fann_get_rprop_delta_min

   The minimum step-size is a small positive number determining how small the minimum step-size may be.

   The default value delta min is 0.0.

   See also:
   	<fann_set_rprop_delta_min>

   This function appears in FANN >= 1.2.0.
*/
FANN_EXTERNAL float FANN_API fann_get_rprop_delta_min(struct fann *ann);

/* Function: fann_set_rprop_delta_min

   The minimum step-size is a small positive number determining how small the minimum step-size may be.

   See also:
   	<fann_get_rprop_delta_min>

   This function appears in FANN >= 1.2.0.
*/
FANN_EXTERNAL void FANN_API fann_set_rprop_delta_min(struct fann *ann, float rprop_delta_min);

/* Function: fann_get_rprop_delta_max

   The maximum step-size is a positive number determining how large the maximum step-size may be.

   The default delta max is 50.0.

   See also:
   	<fann_set_rprop_delta_max>, <fann_get_rprop_delta_min>

   This function appears in FANN >= 1.2.0.
*/
FANN_EXTERNAL float FANN_API fann_get_rprop_delta_max(struct fann *ann);

/* Function: fann_set_rprop_delta_max

   The maximum step-size is a positive number determining how large the maximum step-size may be.

   See also:
   	<fann_get_rprop_delta_max>, <fann_get_rprop_delta_min>

   This function appears in FANN >= 1.2.0.
*/
FANN_EXTERNAL void FANN_API fann_set_rprop_delta_max(struct fann *ann, float rprop_delta_max);

/* Function: fann_get_rprop_delta_zero

   The initial step-size is a positive number determining the initial step size.

   The default delta zero is 0.1.

   See also:
   	<fann_set_rprop_delta_zero>, <fann_get_rprop_delta_min>, <fann_get_rprop_delta_max>

   This function appears in FANN >= 2.1.0.
*/
FANN_EXTERNAL float FANN_API fann_get_rprop_delta_zero(struct fann *ann);

/* Function: fann_set_rprop_delta_zero

   The initial step-size is a positive number determining the initial step size.

   See also:
   	<fann_get_rprop_delta_zero>, <fann_get_rprop_delta_zero>

   This function appears in FANN >= 2.1.0.
*/
FANN_EXTERNAL void FANN_API fann_set_rprop_delta_zero(struct fann *ann, float rprop_delta_max);

/* Method: fann_get_sarprop_weight_decay_shift

   The sarprop weight decay shift.

   The default delta max is -6.644.

   See also:
   <fann fann_set_sarprop_weight_decay_shift>

   This function appears in FANN >= 2.1.0.
   */
FANN_EXTERNAL float FANN_API fann_get_sarprop_weight_decay_shift(struct fann *ann);

/* Method: fann_set_sarprop_weight_decay_shift

   Set the sarprop weight decay shift.

   This function appears in FANN >= 2.1.0.

   See also:
   <fann_set_sarprop_weight_decay_shift>
   */
FANN_EXTERNAL void FANN_API fann_set_sarprop_weight_decay_shift(struct fann *ann, float sarprop_weight_decay_shift);

/* Method: fann_get_sarprop_step_error_threshold_factor

   The sarprop step error threshold factor.

   The default delta max is 0.1.

   See also:
   <fann fann_get_sarprop_step_error_threshold_factor>

   This function appears in FANN >= 2.1.0.
   */
FANN_EXTERNAL float FANN_API fann_get_sarprop_step_error_threshold_factor(struct fann *ann);

/* Method: fann_set_sarprop_step_error_threshold_factor

   Set the sarprop step error threshold factor.

   This function appears in FANN >= 2.1.0.

   See also:
   <fann_get_sarprop_step_error_threshold_factor>
   */
FANN_EXTERNAL void FANN_API fann_set_sarprop_step_error_threshold_factor(struct fann *ann, float sarprop_step_error_threshold_factor);

/* Method: fann_get_sarprop_step_error_shift

   The get sarprop step error shift.

   The default delta max is 1.385.

   See also:
   <fann_set_sarprop_step_error_shift>

   This function appears in FANN >= 2.1.0.
   */
FANN_EXTERNAL float FANN_API fann_get_sarprop_step_error_shift(struct fann *ann);

/* Method: fann_set_sarprop_step_error_shift

   Set the sarprop step error shift.

   This function appears in FANN >= 2.1.0.

   See also:
   <fann_get_sarprop_step_error_shift>
   */
FANN_EXTERNAL void FANN_API fann_set_sarprop_step_error_shift(struct fann *ann, float sarprop_step_error_shift);

/* Method: fann_get_sarprop_temperature

   The sarprop weight decay shift.

   The default delta max is 0.015.

   See also:
   <fann_set_sarprop_temperature>

   This function appears in FANN >= 2.1.0.
   */
FANN_EXTERNAL float FANN_API fann_get_sarprop_temperature(struct fann *ann);

/* Method: fann_set_sarprop_temperature

   Set the sarprop_temperature.

   This function appears in FANN >= 2.1.0.

   See also:
   <fann_get_sarprop_temperature>
   */
FANN_EXTERNAL void FANN_API fann_set_sarprop_temperature(struct fann *ann, float sarprop_temperature);

#endif


text:
/*
Modules: Calendar
-----------------------*/
/** Calendar **/
.calendartable {
    width: 100%;
    font-size: 85%;
}
.calendartable th,
.calendartable td {
    width:14%;
    vertical-align:top;
    text-align: center;
    border-width:0px;
}
.path-calendar .calendar-controls .previous,
.path-calendar .calendar-controls .next,
.path-calendar .calendar-controls .current {
    display: block;
    float: left;
    width: 12%;
}
.path-calendar .calendar-controls .previous {
    text-align: left;
}
.path-calendar .calendar-controls .current {
    text-align: center;
    width: 76%;
}
.path-calendar .calendar-controls .next {
    text-align: right;
}
.path-calendar {}
.path-calendar .maincalendar {
    vertical-align: top;padding:0;
}
.path-calendar .maincalendar .bottom {
    text-align: center;padding:5px 0 0 0;
}
.path-calendar .maincalendar .heightcontainer {
    height: 100%;position: relative;
}
.path-calendar .maincalendar .calendarmonth {
    width:98%;margin:10px auto;
}
.path-calendar .maincalendar .calendarmonth ul {
    margin:0;
}
.path-calendar .maincalendar .calendarmonth ul li {
    list-style-type:none;margin-top: 4px;
}
.path-calendar .maincalendar .calendarmonth td {
    height: 5em;
}
.path-calendar .maincalendar .calendar-controls .previous,
.path-calendar .maincalendar .calendar-controls .next {
    width: 30%;
}
.path-calendar .maincalendar .calendar-controls .current {
    width: 39.95%;
}
.path-calendar .maincalendar .controls {
    width:98%;margin:10px auto;
}
.path-calendar .maincalendar .eventlist .event {
    width:100%;
    margin-bottom:10px;
    border-spacing:0px;
    border-collapse:separate;
    border-width:1px;
    border-style:solid;
}
.path-calendar .maincalendar .eventlist .event .topic .name {
    float:left;
}
.path-calendar .maincalendar .eventlist .event .topic .date {
    float:right;
}
.path-calendar .maincalendar .eventlist .event .course {
    float:left;
    clear:left;
}
.path-calendar .maincalendar .eventlist .event .side {
    width:32px;
}
.path-calendar .maincalendar .header {
    overflow:hidden;
}
.path-calendar .maincalendar .header .buttons {
    float: right;
}
.path-calendar .filters table {
    border-collapse:separate;
    border-spacing: 2px;width: 100%;
}
#page-calendar-export .indent {
    padding-left: 20px;
}
.block .minicalendar {
    width:100%;
    margin:10px auto;
}
.block .minicalendar th,
.block .minicalendar td {
    padding:2px;font-size: 10px;
}
.block .minicalendar td.weekend {
    color:#A00;
}
.block .calendar-controls .previous {
    text-align: left;
    display: block;
    float: left;
    width: 12%;
}
.block .calendar-controls .current {
    float:left;
    text-align: center;
    display: block;
    width:76%;
}
.block .calendar-controls .next {
    text-align: right;
    display: block;
    float: left;
    width: 12%;
}
.block .filters table {
    border-collapse:separate;
    border-spacing: 2px;
    padding: 2px;width: 100%;
}
.block .content h3.eventskey {
    margin-top:0.5em;
    margin-bottom:0;
}
.block .calendar_filters li { padding: 0; }
/*
Colors for Calendar Events
-----------------------*/
#calendar .event_global,
.minicalendar .event_global,
.block_calendar_month .event_global,
.calendar_event_global {
    border-color:#def2ba !important;
    background-color:#def2ba;
}
#calendar .event_course,
.minicalendar .event_course,
.block_calendar_month .event_course,
.calendar_event_course {
    border-color:#c6dfeb !important;
    background-color:#c6dfeb;
}
#calendar .event_group,
.minicalendar .event_group,
.block_calendar_month .event_group,
.calendar_event_group {
    border-color:#feffc2 !important;
    background-color:#feffc2;
}
#calendar .event_user,
.minicalendar .event_user,
.block_calendar_month .event_user,
.calendar_event_user {
    border-color:#d9c6e2 !important;
    background-color:#d9c6e2;
}
table.minicalendar tr td.weekend {
    color: #f00;
}

redpajama_set_name: RedPajamaGithub


text:
class Conversation < ActiveRecord::Base

  acts_as_taggable_on :tags, :bookmarks

  belongs_to :abuse_report # the abuse report record that made this convo disabled
  belongs_to :user, :counter_cache => true
  belongs_to :parent_message, # parent message it was spawned from, in case it was created by spawning
    :class_name => "Message",
    :foreign_key => "parent_message_id"

  has_many :abuse_reports # all the abuse report that were filed against this convo
  has_many :messages # these are the conversations messages
  has_many :subscriptions
  has_many :users, :through => :subscriptions, :uniq => true,:order => "login ASC" # followers,  subscribers
  has_many :recent_followers,
    :through => :subscriptions,
    :source => :user,
    :uniq => true,
    :order => "subscriptions.created_at DESC",
    :limit => 10

  # do not validate the uniquness of the personal conversations names, they will be guaranteed to be unique since the user names will be
  validates_presence_of     :name
  validates_uniqueness_of   :name,                       :unless => :personal? or :spawned?
  validates_length_of       :name,    :within => 3..100, :unless => :personal?
  validates_presence_of     :description
  validates_length_of       :description, :maximum => 10000
  validates_format_of       :something, :with => /^$/ # anti spam, honeypot field must be blank

  named_scope :published, :conditions => { :abuse_report_id => nil }
  named_scope :non_private, :conditions => { :private => false }
  named_scope :not_personal, :conditions => { :personal_conversation => false }
  named_scope :personal, :conditions => { :personal_conversation => true }
  named_scope :no_owned_by, lambda { |user_id| { :conditions => ['conversations.user_id <> ?', user_id] }}

  # sphinx index
  define_index do
    indexes :name
    indexes description
    has created_at
    has abuse_report_id
    set_property :delta => true
  end

  ##
  # class methods
  #
  def self.add_personal(user)
    name = user.name || user.login
    desc = "This is a personal conversation for #{name}. If you wish to collaborate with #{name}, do it here."
    convo = user.conversations.create(:name => user.login, :personal_conversation => true, :description => desc)
    convo.tag_list.add("personal_convo")
    convo.save
    convo
  end

  def self.most_popular
    conversations = ConversationVisit.find(:all, :conditions => ["updated_at >= ?", Date.today - 30.days ], :group => :conversation_id, :order => "visits_count DESC", :limit => 10).map { |convo_visit| convo_visit.conversation }
    conversations
  end

  ##
  # instance methods
  #
  def total_visits
    ConversationVisit.find(:first, :group => :conversation_id, :conditions => ["conversation_id = ?", self.id]).visits_count
  end

  def owner
    self.user
  end

  def escaped_name
    escaped(self.name)
  end

  def escaped_description
    escaped(self.description)
  end

  def followed_by?(user)
    self.subscriptions.find_by_user_id( user.id ).nil? ? false : true
  end

  def readable_by?(user)
    self.owner == user ||
    !self.private? ||
    self.followed_by?(user)
  end

  def writable_by?(user)
    self.owner == user ||
    ( !self.read_only && !self.private? ) ||
    ( self.private? && self.followed_by?(user) )
  end

  def personal?
    self.personal_conversation
  end

  def published?
    self.abuse_report.nil?
  end

  def private?
    self.private
  end

  def spawned?
    !self.parent_message_id.nil?
  end

  def over_abuse_reports_limit?
    self.abuse_reports.size > CONVERSATION_ABUSE_THRESHOLD
  end

  def disabled_by_abuse_report?
    self.abuse_report_id == nil ? false : true
  end

  def add_visit(user)
    if cv = ConversationVisit.find_by_user_id_and_conversation_id(user.id, self.id)
      cv.increment!( :visits_count )
    else
      user.conversation_visits.create( :conversation => self )
    end
  end

  def add_subscription(user)
    self.subscriptions.create( :user => user )
  end

  def remove_subscription(user)
    sub = self.subscriptions.find_all_by_user_id( user.id )
    sub.empty? ? true : sub.each { |s| s.destroy }
  end

  def report_abuse(user)
    unless abuse_report = self.abuse_reports.find_by_user_id( user.id )
      abuse_report = self.abuse_reports.create( :user => user )
    end
    self.reload
    # check if we should deactivate the convo for abuse
    if (user == self.owner and self != self.user.personal_conversation) or self.over_abuse_reports_limit?
      self.update_attributes( :abuse_report => abuse_report )
    end
  end

  def notify_of_new_spawn(user)
    msg = %Q(
      new convo: #{self.name}
      spawned by: #{user.login}

      in response to: #{HOST}/conversations/#{self.parent_message.conversation_id}/messages/#{self.parent_message.id}
    )
    notification = user.messages.create( :conversation => self.parent_message.conversation, :message => msg)
    notification.system_message = true
    notification.save
    return notification
  end

  def get_messages_before(first_message_id)
    self.messages.published.find(:all, :include => [:user], :conditions => ["id < ?", first_message_id], :limit => 100, :order => 'id DESC')
  end

  def has_messages_before?(first_message)
    return false if(first_message == nil)
    messages = self.messages.published.find(:first, :conditions => ["id < ?", first_message.id], :order => 'id DESC')
    messages ? true : false
  end

  def get_messages_after(last_message_id)
   self.messages.published.find(:all, :include => [:user], :conditions => ["id > ?", last_message_id], :limit => 100, :order => 'id ASC').reverse
  end

  def has_messages_after?(last_message)
    return false if(last_message == nil)
    messages = self.messages.published.find(:first, :conditions => ["id > ?", last_message.id], :order => 'id ASC')
    messages ? true : false
  end

  def after_create
    owner.follow(self)
    self.user.tag(self, :with => self.tag_list.to_s  + ", " + self.user.login, :on => :tags)
  end

  def date_time12
    self.created_at.strftime '%m/%d/%Y %I:%M%p'
  end

  def to_param
    "#{id}-#{name.parameterize}"
  end

private

  def escaped(value)
    value.gsub(/"/, '"').gsub(/'/, '.').gsub(/(\r\n|\n|\r)/,'
')
  end

end


text:
package androidx.car.app.sample.showcase.common.misc;

import static androidx.car.app.model.Action.BACK;

import androidx.annotation.NonNull;
import androidx.car.app.CarContext;
import androidx.car.app.Screen;
import androidx.car.app.model.Pane;
import androidx.car.app.model.PaneTemplate;
import androidx.car.app.model.Row;
import androidx.car.app.model.Template;
import androidx.car.app.sample.showcase.common.R;

/** A screen that displays text about canceling the reservation */
public final class ReservationCancelledScreen extends Screen {

    public ReservationCancelledScreen(@NonNull CarContext carContext) {
        super(carContext);
    }

    @NonNull
    @Override
    public Template onGetTemplate() {
        Pane pane = new Pane.Builder()
                .addRow(new Row.Builder()
                        .setTitle(getCarContext().getString(R.string.reservation_cancelled_msg))
                        .build())
                .build();

        return new PaneTemplate.Builder(pane)
                .setTitle(getCarContext().getString(R.string.cancel_reservation_title))
                .setHeaderAction(BACK)
                .build();
    }
}


text:
@implementation BCQueryBillResult

- (instancetype) initWithResult:(NSDictionary *)dic {
    self = [super initWithResult:dic];
    if (self) {
        self.type = BCObjsTypeBillResults;
        self.payResult = [dic boolValueForKey:@"spay_result" defaultValue:NO];
        self.tradeNo = [dic stringValueForKey:@"trade_no" defaultValue:@""];
        self.revertResult = [dic boolValueForKey:@"revert_result" defaultValue:NO];
        self.refundResult = [dic boolValueForKey:@"refund_result" defaultValue:NO];
    }
    return self;
}

@end


text:
package tunnel_test

import (
	"fmt"
	"net/http"
	"reflect"
	"testing"

	"github.com/koding/tunnel/tunneltest"
)

func testWebsocket(name string, n int, t *testing.T, tt *tunneltest.TunnelTest) {
	conn, err := websocketDial(tt, "http")
	if err != nil {
		t.Fatalf("Dial()=%s", err)
	}
	defer conn.Close()

	for i := 0; i < n; i++ {
		want := &EchoMessage{
			Value: fmt.Sprintf("message #%d", i),
			Close: i == (n - 1),
		}

		err := conn.WriteJSON(want)
		if err != nil {
			t.Errorf("(test %s) %d: failed sending %q: %s", name, i, want, err)
			continue
		}

		got := &EchoMessage{}

		err = conn.ReadJSON(got)
		if err != nil {
			t.Errorf("(test %s) %d: failed reading: %s", name, i, err)
			continue
		}

		if !reflect.DeepEqual(got, want) {
			t.Errorf("(test %s) %d: got %+v, want %+v", name, i, got, want)
		}
	}
}

func testHandler(t *testing.T, fn func(w http.ResponseWriter, r *http.Request) error) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		if err := fn(w, r); err != nil {
			t.Errorf("handler func error: %s", err)
		}
	}
}

func TestWebsocket(t *testing.T) {
	tt, err := tunneltest.Serve(singleHTTP(testHandler(t, handlerEchoWS(nil))))
	if err != nil {
		t.Fatal(err)
	}

	testWebsocket("handlerEchoWS", 100, t, tt)
}

func TestLatencyWebsocket(t *testing.T) {
	tt, err := tunneltest.Serve(singleHTTP(testHandler(t, handlerEchoWS(sleep))))
	if err != nil {
		t.Fatal(err)
	}

	testWebsocket("handlerLatencyEchoWS", 20, t, tt)
}


text:
module NetrcHelper
  def spec_open_netrc
    Netrc.read(Netrc.default_path)
  end

  def spec_save_netrc_entry(data)
    netrc = spec_open_netrc
    netrc['api.http://turbot.opencorporates.com'] = data
    netrc.save
  end

  def spec_delete_netrc_entry
    netrc = spec_open_netrc
    netrc.delete('api.http://turbot.opencorporates.com')
    netrc.save
  end

  def spec_read_netrc
    spec_open_netrc['api.http://turbot.opencorporates.com']
  end
end


text:
package org.apache.spark.mllib.clustering

import breeze.linalg.{DenseMatrix => BDM, normalize, sum => brzSum}

import org.apache.spark.annotation.Experimental
import org.apache.spark.api.java.JavaPairRDD
import org.apache.spark.graphx.{VertexId, EdgeContext, Graph}
import org.apache.spark.mllib.linalg.{Vectors, Vector, Matrices, Matrix}
import org.apache.spark.rdd.RDD
import org.apache.spark.util.BoundedPriorityQueue

/**
 * :: Experimental ::
 *
 * Latent Dirichlet Allocation (LDA) model.
 *
 * This abstraction permits for different underlying representations,
 * including local and distributed data structures.
 */
@Experimental
abstract class LDAModel private[clustering] {

  /** Number of topics */
  def k: Int

  /** Vocabulary size (number of terms or terms in the vocabulary) */
  def vocabSize: Int

  /**
   * Inferred topics, where each topic is represented by a distribution over terms.
   * This is a matrix of size vocabSize x k, where each column is a topic.
   * No guarantees are given about the ordering of the topics.
   */
  def topicsMatrix: Matrix

  /**
   * Return the topics described by weighted terms.
   *
   * This limits the number of terms per topic.
   * This is approximate; it may not return exactly the top-weighted terms for each topic.
   * To get a more precise set of top terms, increase maxTermsPerTopic.
   *
   * @param maxTermsPerTopic  Maximum number of terms to collect for each topic.
   * @return  Array over topics.  Each topic is represented as a pair of matching arrays:
   *          (term indices, term weights in topic).
   *          Each topic's terms are sorted in order of decreasing weight.
   */
  def describeTopics(maxTermsPerTopic: Int): Array[(Array[Int], Array[Double])]

  /**
   * Return the topics described by weighted terms.
   *
   * WARNING: If vocabSize and k are large, this can return a large object!
   *
   * @return  Array over topics.  Each topic is represented as a pair of matching arrays:
   *          (term indices, term weights in topic).
   *          Each topic's terms are sorted in order of decreasing weight.
   */
  def describeTopics(): Array[(Array[Int], Array[Double])] = describeTopics(vocabSize)

  /* TODO (once LDA can be trained with Strings or given a dictionary)
   * Return the topics described by weighted terms.
   *
   * This is similar to [[describeTopics()]] but returns String values for terms.
   * If this model was trained using Strings or was given a dictionary, then this method returns
   * terms as text.  Otherwise, this method returns terms as term indices.
   *
   * This limits the number of terms per topic.
   * This is approximate; it may not return exactly the top-weighted terms for each topic.
   * To get a more precise set of top terms, increase maxTermsPerTopic.
   *
   * @param maxTermsPerTopic  Maximum number of terms to collect for each topic.
   * @return  Array over topics.  Each topic is represented as a pair of matching arrays:
   *          (terms, term weights in topic) where terms are either the actual term text
   *          (if available) or the term indices.
   *          Each topic's terms are sorted in order of decreasing weight.
   */
  // def describeTopicsAsStrings(maxTermsPerTopic: Int): Array[(Array[Double], Array[String])]

  /* TODO (once LDA can be trained with Strings or given a dictionary)
   * Return the topics described by weighted terms.
   *
   * This is similar to [[describeTopics()]] but returns String values for terms.
   * If this model was trained using Strings or was given a dictionary, then this method returns
   * terms as text.  Otherwise, this method returns terms as term indices.
   *
   * WARNING: If vocabSize and k are large, this can return a large object!
   *
   * @return  Array over topics.  Each topic is represented as a pair of matching arrays:
   *          (terms, term weights in topic) where terms are either the actual term text
   *          (if available) or the term indices.
   *          Each topic's terms are sorted in order of decreasing weight.
   */
  // def describeTopicsAsStrings(): Array[(Array[Double], Array[String])] =
  //  describeTopicsAsStrings(vocabSize)

  /* TODO
   * Compute the log likelihood of the observed tokens, given the current parameter estimates:
   *  log P(docs | topics, topic distributions for docs, alpha, eta)
   *
   * Note:
   *  - This excludes the prior.
   *  - Even with the prior, this is NOT the same as the data log likelihood given the
   *    hyperparameters.
   *
   * @param documents  RDD of documents, which are term (word) count vectors paired with IDs.
   *                   The term count vectors are "bags of words" with a fixed-size vocabulary
   *                   (where the vocabulary size is the length of the vector).
   *                   This must use the same vocabulary (ordering of term counts) as in training.
   *                   Document IDs must be unique and >= 0.
   * @return  Estimated log likelihood of the data under this model
   */
  // def logLikelihood(documents: RDD[(Long, Vector)]): Double

  /* TODO
   * Compute the estimated topic distribution for each document.
   * This is often called 'theta' in the literature.
   *
   * @param documents  RDD of documents, which are term (word) count vectors paired with IDs.
   *                   The term count vectors are "bags of words" with a fixed-size vocabulary
   *                   (where the vocabulary size is the length of the vector).
   *                   This must use the same vocabulary (ordering of term counts) as in training.
   *                   Document IDs must be unique and >= 0.
   * @return  Estimated topic distribution for each document.
   *          The returned RDD may be zipped with the given RDD, where each returned vector
   *          is a multinomial distribution over topics.
   */
  // def topicDistributions(documents: RDD[(Long, Vector)]): RDD[(Long, Vector)]

}

/**
 * :: Experimental ::
 *
 * Local LDA model.
 * This model stores only the inferred topics.
 * It may be used for computing topics for new documents, but it may give less accurate answers
 * than the [[DistributedLDAModel]].
 *
 * @param topics Inferred topics (vocabSize x k matrix).
 */
@Experimental
class LocalLDAModel private[clustering] (
    private val topics: Matrix) extends LDAModel with Serializable {

  override def k: Int = topics.numCols

  override def vocabSize: Int = topics.numRows

  override def topicsMatrix: Matrix = topics

  override def describeTopics(maxTermsPerTopic: Int): Array[(Array[Int], Array[Double])] = {
    val brzTopics = topics.toBreeze.toDenseMatrix
    Range(0, k).map { topicIndex =>
      val topic = normalize(brzTopics(::, topicIndex), 1.0)
      val (termWeights, terms) =
        topic.toArray.zipWithIndex.sortBy(-_._1).take(maxTermsPerTopic).unzip
      (terms.toArray, termWeights.toArray)
    }.toArray
  }

  // TODO
  // override def logLikelihood(documents: RDD[(Long, Vector)]): Double = ???

  // TODO:
  // override def topicDistributions(documents: RDD[(Long, Vector)]): RDD[(Long, Vector)] = ???

}

/**
 * :: Experimental ::
 *
 * Distributed LDA model.
 * This model stores the inferred topics, the full training dataset, and the topic distributions.
 * When computing topics for new documents, it may give more accurate answers
 * than the [[LocalLDAModel]].
 */
@Experimental
class DistributedLDAModel private (
    private val graph: Graph[LDA.TopicCounts, LDA.TokenCount],
    private val globalTopicTotals: LDA.TopicCounts,
    val k: Int,
    val vocabSize: Int,
    private val docConcentration: Double,
    private val topicConcentration: Double,
    private[spark] val iterationTimes: Array[Double]) extends LDAModel {

  import LDA._

  private[clustering] def this(state: EMLDAOptimizer, iterationTimes: Array[Double]) = {
    this(state.graph, state.globalTopicTotals, state.k, state.vocabSize, state.docConcentration,
      state.topicConcentration, iterationTimes)
  }

  /**
   * Convert model to a local model.
   * The local model stores the inferred topics but not the topic distributions for training
   * documents.
   */
  def toLocal: LocalLDAModel = new LocalLDAModel(topicsMatrix)

  /**
   * Inferred topics, where each topic is represented by a distribution over terms.
   * This is a matrix of size vocabSize x k, where each column is a topic.
   * No guarantees are given about the ordering of the topics.
   *
   * WARNING: This matrix is collected from an RDD. Beware memory usage when vocabSize, k are large.
   */
  override lazy val topicsMatrix: Matrix = {
    // Collect row-major topics
    val termTopicCounts: Array[(Int, TopicCounts)] =
      graph.vertices.filter(_._1 < 0).map { case (termIndex, cnts) =>
        (index2term(termIndex), cnts)
      }.collect()
    // Convert to Matrix
    val brzTopics = BDM.zeros[Double](vocabSize, k)
    termTopicCounts.foreach { case (term, cnts) =>
      var j = 0
      while (j < k) {
        brzTopics(term, j) = cnts(j)
        j += 1
      }
    }
    Matrices.fromBreeze(brzTopics)
  }

  override def describeTopics(maxTermsPerTopic: Int): Array[(Array[Int], Array[Double])] = {
    val numTopics = k
    // Note: N_k is not needed to find the top terms, but it is needed to normalize weights
    //       to a distribution over terms.
    val N_k: TopicCounts = globalTopicTotals
    val topicsInQueues: Array[BoundedPriorityQueue[(Double, Int)]] =
      graph.vertices.filter(isTermVertex)
        .mapPartitions { termVertices =>
        // For this partition, collect the most common terms for each topic in queues:
        //  queues(topic) = queue of (term weight, term index).
        // Term weights are N_{wk} / N_k.
        val queues =
          Array.fill(numTopics)(new BoundedPriorityQueue[(Double, Int)](maxTermsPerTopic))
        for ((termId, n_wk) <- termVertices) {
          var topic = 0
          while (topic < numTopics) {
            queues(topic) += (n_wk(topic) / N_k(topic) -> index2term(termId.toInt))
            topic += 1
          }
        }
        Iterator(queues)
      }.reduce { (q1, q2) =>
        q1.zip(q2).foreach { case (a, b) => a ++= b}
        q1
      }
    topicsInQueues.map { q =>
      val (termWeights, terms) = q.toArray.sortBy(-_._1).unzip
      (terms.toArray, termWeights.toArray)
    }
  }

  // TODO
  // override def logLikelihood(documents: RDD[(Long, Vector)]): Double = ???

  /**
   * Log likelihood of the observed tokens in the training set,
   * given the current parameter estimates:
   *  log P(docs | topics, topic distributions for docs, alpha, eta)
   *
   * Note:
   *  - This excludes the prior; for that, use [[logPrior]].
   *  - Even with [[logPrior]], this is NOT the same as the data log likelihood given the
   *    hyperparameters.
   */
  lazy val logLikelihood: Double = {
    val eta = topicConcentration
    val alpha = docConcentration
    assert(eta > 1.0)
    assert(alpha > 1.0)
    val N_k = globalTopicTotals
    val smoothed_N_k: TopicCounts = N_k + (vocabSize * (eta - 1.0))
    // Edges: Compute token log probability from phi_{wk}, theta_{kj}.
    val sendMsg: EdgeContext[TopicCounts, TokenCount, Double] => Unit = (edgeContext) => {
      val N_wj = edgeContext.attr
      val smoothed_N_wk: TopicCounts = edgeContext.dstAttr + (eta - 1.0)
      val smoothed_N_kj: TopicCounts = edgeContext.srcAttr + (alpha - 1.0)
      val phi_wk: TopicCounts = smoothed_N_wk :/ smoothed_N_k
      val theta_kj: TopicCounts = normalize(smoothed_N_kj, 1.0)
      val tokenLogLikelihood = N_wj * math.log(phi_wk.dot(theta_kj))
      edgeContext.sendToDst(tokenLogLikelihood)
    }
    graph.aggregateMessages[Double](sendMsg, _ + _)
      .map(_._2).fold(0.0)(_ + _)
  }

  /**
   * Log probability of the current parameter estimate:
   *  log P(topics, topic distributions for docs | alpha, eta)
   */
  lazy val logPrior: Double = {
    val eta = topicConcentration
    val alpha = docConcentration
    // Term vertices: Compute phi_{wk}.  Use to compute prior log probability.
    // Doc vertex: Compute theta_{kj}.  Use to compute prior log probability.
    val N_k = globalTopicTotals
    val smoothed_N_k: TopicCounts = N_k + (vocabSize * (eta - 1.0))
    val seqOp: (Double, (VertexId, TopicCounts)) => Double = {
      case (sumPrior: Double, vertex: (VertexId, TopicCounts)) =>
        if (isTermVertex(vertex)) {
          val N_wk = vertex._2
          val smoothed_N_wk: TopicCounts = N_wk + (eta - 1.0)
          val phi_wk: TopicCounts = smoothed_N_wk :/ smoothed_N_k
          (eta - 1.0) * brzSum(phi_wk.map(math.log))
        } else {
          val N_kj = vertex._2
          val smoothed_N_kj: TopicCounts = N_kj + (alpha - 1.0)
          val theta_kj: TopicCounts = normalize(smoothed_N_kj, 1.0)
          (alpha - 1.0) * brzSum(theta_kj.map(math.log))
        }
    }
    graph.vertices.aggregate(0.0)(seqOp, _ + _)
  }

  /**
   * For each document in the training set, return the distribution over topics for that document
   * ("theta_doc").
   *
   * @return  RDD of (document ID, topic distribution) pairs
   */
  def topicDistributions: RDD[(Long, Vector)] = {
    graph.vertices.filter(LDA.isDocumentVertex).map { case (docID, topicCounts) =>
      (docID.toLong, Vectors.fromBreeze(normalize(topicCounts, 1.0)))
    }
  }

  /** Java-friendly version of [[topicDistributions]] */
  def javaTopicDistributions: JavaPairRDD[java.lang.Long, Vector] = {
    JavaPairRDD.fromRDD(topicDistributions.asInstanceOf[RDD[(java.lang.Long, Vector)]])
  }

  // TODO:
  // override def topicDistributions(documents: RDD[(Long, Vector)]): RDD[(Long, Vector)] = ???

}


text:
	Please edit the settings related to metadata item types and peer review status. Each line must contain the
    SWAP URL followed by a description. Each entry must be on a line.

<?php echo validation_errors(); ?>

<?php echo form_open('admin/editstepsettings/' . $stepname); ?>

<input type="hidden" name="define-itemtypes" value="assocarray" />
<input type="hidden" name="description-itemtypes" value="Item type URLs" />

<input type="hidden" name="define-peerreviewstatus" value="assocarray" />
<input type="hidden" name="description-peerreviewstatus" value="Peer review status" />

        Item type URLs:
        <textarea id="itemtypes" name="itemtypes" cols="90" rows="12"><?php if (!empty($configoptions['itemtypes'])) {
            foreach ($configoptions['itemtypes'] as $key => $value)
            {
                echo $key . ' ' . $value . '
';
            }
        } ?></textarea>

        Peer review status:
        <textarea id="peerreviewstatus" name="peerreviewstatus" cols="90" rows="3"><?php if (!empty($configoptions['peerreviewstatus'])) {
            foreach ($configoptions['peerreviewstatus'] as $key => $value)
            {
                echo $key . ' ' . $value . '
';
            }
        } ?></textarea>

    <input type="Submit" name="submit" id="submit" value="Update" />
    <input type="Submit" name="cancel" id="cancel" value="Cancel" />

<?php echo form_close(); ?>


text:
package com.techgrains.session;

import com.techgrains.common.TGObject;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * Singleton Session instance.
 *
 * Holds single instance of session in memory along with keyValues.
 * - Extremely handy to avoid local storage operation (shared preference, database etc.)
 * - Very handy to access from any layer of the application (from UI to Service)
 */
public class TGSession extends TGObject {

    // Static singleton instance
    private static TGSession session = null;

    // Non-static member variables
    private long createdAt;
    private Map<String, Object> keyValues;
    private Set<TGSessionListener> listeners;

    /**
     * Private constructor to avoid empty initialisation of session object.
     */
    private TGSession() {
    }

    /**
     * Returns current active session. It creates if not present or invalidated before.
     *
     * @return Current session if its already created. Otherwise creates new session.
     */
    public static TGSession instance() {
        if (!hasValue(session)) {
            createSession();
        }
        return session;
    }

    /**
     * Creates new session.
     */
    private static void createSession() {
        session = new TGSession();
        session.init();
    }

    /**
     * Checks session is valid or not by the session instance.
     *
     * @return boolean represents validity of session.
     */
    public static boolean isValid() {
        return hasValue(session);
    }

    /**
     * Initialize session member variables.
     */
    private void init() {
        createdAt = System.currentTimeMillis();
        keyValues = new HashMap<String, Object>();
        listeners = new HashSet<TGSessionListener>();
    }

    /**
     * Invalidate the current session. It also fires "sessionInvalidate" method of every added TGSessionListener.
     */
    public void invalidate() {
        for (TGSessionListener listener : listeners)
            listener.sessionInvalidate();

        session = null;
    }

    /**
     * Number of milliseconds passed since valid session has been created.
     *
     * @return Milliseconds
     */
    public long validSince() {
        return System.currentTimeMillis() - createdAt;
    }

    /**
     * Unique Session Id. (Timestamp of Session creation)
     *
     * @return Session Id
     */
    public long id() {
        return createdAt;
    }

    /* * * Key Values * * */

    /**
     * Store key-value pair as part of session. If provided key is already there, will be replaced with this new one.
     * Calls TGSessionListener.keyPut after adding into session.
     *
     * @param key   Non-null String to represent as key
     * @param value Any Object as value paired with the key
     */
    public void put(String key, Object value) {
        keyValues.put(key, value);
        for (TGSessionListener listener : listeners)
            listener.keyPut(key);
    }

    /**
     * Fetches value from the session for the given key. It returns null if key is not available.
     *
     * @param key Non-null String to represent as key
     * @return Object which paired with the key as value
     */
    public Object get(String key) {
        return keyValues.get(key);
    }

    /**
     * Fetches value from the session for the given key. It returns defaultValue if key is not available or having value null.
     *
     * @param key Non-null String to represent as key
     * @param defaultValue Object to represent default value in case of value is null
     * @return Object which paired with the key as value
     */
    public Object get(String key, Object defaultValue) {
        Object value = keyValues.get(key);
        if(value!=null)
            return value;
        return defaultValue;
    }

    /**
     * Removes key-value pair from the session for the provided key. Calls TGSessionListener.keyRemove prior to remove from session.
     *
     * @param key Non-null String to represent as key
     */
    public void remove(String key) {
        for (TGSessionListener listener : listeners)
            listener.keyRemove(key);
        keyValues.remove(key);
    }

    /**
     * Checks key-value pair is available in the session.
     *
     * @param key Non-null String to represent as key
     * @return "true" if key is
     */
    public boolean hasKey(String key) {
        return keyValues.containsKey(key);
    }

    /**
     * Collects all keys from all the key-value pairs.
     *
     * @return Set of keys.
     */
    public Set<String> keys() {
        return keyValues.keySet();
    }

    /* * * Session Listener * * */

    /**
     * Adds given session listener to the collection of listeners.
     *
     * @param sessionListener TGSessionListener
     */
    public void addSessionListener(TGSessionListener sessionListener) {
        listeners.add(sessionListener);
    }

    /**
     * Removes provided session listener from the collection of listeners.
     *
     * @param sessionListener TGSessionListener
     */
    public void removeSessionListener(TGSessionListener sessionListener) {
        listeners.remove(sessionListener);
    }

    /**
     * Removes all Session listeners.
     */
    public void removeAllSessionListeners() {
        listeners.clear();
    }

    /**
     * Gives total counts of listeners
     *
     * @return count of session listeners
     */
    public int countSessionListeners() {
        return listeners.size();
    }

    /* * * Object Methods * * */

    @Override
    /**
     * Compares this instance with the specified object and indicates if they are equal.
     */
    public boolean equals(Object object) {
        if (object == null) return false;
        if (!(object instanceof TGSession)) return false;

        TGSession other = (TGSession) object;
        if (other.id() != id()) return false;
        return true;
    }

    @Override
    /**
     * Returns an integer hash code for this object.
     */
    public int hashCode() {
        return Long.valueOf(id()).hashCode();
    }
}


text:
package com.googlecode.aluminumproject.context;

import com.googlecode.aluminumproject.AluminumException;
import com.googlecode.aluminumproject.configuration.ConfigurationElement;

/**
 * Enriches the context when a template is being processed.
 * <p>
 * An example of where a context enricher might be useful is when a library would like to ensure that the context
 * contains a certain implicit object, so that all of its actions and functions can use it.
 */
public interface ContextEnricher extends ConfigurationElement {
	/**
	 * Invoked before a template is being processed.
	 *
	 * @param context the context in which the template will be processed
	 * @throws AluminumException when something goes wrong while working with the context
	 */
	void beforeTemplate(Context context) throws AluminumException;

	/**
	 * Invoked after a template is being processed.
	 *
	 * @param context the context in which the template was processed
	 * @throws AluminumException when something goes wrong while working with the context
	 */
	void afterTemplate(Context context) throws AluminumException;
}


text:
<?php
/**
 * AccountsReceivableRetryStatMetrics
 *
 * PHP version 5
 *
 * @category Class
 * @package  ultracart\v2
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */

/**
 * UltraCart Rest API V2
 *
 * UltraCart REST API Version 2
 *
 * OpenAPI spec version: 2.0.0
 * Contact: support@ultracart.com
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 * Swagger Codegen version: 2.4.15-SNAPSHOT
 */

/**
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen
 * Do not edit the class manually.
 */

namespace ultracart\v2\models;

use \ArrayAccess;
use \ultracart\v2\ObjectSerializer;

/**
 * AccountsReceivableRetryStatMetrics Class Doc Comment
 *
 * @category Class
 * @package  ultracart\v2
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */
class AccountsReceivableRetryStatMetrics implements ModelInterface, ArrayAccess
{
    const DISCRIMINATOR = null;

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static $swaggerModelName = 'AccountsReceivableRetryStatMetrics';

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $swaggerTypes = [
        'attempts' => 'int',
        'attempts_formatted' => 'string',
        'conversion_rate' => 'float',
        'conversion_rate_formatted' => 'string',
        'day' => 'int',
        'discounts' => 'float',
        'discounts_formatted' => 'string',
        'revenue' => 'float',
        'revenue_formatted' => 'string',
        'successes' => 'int',
        'successes_formatted' => 'string'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $swaggerFormats = [
        'attempts' => 'int32',
        'attempts_formatted' => null,
        'conversion_rate' => null,
        'conversion_rate_formatted' => null,
        'day' => 'int32',
        'discounts' => null,
        'discounts_formatted' => null,
        'revenue' => null,
        'revenue_formatted' => null,
        'successes' => 'int32',
        'successes_formatted' => null
    ];

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function swaggerTypes()
    {
        return self::$swaggerTypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function swaggerFormats()
    {
        return self::$swaggerFormats;
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'attempts' => 'attempts',
        'attempts_formatted' => 'attempts_formatted',
        'conversion_rate' => 'conversion_rate',
        'conversion_rate_formatted' => 'conversion_rate_formatted',
        'day' => 'day',
        'discounts' => 'discounts',
        'discounts_formatted' => 'discounts_formatted',
        'revenue' => 'revenue',
        'revenue_formatted' => 'revenue_formatted',
        'successes' => 'successes',
        'successes_formatted' => 'successes_formatted'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'attempts' => 'setAttempts',
        'attempts_formatted' => 'setAttemptsFormatted',
        'conversion_rate' => 'setConversionRate',
        'conversion_rate_formatted' => 'setConversionRateFormatted',
        'day' => 'setDay',
        'discounts' => 'setDiscounts',
        'discounts_formatted' => 'setDiscountsFormatted',
        'revenue' => 'setRevenue',
        'revenue_formatted' => 'setRevenueFormatted',
        'successes' => 'setSuccesses',
        'successes_formatted' => 'setSuccessesFormatted'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'attempts' => 'getAttempts',
        'attempts_formatted' => 'getAttemptsFormatted',
        'conversion_rate' => 'getConversionRate',
        'conversion_rate_formatted' => 'getConversionRateFormatted',
        'day' => 'getDay',
        'discounts' => 'getDiscounts',
        'discounts_formatted' => 'getDiscountsFormatted',
        'revenue' => 'getRevenue',
        'revenue_formatted' => 'getRevenueFormatted',
        'successes' => 'getSuccesses',
        'successes_formatted' => 'getSuccessesFormatted'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$swaggerModelName;
    }

    /**
     * Associative array for storing property values
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->container['attempts'] = isset($data['attempts']) ? $data['attempts'] : null;
        $this->container['attempts_formatted'] = isset($data['attempts_formatted']) ? $data['attempts_formatted'] : null;
        $this->container['conversion_rate'] = isset($data['conversion_rate']) ? $data['conversion_rate'] : null;
        $this->container['conversion_rate_formatted'] = isset($data['conversion_rate_formatted']) ? $data['conversion_rate_formatted'] : null;
        $this->container['day'] = isset($data['day']) ? $data['day'] : null;
        $this->container['discounts'] = isset($data['discounts']) ? $data['discounts'] : null;
        $this->container['discounts_formatted'] = isset($data['discounts_formatted']) ? $data['discounts_formatted'] : null;
        $this->container['revenue'] = isset($data['revenue']) ? $data['revenue'] : null;
        $this->container['revenue_formatted'] = isset($data['revenue_formatted']) ? $data['revenue_formatted'] : null;
        $this->container['successes'] = isset($data['successes']) ? $data['successes'] : null;
        $this->container['successes_formatted'] = isset($data['successes_formatted']) ? $data['successes_formatted'] : null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }

    /**
     * Gets attempts
     *
     * @return int
     */
    public function getAttempts()
    {
        return $this->container['attempts'];
    }

    /**
     * Sets attempts
     *
     * @param int $attempts attempts
     *
     * @return $this
     */
    public function setAttempts($attempts)
    {
        $this->container['attempts'] = $attempts;

        return $this;
    }

    /**
     * Gets attempts_formatted
     *
     * @return string
     */
    public function getAttemptsFormatted()
    {
        return $this->container['attempts_formatted'];
    }

    /**
     * Sets attempts_formatted
     *
     * @param string $attempts_formatted attempts_formatted
     *
     * @return $this
     */
    public function setAttemptsFormatted($attempts_formatted)
    {
        $this->container['attempts_formatted'] = $attempts_formatted;

        return $this;
    }

    /**
     * Gets conversion_rate
     *
     * @return float
     */
    public function getConversionRate()
    {
        return $this->container['conversion_rate'];
    }

    /**
     * Sets conversion_rate
     *
     * @param float $conversion_rate conversion_rate
     *
     * @return $this
     */
    public function setConversionRate($conversion_rate)
    {
        $this->container['conversion_rate'] = $conversion_rate;

        return $this;
    }

    /**
     * Gets conversion_rate_formatted
     *
     * @return string
     */
    public function getConversionRateFormatted()
    {
        return $this->container['conversion_rate_formatted'];
    }

    /**
     * Sets conversion_rate_formatted
     *
     * @param string $conversion_rate_formatted conversion_rate_formatted
     *
     * @return $this
     */
    public function setConversionRateFormatted($conversion_rate_formatted)
    {
        $this->container['conversion_rate_formatted'] = $conversion_rate_formatted;

        return $this;
    }

    /**
     * Gets day
     *
     * @return int
     */
    public function getDay()
    {
        return $this->container['day'];
    }

    /**
     * Sets day
     *
     * @param int $day day
     *
     * @return $this
     */
    public function setDay($day)
    {
        $this->container['day'] = $day;

        return $this;
    }

    /**
     * Gets discounts
     *
     * @return float
     */
    public function getDiscounts()
    {
        return $this->container['discounts'];
    }

    /**
     * Sets discounts
     *
     * @param float $discounts discounts
     *
     * @return $this
     */
    public function setDiscounts($discounts)
    {
        $this->container['discounts'] = $discounts;

        return $this;
    }

    /**
     * Gets discounts_formatted
     *
     * @return string
     */
    public function getDiscountsFormatted()
    {
        return $this->container['discounts_formatted'];
    }

    /**
     * Sets discounts_formatted
     *
     * @param string $discounts_formatted discounts_formatted
     *
     * @return $this
     */
    public function setDiscountsFormatted($discounts_formatted)
    {
        $this->container['discounts_formatted'] = $discounts_formatted;

        return $this;
    }

    /**
     * Gets revenue
     *
     * @return float
     */
    public function getRevenue()
    {
        return $this->container['revenue'];
    }

    /**
     * Sets revenue
     *
     * @param float $revenue revenue
     *
     * @return $this
     */
    public function setRevenue($revenue)
    {
        $this->container['revenue'] = $revenue;

        return $this;
    }

    /**
     * Gets revenue_formatted
     *
     * @return string
     */
    public function getRevenueFormatted()
    {
        return $this->container['revenue_formatted'];
    }

    /**
     * Sets revenue_formatted
     *
     * @param string $revenue_formatted revenue_formatted
     *
     * @return $this
     */
    public function setRevenueFormatted($revenue_formatted)
    {
        $this->container['revenue_formatted'] = $revenue_formatted;

        return $this;
    }

    /**
     * Gets successes
     *
     * @return int
     */
    public function getSuccesses()
    {
        return $this->container['successes'];
    }

    /**
     * Sets successes
     *
     * @param int $successes successes
     *
     * @return $this
     */
    public function setSuccesses($successes)
    {
        $this->container['successes'] = $successes;

        return $this;
    }

    /**
     * Gets successes_formatted
     *
     * @return string
     */
    public function getSuccessesFormatted()
    {
        return $this->container['successes_formatted'];
    }

    /**
     * Sets successes_formatted
     *
     * @param string $successes_formatted successes_formatted
     *
     * @return $this
     */
    public function setSuccessesFormatted($successes_formatted)
    {
        $this->container['successes_formatted'] = $successes_formatted;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    public function offsetExists($offset)
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed
     */
    public function offsetGet($offset)
    {
        return isset($this->container[$offset]) ? $this->container[$offset] : null;
    }

    /**
     * Sets value based on offset.
     *
     * @param integer $offset Offset
     * @param mixed   $value  Value to be set
     *
     * @return void
     */
    public function offsetSet($offset, $value)
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer $offset Offset
     *
     * @return void
     */
    public function offsetUnset($offset)
    {
        unset($this->container[$offset]);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
            return json_encode(
                ObjectSerializer::sanitizeForSerialization($this),
                JSON_PRETTY_PRINT
            );
        }

        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}


text:
subdir = src/backend/cdb/motion
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global

override CPPFLAGS := -I$(top_srcdir)/src/backend/gp_libpq_fe $(CPPFLAGS)

OBJS = cdbmotion.o tupchunklist.o tupser.o  \
	ic_common.o ic_tcp.o ic_udp.o htupfifo.o

include $(top_srcdir)/src/backend/common.mk