feat(reader): multi-word and phrasal verb detector in reader (Task 14)
This commit is contained in:
1 parent
37a1f1ab35
commit
1c3f03a64c
9 files changed
+738
-16
No files matched your search
@@ -96,13 +96,21 @@ export const api = {
|
||||
|
||||
// Dictionary Lookup & AI Sentence Translation
|
||||
lookup: {
|
||||
async search(term) {
|
||||
const resp = await fetch(`/api/lookup?term=${encodeURIComponent(term)}`);
|
||||
async search(term, context = '') {
|
||||
let url = `/api/lookup?term=${encodeURIComponent(term)}`;
|
||||
if (context) {
|
||||
url += `&context=${encodeURIComponent(context)}`;
|
||||
}
|
||||
const resp = await fetch(url);
|
||||
if (resp.ok) {
|
||||
return await resp.json();
|
||||
}
|
||||
throw new Error(`Lookup failed: ${resp.status}`);
|
||||
},
|
||||
async detectPhrasalVerb(sentence, word) {
|
||||
const resp = await fetch(`/api/detect-phrasal-verb?sentence=${encodeURIComponent(sentence)}&word=${encodeURIComponent(word)}`);
|
||||
return resp.ok ? await resp.json() : { detected: false, phrasal_verb: null };
|
||||
},
|
||||
async translateSentence(sentence, targetWord = '') {
|
||||
const resp = await fetch('/api/translate-sentence', {
|
||||
method: 'POST',
|
||||
|
||||
Reference in new issue
Block a user