MCPcopy Create free account
hub / github.com/BIT-DataLab/LakeBench / expandQuery

Function expandQuery

union/Santos/expandSearch.py:57–85  ·  view source on GitHub ↗
(stringList)

Source from the content-addressed store, hash-verified

55 return nouns
56
57def 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

Callers

nothing calls this directly

Calls 5

cleanBracesContentsFunction · 0.85
countMethod · 0.80
preprocessListValuesFunction · 0.70
extractNounsFunction · 0.70
removeMethod · 0.45

Tested by

no test coverage detected