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

Function expandQuery

union/TUS/generalFunctions.py:79–105  ·  view source on GitHub ↗
(stringList)

Source from the content-addressed store, hash-verified

77
78#extracts tokens from the cell value or value list
79def expandQuery(stringList):
80 stringList = [item for item in stringList if type(item) == str]
81 stringList = preprocessListValues(stringList)
82 nounList = extractNouns(stringList)
83 expandedQueryList = [words for segments in nounList for words in segments.split()]
84 # handle phrase queries
85 removeNouns = []
86 for entity in puncCleanedList:
87 entityList = entity.split(" ")
88 if entityList.count('') > 0 and entityList.count('') <= 2:
89 entityList.remove('')
90 index = 0
91 while index <= len(entityList) - 1:
92 word = entityList[index]
93 if word in nounList:
94 if index + 1 < len(entityList):
95 nextWord = entityList[index + 1]
96 if entityList[index + 1] in nounList:
97 removeNouns.append(word)
98 removeNouns.append(entityList[index + 1])
99 expandedQueryList.append(word + " " + entityList[index + 1])
100 index += 1
101 index += 1
102
103 finalNouns = [noun for noun in expandedQueryList if noun not in removeNouns]
104 stopWordsRemovedList= [word for word in finalNouns if word.lower() not in stopwords.words('english')]
105 return (list(set(stopWordsRemovedList)))
106
107#This function saves dictionaries as pickle files in the storage.
108def saveDictionaryAsPickleFile(dictionary, dictionaryPath):

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected