Skip to content

Commit

Permalink
fix triminng
Browse files Browse the repository at this point in the history
  • Loading branch information
ntedgi committed Jan 3, 2019
1 parent 94278f4 commit cc0d771
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion algo/lib/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ const extractWordsPartsOfQuery = (cleanQuery, keys) => {
return result
}

const cleanText = str => str.replace(/[^A-Za-z]/g, '')

const findHashTagOrEquivelentInKeys = (cleanQuery, keys) => {
let candidates = []
keys = keys.map(e => cleanText(e))
keys.forEach(e => {
let cleanTerm = e.toLowerCase()
if (cleanTerm == cleanQuery || cleanTerm.replace('#', '') == cleanQuery) {
Expand Down Expand Up @@ -171,7 +174,10 @@ module.exports = query => {
let results = tweets['statuses']
let texts = new Set(results.map(x => x.text))
console.log(`${texts.size} qureys returns on term : ${query}`)
resolve({ words: countWords(texts, queryTerm), texts: [...texts].slice(1, 10) })
resolve({
words: countWords(texts, queryTerm),
texts: [...texts].slice(1, 10)
})
}
}
)
Expand Down

0 comments on commit cc0d771

Please sign in to comment.