Download frontend/src/components/SearchStrategyEditor.tsx from Smart-Slate/Systematic-tool-review: direct link, hf CLI and curl.
- Browser
- Download file 4.18 kB
-
https://huggingface.co/spaces/Smart-Slate/Systematic-tool-review/resolve/main/frontend/src/components/SearchStrategyEditor.tsx
- Command line
-
hf download hf://spaces/Smart-Slate/Systematic-tool-review/frontend/src/components/SearchStrategyEditor.tsx
-
curl -L -o SearchStrategyEditor.tsx https://huggingface.co/spaces/Smart-Slate/Systematic-tool-review/resolve/main/frontend/src/components/SearchStrategyEditor.tsx
4.18 kB
| import type { ProtocolDraft } from "../types"; | |
| import { describeSearchStrategy } from "../utils/searchStrategy"; | |
| import { TermListEditor } from "./TermListEditor"; | |
| import "./review-fixes.css"; | |
| interface SearchStrategyEditorProps { | |
| draft: ProtocolDraft; | |
| onChange: (draft: ProtocolDraft) => void; | |
| } | |
| /** Words so common in abstracts that, used alone as search terms, they pull | |
| * in large numbers of unrelated records. A warning only; saving is allowed. */ | |
| const GENERIC_TERMS = new Set([ | |
| "oral", | |
| "inhalation", | |
| "dermal", | |
| "exposure", | |
| "study", | |
| "studies", | |
| "effect", | |
| "effects", | |
| "risk", | |
| "safety", | |
| "human", | |
| "humans", | |
| "animal", | |
| "animals", | |
| "in vitro", | |
| "in vivo", | |
| "assay", | |
| "test", | |
| "review", | |
| "analysis", | |
| ]); | |
| function lowerSet(terms: string[]): Set<string> { | |
| return new Set(terms.map((t) => t.trim().toLowerCase()).filter(Boolean)); | |
| } | |
| /** Shared by the new-protocol form and the draft edit view. */ | |
| export function SearchStrategyEditor({ draft, onChange }: SearchStrategyEditorProps) { | |
| const preview = describeSearchStrategy( | |
| draft.intervention, | |
| draft.outcome, | |
| draft.intervention_terms, | |
| draft.outcome_terms | |
| ); | |
| const exposureTerms = draft.intervention_terms ?? []; | |
| const outcomeTerms = draft.outcome_terms ?? []; | |
| const exposureSet = lowerSet(exposureTerms); | |
| const outcomeSet = lowerSet(outcomeTerms); | |
| const sharedTerms = [...exposureSet].filter((t) => outcomeSet.has(t)).sort(); | |
| const genericTerms = [...new Set([...exposureSet, ...outcomeSet])] | |
| .filter((t) => GENERIC_TERMS.has(t)) | |
| .sort(); | |
| return ( | |
| <div className="search-strategy-section"> | |
| <label className="field-label">Search strategy</label> | |
| <p className="form-hint"> | |
| List the words a study must use in its <strong>title or abstract</strong>. | |
| Studies need at least one exposure term <strong>and</strong> at least one | |
| outcome term. Add synonyms and abbreviations as separate terms (e.g.{" "} | |
| <em>bisphenol A</em>, <em>BPA</em>). If you leave a list empty, its | |
| Intervention or Outcome text above is used as a single phrase. | |
| </p> | |
| <p className="form-hint"> | |
| <strong>Exposure terms:</strong> the chemical or intervention only — its | |
| names, abbreviations and CAS number. <strong>Outcome terms:</strong> the | |
| endpoints or effects only. Don't put the same word in both lists, and keep | |
| route or study-design words (such as oral or inhalation) in the inclusion | |
| criteria instead. | |
| </p> | |
| <TermListEditor | |
| label="Exposure search terms" | |
| placeholder="e.g. metformin — press Enter or Add after each term" | |
| terms={exposureTerms} | |
| onChange={(terms) => onChange({ ...draft, intervention_terms: terms })} | |
| /> | |
| <TermListEditor | |
| label="Outcome search terms" | |
| placeholder="e.g. lactic acidosis — press Enter or Add after each term" | |
| terms={outcomeTerms} | |
| onChange={(terms) => onChange({ ...draft, outcome_terms: terms })} | |
| /> | |
| {sharedTerms.length > 0 && ( | |
| <div className="form-error"> | |
| These terms are in both lists: {sharedTerms.join(", ")}. A paper could match on | |
| that one word alone, so the search would return unrelated records. Keep each term | |
| in one list only. The protocol can't be saved until this is fixed. | |
| </div> | |
| )} | |
| {genericTerms.length > 0 && ( | |
| <div className="notice notice-warn"> | |
| Very broad words: {genericTerms.join(", ")}. Words like these appear in a large | |
| share of abstracts and can bring in unrelated records. Consider removing them, | |
| or put them in the inclusion criteria instead. | |
| </div> | |
| )} | |
| <div className="strategy-preview"> | |
| {preview.mode === "search_terms" ? ( | |
| <> | |
| Search: <code>{preview.text}</code> | |
| </> | |
| ) : ( | |
| <> | |
| No search terms yet — the search will use the free text{" "} | |
| <code>{preview.text || "…"}</code> without title/abstract | |
| restriction. Adding terms is recommended. | |
| </> | |
| )} | |
| </div> | |
| </div> | |
| ); | |
| } |