<commit_before>/* The Schema for news */
import mongoose from 'mongoose'
import moment from 'moment'

const NewsSchema = new mongoose.Schema({
  header: {type: String, required: true},
  text: {type: String, required: true},
  url: String,
  author: String,
  created_at: {
    type: Date,
    default: Date.now
  }
})
<commit_msg>added news max chars 256<commit_after>/* The Schema for news */
import mongoose from 'mongoose'
import moment from 'moment'

const NewsSchema = new mongoose.Schema({
  header: {type: String, required: true},
  text: {type: String, required: true},
  url: String,
  author: String,
  created_at: {
    type: Date,
    default: Date.now
  }
})

NewsSchema.path('text').get(v => {
  if (v.length < 256) return v
  let str = v.substring(0, 256)
  let idx = str.lastIndexOf(' ')
  str = str.substring(0, idx !== -1 ? idx : 255) + ` ${String.fromCharCode(8230)}`
  return str
})

{'fraction_non_alphanumeric': 0.14491150442477876, 'fraction_numerical': 0.02101769911504425, 'mean_word_length': 3.738219895287958, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4515017', 'n_tokens_mistral': 321, 'n_tokens_neox': 311, 'n_words': 98}