<commit_before>import { find } from "lodash"
import React from "react"

interface ReadMoreWrapperProps {
  isTruncated?: boolean
  id?: any
}

interface ReadMoreWrapperState {
  truncationHeight: number | string
}

class ReadMoreWrapper extends React.Component<ReadMoreWrapperProps, ReadMoreWrapperState> {
  constructor(props) {
    super(props)
    this.state = {
      truncationHeight: "100%",
    }
  }

  componentDidMount() {
    if (this.props.isTruncated) {
      this.setState({ truncationHeight: this.calculateTruncation() })
    }
  }

  calculateTruncation = () => {
    if (this.props.isTruncated) {
      let height = 0
      let charCount = 0
      find(document.getElementsByClassName("article__text-section"), section => {
        let sectionCharCount = 0
        const foundTag = find(section.getElementsByTagName("p"), tag => {
          const textContent = tag.textContent
          sectionCharCount = sectionCharCount + textContent.length
          charCount = charCount + textContent.length
          if (textContent && sectionCharCount > 150 && charCount > 2000) {
            height =
              tag.getBoundingClientRect().bottom -
              document.getElementsByClassName(`article-id__${this.props.id}`)[0].getBoundingClientRect().top
            return true
          }
          return false
        })
        return foundTag ? true : false
      })
      return height > 0 ? height : "100%"
    } else {
      return "100%"
    }
  }

  getTruncationHeight = () => {
    return this.props.isTruncated ? this.state.truncationHeight : "100%"
  }

  getOverflow = () => {<commit_msg>Rename method<commit_after>import { find } from "lodash"
import React from "react"

interface ReadMoreWrapperProps {
  isTruncated?: boolean
  id?: any
}

interface ReadMoreWrapperState {
  truncationHeight: number | string
}

class ReadMoreWrapper extends React.Component<ReadMoreWrapperProps, ReadMoreWrapperState> {
  constructor(props) {
    super(props)
    this.state = {
      truncationHeight: "100%",
    }
  }

  componentDidMount() {
    if (this.props.isTruncated) {
      this.setState({ truncationHeight: this.calculateTruncationHeight() })
    }
  }

  calculateTruncationHeight = () => {
    if (this.props.isTruncated) {
      let height = 0
      let charCount = 0
      find(document.getElementsByClassName("article__text-section"), section => {
        let sectionCharCount = 0
        const foundTag = find(section.getElementsByTagName("p"), tag => {
          const textContent = tag.textContent
          sectionCharCount = sectionCharCount + textContent.length
          charCount = charCount + textContent.length
          if (textContent && sectionCharCount > 150 && charCount > 2000) {
            height =
              tag.getBoundingClientRect().bottom -
              document.getElementsByClassName(`article-id__${this.props.id}`)[0].getBoundingClientRect().top
            return true
          }
          return false
        })
        return foundTag ? true : false
      })
      return height > 0 ? height : "100%"
    } else {
      return "100%"
    }
  }

  getTruncationHeight = () => {
    return this.props.isTruncated ? this.state.truncationHeight : "100%"
  }

  getOverflow = () => {
{'fraction_non_alphanumeric': 0.10830769230769231, 'fraction_numerical': 0.014769230769230769, 'mean_word_length': 2.652808988764045, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '2394676', 'n_tokens_mistral': 975, 'n_tokens_neox': 922, 'n_words': 187}