Closed monk1337 closed 1 year ago
Not sure how far you've gotten on this bug, but I'll throw out a suggestion.
Since the user can specify any kind of output, it would be difficult to build a universal parser/verifier. Maybe we could just settle for a collection of parsers that the users can select from depending on the output format they specified, e.g. something like this?:
result = nlp_prompter.fit('ner.jinja',
parser=promptify.parser.parse_dict_of_str
...
@escesare That's an interesting suggestion. I am working on a parser class; if you are using discord, please reach out to me, and let's discuss this in detail.
discord: StoicBatman#6403
Temporary solution
def escaped_(data):
escaped_str = re.sub(r'(\w)(\')(\w)', r'\1\'\3', data)
obj = ast.literal_eval(escaped_str)
return obj
or
def escaped_(data):
if "'" in data:
escaped_str = re.sub(r'(\w)(\')(\w)', r'\1\"\3', data)
else:
escaped_str = re.sub(r'(\w)(\")(\w)', r'\1\'\3', data)
return escaped_str
Issue was in Question-Generation prompt, Need to check and fix it.
Issue code:
The output is :
Parsing this output with
eval()
gives error because of single and double quote issue.