//  Copyright 2013 Google Inc. All Rights Reserved.
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <pthread.h>

#define MAX_STRING 100
#define EXP_TABLE_SIZE 1000
#define MAX_EXP 6
#define MAX_SENTENCE_LENGTH 1000
#define MAX_CODE_LENGTH 40

const int vocab_hash_size = 30000000; // Maximum 30 * 0.7 = 21M words in the vocabulary

typedef float real;                    // Precision of float numbers

struct vocab_word {
	long long cn;
	int *point;
	char *word, *code, codelen;
};

char train_file[MAX_STRING], output_file[MAX_STRING];
char save_vocab_file[MAX_STRING], read_vocab_file[MAX_STRING];
char save_net_file[MAX_STRING], read_net_file[MAX_STRING];
struct vocab_word *vocab;
int binary = 0, type = 1, debug_mode = 2, window = 5, min_count = 5,
		num_threads = 12, min_reduce = 1;
int *vocab_hash;
long long vocab_max_size = 1000, vocab_size = 0, layer1_size = 100;
long long train_words = 0, word_count_actual = 0, iter = 5, file_size = 0,
		classes = 0;
real alpha = 0.025, starting_alpha, sample = 1e-3;
real *syn0, *syn1, *syn1neg, *syn1nce, *expTable;
clock_t start;

real *syn1_window, *syn1neg_window, *syn1nce_window;
int w_offset, window_layer_size;

int window_hidden_size = 500;
real *syn_window_hidden, *syn_hidden_word, *syn_hidden_word_neg,
		*syn_hidden_word_nce;

int hs = 0, negative = 5;
const int table_size = 1e8;
int *table;

long cc = 0;

//constrastive negative sampling
char negative_classes_file[MAX_STRING];
int *word_to_group;
int *group_to_table; //group_size*table_size
int class_number;

//nce
real* noise_distribution;
int nce = 0;

//param caps
real CAP_VALUE = 50;
int cap = 0;

void capParam(real* array, int index) {
	if (array[index] > CAP_VALUE)
		array[index] = CAP_VALUE;
	else if (array[index] < -CAP_VALUE)
		array[index] = -CAP_VALUE;
}

real hardTanh(real x) {
	if (x >= 1) {
		return 1;
	} else if (x <= -1) {
		return -1;
	} else {
		return x;
	}
}

real dHardTanh(real x, real g) {
	if (x > 1 && g > 0) {
		return 0;
	}
	if (x < -1 && g < 0) {
		return 0;
	}
	return 1;
}

void InitUnigramTable() {
	int a, i;
	long long train_words_pow = 0;
	real d1, power = 0.75;
	table = (int *) malloc(table_size * sizeof(int));
	for (a = 0; a < vocab_size; a++)
		train_words_pow += pow(vocab[a].cn, power);
	i = 0;
	d1 = pow(vocab[i].cn, power) / (real) train_words_pow;
	for (a = 0; a < table_size; a++) {
		table[a] = i;
		if (a / (real) table_size > d1) {
			i++;
			d1 += pow(vocab[i].cn, power) / (real) train_words_pow;
		}
		if (i >= vocab_size)
			i = vocab_size - 1;
	}

	noise_distribution = (real *) calloc(vocab_size, sizeof(real));
	for (a = 0; a < vocab_size; a++)
		noise_distribution[a] = pow(vocab[a].cn, power)
				/ (real) train_words_pow;
}

// Reads a single word from a file, assuming space + tab + EOL to be word boundaries
void ReadWord(char *word, FILE *fin) {
	int a = 0, ch;
	while (!feof(fin)) {
		ch = fgetc(fin);
		if (ch == 13)
			continue;
		if ((ch == ' ') || (ch == '\t') || (ch == '\n')) {
			if (a > 0) {
				if (ch == '\n')
					ungetc(ch, fin);
				break;
			}
			if (ch == '\n') {
				strcpy(word, (char *) "</s>");
				return;
			} else
				continue;
		}
		word[a] = ch;
		a++;
		if (a >= MAX_STRING - 1)
			a--;   // Truncate too long words
	}
	word[a] = 0;
}

// Returns hash value of a word
int GetWordHash(char *word) {
	unsigned long long a, hash = 0;
	for (a = 0; a < strlen(word); a++)
		hash = hash * 257 + word[a];
	hash = hash % vocab_hash_size;
	return hash;
}

// Returns position of a word in the vocabulary; if the word is not found, returns -1
int SearchVocab(char *word) {
	unsigned int hash = GetWordHash(word);
	while (1) {
		if (vocab_hash[hash] == -1)
			return -1;
		if (!strcmp(word, vocab[vocab_hash[hash]].word))
			return vocab_hash[hash];
		hash = (hash + 1) % vocab_hash_size;
	}
	return -1;
}

// Reads a word and returns its index in the vocabulary
int ReadWordIndex(FILE *fin) {
	char word[MAX_STRING];
	ReadWord(word, fin);
	if (feof(fin))
		return -1;
	return SearchVocab(word);
}

// Adds a word to the vocabulary
int AddWordToVocab(char *word) {
	unsigned int hash, length = strlen(word) + 1;
	if (length > MAX_STRING)
		length = MAX_STRING;
	vocab[vocab_size].word = (char *) calloc(length, sizeof(char));
	strcpy(vocab[vocab_size].word, word);
	vocab[vocab_size].cn = 0;
	vocab_size++;
	// Reallocate memory if needed
	if (vocab_size + 2 >= vocab_max_size) {
		vocab_max_size += 1000;
		vocab = (struct vocab_word *) realloc(vocab,
				vocab_max_size * sizeof(struct vocab_word));
	}
	hash = GetWordHash(word);
	while (vocab_hash[hash] != -1)
		hash = (hash + 1) % vocab_hash_size;
	vocab_hash[hash] = vocab_size - 1;
	return vocab_size - 1;
}

// Used later for sorting by word counts
int VocabCompare(const void *a, const void *b) {
	return ((struct vocab_word *) b)->cn - ((struct vocab_word *) a)->cn;
}

// Sorts the vocabulary by frequency using word counts
void SortVocab() {
	int a, size;
	unsigned int hash;
	// Sort the vocabulary and keep </s> at the first position
	qsort(&vocab[1], vocab_size - 1, sizeof(struct vocab_word), VocabCompare);
	for (a = 0; a < vocab_hash_size; a++)
		vocab_hash[a] = -1;
	size = vocab_size;
	train_words = 0;
	for (a = 0; a < size; a++) {
		// Words occuring less than min_count times will be discarded from the vocab
		if ((vocab[a].cn < min_count) && (a != 0)) {
			vocab_size--;
			free(vocab[a].word);
		} else {
			// Hash will be re-computed, as after the sorting it is not actual
			hash = GetWordHash(vocab[a].word);
			while (vocab_hash[hash] != -1)
				hash = (hash + 1) % vocab_hash_size;
			vocab_hash[hash] = a;
			train_words += vocab[a].cn;
		}
	}
	vocab = (struct vocab_word *) realloc(vocab,
			(vocab_size + 1) * sizeof(struct vocab_word));
	// Allocate memory for the binary tree construction
	for (a = 0; a < vocab_size; a++) {
		vocab[a].code = (char *) calloc(MAX_CODE_LENGTH, sizeof(char));
		vocab[a].point = (int *) calloc(MAX_CODE_LENGTH, sizeof(int));
	}
}

// Reduces the vocabulary by removing infrequent tokens
void ReduceVocab() {
	int a, b = 0;
	unsigned int hash;
	for (a = 0; a < vocab_size; a++)
		if (vocab[a].cn > min_reduce) {
			vocab[b].cn = vocab[a].cn;
			vocab[b].word = vocab[a].word;
			b++;
		} else
			free(vocab[a].word);
	vocab_size = b;
	for (a = 0; a < vocab_hash_size; a++)
		vocab_hash[a] = -1;
	for (a = 0; a < vocab_size; a++) {
		// Hash will be re-computed, as it is not actual
		hash = GetWordHash(vocab[a].word);
		while (vocab_hash[hash] != -1)
			hash = (hash + 1) % vocab_hash_size;
		vocab_hash[hash] = a;
	}
	fflush(stdout);
	min_reduce++;
}

