{"id":15412841,"url":"https://github.com/aralroca/react-text-toxicity","last_synced_at":"2025-04-19T03:20:26.721Z","repository":{"id":42862375,"uuid":"259599365","full_name":"aralroca/react-text-toxicity","owner":"aralroca","description":"Detect text toxicity in a simple way, using React. Based in a Keras model, loaded with Tensorflow.js.","archived":false,"fork":false,"pushed_at":"2023-01-06T04:32:05.000Z","size":1922,"stargazers_count":44,"open_issues_count":13,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T06:43:20.847Z","etag":null,"topics":["javascript","machine-learning","preact","react","tensorflow","text","toxicity"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aralroca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-28T10:04:17.000Z","updated_at":"2024-08-05T09:40:48.000Z","dependencies_parsed_at":"2023-02-05T08:00:59.842Z","dependency_job_id":null,"html_url":"https://github.com/aralroca/react-text-toxicity","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aralroca%2Freact-text-toxicity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aralroca%2Freact-text-toxicity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aralroca%2Freact-text-toxicity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aralroca%2Freact-text-toxicity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aralroca","download_url":"https://codeload.github.com/aralroca/react-text-toxicity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249598452,"owners_count":21297464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","machine-learning","preact","react","tensorflow","text","toxicity"],"created_at":"2024-10-01T16:54:34.305Z","updated_at":"2025-04-19T03:20:26.693Z","avatar_url":"https://github.com/aralroca.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## React Text Toxicity\n\nDetect toxicity in text using React.\n\nIt's based on this model: https://github.com/tensorflow/tfjs-models/tree/master/toxicity\n\n## Getting started\n\n```\nyarn add react-text-toxicity\n```\n\nImport as:\n\n```js\nimport useTextToxicity from \"react-text-toxicity\";\n```\n\nUse it as:\n\n```js\nconst predictions = useTextToxicity('text', { threshold, delay });\n```\n\n* **text** - Text to predict\n* **options**\n  * **threshold** Prediction threshold *(0.9 as default)*\n  * **delay** Delay in milliseconds applied to debounce multiple changes *(300ms as default)*\n\n\n## Example\n\n![example](./example/toxicity.gif)\n\n```jsx\nimport React, { Fragment, useState } from \"react\";\nimport useTextToxicity from \"react-text-toxicity\";\n\nfunction Toxicity({ predictions }) {\n  const style = { margin: 10 };\n\n  if (!predictions) return \u003cdiv style={style}\u003eLoading predictions...\u003c/div\u003e;\n\n  return (\n    \u003cdiv style={style}\u003e\n      {predictions.map(({ label, match, probability }) =\u003e (\n        \u003cdiv style={{ margin: 5 }} key={label}\u003e\n          {`${label} - ${probability} - ${match ? \"🤢\" : \"🥰\"}`}\n        \u003c/div\u003e\n      ))}\n    \u003c/div\u003e\n  );\n}\n\nexport default function Index() {\n  const [value, setValue] = useState(\"\");\n  const predictions = useTextToxicity(value);\n\n  return (\n    \u003cdiv style={{ display: \"flex\" }}\u003e\n      \u003cdiv\u003e\n        \u003cdiv\u003eWrite something\u003c/div\u003e\n        \u003ctextarea\n          style={{ width: 300, height: 200 }}\n          value={value}\n          onChange={(e) =\u003e setValue(e.target.value)}\n        /\u003e\n      \u003c/div\u003e\n      {value \u0026\u0026 \u003cToxicity predictions={predictions} /\u003e}\n    \u003c/div\u003e\n  );\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faralroca%2Freact-text-toxicity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faralroca%2Freact-text-toxicity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faralroca%2Freact-text-toxicity/lists"}