Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Commit

Permalink
fix(transcripts): better transcript end detection
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-heimbuch committed Nov 16, 2018
1 parent db5a18d commit cd4f7f9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/effects/transcripts/fetch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { get, last, find, isNumber } from 'lodash'
import { get, last, find, isNumber, endsWith } from 'lodash'
import { compose, map, concat, orderBy, reduce } from 'lodash/fp'

import request from 'utils/request'
Expand All @@ -17,7 +17,7 @@ const isNewChunk = (current, last) => {

const differentSpeaker = current.speaker !== last.speaker
const text = last.texts.reduce((result, item) => result + ' ' + item.text, '')
const endOfSentence = new RegExp(/.*(\.|!|\?)$/).test(text) === false
const endOfSentence = endsWith(text, '.') || endsWith(text, '!') || endsWith(text, '?')

return differentSpeaker || (text.length > 500 && endOfSentence)
}
Expand Down Expand Up @@ -87,6 +87,9 @@ export default handleActions({

request(transcriptsUrl)
.then(transformTranscript)
.then(data => {
return data
})
.catch(() => [])
.then(compose(dispatch, actions.initTranscripts))
},
Expand Down

0 comments on commit cd4f7f9

Please sign in to comment.