// Create binary Huffman tree using the word counts
// Frequent words will have short uniqe binary codes
void CreateBinaryTree() {
	long long a, b, i, min1i, min2i, pos1, pos2, point[MAX_CODE_LENGTH];
	char code[MAX_CODE_LENGTH];
	long long *count = (long long *) calloc(vocab_size * 2 + 1,
			sizeof(long long));
	long long *binary = (long long *) calloc(vocab_size * 2 + 1,
			sizeof(long long));
	long long *parent_node = (long long *) calloc(vocab_size * 2 + 1,
			sizeof(long long));
	for (a = 0; a < vocab_size; a++)
		count[a] = vocab[a].cn;
	for (a = vocab_size; a < vocab_size * 2; a++)
		count[a] = 1e15;
	pos1 = vocab_size - 1;
	pos2 = vocab_size;
	// Following algorithm constructs the Huffman tree by adding one node at a time
	for (a = 0; a < vocab_size - 1; a++) {
		// First, find two smallest nodes 'min1, min2'
		if (pos1 >= 0) {
			if (count[pos1] < count[pos2]) {
				min1i = pos1;
				pos1--;
			} else {
				min1i = pos2;
				pos2++;
			}
		} else {
			min1i = pos2;
			pos2++;
		}
		if (pos1 >= 0) {
			if (count[pos1] < count[pos2]) {
				min2i = pos1;
				pos1--;
			} else {
				min2i = pos2;
				pos2++;
			}
		} else {
			min2i = pos2;
			pos2++;
		}
		count[vocab_size + a] = count[min1i] + count[min2i];
		parent_node[min1i] = vocab_size + a;
		parent_node[min2i] = vocab_size + a;
		binary[min2i] = 1;
	}
	// Now assign binary code to each vocabulary word
	for (a = 0; a < vocab_size; a++) {
		b = a;
		i = 0;
		while (1) {
			code[i] = binary[b];
			point[i] = b;
			i++;
			b = parent_node[b];
			if (b == vocab_size * 2 - 2)
				break;
		}
		vocab[a].codelen = i;
		vocab[a].point[0] = vocab_size - 2;
		for (b = 0; b < i; b++) {
			vocab[a].code[i - b - 1] = code[b];
			vocab[a].point[i - b] = point[b] - vocab_size;
		}
	}
	free(count);
	free(binary);
	free(parent_node);
}

void LearnVocabFromTrainFile() {
	char word[MAX_STRING];
	FILE *fin;
	long long a, i;
	for (a = 0; a < vocab_hash_size; a++)
		vocab_hash[a] = -1;
	fin = fopen(train_file, "rb");
	if (fin == NULL) {
		printf("ERROR: training data file not found!\n");
		exit(1);
	}
	vocab_size = 0;
	AddWordToVocab((char *) "</s>");
	while (1) {
		ReadWord(word, fin);
		if (feof(fin))
			break;
		train_words++;
		if ((debug_mode > 1) && (train_words % 100000 == 0)) {
			printf("%lldK%c", train_words / 1000, 13);
			fflush(stdout);
		}
		i = SearchVocab(word);
		if (i == -1) {
			a = AddWordToVocab(word);
			vocab[a].cn = 1;
		} else
			vocab[i].cn++;
		if (vocab_size > vocab_hash_size * 0.7)
			ReduceVocab();
	}
	SortVocab();
	if (debug_mode > 0) {
		printf("Vocab size: %lld\n", vocab_size);
		printf("Words in train file: %lld\n", train_words);
	}
	file_size = ftell(fin);
	fclose(fin);
}

void SaveVocab() {
	long long i;
	FILE *fo = fopen(save_vocab_file, "wb");
	for (i = 0; i < vocab_size; i++)
		fprintf(fo, "%s %lld\n", vocab[i].word, vocab[i].cn);
	fclose(fo);
}

void ReadVocab() {
	long long a, i = 0;
	char c;
	char word[MAX_STRING];
	FILE *fin = fopen(read_vocab_file, "rb");
	if (fin == NULL) {
		printf("Vocabulary file not found\n");
		exit(1);
	}
	for (a = 0; a < vocab_hash_size; a++)
		vocab_hash[a] = -1;
	vocab_size = 0;
	while (1) {
		ReadWord(word, fin);
		if (feof(fin))
			break;
		a = AddWordToVocab(word);
		fscanf(fin, "%lld%c", &vocab[a].cn, &c);
		i++;
	}
	SortVocab();
	if (debug_mode > 0) {
		printf("Vocab size: %lld\n", vocab_size);
		printf("Words in train file: %lld\n", train_words);
	}
	fin = fopen(train_file, "rb");
	if (fin == NULL) {
		printf("ERROR: training data file not found!\n");
		exit(1);
	}
	fseek(fin, 0, SEEK_END);
	file_size = ftell(fin);
	fclose(fin);
}

void InitClassUnigramTable() {
	long long a, c;
	printf("loading class unigrams \n");
	FILE *fin = fopen(negative_classes_file, "rb");
	if (fin == NULL) {
		printf("ERROR: class file not found!\n");
		exit(1);
	}
	word_to_group = (int *) malloc(vocab_size * sizeof(int));
	for (a = 0; a < vocab_size; a++)
		word_to_group[a] = -1;
	char class[MAX_STRING];
	char prev_class[MAX_STRING];
	prev_class[0] = 0;
	char word[MAX_STRING];
	class_number = -1;
	while (1) {
		if (feof(fin))
			break;
		ReadWord(class, fin);
		ReadWord(word, fin);
		int word_index = SearchVocab(word);
		if (word_index != -1) {
			if (strcmp(class, prev_class) != 0) {
				class_number++;
				strcpy(prev_class, class);
			}
			word_to_group[word_index] = class_number;
		}
		ReadWord(word, fin);
	}
	class_number++;
	fclose(fin);

	group_to_table = (int *) malloc(table_size * class_number * sizeof(int));
	long long train_words_pow = 0;
	real d1, power = 0.75;

	for (c = 0; c < class_number; c++) {
		long long offset = c * table_size;
		train_words_pow = 0;
		for (a = 0; a < vocab_size; a++)
			if (word_to_group[a] == c)
				train_words_pow += pow(vocab[a].cn, power);
		int i = 0;
		while (word_to_group[i] != c && i < vocab_size)
			i++;
		d1 = pow(vocab[i].cn, power) / (real) train_words_pow;
		for (a = 0; a < table_size; a++) {
			//printf("index %lld , word %d\n", a, i);
			group_to_table[offset + a] = i;
			if (a / (real) table_size > d1) {
				i++;
				while (word_to_group[i] != c && i < vocab_size)
					i++;
				d1 += pow(vocab[i].cn, power) / (real) train_words_pow;
			}
			if (i >= vocab_size)
				while (word_to_group[i] != c && i >= 0)
					i--;
		}
	}
}

void SaveNet() {
	if(type != 3 || negative <= 0) { 
		fprintf(stderr, "save-net only supported for type 3 with negative sampling\n");
		return;
	}

	FILE *fnet = fopen(save_net_file, "wb");
	if (fnet == NULL) {
		printf("Net parameter file not found\n");
		exit(1);
	}
	fwrite(syn0, sizeof(real), vocab_size * layer1_size, fnet);
	fwrite(syn1neg_window, sizeof(real), vocab_size * window_layer_size, fnet);
	fclose(fnet);
}

