From 1d51335b61db58b7fdc3f2302ecc63a689823932 Mon Sep 17 00:00:00 2001 From: adjscent Date: Sun, 21 Apr 2019 11:31:51 +0800 Subject: [PATCH] util function to strip and and phrases --- QueryExpansion.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/QueryExpansion.py b/QueryExpansion.py index 8d408a3..5535cde 100644 --- a/QueryExpansion.py +++ b/QueryExpansion.py @@ -290,6 +290,19 @@ def convert_wordnet_terms(terms): ######################## UTIL FUNCTIONS ######################## +def drop_AND_phrase(line): + """ + A really simple util function that strips out all bool and phrase markings + :param: line: Query string + """ + result = [] + b1, b2, tokens = tokenize(line) + for token in tokens: + if token != AND: + for subtoken in token.split(): + result.append(subtoken) + return convert_list_to_string(result) + def tokenize(line): """ Tokenises a line to a list of words, using the delimiter as space or ".