code lacks documentation, but this sample code may reflect developer's intent
Opened this issue · 0 comments
I didn't find a comment or document with sample code illustrating how to run the project. However, of the three TextRank projects written in Swift on Github I've tried, this was the first I got running. To experiment with extractive text summarization this project could be a good starting point.
Summary.build() returns a [String] array. Those testing the project might consider modifying Summary.build(), which calls TextRank.build(), so that it returns an array of structs, with each struct containing the String and the floating point value for the score.
The code ran for me when I tried this:
//sample: Litany Against Fear from Dune by Frank Herbert
let text =
"""
I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its path.
Where the fear has gone there will be nothing. Only I will remain.
"""
let summary = Summary(text)
let build = summary.build()
for item in build
{
print(item)
}
Output:
Where the fear has gone there will be nothing.
Fear is the mind-killer.Only I will remain.
I will permit it to pass over me and through me.Fear is the little-death that brings total obliteration.
I will face my fear.
And when it has gone past, I will turn the inner eye to see its path.
I must not fear.
For a longer text try the input from a page such as this:
https://medium.com/analytics-vidhya/text-summarization-in-python-using-extractive-method-including-end-to-end-implementation-2688b3fd1c8c
However, processing longer texts might take minutes to run in an Xcode Playground.