void InitNet() {
	long long a, b;
	unsigned long long next_random = 1;
	window_layer_size = layer1_size * window * 2;
	a = posix_memalign((void **) &syn0, 128,
			(long long) vocab_size * layer1_size * sizeof(real));
	if (syn0 == NULL) {
		printf("Memory allocation failed\n");
		exit(1);
	}

	if (hs) {
		a = posix_memalign((void **) &syn1, 128,
				(long long) vocab_size * layer1_size * sizeof(real));
		if (syn1 == NULL) {
			printf("Memory allocation failed\n");
			exit(1);
		}
		a = posix_memalign((void **) &syn1_window, 128,
				(long long) vocab_size * window_layer_size * sizeof(real));
		if (syn1_window == NULL) {
			printf("Memory allocation failed\n");
			exit(1);
		}
		a = posix_memalign((void **) &syn_hidden_word, 128,
				(long long) vocab_size * window_hidden_size * sizeof(real));
		if (syn_hidden_word == NULL) {
			printf("Memory allocation failed\n");
			exit(1);
		}

		for (a = 0; a < vocab_size; a++)
			for (b = 0; b < layer1_size; b++)
				syn1[a * layer1_size + b] = 0;
		for (a = 0; a < vocab_size; a++)
			for (b = 0; b < window_layer_size; b++)
				syn1_window[a * window_layer_size + b] = 0;
		for (a = 0; a < vocab_size; a++)
			for (b = 0; b < window_hidden_size; b++)
				syn_hidden_word[a * window_hidden_size + b] = 0;
	}
	if (negative > 0) {
		if(type == 0) {
			a = posix_memalign((void **) &syn1neg, 128,
												 (long long) vocab_size * layer1_size * sizeof(real));
			if (syn1neg == NULL) {
				printf("Memory allocation failed\n");
				exit(1);
			}
			for (a = 0; a < vocab_size; a++)
				for (b = 0; b < layer1_size; b++)
					syn1neg[a * layer1_size + b] = 0;
		} else if (type == 3) {
			a = posix_memalign((void **) &syn1neg_window, 128,
												 (long long) vocab_size * window_layer_size * sizeof(real));
			if (syn1neg_window == NULL) {
				printf("Memory allocation failed\n");
				exit(1);
			}
			for (a = 0; a < vocab_size; a++)
				for (b = 0; b < window_layer_size; b++)
					syn1neg_window[a * window_layer_size + b] = 0;
		} else if (type == 4) {
			a = posix_memalign((void **) &syn_hidden_word_neg, 128,
												 (long long) vocab_size * window_hidden_size * sizeof(real));
			if (syn_hidden_word_neg == NULL) {
				printf("Memory allocation failed\n");
				exit(1);
			}
			for (a = 0; a < vocab_size; a++)
				for (b = 0; b < window_hidden_size; b++)
					syn_hidden_word_neg[a * window_hidden_size + b] = 0;
		}
	}
	if (nce > 0) {
		a = posix_memalign((void **) &syn1nce, 128,
				(long long) vocab_size * layer1_size * sizeof(real));
		if (syn1nce == NULL) {
			printf("Memory allocation failed\n");
			exit(1);
		}
		a = posix_memalign((void **) &syn1nce_window, 128,
				(long long) vocab_size * window_layer_size * sizeof(real));
		if (syn1nce_window == NULL) {
			printf("Memory allocation failed\n");
			exit(1);
		}
		a = posix_memalign((void **) &syn_hidden_word_nce, 128,
				(long long) vocab_size * window_hidden_size * sizeof(real));
		if (syn_hidden_word_nce == NULL) {
			printf("Memory allocation failed\n");
			exit(1);
		}

		for (a = 0; a < vocab_size; a++)
			for (b = 0; b < layer1_size; b++)
				syn1nce[a * layer1_size + b] = 0;
		for (a = 0; a < vocab_size; a++)
			for (b = 0; b < window_layer_size; b++)
				syn1nce_window[a * window_layer_size + b] = 0;
		for (a = 0; a < vocab_size; a++)
			for (b = 0; b < window_hidden_size; b++)
				syn_hidden_word_nce[a * window_hidden_size + b] = 0;
	}

	if(type == 4) {
		a = posix_memalign((void **) &syn_window_hidden, 128,
				window_hidden_size * window_layer_size * sizeof(real));
		if (syn_window_hidden == NULL) {
			printf("Memory allocation failed\n");
			exit(1);
		}
		for (a = 0; a < window_hidden_size * window_layer_size; a++) {
			next_random = next_random * (unsigned long long) 25214903917 + 11;
			syn_window_hidden[a] = (((next_random & 0xFFFF) / (real) 65536)
					- 0.5) / (window_hidden_size * window_layer_size);
		}
	}

	if (read_net_file[0] == 0) {
		for (a = 0; a < vocab_size; a++)
			for (b = 0; b < layer1_size; b++) {
				next_random = next_random * (unsigned long long) 25214903917
						+ 11;
				syn0[a * layer1_size + b] = (((next_random & 0xFFFF)
						/ (real) 65536) - 0.5) / layer1_size;
			}
	} else if(type == 3 && negative > 0) {
		FILE *fnet = fopen(read_net_file, "rb");
		if (fnet == NULL) {
			printf("Net parameter file not found\n");
			exit(1);
		}
		fread(syn0, sizeof(real), vocab_size * layer1_size, fnet);
		fread(syn1neg_window, sizeof(real), vocab_size * window_layer_size, fnet);
		fclose(fnet);
	} else {
		fprintf(stderr, "read-net only supported for type 3 with negative sampling\n");
		exit(-1);
	}

	CreateBinaryTree();
}

