diff --git a/src/ui/pages/component/common/Header.jsx b/src/ui/pages/component/common/Header.jsx index af78c399..5f272b6d 100644 --- a/src/ui/pages/component/common/Header.jsx +++ b/src/ui/pages/component/common/Header.jsx @@ -1139,14 +1139,6 @@ console.log(unseenNotifications,'uuu'); /> - - {/* {showRomanisedTransliterationModel && - setShowRomanisedTransliterationModel(false)} - setShowRomanisedTransliterationModel = {setShowRomanisedTransliterationModel} - /> - } */} ); }; diff --git a/src/ui/pages/container/Label-Studio/LSF.jsx b/src/ui/pages/container/Label-Studio/LSF.jsx index 78ba92fb..df2a61cb 100644 --- a/src/ui/pages/container/Label-Studio/LSF.jsx +++ b/src/ui/pages/container/Label-Studio/LSF.jsx @@ -264,11 +264,6 @@ const LabelStudioWrapper = ({ }));}); }, []); - // useEffect(() => { - // const showModel = localStorage.getItem("showRomanisedTransliterationModel") === "true"; - // setShowRomanisedTransliterationModel(showModel); - // }, [localStorage]); - const tasksComplete = (id) => { if (id) { resetNotes(); @@ -1492,7 +1487,6 @@ export default function LSF() { useEffect(() => { fetchAnnotation(taskId).then((data) => { if (data && Array.isArray(data) && data.length > 0) { - // console.log(annotationNotesRef); annotationNotesRef.current.value = data[0].annotation_notes ?? ""; reviewNotesRef.current.value = data[0].review_notes ?? ""; try { @@ -1500,7 +1494,6 @@ export default function LSF() { annotationNotesRef.current.value !== "" ? JSON.parse(annotationNotesRef.current.value) : ""; - // console.log(newDelta2); annotationNotesRef.current.getEditor().setContents(newDelta2); } catch (err) { if (err instanceof SyntaxError) { diff --git a/src/ui/pages/container/Label-Studio/ReviewLSF.jsx b/src/ui/pages/container/Label-Studio/ReviewLSF.jsx index cdf5677b..e985f59a 100644 --- a/src/ui/pages/container/Label-Studio/ReviewLSF.jsx +++ b/src/ui/pages/container/Label-Studio/ReviewLSF.jsx @@ -58,7 +58,7 @@ import CustomButton from "../../component/common/Button"; import CircularProgress from '@mui/material/CircularProgress'; import LanguageCode from "../../../../utils/LanguageCode"; import PostTransliterationForLogging from "../../../../redux/actions/api/Annotation/PostTransliterationForLogging"; - +import RomanisedTransliteration from "../Transliteration/RomanisedTransliteration"; const StyledMenu = styled((props) => ( { if (taskId) { fetchAnnotationTask(); } - }, [taskId]); - + }, [taskId]); const fetchAnnotationTask = async () => { const res = await fetchAnnotation(taskId); // console.log(res); if(res[0]?.result[0]) { - setIndicText(res[0]?.result[0]?.value?.text); + setIndicText(res[0]?.result[0]?.value?.text[0]); } setTaskData(res); setAnnotations(res?.annotations); @@ -1189,16 +1195,15 @@ useEffect(() => { // create a handleSubmitRomanisedText function const handleSubmitRomanisedText = async () => { - if(taskData?.data?.input_text && taskData?.data?.input_language && taskData?.data?.output_language){ + if(taskData?.data?.input_text && taskData?.data?.output_language){ const language = LanguageCode.languages let output_lng_code = '' language.filter((lang) => { - if(lang.label === taskData?.data?.input_language){ + if(lang.label === taskData?.data?.output_language){ output_lng_code= lang.code } }); - // Create a new instance of the class const postTransliterationForLogging = new PostTransliterationForLogging( taskData?.data?.input_text, @@ -1210,7 +1215,15 @@ useEffect(() => { const res = dispatch(APITransport(postTransliterationForLogging)); if(res){ - setTransliterationData([]); + setRomanisedTransliterationData( + { + timestamp: '', + error: '', + input: '', + romanised_transliteration: '', + success: false + } + ) setOriginalRomanisedText(""); setEditedRomanisedText(""); setSnackbarInfo({ @@ -1234,22 +1247,21 @@ useEffect(() => { const handleTranslitrationOnClick = async () => { setShowSpinner(true) const language = LanguageCode.languages - let input_lng_code = '' let output_lng_code = '' + language.filter((lang) => { - if(lang.label === taskData?.data?.input_language){ - input_lng_code= lang.code - } - if(lang.label === taskData?.data?.output_language){ + if(lang.label == taskData?.data?.output_language){ output_lng_code = lang.code } }) - const res = await fetchTransliteration(taskData?.data?.input_text,input_lng_code, output_lng_code); - if(res && res?.output) { - setTransliterationData(res); - if(res?.output) + try { + + const res = await fetchTransliteration(indicText, output_lng_code); + if(res?.success && res?.romanised_transliteration) { + setRomanisedTransliterationData(res); + if(res?.romanised_transliteration) { - setOriginalRomanisedText(res?.output.map((item) => item.target).join(" ")); + setOriginalRomanisedText(res.romanised_transliteration); } setSnackbarInfo({ open: true, @@ -1258,6 +1270,16 @@ useEffect(() => { }); setShowSpinner(false) } + } + catch (error) { + setSnackbarInfo({ + open: true, + message: "Error in fetching romanised text", + variant: "error", + }); + setShowSpinner(false) + } + } useEffect(() => { if(originalRomanisedText) { @@ -1265,9 +1287,41 @@ useEffect(() => { } }, [originalRomanisedText]); + useEffect(() => { + let annotation = lsfRef?.current?.store?.annotationStore?.selected; + let temp; + for (let i = 0; i < annotations?.length; i++) { + if ( + !annotations[i]?.result?.length || + annotation.serializeAnnotation()[0].id === + annotations[i]?.result[0].id + ) { + temp = annotation.serializeAnnotation(); + if (annotations[i]?.annotation_type !== 1) continue; + for (let i = 0; i < temp?.length; i++) { + if(temp[i].type === "relation"){ + continue; + }else if (temp[i]?.value.text) { + temp[i].value.text = [temp[i].value.text[0]]; + } + } + if(temp[0]?.value?.text[0]?.length >0){ + setIndicText(temp[0]?.value?.text[0]) + } + } + } + }, [annotations, fetchTransliteration, handleSubmitRomanisedText]); + const handleEditableRomanisedText =(e)=>{ setEditedRomanisedText(e.target.value) } + + // call the handleTransliteration for first time if the indic text is present + useEffect(() => { + if(indicText){ + handleTranslitrationOnClick() + } + }, [indicText]); const [anchorEl, setAnchorEl] = useState(null); const open = Boolean(anchorEl); const handleClick = (event) => { @@ -1518,41 +1572,22 @@ useEffect(() => { > {tagSuggestionList} - {!loader&& ProjectDetails?.project_type?.includes("ContextualTranslationEditing") && - - - } - onClick={handleTranslitrationOnClick} - label="Check Transliteration" - disabled={showSpinner} - /> - {originalRomanisedText && - } - onClick={handleSubmitRomanisedText} - label="Submit" - /> - } - - - {translitrationData?.output && - -