{"id":21770291,"url":"https://github.com/flight-school/sentiment","last_synced_at":"2025-07-19T07:30:40.043Z","repository":{"id":95269111,"uuid":"223591675","full_name":"Flight-School/sentiment","owner":"Flight-School","description":"A command-line utility that evaluates the emotional sentiment of natural language text.","archived":false,"fork":false,"pushed_at":"2019-11-23T13:35:36.000Z","size":4,"stargazers_count":68,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-10T14:19:20.359Z","etag":null,"topics":["macos","nlp","polarity","sentiment-analysis","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Flight-School.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-11-23T13:20:11.000Z","updated_at":"2022-07-01T07:59:13.000Z","dependencies_parsed_at":"2023-03-06T04:45:17.244Z","dependency_job_id":null,"html_url":"https://github.com/Flight-School/sentiment","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/Flight-School%2Fsentiment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flight-School%2Fsentiment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flight-School%2Fsentiment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flight-School%2Fsentiment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flight-School","download_url":"https://codeload.github.com/Flight-School/sentiment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226555707,"owners_count":17650731,"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":["macos","nlp","polarity","sentiment-analysis","swift"],"created_at":"2024-11-26T14:12:03.257Z","updated_at":"2024-11-26T14:12:04.095Z","avatar_url":"https://github.com/Flight-School.png","language":"Swift","readme":"# sentiment\n\n`sentiment` is a command-line utility that\nevaluates the emotional sentiment of natural language text.\n\n```terminal\n$ echo \"With a comfortable fit, great sound, and awesome noise canceling, these are the best AirPods ever.\" | sentiment\n1.0\n\n$ echo \"No wireless, less space than a Nomad. Lame.\" | sentiment\n-0.8\n```\n\n---\n\nFor more information about natural language processing,\ncheck out Chapter 7 of the\n[Flight School Guide to Swift Strings](https://flight.school/books/strings).\n\n---\n\n## Requirements\n\n- macOS 10.15+\n\n## Installation\n\nInstall `sentiment` with [Homebrew](https://brew.sh) using the following command:\n\n```terminal\n$ brew install flight-school/formulae/sentiment\n```\n\n## Usage\n\nText can be read from either standard input or file arguments,\nand named entities are written to standard output on separate lines.\n\n### Reading from Piped Standard Input\n\n```terminal\n$ echo \"It was a good day.\" | sentiment\n0.4\n\n```\n\n### Reading from Standard Input Interactively\n\n```terminal\n$ sentiment\nGreat!\n1.0\n```\n\n### Reading from a File\n\n```terminal\n$ head -n 1 anna_karenina.txt\nHappy families are all alike; every unhappy family is unhappy in its own way.\n\n$ sentiment anna_karenina.txt\n-0.400151\n\n```\n\n\u003e **Note**: `sentiment` can take a long time for large documents.\n\n```terminal\n$ time sentiment anna-karenina.txt\n-0.400151\n       33.44 real        61.84 user         4.62 sys\n\n```\n\n## Advanced Usage\n\n`sentiment` can be used with `ls`, `find` and other Unix commands\nto analyze the sentiment of multiple files at once.\n\n### Performing Sentiment Analysis for Multiple Files\n\n```terminal\n$ find . -iname '*.txt' -exec \\\n    sh -c 'printf \"%s\\t%s\\n\" {} $(sentiment {})' \\;\n./positive.txt\t1.0\n./somewhat-negative.txt\t-0.5\n./neutral.txt\t0.0\n\n```\n\n## Additional Details\n\nIf the command is able to determine an emotional sentiment for the provided text,\nit writes a number between `-1.0` (negative) and `1.0` (positive)\nto standard output (`0.0` indicates neutral or unknown sentiment).\nThe resulting number has an unlocalized format\nconsisting of an optional leading minus sign `-` (U+002D HYPHEN-MINUS)\nfollowed by a decimal point `.` (U+002E FULL STOP)\nand between one and six decimal digits `0` – `9` (U+0030 – U+0039):\n\n```regexp\n^-?[01]\\.\\d{1,6}$\n```\n\n`sentiment` uses\n[`NLTagger`](https://developer.apple.com/documentation/naturallanguage/nltagger)\nwith the\n[`sentimentScore`](https://developer.apple.com/documentation/naturallanguage/nltagscheme/3113856-sentimentscore)\ntag scheme.\nThe overall sentiment of a text input is calculated from\nthe average sentiment of each paragraph.\n\n## License\n\nMIT\n\n## Contact\n\nMattt ([@mattt](https://twitter.com/mattt))\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflight-school%2Fsentiment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflight-school%2Fsentiment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflight-school%2Fsentiment/lists"}