void *TrainModelThread(void *id) {
	long long a, b, d, cw, word, last_word, sentence_length = 0,
			sentence_position = 0;
	long long word_count = 0, last_word_count = 0, sen[MAX_SENTENCE_LENGTH + 1];
	long long l1, l2, c, target, label, local_iter = iter;
	unsigned long long next_random = (long long) id;
	real f, g;
	clock_t now;
	int input_len_1 = layer1_size;
	int window_offset = -1;
	if (type == 2 || type == 4) {
		input_len_1 = window_layer_size;
	}
	real *neu1 = (real *) calloc(input_len_1, sizeof(real));
	real *neu1e = (real *) calloc(input_len_1, sizeof(real));

	int input_len_2 = 0;
	if (type == 4) {
		input_len_2 = window_hidden_size;
	}
	real *neu2 = (real *) calloc(input_len_2, sizeof(real));
	real *neu2e = (real *) calloc(input_len_2, sizeof(real));

	FILE *fi = fopen(train_file, "rb");
	fseek(fi, file_size / (long long) num_threads * (long long) id, SEEK_SET);
	while (1) {
		if (word_count - last_word_count > 10000) {
			word_count_actual += word_count - last_word_count;
			last_word_count = word_count;
			if ((debug_mode > 1)) {
				now = clock();
				printf(
						"%cAlpha: %f  Progress: %.2f%%  Words/thread/sec: %.2fk  ",
						13, alpha,
						word_count_actual / (real) (iter * train_words + 1)
								* 100,
						word_count_actual
								/ ((real) (now - start + 1)
										/ (real) CLOCKS_PER_SEC * 1000));
				fflush(stdout);
			}
			alpha = starting_alpha
					* (1 - word_count_actual / (real) (iter * train_words + 1));
			if (alpha < starting_alpha * 0.0001)
				alpha = starting_alpha * 0.0001;
		}
		if (sentence_length == 0) {
			while (1) {
				word = ReadWordIndex(fi);
				if (feof(fi))
					break;
				if (word == -1)
					continue;
				word_count++;
				if (word == 0)
					break;
				// The subsampling randomly discards frequent words while keeping the ranking same
				if (sample > 0) {
					real ran = (sqrt(vocab[word].cn / (sample * train_words))
							+ 1) * (sample * train_words) / vocab[word].cn;
					next_random = next_random * (unsigned long long) 25214903917
							+ 11;
					if (ran < (next_random & 0xFFFF) / (real) 65536)
						continue;
				}
				sen[sentence_length] = word;
				sentence_length++;
				if (sentence_length >= MAX_SENTENCE_LENGTH)
					break;
			}
			sentence_position = 0;
		}
		if (feof(fi) || (word_count > train_words / num_threads)) {
			word_count_actual += word_count - last_word_count;
			local_iter--;
			if (local_iter == 0)
				break;
			word_count = 0;
			last_word_count = 0;
			sentence_length = 0;
			fseek(fi, file_size / (long long) num_threads * (long long) id,
					SEEK_SET);
			continue;
		}
		word = sen[sentence_position];
		if (word == -1)
			continue;
		for (c = 0; c < input_len_1; c++)
			neu1[c] = 0;
		for (c = 0; c < input_len_1; c++)
			neu1e[c] = 0;
		for (c = 0; c < input_len_2; c++)
			neu2[c] = 0;
		for (c = 0; c < input_len_2; c++)
			neu2e[c] = 0;
		next_random = next_random * (unsigned long long) 25214903917 + 11;
		b = next_random % window;
		if (type == 0) {  //train the cbow architecture
			// in -> hidden
			cw = 0;
			for (a = b; a < window * 2 + 1 - b; a++)
				if (a != window) {
					c = sentence_position - window + a;
					if (c < 0)
						continue;
					if (c >= sentence_length)
						continue;
					last_word = sen[c];
					if (last_word == -1)
						continue;
					for (c = 0; c < layer1_size; c++)
						neu1[c] += syn0[c + last_word * layer1_size];
					cw++;
				}
			if (cw) {
				for (c = 0; c < layer1_size; c++)
					neu1[c] /= cw;
				if (hs)
					for (d = 0; d < vocab[word].codelen; d++) {
						f = 0;
						l2 = vocab[word].point[d] * layer1_size;
						// Propagate hidden -> output
						for (c = 0; c < layer1_size; c++)
							f += neu1[c] * syn1[c + l2];
						if (f <= -MAX_EXP)
							continue;
						else if (f >= MAX_EXP)
							continue;
						else
							f = expTable[(int) ((f + MAX_EXP)
									* (EXP_TABLE_SIZE / MAX_EXP / 2))];
						// 'g' is the gradient multiplied by the learning rate
						g = (1 - vocab[word].code[d] - f) * alpha;
						// Propagate errors output -> hidden
						for (c = 0; c < layer1_size; c++)
							neu1e[c] += g * syn1[c + l2];
						// Learn weights hidden -> output
						for (c = 0; c < layer1_size; c++)
							syn1[c + l2] += g * neu1[c];
						if (cap == 1)
							for (c = 0; c < layer1_size; c++)
								capParam(syn1, c + l2);
					}
				// NEGATIVE SAMPLING
				if (negative > 0)
					for (d = 0; d < negative + 1; d++) {
						if (d == 0) {
							target = word;
							label = 1;
						} else {
							next_random = next_random
									* (unsigned long long) 25214903917 + 11;
							if (word_to_group != NULL
									&& word_to_group[word] != -1) {
								target = word;
								while (target == word) {
									target = group_to_table[word_to_group[word]
											* table_size
											+ (next_random >> 16) % table_size];
									next_random = next_random
											* (unsigned long long) 25214903917
											+ 11;
								}
								//printf("negative sampling %lld for word %s returned %s\n", d, vocab[word].word, vocab[target].word);
							} else {
								target =
										table[(next_random >> 16) % table_size];
							}
							if (target == 0)
								target = next_random % (vocab_size - 1) + 1;
							if (target == word)
								continue;
							label = 0;
						}
						l2 = target * layer1_size;
						f = 0;
						for (c = 0; c < layer1_size; c++)
							f += neu1[c] * syn1neg[c + l2];
						if (f > MAX_EXP)
							g = (label - 1) * alpha;
						else if (f < -MAX_EXP)
							g = (label - 0) * alpha;
						else
							g = (label
									- expTable[(int) ((f + MAX_EXP)
											* (EXP_TABLE_SIZE / MAX_EXP / 2))])
									* alpha;
						for (c = 0; c < layer1_size; c++)
							neu1e[c] += g * syn1neg[c + l2];
						for (c = 0; c < layer1_size; c++)
							syn1neg[c + l2] += g * neu1[c];
						if (cap == 1)
							for (c = 0; c < layer1_size; c++)
								capParam(syn1neg, c + l2);
					}
				// Noise Contrastive Estimation
				if (nce > 0)
					for (d = 0; d < nce + 1; d++) {
						if (d == 0) {
							target = word;
							label = 1;
						} else {
							next_random = next_random
									* (unsigned long long) 25214903917 + 11;
							if (word_to_group != NULL
									&& word_to_group[word] != -1) {
								target = word;
								while (target == word) {
									target = group_to_table[word_to_group[word]
											* table_size
											+ (next_random >> 16) % table_size];
									next_random = next_random
											* (unsigned long long) 25214903917
											+ 11;
								}
							} else {
								target =
										table[(next_random >> 16) % table_size];
							}
							if (target == 0)
								target = next_random % (vocab_size - 1) + 1;
							if (target == word)
								continue;
							label = 0;
						}
						l2 = target * layer1_size;
						f = 0;

						for (c = 0; c < layer1_size; c++)
							f += neu1[c] * syn1nce[c + l2];
						if (f > MAX_EXP)
							g = (label - 1) * alpha;
						else if (f < -MAX_EXP)
							g = (label - 0) * alpha;
						else {
							f = exp(f);
							g =
									(label
											- f
													/ (noise_distribution[target]
															* nce + f)) * alpha;
						}
						for (c = 0; c < layer1_size; c++)
							neu1e[c] += g * syn1nce[c + l2];
						for (c = 0; c < layer1_size; c++)
							syn1nce[c + l2] += g * neu1[c];
						if (cap == 1)
							for (c = 0; c < layer1_size; c++)
								capParam(syn1nce, c + l2);
					}
				// hidden -> in
				for (a = b; a < window * 2 + 1 - b; a++)
					if (a != window) {
						c = sentence_position - window + a;
						if (c < 0)
							continue;
						if (c >= sentence_length)
							continue;
						last_word = sen[c];
						if (last_word == -1)
							continue;
						for (c = 0; c < layer1_size; c++)
							syn0[c + last_word * layer1_size] += neu1e[c];
					}
			}
		} else if (type == 1) {  //train skip-gram
			for (a = b; a < window * 2 + 1 - b; a++)
				if (a != window) {
					c = sentence_position - window + a;
					if (c < 0)
						continue;
					if (c >= sentence_length)
						continue;
					last_word = sen[c];
					if (last_word == -1)
						continue;
					l1 = last_word * layer1_size;
					for (c = 0; c < layer1_size; c++)
						neu1e[c] = 0;
					// HIERARCHICAL SOFTMAX
					if (hs)
						for (d = 0; d < vocab[word].codelen; d++) {
							f = 0;
							l2 = vocab[word].point[d] * layer1_size;
							// Propagate hidden -> output
							for (c = 0; c < layer1_size; c++)
								f += syn0[c + l1] * syn1[c + l2];
							if (f <= -MAX_EXP)
								continue;
							else if (f >= MAX_EXP)
								continue;
							else
								f = expTable[(int) ((f + MAX_EXP)
										* (EXP_TABLE_SIZE / MAX_EXP / 2))];
							// 'g' is the gradient multiplied by the learning rate
							g = (1 - vocab[word].code[d] - f) * alpha;
							// Propagate errors output -> hidden
							for (c = 0; c < layer1_size; c++)
								neu1e[c] += g * syn1[c + l2];
							// Learn weights hidden -> output
							for (c = 0; c < layer1_size; c++)
								syn1[c + l2] += g * syn0[c + l1];
							if (cap == 1)
								for (c = 0; c < layer1_size; c++)
									capParam(syn1, c + l2);
						}
					// NEGATIVE SAMPLING
					if (negative > 0)
						for (d = 0; d < negative + 1; d++) {
							if (d == 0) {
								target = word;
								label = 1;
							} else {
								next_random = next_random
										* (unsigned long long) 25214903917 + 11;
								if (word_to_group != NULL
										&& word_to_group[word] != -1) {
									target = word;
									while (target == word) {
										target =
												group_to_table[word_to_group[word]
														* table_size
														+ (next_random >> 16)
																% table_size];
										next_random =
												next_random
														* (unsigned long long) 25214903917
														+ 11;
									}
									//printf("negative sampling %lld for word %s returned %s\n", d, vocab[word].word, vocab[target].word);
								} else {
									target = table[(next_random >> 16)
											% table_size];
								}
								if (target == 0)
									target = next_random % (vocab_size - 1) + 1;
								if (target == word)
									continue;
								label = 0;
							}
							l2 = target * layer1_size;
							f = 0;
							for (c = 0; c < layer1_size; c++)
								f += syn0[c + l1] * syn1neg[c + l2];
							if (f > MAX_EXP)
								g = (label - 1) * alpha;
							else if (f < -MAX_EXP)
								g = (label - 0) * alpha;
							else
								g =
										(label
												- expTable[(int) ((f + MAX_EXP)
														* (EXP_TABLE_SIZE
																/ MAX_EXP / 2))])
												* alpha;
							for (c = 0; c < layer1_size; c++)
								neu1e[c] += g * syn1neg[c + l2];
							for (c = 0; c < layer1_size; c++)
								syn1neg[c + l2] += g * syn0[c + l1];
							if (cap == 1)
								for (c = 0; c < layer1_size; c++)
									capParam(syn1neg, c + l2);
						}
					//Noise Contrastive Estimation
					if (nce > 0)
						for (d = 0; d < nce + 1; d++) {
							if (d == 0) {
								target = word;
								label = 1;
							} else {
								next_random = next_random
										* (unsigned long long) 25214903917 + 11;
								if (word_to_group != NULL
										&& word_to_group[word] != -1) {
									target = word;
									while (target == word) {
										target =
												group_to_table[word_to_group[word]
														* table_size
														+ (next_random >> 16)
																% table_size];
										next_random =
												next_random
														* (unsigned long long) 25214903917
														+ 11;
									}
									//printf("negative sampling %lld for word %s returned %s\n", d, vocab[word].word, vocab[target].word);
								} else {
									target = table[(next_random >> 16)
											% table_size];
								}
								if (target == 0)
									target = next_random % (vocab_size - 1) + 1;
								if (target == word)
									continue;
								label = 0;
							}
							l2 = target * layer1_size;
							f = 0;
							for (c = 0; c < layer1_size; c++)
								f += syn0[c + l1] * syn1nce[c + l2];
							if (f > MAX_EXP)
								g = (label - 1) * alpha;
							else if (f < -MAX_EXP)
								g = (label - 0) * alpha;
							else {
								f = exp(f);
								g = (label
										- f
												/ (noise_distribution[target]
														* nce + f)) * alpha;
							}
							for (c = 0; c < layer1_size; c++)
								neu1e[c] += g * syn1nce[c + l2];
							for (c = 0; c < layer1_size; c++)
								syn1nce[c + l2] += g * syn0[c + l1];
							if (cap == 1)
								for (c = 0; c < layer1_size; c++)
									capParam(syn1nce, c + l2);
						}
					// Learn weights input -> hidden
					for (c = 0; c < layer1_size; c++)
						syn0[c + l1] += neu1e[c];
				}
		} else if (type == 2) { //train the cwindow architecture
			// in -> hidden
			cw = 0;
			for (a = 0; a < window * 2 + 1; a++)
				if (a != window) {
					c = sentence_position - window + a;
					if (c < 0)
						continue;
					if (c >= sentence_length)
						continue;
					last_word = sen[c];
					if (last_word == -1)
						continue;
					window_offset = a * layer1_size;
					if (a > window)
						window_offset -= layer1_size;
					for (c = 0; c < layer1_size; c++)
						neu1[c + window_offset] += syn0[c
								+ last_word * layer1_size];
					cw++;
				}
			if (cw) {
				if (hs)
					for (d = 0; d < vocab[word].codelen; d++) {
						f = 0;
						l2 = vocab[word].point[d] * window_layer_size;
						// Propagate hidden -> output
						for (c = 0; c < window_layer_size; c++)
							f += neu1[c] * syn1_window[c + l2];
						if (f <= -MAX_EXP)
							continue;
						else if (f >= MAX_EXP)
							continue;
						else
							f = expTable[(int) ((f + MAX_EXP)
									* (EXP_TABLE_SIZE / MAX_EXP / 2))];
						// 'g' is the gradient multiplied by the learning rate
						g = (1 - vocab[word].code[d] - f) * alpha;
						// Propagate errors output -> hidden
						for (c = 0; c < window_layer_size; c++)
							neu1e[c] += g * syn1_window[c + l2];
						// Learn weights hidden -> output
						for (c = 0; c < window_layer_size; c++)
							syn1_window[c + l2] += g * neu1[c];
						if (cap == 1)
							for (c = 0; c < window_layer_size; c++)
								capParam(syn1_window, c + l2);
					}
				// NEGATIVE SAMPLING
				if (negative > 0)
					for (d = 0; d < negative + 1; d++) {
						if (d == 0) {
							target = word;
							label = 1;
						} else {
							next_random = next_random
									* (unsigned long long) 25214903917 + 11;
							if (word_to_group != NULL
									&& word_to_group[word] != -1) {
								target = word;
								while (target == word) {
									target = group_to_table[word_to_group[word]
											* table_size
											+ (next_random >> 16) % table_size];
									next_random = next_random
											* (unsigned long long) 25214903917
											+ 11;
								}
								//printf("negative sampling %lld for word %s returned %s\n", d, vocab[word].word, vocab[target].word);
							} else {
								target =
										table[(next_random >> 16) % table_size];
							}
							if (target == 0)
								target = next_random % (vocab_size - 1) + 1;
							if (target == word)
								continue;
							label = 0;
						}
						l2 = target * window_layer_size;
						f = 0;
						for (c = 0; c < window_layer_size; c++)
							f += neu1[c] * syn1neg_window[c + l2];
						if (f > MAX_EXP)
							g = (label - 1) * alpha;
						else if (f < -MAX_EXP)
							g = (label - 0) * alpha;
						else
							g = (label
									- expTable[(int) ((f + MAX_EXP)
											* (EXP_TABLE_SIZE / MAX_EXP / 2))])
									* alpha;
						for (c = 0; c < window_layer_size; c++)
							neu1e[c] += g * syn1neg_window[c + l2];
						for (c = 0; c < window_layer_size; c++)
							syn1neg_window[c + l2] += g * neu1[c];
						if (cap == 1)
							for (c = 0; c < window_layer_size; c++)
								capParam(syn1neg_window, c + l2);
					}
				// Noise Contrastive Estimation
				if (nce > 0)
					for (d = 0; d < nce + 1; d++) {
						if (d == 0) {
							target = word;
							label = 1;
						} else {
							next_random = next_random
									* (unsigned long long) 25214903917 + 11;
							if (word_to_group != NULL
									&& word_to_group[word] != -1) {
								target = word;
								while (target == word) {
									target = group_to_table[word_to_group[word]
											* table_size
											+ (next_random >> 16) % table_size];
									next_random = next_random
											* (unsigned long long) 25214903917
											+ 11;
								}
								//printf("negative sampling %lld for word %s returned %s\n", d, vocab[word].word, vocab[target].word);
							} else {
								target =
										table[(next_random >> 16) % table_size];
							}
							if (target == 0)
								target = next_random % (vocab_size - 1) + 1;
							if (target == word)
								continue;
							label = 0;
						}
						l2 = target * window_layer_size;
						f = 0;
						for (c = 0; c < window_layer_size; c++)
							f += neu1[c] * syn1nce_window[c + l2];
						if (f > MAX_EXP)
							g = (label - 1) * alpha;
						else if (f < -MAX_EXP)
							g = (label - 0) * alpha;
						else {
							f = exp(f);
							g =
									(label
											- f
													/ (noise_distribution[target]
															* nce + f)) * alpha;
						}
						for (c = 0; c < window_layer_size; c++)
							neu1e[c] += g * syn1nce_window[c + l2];
						for (c = 0; c < window_layer_size; c++)
							syn1nce_window[c + l2] += g * neu1[c];
						if (cap == 1)
							for (c = 0; c < window_layer_size; c++)
								capParam(syn1nce_window, c + l2);
					}
				// hidden -> in
				for (a = 0; a < window * 2 + 1; a++)
					if (a != window) {
						c = sentence_position - window + a;
						if (c < 0)
							continue;
						if (c >= sentence_length)
							continue;
						last_word = sen[c];
						if (last_word == -1)
							continue;
						window_offset = a * layer1_size;
						if (a > window)
							window_offset -= layer1_size;
						for (c = 0; c < layer1_size; c++)
							syn0[c + last_word * layer1_size] += neu1e[c
									+ window_offset];
					}
			}
		} else if (type == 3) {  //train structured skip-gram
			for (a = 0; a < window * 2 + 1; a++)
				if (a != window) {
					c = sentence_position - window + a;
					if (c < 0)
						continue;
					if (c >= sentence_length)
						continue;
					last_word = sen[c];
					if (last_word == -1)
						continue;
					l1 = last_word * layer1_size;
					window_offset = a * layer1_size;
					if (a > window)
						window_offset -= layer1_size;
					for (c = 0; c < layer1_size; c++)
						neu1e[c] = 0;
					// HIERARCHICAL SOFTMAX
					if (hs)
						for (d = 0; d < vocab[word].codelen; d++) {
							f = 0;
							l2 = vocab[word].point[d] * window_layer_size;
							// Propagate hidden -> output
							for (c = 0; c < layer1_size; c++)
								f += syn0[c + l1]
										* syn1_window[c + l2 + window_offset];
							if (f <= -MAX_EXP)
								continue;
							else if (f >= MAX_EXP)
								continue;
							else
								f = expTable[(int) ((f + MAX_EXP)
										* (EXP_TABLE_SIZE / MAX_EXP / 2))];
							// 'g' is the gradient multiplied by the learning rate
							g = (1 - vocab[word].code[d] - f) * alpha;
							// Propagate errors output -> hidden
							for (c = 0; c < layer1_size; c++)
								neu1e[c] += g
										* syn1_window[c + l2 + window_offset];
							// Learn weights hidden -> output
							for (c = 0; c < layer1_size; c++)
								syn1[c + l2 + window_offset] += g
										* syn0[c + l1];
							if (cap == 1)
								for (c = 0; c < layer1_size; c++)
									capParam(syn1, c + l2 + window_offset);
						}
					// NEGATIVE SAMPLING
					if (negative > 0)
						for (d = 0; d < negative + 1; d++) {
							if (d == 0) {
								target = word;
								label = 1;
							} else {
								next_random = next_random
										* (unsigned long long) 25214903917 + 11;
								if (word_to_group != NULL
										&& word_to_group[word] != -1) {
									target = word;
									while (target == word) {
										target =
												group_to_table[word_to_group[word]
														* table_size
														+ (next_random >> 16)
																% table_size];
										next_random =
												next_random
														* (unsigned long long) 25214903917
														+ 11;
									}
									//printf("negative sampling %lld for word %s returned %s\n", d, vocab[word].word, vocab[target].word);
								} else {
									target = table[(next_random >> 16)
											% table_size];
								}
								if (target == 0)
									target = next_random % (vocab_size - 1) + 1;
								if (target == word)
									continue;
								label = 0;
							}
							l2 = target * window_layer_size;
							f = 0;
							for (c = 0; c < layer1_size; c++)
								f +=
										syn0[c + l1]
												* syn1neg_window[c + l2
														+ window_offset];
							if (f > MAX_EXP)
								g = (label - 1) * alpha;
							else if (f < -MAX_EXP)
								g = (label - 0) * alpha;
							else
								g =
										(label
												- expTable[(int) ((f + MAX_EXP)
														* (EXP_TABLE_SIZE
																/ MAX_EXP / 2))])
												* alpha;
							if(debug_mode > 2 && ((long long) id) == 0) {
								printf("negative sampling %lld for input (word) %s (#%lld), target (last word) %s returned %s (#%lld), ", d, vocab[word].word, word, vocab[last_word].word, vocab[target].word, target);
								printf("label %lld, a %lld, gain %.4f\n", label, a-window, g);
							}
							for (c = 0; c < layer1_size; c++)
								neu1e[c] +=
										g
												* syn1neg_window[c + l2
														+ window_offset];
							for (c = 0; c < layer1_size; c++)
								syn1neg_window[c + l2 + window_offset] += g
										* syn0[c + l1];
							if (cap == 1)
								for (c = 0; c < layer1_size; c++)
									capParam(syn1neg_window,
											c + l2 + window_offset);
						}
					// Noise Constrastive Estimation
					if (nce > 0)
						for (d = 0; d < nce + 1; d++) {
							if (d == 0) {
								target = word;
								label = 1;
							} else {
								next_random = next_random
										* (unsigned long long) 25214903917 + 11;
								if (word_to_group != NULL
										&& word_to_group[word] != -1) {
									target = word;
									while (target == word) {
										target =
												group_to_table[word_to_group[word]
														* table_size
														+ (next_random >> 16)
																% table_size];
										next_random =
												next_random
														* (unsigned long long) 25214903917
														+ 11;
									}
									//printf("negative sampling %lld for word %s returned %s\n", d, vocab[word].word, vocab[target].word);
								} else {
									target = table[(next_random >> 16)
											% table_size];
								}
								if (target == 0)
									target = next_random % (vocab_size - 1) + 1;
								if (target == word)
									continue;
								label = 0;
							}
							l2 = target * window_layer_size;
							f = 0;
							for (c = 0; c < layer1_size; c++)
								f +=
										syn0[c + l1]
												* syn1nce_window[c + l2
														+ window_offset];
							if (f > MAX_EXP)
								g = (label - 1) * alpha;
							else if (f < -MAX_EXP)
								g = (label - 0) * alpha;
							else {
								f = exp(f);
								g = (label
										- f
												/ (noise_distribution[target]
														* nce + f)) * alpha;
							}
							for (c = 0; c < layer1_size; c++)
								neu1e[c] +=
										g
												* syn1nce_window[c + l2
														+ window_offset];
							for (c = 0; c < layer1_size; c++)
								syn1nce_window[c + l2 + window_offset] += g
										* syn0[c + l1];
							if (cap == 1)
								for (c = 0; c < layer1_size; c++)
									capParam(syn1nce_window,
											c + l2 + window_offset);
						}
					// Learn weights input -> hidden
					for (c = 0; c < layer1_size; c++) {
						syn0[c + l1] += neu1e[c];
						if (syn0[c + l1] > 50)
							syn0[c + l1] = 50;
						if (syn0[c + l1] < -50)
							syn0[c + l1] = -50;
					}
				}
		} else if (type == 4) { //training senna
			// in -> hidden
			cw = 0;
			for (a = 0; a < window * 2 + 1; a++)
				if (a != window) {
					c = sentence_position - window + a;
					if (c < 0)
						continue;
					if (c >= sentence_length)
						continue;
					last_word = sen[c];
					if (last_word == -1)
						continue;
					window_offset = a * layer1_size;
					if (a > window)
						window_offset -= layer1_size;
					for (c = 0; c < layer1_size; c++)
						neu1[c + window_offset] += syn0[c
								+ last_word * layer1_size];
					cw++;
				}
			if (cw) {
				for (a = 0; a < window_hidden_size; a++) {
					c = a * window_layer_size;
					for (b = 0; b < window_layer_size; b++) {
						neu2[a] += syn_window_hidden[c + b] * neu1[b];
					}
				}
				if (hs)
					for (d = 0; d < vocab[word].codelen; d++) {
						f = 0;
						l2 = vocab[word].point[d] * window_hidden_size;
						// Propagate hidden -> output
						for (c = 0; c < window_hidden_size; c++)
							f += hardTanh(neu2[c]) * syn_hidden_word[c + l2];
						if (f <= -MAX_EXP)
							continue;
						else if (f >= MAX_EXP)
							continue;
						else
							f = expTable[(int) ((f + MAX_EXP)
									* (EXP_TABLE_SIZE / MAX_EXP / 2))];
						// 'g' is the gradient multiplied by the learning rate
						g = (1 - vocab[word].code[d] - f) * alpha;
						// Propagate errors output -> hidden
						for (c = 0; c < window_hidden_size; c++)
							neu2e[c] += dHardTanh(neu2[c], g) * g
									* syn_hidden_word[c + l2];
						// Learn weights hidden -> output
						for (c = 0; c < window_hidden_size; c++)
							syn_hidden_word[c + l2] += dHardTanh(neu2[c], g) * g
									* neu2[c];
					}
				// NEGATIVE SAMPLING
				if (negative > 0)
					for (d = 0; d < negative + 1; d++) {
						if (d == 0) {
							target = word;
							label = 1;
						} else {
							next_random = next_random
									* (unsigned long long) 25214903917 + 11;
							if (word_to_group != NULL
									&& word_to_group[word] != -1) {
								target = word;
								while (target == word) {
									target = group_to_table[word_to_group[word]
											* table_size
											+ (next_random >> 16) % table_size];
									next_random = next_random
											* (unsigned long long) 25214903917
											+ 11;
								}
								//printf("negative sampling %lld for word %s returned %s\n", d, vocab[word].word, vocab[target].word);
							} else {
								target =
										table[(next_random >> 16) % table_size];
							}
							if (target == 0)
								target = next_random % (vocab_size - 1) + 1;
							if (target == word)
								continue;
							label = 0;
						}
						l2 = target * window_hidden_size;
						f = 0;
						for (c = 0; c < window_hidden_size; c++)
							f += hardTanh(neu2[c])
									* syn_hidden_word_neg[c + l2];
						if (f > MAX_EXP)
							g = (label - 1) * alpha / negative;
						else if (f < -MAX_EXP)
							g = (label - 0) * alpha / negative;
						else
							g = (label
									- expTable[(int) ((f + MAX_EXP)
											* (EXP_TABLE_SIZE / MAX_EXP / 2))])
									* alpha / negative;
						for (c = 0; c < window_hidden_size; c++)
							neu2e[c] += dHardTanh(neu2[c], g) * g
									* syn_hidden_word_neg[c + l2];
						for (c = 0; c < window_hidden_size; c++)
							syn_hidden_word_neg[c + l2] += dHardTanh(neu2[c], g)
									* g * neu2[c];
					}
				for (a = 0; a < window_hidden_size; a++)
					for (b = 0; b < window_layer_size; b++)
						neu1e[b] += neu2e[a]
								* syn_window_hidden[a * window_layer_size + b];
				for (a = 0; a < window_hidden_size; a++)
					for (b = 0; b < window_layer_size; b++)
						syn_window_hidden[a * window_layer_size + b] += neu2e[a]
								* neu1[b];
				// hidden -> in
				for (a = 0; a < window * 2 + 1; a++)
					if (a != window) {
						c = sentence_position - window + a;
						if (c < 0)
							continue;
						if (c >= sentence_length)
							continue;
						last_word = sen[c];
						if (last_word == -1)
							continue;
						window_offset = a * layer1_size;
						if (a > window)
							window_offset -= layer1_size;
						for (c = 0; c < layer1_size; c++)
							syn0[c + last_word * layer1_size] += neu1e[c
									+ window_offset];
					}
			}
		} else {
			printf("unknown type %i", type);
			exit(0);
		}
		sentence_position++;
		if (sentence_position >= sentence_length) {
			sentence_length = 0;
			continue;
		}
	}
	fclose(fi);
	free(neu1);
	free(neu1e);
	pthread_exit(NULL);
}

