(stringList)
| 55 | return nouns |
| 56 | |
| 57 | def expandQuery(stringList): |
| 58 | stringList = [item for item in stringList if type(item) == str] |
| 59 | sentence = ' '.join(item for item in stringList) |
| 60 | stringList = cleanBracesContents(stringList) |
| 61 | puncCleanedList = preprocessListValues(stringList) |
| 62 | nounList = extractNouns(puncCleanedList) |
| 63 | expandedQueryList = [words for segments in nounList for words in segments.split()] |
| 64 | # handle phrase queries |
| 65 | removeNouns = [] |
| 66 | for entity in puncCleanedList: |
| 67 | entityList = entity.split(" ") |
| 68 | if entityList.count('') > 0 and entityList.count('') <= 2: |
| 69 | entityList.remove('') |
| 70 | index = 0 |
| 71 | while index <= len(entityList) - 1: |
| 72 | word = entityList[index] |
| 73 | if word in nounList: |
| 74 | if index + 1 < len(entityList): |
| 75 | nextWord = entityList[index + 1] |
| 76 | if entityList[index + 1] in nounList: |
| 77 | removeNouns.append(word) |
| 78 | removeNouns.append(entityList[index + 1]) |
| 79 | expandedQueryList.append(word + " " + entityList[index + 1]) |
| 80 | index += 1 |
| 81 | index += 1 |
| 82 | |
| 83 | finalNouns = [noun for noun in expandedQueryList if noun not in removeNouns] |
| 84 | stopWordsRemovedList= [word for word in finalNouns if word.lower() not in stopwords.words('english')] |
| 85 | return (list(set(stopWordsRemovedList))) |
| 86 |
nothing calls this directly
no test coverage detected