Download src/utils/countWords.ts from webml-community/TranslateGemma-WebGPU: direct link, hf CLI and curl.
- Browser
- Download file 283 Bytes
-
https://huggingface.co/spaces/webml-community/TranslateGemma-WebGPU/resolve/main/src/utils/countWords.ts
- Command line
-
hf download hf://spaces/webml-community/TranslateGemma-WebGPU/src/utils/countWords.ts
-
curl -L -o countWords.ts https://huggingface.co/spaces/webml-community/TranslateGemma-WebGPU/resolve/main/src/utils/countWords.ts
283 Bytes
| export function countWords(text: string): number { | |
| if (!text || text.trim().length === 0) { | |
| return 0; | |
| } | |
| // Remove extra whitespace and split by whitespace | |
| const words = text | |
| .trim() | |
| .split(/\s+/) | |
| .filter((word) => word.length > 0); | |
| return words.length; | |
| } | |