void ShowCollocations() {
	long a, b, c, d, window_offset, target, max_target=0, maxmax_target;
	real f, max_f, maxmax_f;
	real *target_sums;
	a = posix_memalign((void **) &target_sums, 128, vocab_size * sizeof(real));

	for (d = cc; d < vocab_size; d++) {
		for (b = 0; b < vocab_size; b++)
			target_sums[b]=0;
		maxmax_f = -1;
		maxmax_target = 0;
		for (a = 0; a < window * 2 + 1; a++) {
			if (a != window) {
				max_f = -1;
				window_offset = a * layer1_size;
				if (a > window)
					window_offset -= layer1_size;
				for(target = 0; target < vocab_size; target ++) {
					if(target == d)
						continue;
					f = 0;
					for (c = 0; c < layer1_size; c++)
						f += syn0[d* layer1_size + c]	* syn1neg_window[target * window_layer_size	+ window_offset + c];
					if (f < -MAX_EXP)
						continue;
					else if (f > MAX_EXP)
						continue;
					else
						f = expTable[(int) ((f + MAX_EXP)	* (EXP_TABLE_SIZE / MAX_EXP / 2))];
					if(f > max_f) {
						max_f = f;
						max_target = target;
					}
					target_sums[target] += (1-target_sums[target]) * f;
				}
				printf("%s (%.2f) ", vocab[max_target].word, max_f);
				if(max_f > maxmax_f) {
					maxmax_f = max_f;
					maxmax_target = max_target;
				}
			} else {
				printf("\x1b[1m%s\x1b[0m ", vocab[d].word);
			}
		}
		max_f = -1;
		for (b = 0; b < vocab_size; b++) {
			if(target_sums[b] > max_f) {
				max_f = target_sums[b];
				max_target = b;
			}
		}
		printf(" – max sum: %s (%.2f), max resp.: \x1b[1m%s\x1b[0m (%.2f)\n",
					 vocab[max_target].word, max_f,
					 vocab[maxmax_target].word, maxmax_f);
	}
}

