<commit_before>import React from 'react';
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';
import { Roles } from 'meteor/alanning:roles';
import { createContainer } from 'meteor/react-meteor-data';
import slugify from 'slugify';
import cookie from 'react-cookie';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';

// components:
import Header from '/imports/ui/layouts/header/Header';
import FilterWidget from '/imports/ui/components/commentary/FilterWidget';
import Spinner from '/imports/ui/components/loading/Spinner';
import CommentLemmaSelect from '/imports/ui/components/editor/addComment/CommentLemmaSelect';
import AddComment from '/imports/ui/components/editor/addComment/AddComment';
import ContextPanel from '/imports/ui/layouts/commentary/ContextPanel';

// lib
import muiTheme from '/imports/lib/muiTheme';

// api
import Commenters from '/imports/api/collections/commenters';
import Keywords from '/imports/api/collections/keywords';


/*
 *	helpers
 */
const handlePermissions = () => {
	if (Roles.subscription.ready()) {
		if (!Roles.userIsInRole(Meteor.userId(), ['editor', 'admin', 'commenter'])) {
			FlowRouter.go('/');
		}
	}
};
const matchKeywords = (keywords) => {
	const matchedKeywords = [];
	if (keywords) {
		keywords.forEach((keyword) => {
			const foundKeyword = Keywords.findOne({
				title: keyword.label,
			});
			matchedKeywords.push(foundKeyword);
		});
	}
	return matchedKeywords;
};
const addNewKeywords = (keywords, type, next) => {
	// TODO should be handled server-side<commit_msg>add missing referenceworks import to AddCommentLayout<commit_after>import React from 'react';
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';
import { Roles } from 'meteor/alanning:roles';
import { createContainer } from 'meteor/react-meteor-data';
import slugify from 'slugify';
import cookie from 'react-cookie';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';

// components:
import Header from '/imports/ui/layouts/header/Header';
import FilterWidget from '/imports/ui/components/commentary/FilterWidget';
import Spinner from '/imports/ui/components/loading/Spinner';
import CommentLemmaSelect from '/imports/ui/components/editor/addComment/CommentLemmaSelect';
import AddComment from '/imports/ui/components/editor/addComment/AddComment';
import ContextPanel from '/imports/ui/layouts/commentary/ContextPanel';

// lib
import muiTheme from '/imports/lib/muiTheme';

// api
import Commenters from '/imports/api/collections/commenters';
import Keywords from '/imports/api/collections/keywords';
import ReferenceWorks from '/imports/api/collections/referenceWorks';


/*
 *	helpers
 */
const handlePermissions = () => {
	if (Roles.subscription.ready()) {
		if (!Roles.userIsInRole(Meteor.userId(), ['editor', 'admin', 'commenter'])) {
			FlowRouter.go('/');
		}
	}
};
const matchKeywords = (keywords) => {
	const matchedKeywords = [];
	if (keywords) {
		keywords.forEach((keyword) => {
			const foundKeyword = Keywords.findOne({
				title: keyword.label,
			});
			matchedKeywords.push(foundKeyword);
		});
	}
	return matchedKeywords;
};
const addNewKeywords = (keywords, type, next) => {
	// TODO should be handled server-side
{'fraction_non_alphanumeric': 0.13908659549228944, 'fraction_numerical': 0.0, 'mean_word_length': 5.177655677655678, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '416452', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1029, 'n_words': 232}