Skip to content

Commit

Permalink
Merge pull request #986 from AI4Bharat/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ishvindersethi22 authored Mar 25, 2024
2 parents 1dc95bd + 9578e27 commit 17f559e
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 46 deletions.
6 changes: 5 additions & 1 deletion src/redux/actions/api/LSFAPI/LSFAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ const patchAnnotation = async (
lead_time,
annotation_status,
notes,
autoSave=false
autoSave=false,
languages,
ocr_domain
) => {
try {
const res = await axiosInstance.patch(`/annotation/${annotationID}/`, {
Expand All @@ -116,6 +118,8 @@ const patchAnnotation = async (
}),
task_id: taskId,
annotation_notes: notes,
...(languages && {languages: languages.current}),
...(ocr_domain && {ocr_domain: ocr_domain.current}),
...(autoSave && { auto_save: true }),
});
return res;
Expand Down
3 changes: 3 additions & 0 deletions src/ui/pages/component/Organization/OrganizationReports.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ const OrganizationReports = () => {
"AllAudioProjects",
"OCRTranscription",
"OCRTranscriptionEditing",
"ContextualTranslation",
"ContextualSentenceVerification",
"ContextualTranslationEditing"
]);
setSelectedType("AllAudioProjects");
} else if (ProjectTypes) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/component/common/DataitemsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ useEffect(() => {
align: "center",
customHeadLabelRender: customColumnHead,
customBodyRender: (value) => {
if ((key == "metadata_json" || key == "prediction_json"|| key == "ocr_prediction_json"|| key == "transcribed_json"|| key == "draft_data_json" || key == "ocr_transcribed_json" || key == "bboxes_relation_json") && value !== null ) {
if ((key.includes("json")) && value !== null ) {
const data = JSON.stringify(value)
const metadata = data.replace(/\\/g, "");
return metadata;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/component/common/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ console.log(unseenNotifications,'uuu');
};

return (
<Grid container direction="row" style={{ zIndex: 1 }}>
<Grid container direction="row" style={{ zIndex: 200 }}>
<Box
className={location.pathname.includes("AudioTranscriptionLandingPage") ? classes.AudioparentContainers
: classes.parentContainer
Expand Down
3 changes: 3 additions & 0 deletions src/ui/pages/component/common/WorkspaceReports.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ const WorkspaceReports = () => {
"AllAudioProjects",
"OCRTranscription",
"OCRTranscriptionEditing",
"ContextualTranslation",
"ContextualSentenceVerification",
"ContextualTranslationEditing"
]);
setSelectedType("AllAudioProjects");
} else if (ProjectTypes) {
Expand Down
10 changes: 9 additions & 1 deletion src/ui/pages/container/Admin/EditProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,15 @@ const EditProfile = (props) => {
id="demo-simple-select-helper"
value={Role}
label="Role"
onChange={(e) => setRole(e.target.value)}
//onChange={(e) => setRole(e.target.value)}
onChange={(e) => {
const newRole = e.target.value;
const currentRole = Role;
if (newRole < currentRole) {
alert("Warning: Demoting someone’s role on the platform may cause inconsistencies and is not advised. Please check with platform admins on this");
}
setRole(newRole);
}}
sx={{
textAlign: "left",
}}
Expand Down
131 changes: 111 additions & 20 deletions src/ui/pages/container/Label-Studio/LSF.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,12 @@ const LabelStudioWrapper = ({
message: "",
variant: "success",
});

const ocrDomain = useRef();
const [ocrD, setOcrD] = useState("");
const selectedLanguages = useRef([]);
const [selectedL, setSelectedL] = useState([]);
const [taskData, setTaskData] = useState(undefined);
const [predictions, setPredictions] = useState([]);
const [annotations, setAnnotations] = useState([]);
const load_time = useRef();
const [autoSave, setAutoSave] = useState(true);
Expand All @@ -191,6 +195,10 @@ const LabelStudioWrapper = ({
const userData = useSelector((state) => state.fetchLoggedInUserData.data);
let loaded = useRef();

useEffect(() => {
setPredictions(taskData?.data?.ocr_prediction_json);
}, [taskData]);

const [showTagSuggestionsAnchorEl, setShowTagSuggestionsAnchorEl] =
useState(null);
const [tagSuggestionList, setTagSuggestionList] = useState();
Expand Down Expand Up @@ -472,9 +480,7 @@ const LabelStudioWrapper = ({
load_time.current,
annotation.lead_time,
"skipped",
JSON.stringify(
annotationNotesRef.current.getEditor().getContents()
)
JSON.stringify(annotationNotesRef.current.getEditor().getContents())
).then(() => {
getNextProject(projectId, taskData.id).then((res) => {
hideLoader();
Expand All @@ -490,6 +496,7 @@ const LabelStudioWrapper = ({
let countLables = 0;
temp.map((curr) => {
// console.log(curr);
ids.add(curr.id);
if(curr.type !== "relation"){
ids.add(curr.id);
}
Expand Down Expand Up @@ -553,9 +560,10 @@ const LabelStudioWrapper = ({
load_time.current,
annotations[i].lead_time,
annotation_status.current,
JSON.stringify(
annotationNotesRef.current.getEditor().getContents()
)
JSON.stringify(annotationNotesRef.current.getEditor().getContents()),
false,
selectedLanguages,
ocrDomain
).then((res) => {
hideLoader();
if (res.status !== 200) {
Expand Down Expand Up @@ -826,7 +834,9 @@ const LabelStudioWrapper = ({
annotations[i].lead_time,
annotations[i].annotation_status,
JSON.stringify(annotationNotesRef.current.getEditor().getContents()),
true
true,
selectedLanguages,
ocrDomain
).then((res) => {
if (res.status !== 200) {
setSnackbarInfo({
Expand Down Expand Up @@ -914,6 +924,31 @@ const LabelStudioWrapper = ({
);
};

const handleSelectChange = (event) => {
selectedLanguages.current = Array.from(event.target.selectedOptions, (option) => option.value);
setSelectedL(Array.from(event.target.selectedOptions, (option) => option.value));
};

useEffect(() => {
if(taskData){
if(Array.isArray(taskData?.data?.language)){
taskData?.data?.language?.map((lang)=>{
selectedLanguages.current?.push(lang);
const newLanguages = [...selectedL, ...taskData?.data?.language];
setSelectedL(newLanguages);
});
}
if(typeof taskData?.data?.language === 'string' && taskData?.data?.ocr_domain !== ""){
setSelectedL([taskData?.data?.language]);
selectedLanguages.current?.push(taskData?.data?.language);
}
if(typeof taskData?.data?.ocr_domain === 'string' && taskData?.data?.ocr_domain !== ""){
ocrDomain.current = taskData?.data?.ocr_domain;
setOcrD(taskData?.data?.ocr_domain);
}
}
}, [taskData]);

return (
<div>
{autoSave && (
Expand Down Expand Up @@ -1027,7 +1062,68 @@ const LabelStudioWrapper = ({
{tagSuggestionList}
</Popover>
</Box>

{!loader && ProjectDetails?.project_type?.includes("OCRSegmentCategorization") &&
<>
<div style={{borderStyle:"solid", borderWidth:"1px", borderColor:"#E0E0E0", paddingBottom:"1%", display:"flex", justifyContent:"space-around"}}>
<div style={{paddingLeft:"1%", fontSize:"medium", paddingTop:"1%", display:"flex"}}><div style={{margin:"auto"}}>Languages :&nbsp;</div>
<select multiple onChange={handleSelectChange} value={selectedL}>
<option value="English">English</option>
<option value="Hindi">Hindi</option>
<option value="Marathi">Marathi</option>
<option value="Tamil">Tamil</option>
<option value="Telugu">Telugu</option>
<option value="Kannada">Kannada</option>
<option value="Gujarati">Gujarati</option>
<option value="Punjabi">Punjabi</option>
<option value="Bengali">Bengali</option>
<option value="Malayalam">Malayalam</option>
<option value="Assamese">Assamese</option>
<option value="Bodo">Bodo</option>
<option value="Dogri">Dogri</option>
<option value="Kashmiri">Kashmiri</option>
<option value="Maithili">Maithili</option>
<option value="Manipuri">Manipuri</option>
<option value="Nepali">Nepali</option>
<option value="Odia">Odia</option>
<option value="Sindhi">Sindhi</option>
<option value="Sinhala">Sinhala</option>
<option value="Urdu">Urdu</option>
<option value="Santali">Santali</option>
<option value="Sanskrit">Sanskrit</option>
<option value="Goan Konkani">Goan Konkani</option>
</select>
</div>
<div style={{paddingLeft:"1%", fontSize:"medium", paddingTop:"1%", display:"flex"}}><div style={{margin:"auto"}}>Domain :&nbsp;</div>
<select style={{margin:"auto"}} onChange={(e) => {setOcrD(e.target.value); ocrDomain.current = e.target.value;}} value={ocrD}>
<option disabled selected></option>
<option value="BO">Books</option>
<option value="FO">Forms</option>
<option value="OT">Others</option>
<option value="TB">Textbooks</option>
<option value="NV">Novels</option>
<option value="NP">Newspapers</option>
<option value="MG">Magazines</option>
<option value="RP">Research_Papers</option>
<option value="FM">Form</option>
<option value="BR">Brochure_Posters_Leaflets</option>
<option value="AR">Acts_Rules</option>
<option value="PB">Publication</option>
<option value="NT">Notice</option>
<option value="SY">Syllabus</option>
<option value="QP">Question_Papers</option>
<option value="MN">Manual</option>
</select>
</div>
</div>
<div style={{borderStyle:"solid", borderWidth:"1px", borderColor:"#E0E0E0", paddingBottom:"1%"}}>
<div style={{paddingLeft:"1%", fontSize:"medium", paddingTop:"1%", paddingBottom:"1%"}}>Predictions</div>
{predictions?.length > 0 ?
predictions?.map((pred, index) => (
<div style={{paddingLeft:"2%", display:"flex", paddingRight:"2%", paddingBottom:"1%"}}><div style={{padding:"1%", margin:"auto", color:"#9E9E9E"}}>{index}</div><textarea readOnly style={{width:"100%", borderColor:"#E0E0E0"}} value={pred.text}/></div>
)) : <div style={{textAlign:"center"}}>No Predictions Present</div>}
</div>
</>
}
{loader}
{renderSnackBar()}
</div>
Expand All @@ -1041,8 +1137,8 @@ export default function LSF() {
const reviewNotesRef = useRef(null);
const { taskId } = useParams();
const [taskData, setTaskData] = useState([]);
const [annotationtext, setannotationtext] = useState("");
const [reviewtext, setreviewtext] = useState("");
const [annotationtext,setannotationtext] = useState('')
const [reviewtext,setreviewtext] = useState('')
const [showTagsInput, setShowTagsInput] = useState(false);
const [selectedTag, setSelectedTag] = useState("");
const [alertData, setAlertData] = useState({
Expand All @@ -1064,15 +1160,10 @@ export default function LSF() {
};

const formats = [
"size",
"bold",
"italic",
"underline",
"strike",
"color",
"background",
"script",
];
'size',
'bold','italic','underline','strike',
'color','background',
'script']

const handleTagChange = (event, value, reason) => {
if (reason === "selectOption") {
Expand Down
46 changes: 25 additions & 21 deletions src/ui/pages/container/Label-Studio/labelConfigJSX.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const labelConfigJS = `<View>
<Image name="image_url" value="$image_url"/>
<Image name="image_url" value="$image_url" maxWidth="900px"/>
<Filter name="filter" toName="annotation_labels"
hotkey="shift+f" minlength="0"
placeholder="Filter Labels" />
Expand All @@ -9,40 +9,44 @@ export const labelConfigJS = `<View>
<Label value="figure-caption" name="figure-caption" background="#FDCB6E" className="ignore_assertion"/>
<Label value="table" name="table" background="#FAB1A0" className="ignore_assertion"/>
<Label value="table-caption" name="table-caption" background="#E17055" className="ignore_assertion"/>
<Label value="header" name="header" background="#8CC0DE" className="ignore_assertion"/>
<Label value="footer" name="footer" background="#81ECEC" className="ignore_assertion"/>
<Label value="folio" name="folio" background="#74B9FF" className="ignore_assertion"/>
<Label value="footnote" name="footnote" background="#A29BFE" className="ignore_assertion"/>
<Label value="page-number" name="page-number" background="#A0BCC2" className="ignore_assertion"/>
<Label value="author" name="author" background="#E5E3C9" className="ignore_assertion"/>
<Label value="dateline" name="dateline" background="#E7FBBE" className="ignore_assertion"/>
<Label value="ordered-list" name="ordered-list" background="#F9F7C9" className="ignore_assertion"/>
<Label value="sub-ordered-list" name="sub-ordered-list" background="#D5F0C1" className="ignore_assertion"/>
<Label value="author" name="author" background="#2980B9" className="ignore_assertion"/>
<Label value="dateline" name="dateline" background="#16A085" className="ignore_assertion"/>
<Label value="ordered-list" name="ordered-list" background="#2C3E50" className="ignore_assertion"/>
<Label value="sub-ordered-list" name="sub-ordered-list" background="#E67E22" className="ignore_assertion"/>
<Label value="subsub-ordered-list" name="subsub-ordered-list" background="#AAD9BB" className="ignore_assertion"/>
<Label value="unordered-list" name="unordered-list" background="#FFE5E5" className="ignore_assertion"/>
<Label value="unordered-list" name="unordered-list" background="#8E44AD" className="ignore_assertion"/>
<Label value="sub-unordered-list" name="sub-unordered-list" background="#E0AED0" className="ignore_assertion"/>
<Label value="subsub-unordered-list" name="subsub-unordered-list" background="#AC87C5" className="ignore_assertion"/>
<Label value="section-title" name="section-title" background="#F7FFE5" className="ignore_assertion"/>
<Label value="sub-section-title" name="sub-section-title" background="#E1ECC8" className="ignore_assertion"/>
<Label value="subsub-section-title" name="subsub-section-title" background="#C4D7B2" className="ignore_assertion"/>
<Label value="headline" name="headline" background="#F5EBEB" className="ignore_assertion"/>
<Label value="sub-headline" name="sub-headline" background="#E4D0D0" className="ignore_assertion"/>
<Label value="section-title" name="section-title" background="#F39C12" className="ignore_assertion"/>
<Label value="sub-section-title" name="sub-section-title" background="#C0392B" className="ignore_assertion"/>
<Label value="subsub-section-title" name="subsub-section-title" background="#27AE60" className="ignore_assertion"/>
<Label value="headline" name="headline" background="#D35400" className="ignore_assertion"/>
<Label value="sub-headline" name="sub-headline" background="#8E44AD" className="ignore_assertion"/>
<Label value="subsub-headline" name="subsub-headline" background="#D5B4B4" className="ignore_assertion"/>
<Label value="chapter-title" name="chapter-title" background="#F7C8E0" className="ignore_assertion"/>
<Label value="placeholder-text" name="placeholder-text" background="#EEF1FF" className="ignore_assertion"/>
<Label value="formula" name="formula" background="#CDF0EA" className="ignore_assertion"/>
<Label value="first-level-question" name="first-level-question" background="#FFE3E1" className="ignore_assertion"/>
<Label value="second-level-question" name="second-level-question" background="#FFD1D1" className="ignore_assertion"/>
<Label value="placeholder-text" name="placeholder-text" background="#3498DB" className="ignore_assertion"/>
<Label value="formula" name="formula" background="#2ECC71" className="ignore_assertion"/>
<Label value="first-level-question" name="first-level-question" background="#E74C3C" className="ignore_assertion"/>
<Label value="second-level-question" name="second-level-question" background="#9B59B6" className="ignore_assertion"/>
<Label value="third-level-question" name="third-level-question" background="#FF9494" className="ignore_assertion"/>
<Label value="answer" name="answer" background="#2980B9" className="ignore_assertion"/>
<Label value="options" name="options" background="#E8DFCA" className="ignore_assertion"/>
<Label value="index" name="index" background="#FFCCB3" className="ignore_assertion"/>
<Label value="table-of-contents" name="table-of-contents" background="#9ED2C6" className="ignore_assertion"/>
<Label value="jumpline" name="jumpline" background="#F5E8C7" className="ignore_assertion"/>
<Label value="advertisement" name="advertisement" background="#ECCCB2" className="ignore_assertion"/>
<Label value="sidebar" name="sidebar" background="#FFDBA4" className="ignore_assertion"/>
<Label value="flag" name="flag" background="#C4DFAA" className="ignore_assertion"/>
<Label value="reference" name="reference" background="#F2D7D9" className="ignore_assertion"/>
<Label value="contact-info" name="contact-info" background="#DAEAF1" className="ignore_assertion"/>
<Label value="jumpline" name="jumpline" background="#F39C12" className="ignore_assertion"/>
<Label value="advertisement" name="advertisement" background="#1ABC9C" className="ignore_assertion"/>
<Label value="sidebar" name="sidebar" background="#F1C40F" className="ignore_assertion"/>
<Label value="flag" name="flag" background="#34495E" className="ignore_assertion"/>
<Label value="reference" name="reference" background="#27AE60" className="ignore_assertion"/>
<Label value="contact-info" name="contact-info" background="#D35400" className="ignore_assertion"/>
<Label value="website-link" name="website-link" background="#8CC0DE" className="ignore_assertion"/>
<Label value="unsure" name="unsure" background="#D35400" className="ignore_assertion"/>
</Labels>
<Rectangle name="annotation_bboxes" toName="image_url" strokeWidth="3" className="ignore_assertion"/>
<Relations>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/container/Workspace/AnnotationProject.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ const AnnotationProject = (props) => {
align: "center",
customHeadLabelRender: customColumnHead,
customBodyRender: (value) => {
if ((keys == "metadata_json" || keys == "prediction_json" || keys == "ocr_prediction_json" || keys == "transcribed_json" || keys == "draft_data_json" || keys == "ocr_transcribed_json") && value !== null) {
if ((keys.includes("json")) && value !== null ) {
const data = JSON.stringify(value)
const metadata = data.replace(/\\/g, "");
return metadata;
Expand Down

0 comments on commit 17f559e

Please sign in to comment.