void TrainModel() {
	long a, b, c, d;
	FILE *fo;
	pthread_t *pt = (pthread_t *) malloc(num_threads * sizeof(pthread_t));
	printf("Starting training using file %s\n", train_file);
	starting_alpha = alpha;
	if (read_vocab_file[0] != 0)
		ReadVocab();
	else
		LearnVocabFromTrainFile();
	if (save_vocab_file[0] != 0)
		SaveVocab();
	if (output_file[0] == 0)
		return;
	InitNet();
	if(cc > 0)
		ShowCollocations();
	if (negative > 0 || nce > 0)
		InitUnigramTable();
	if (negative_classes_file[0] != 0)
		InitClassUnigramTable();
	start = clock();
	for (a = 0; a < num_threads; a++)
		pthread_create(&pt[a], NULL, TrainModelThread, (void *) a);
	for (a = 0; a < num_threads; a++)
		pthread_join(pt[a], NULL);
	fo = fopen(output_file, "wb");
	if (classes == 0) {
		// Save the word vectors
		fprintf(fo, "%lld %lld\n", vocab_size, layer1_size);
		for (a = 0; a < vocab_size; a++) {
			fprintf(fo, "%s ", vocab[a].word);
			if (binary)
				for (b = 0; b < layer1_size; b++)
					fwrite(&syn0[a * layer1_size + b], sizeof(real), 1, fo);
			else
				for (b = 0; b < layer1_size; b++)
					fprintf(fo, "%lf ", syn0[a * layer1_size + b]);
			fprintf(fo, "\n");
		}
	} else {
		// Run K-means on the word vectors
		int clcn = classes, iter = 10, closeid;
		int *centcn = (int *) malloc(classes * sizeof(int));
		int *cl = (int *) calloc(vocab_size, sizeof(int));
		real closev, x;
		real *cent = (real *) calloc(classes * layer1_size, sizeof(real));
		for (a = 0; a < vocab_size; a++)
			cl[a] = a % clcn;
		for (a = 0; a < iter; a++) {
			for (b = 0; b < clcn * layer1_size; b++)
				cent[b] = 0;
			for (b = 0; b < clcn; b++)
				centcn[b] = 1;
			for (c = 0; c < vocab_size; c++) {
				for (d = 0; d < layer1_size; d++)
					cent[layer1_size * cl[c] + d] += syn0[c * layer1_size + d];
				centcn[cl[c]]++;
			}
			for (b = 0; b < clcn; b++) {
				closev = 0;
				for (c = 0; c < layer1_size; c++) {
					cent[layer1_size * b + c] /= centcn[b];
					closev += cent[layer1_size * b + c]
							* cent[layer1_size * b + c];
				}
				closev = sqrt(closev);
				for (c = 0; c < layer1_size; c++)
					cent[layer1_size * b + c] /= closev;
			}
			for (c = 0; c < vocab_size; c++) {
				closev = -10;
				closeid = 0;
				for (d = 0; d < clcn; d++) {
					x = 0;
					for (b = 0; b < layer1_size; b++)
						x += cent[layer1_size * d + b]
								* syn0[c * layer1_size + b];
					if (x > closev) {
						closev = x;
						closeid = d;
					}
				}
				cl[c] = closeid;
			}
		}
		// Save the K-means classes
		for (a = 0; a < vocab_size; a++)
			fprintf(fo, "%s %d\n", vocab[a].word, cl[a]);
		free(centcn);
		free(cent);
		free(cl);
	}
	fclose(fo);
	if (save_net_file[0] != 0)
		SaveNet();
}

