-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: toResponse() #1118
Comments
@Ocean-OS - you could... But it's the matter of how long you want to take to determine the structure of how questions can start etc as they are in various patterns... As well the patterns of what the responses should look like..... Here is a VERY basic example of how you could do this. import nlp from "https://esm.sh/compromise";
function generateResponse(question) {
// Parse the question using compromise
let doc = nlp(question);
// Extract the main subject and verb from the question
let questionWord = doc.match("#QuestionWord+").first().text();
let secondPart = doc.match("(#Verb+|#Determiner+)").first().text();
//console.log(verb)
return (
question.replace(questionWord, "").replace(secondPart, "").trim() +
` ${secondPart}`
);
}
// Example usage
let question = "When was World War II";
let response = generateResponse(question);
console.log(response); // Output: "World War II was" This would be a VERY tedious task. Tho I love Compromise.js and it's capabilities. I suggest you look at another tool / option if you are looking to do more than just VERY basic use cases. Hope this answers your question. ps; if it deal. Feel feel to close this issue to save some stress on Spencer! |
hey ComputerGuy, yep I would start writing some templates, like jared has suggested. Could get you somewhere, if your question-answer forms were in well-understood formats: let m = doc.match('what [<verb>(is|was)] [<subj>#Noun+]$')
if(m.found){
return m.groups('subj').text() + ' ' + m.groups('verb').text() +' ...'
} https://runkit.com/spencermountain/6674229afd6d9b00083261b3 |
We already have a way to detect if a group of sentences is a question. Is it possible to make a function that could take a question, and return the beginning of a response to the question? (eg "What was World War II?" becomes "World War II was").
The text was updated successfully, but these errors were encountered: