https://github.com/stefkors/swiftsummarize
Create a summary from any string or text
https://github.com/stefkors/swiftsummarize
abstract summarizer summary swift swiftui
Last synced: 10 months ago
JSON representation
Create a summary from any string or text
- Host: GitHub
- URL: https://github.com/stefkors/swiftsummarize
- Owner: StefKors
- License: mit
- Created: 2023-10-18T13:27:57.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-27T10:29:04.000Z (over 2 years ago)
- Last Synced: 2025-08-30T22:02:23.752Z (10 months ago)
- Topics: abstract, summarizer, summary, swift, swiftui
- Language: Swift
- Homepage:
- Size: 276 KB
- Stars: 28
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# SwiftSummarize
SwiftSummarize is the easiest way to create a summary from a String. Internally it's a simple wrapper around CoreServices [SKSummary](https://developer.apple.com/documentation/coreservices/1446229-sksummarycreatewithstring)
**Before**
> Here's to the crazy ones. The misfits. The rebels. The troublemakers. The round pegs in the square holes. The ones who see things differently. They're not fond of rules. And they have no respect for the status quo. You can quote them, disagree with them, glorify or vilify them. About the only thing you can't do is ignore them. Because they change things. They push the human race forward. And while some may see them as the crazy ones, we see genius. Because the people who are crazy enough to think they can change the world, are the ones who do.
**After**
> Because the people who are crazy enough to think they can change the world, are the ones who do
## Install
Add this url to your dependencies:
```
https://github.com/StefKors/SwiftSummarize
```
## Example
```Swift
let input = """
Here's to the crazy ones. The misfits. The rebels. The troublemakers. The
round pegs in the square holes. The ones who see things differently. They're not
fond of rules. And they have no respect for the status quo. You can quote them,
disagree with them, glorify or vilify them. About the only thing you can't do is ignore
them. Because they change things. They push the human race forward. And while some
may see them as the crazy ones, we see genius. Because the people who are crazy
enough to think they can change the world, are the ones who do.
"""
let summary = Summary(text, numberOfSentences: 1)
print(summary.output)
// Because the people who are crazy enough to think they can change the world, are the ones who do
```
Or use it directly on Strings with the extension
```Swift
let input = """
Here's to the crazy ones. The misfits. The rebels. The troublemakers. The
round pegs in the square holes. The ones who see things differently. They're not
fond of rules. And they have no respect for the status quo. You can quote them,
disagree with them, glorify or vilify them. About the only thing you can't do is ignore
them. Because they change things. They push the human race forward. And while some
may see them as the crazy ones, we see genius. Because the people who are crazy
enough to think they can change the world, are the ones who do.
"""
let output = input.summarize(numberOfSentences: 1)
print(output)
// Because the people who are crazy enough to think they can change the world, are the ones who do
```
A full SwiftUI code example can be found at [/Example/ExampleSwiftUI.swift](https://github.com/StefKors/SwiftSummarize/blob/main/Example/ExampleSwiftUI.swift)