int ArgPos(char *str, int argc, char **argv) {
	int a;
	for (a = 1; a < argc; a++)
		if (!strcmp(str, argv[a])) {
			if (a == argc - 1) {
				printf("Argument missing for %s\n", str);
				exit(1);
			}
			return a;
		}
	return -1;
}

int main(int argc, char **argv) {
	int i;
	if (argc == 1) {
		printf("WORD VECTOR estimation toolkit v 0.1c\n\n");
		printf("Options:\n");
		printf("Parameters for training:\n");
		printf("\t-train <file>\n");
		printf("\t\tUse text data from <file> to train the model\n");
		printf("\t-output <file>\n");
		printf(
				"\t\tUse <file> to save the resulting word vectors / word clusters\n");
		printf("\t-size <int>\n");
		printf("\t\tSet size of word vectors; default is 100\n");
		printf("\t-window <int>\n");
		printf("\t\tSet max skip length between words; default is 5\n");
		printf("\t-sample <float>\n");
		printf(
				"\t\tSet threshold for occurrence of words. Those that appear with higher frequency in the training data\n");
		printf(
				"\t\twill be randomly down-sampled; default is 1e-3, useful range is (0, 1e-5)\n");
		printf("\t-hs <int>\n");
		printf("\t\tUse Hierarchical Softmax; default is 0 (not used)\n");
		printf("\t-negative <int>\n");
		printf(
				"\t\tNumber of negative examples; default is 5, common values are 3 - 10 (0 = not used)\n");
		printf("\t-negative-classes <file>\n");
		printf("\t\tNegative classes to sample from\n");
		printf("\t-nce <int>\n");
		printf(
				"\t\tNumber of negative examples for nce; default is 0, common values are 3 - 10 (0 = not used)\n");
		printf("\t-threads <int>\n");
		printf("\t\tUse <int> threads (default 12)\n");
		printf("\t-iter <int>\n");
		printf("\t\tRun more training iterations (default 5)\n");
		printf("\t-min-count <int>\n");
		printf(
				"\t\tThis will discard words that appear less than <int> times; default is 5\n");
		printf("\t-alpha <float>\n");
		printf(
				"\t\tSet the starting learning rate; default is 0.025 for skip-gram and 0.05 for CBOW\n");
		printf("\t-classes <int>\n");
		printf(
				"\t\tOutput word classes rather than word vectors; default number of classes is 0 (vectors are written)\n");
		printf("\t-debug <int>\n");
		printf(
				"\t\tSet the debug mode (default = 2 = more info during training)\n");
		printf("\t-binary <int>\n");
		printf(
				"\t\tSave the resulting vectors in binary moded; default is 0 (off)\n");
		printf("\t-save-vocab <file>\n");
		printf("\t\tThe vocabulary will be saved to <file>\n");
		printf("\t-read-vocab <file>\n");
		printf(
				"\t\tThe vocabulary will be read from <file>, not constructed from the training data\n");
		printf("\t-read-net <file>\n");
		printf(
				"\t\tThe net parameters will be read from <file>, not initialized randomly\n");
		printf("\t-save-net <file>\n");
		printf("\t\tThe net parameters will be saved to <file>\n");
		printf("\t-show-cc <int>\n");
		printf("\t\tShow words with their collocators starting from word rank <int>. Depends on -read-vocab and -read-net.\n");
		printf("\t-type <int>\n");
		printf(
				"\t\tType of embeddings (0 for cbow, 1 for skipngram, 2 for cwindow, 3 for structured skipngram, 4 for senna type)\n");
		printf("\t-cap <int>\n");
		printf(
				"\t\tlimit the parameter values to the range [-50, 50]; default is 0 (off)\n");
		printf("\nExamples:\n");
		printf(
				"./word2vec -train data.txt -output vec.txt -size 200 -window 5 -sample 1e-4 -negative 5 -hs 0 -binary 0 -type 1 -iter 3\n\n");
		return 0;
	}
	output_file[0] = 0;
	save_vocab_file[0] = 0;
	read_vocab_file[0] = 0;
	save_net_file[0] = 0;
	read_net_file[0] = 0;
	negative_classes_file[0] = 0;
	if ((i = ArgPos((char *) "-size", argc, argv)) > 0)
		layer1_size = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-train", argc, argv)) > 0)
		strcpy(train_file, argv[i + 1]);
	if ((i = ArgPos((char *) "-save-vocab", argc, argv)) > 0)
		strcpy(save_vocab_file, argv[i + 1]);
	if ((i = ArgPos((char *) "-read-vocab", argc, argv)) > 0)
		strcpy(read_vocab_file, argv[i + 1]);
	if ((i = ArgPos((char *) "-save-net", argc, argv)) > 0)
		strcpy(save_net_file, argv[i + 1]);
	if ((i = ArgPos((char *) "-read-net", argc, argv)) > 0)
		strcpy(read_net_file, argv[i + 1]);
	if ((i = ArgPos((char *) "-debug", argc, argv)) > 0)
		debug_mode = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-binary", argc, argv)) > 0)
		binary = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-show-cc", argc, argv)) > 0)
		cc = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-type", argc, argv)) > 0)
		type = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-output", argc, argv)) > 0)
		strcpy(output_file, argv[i + 1]);
	if ((i = ArgPos((char *) "-window", argc, argv)) > 0)
		window = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-sample", argc, argv)) > 0)
		sample = atof(argv[i + 1]);
	if ((i = ArgPos((char *) "-hs", argc, argv)) > 0)
		hs = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-negative", argc, argv)) > 0)
		negative = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-negative-classes", argc, argv)) > 0)
		strcpy(negative_classes_file, argv[i + 1]);
	if ((i = ArgPos((char *) "-nce", argc, argv)) > 0)
		nce = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-threads", argc, argv)) > 0)
		num_threads = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-iter", argc, argv)) > 0)
		iter = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-min-count", argc, argv)) > 0)
		min_count = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-classes", argc, argv)) > 0)
		classes = atoi(argv[i + 1]);
	if ((i = ArgPos((char *) "-cap", argc, argv)) > 0)
		cap = atoi(argv[i + 1]);
	if (type == 0 || type == 2 || type == 4)
		alpha = 0.05;
	if ((i = ArgPos((char *) "-alpha", argc, argv)) > 0)
		alpha = atof(argv[i + 1]);
	vocab = (struct vocab_word *) calloc(vocab_max_size,
			sizeof(struct vocab_word));
	vocab_hash = (int *) calloc(vocab_hash_size, sizeof(int));
	expTable = (real *) malloc((EXP_TABLE_SIZE + 1) * sizeof(real));
	for (i = 0; i < EXP_TABLE_SIZE; i++) {
		expTable[i] = exp((i / (real) EXP_TABLE_SIZE * 2 - 1) * MAX_EXP); // Precompute the exp() table
		expTable[i] = expTable[i] / (expTable[i] + 1); // Precompute f(x) = x / (x + 1)
	}
	TrainModel();
	return 0;
}

