<commit_before>import JournalInput from '../components/JournalInput';
import { Field, reduxForm, reset } from 'redux-form';
import { connect } from 'react-redux';
import { addEntry } from '../reducers/entry';
import { setTranscript } from '../reducers/transcription';
import sentiment from 'sentiment';
import { emotinator, validateJournal, sentiMentator, bayesinator } from "../utils";


let title, content, user, sentimentObject, emotionObject, emotionCount

const mapstate = (state) => {
  title =  state.form.journalForm ? state.form.journalForm.values ? state.form.journalForm.values.title ? state.form.journalForm.values.title : '' : '' : ''
  content =   state.transcription ? state.transcription : '';
  user =   state.auth.user
  console.log('about to perform emotinator on ', content);
  let emotionReturn = emotinator(content);
  emotionObject = emotionReturn[0];
  emotionCount = emotionReturn[1];

  sentimentObject =  sentiMentator( sentiment(content) , 'journal' );
  let teachDocs = state.teachDoc.allTeachDocs
  let [smartObject] = bayesinator(teachDocs, content)

  return {
    title,
    content,
    user,
    sentimentObject,
    emotionObject,
    emotionCount,
    smartObject,
    transcript: state.transcription,
    alertShow: false
  }
}

const mapDisptachToProps = (dispatch, ownProps) => {
  return {
     addEntry (e) {
      e.preventDefault()
      dispatch(addEntry({title,content,sent:sentimentObject,emotion:emotionObject,user_id:user.id}))
      dispatch(reset('journalForm'))
      window.location.replace('/user')
    },
    onChangePostText: (event) => {
      console.log('text is being changed');
      dispatch(setTranscript(event.target.value))
    },

  }
}

const JournalForm = reduxForm({
  form: 'journalForm',
  validateJournal
})(JournalInput)

export default connect(mapstate, mapDisptachToProps)(JournalForm);

<commit_msg>redirects to home on submit<commit_after>import JournalInput from '../components/JournalInput';
import { Field, reduxForm, reset } from 'redux-form';
import { connect } from 'react-redux';
import { addEntry } from '../reducers/entry';
import { setTranscript } from '../reducers/transcription';
import sentiment from 'sentiment';
import { emotinator, validateJournal, sentiMentator, bayesinator } from "../utils";


let title, content, user, sentimentObject, emotionObject, emotionCount

const mapstate = (state) => {
  title =  state.form.journalForm ? state.form.journalForm.values ? state.form.journalForm.values.title ? state.form.journalForm.values.title : '' : '' : ''
  content =   state.transcription ? state.transcription : '';
  user =   state.auth.user
  console.log('about to perform emotinator on ', content);
  let emotionReturn = emotinator(content);
  emotionObject = emotionReturn[0];
  emotionCount = emotionReturn[1];

  sentimentObject =  sentiMentator( sentiment(content) , 'journal' );
  let teachDocs = state.teachDoc.allTeachDocs
  let [smartObject] = bayesinator(teachDocs, content)

  return {
    title,
    content,
    user,
    sentimentObject,
    emotionObject,
    emotionCount,
    smartObject,
    transcript: state.transcription,
    alertShow: false
  }
}

const mapDisptachToProps = (dispatch, ownProps) => {
  return {
     addEntry (e) {
      e.preventDefault()
      dispatch(addEntry({title,content,sent:sentimentObject,emotion:emotionObject,user_id:user.id}))
      dispatch(reset('journalForm'))
      window.location.replace('/home')
    },
    onChangePostText: (event) => {
      console.log('text is being changed');
      dispatch(setTranscript(event.target.value))
    },

  }
}

const JournalForm = reduxForm({
  form: 'journalForm',
  validateJournal
})(JournalInput)

export default connect(mapstate, mapDisptachToProps)(JournalForm);


{'fraction_non_alphanumeric': 0.1259298618490967, 'fraction_numerical': 0.0010626992561105207, 'mean_word_length': 4.29535864978903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1774498', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1122, 'n_words': 240}