Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reductio tends to freeze app when summarizing long articles #8

Open
tetron432 opened this issue May 27, 2019 · 1 comment
Open

Reductio tends to freeze app when summarizing long articles #8

tetron432 opened this issue May 27, 2019 · 1 comment

Comments

@tetron432
Copy link

The library works fine unless its trying to summarize very long articles, such as this: https://www.popsci.com/can-ai-destroy-humanity?utm_source=pocket-newtab

@philip-iii
Copy link

I don't know if is still a concern, but I had some difficulties with some peculiar texts as well. I think I pinpointed it to this part

let score: Float = links.reduce(0.0) { $0 + nodes[$1] / outlinks[$1] * weights[$1, node] }

in iteration within TextRank, which in my case yielded NaN for some parts, I am guessing due to outlinks[$1] and/or weights[$1, node] being 0 (did not debug that deep yet).

My current workaround is to check for NaN and in case replace the score with 0, i.e.

    private func iteration(_ nodes: Node) -> Node {
        var vertex = Node()
        for (node, links) in graph {
            let score: Float = links.reduce(0.0) { $0 + nodes[$1] / outlinks[$1] * weights[$1, node] }
            if score.isNaN {
                vertex[node] = (1-damping/nodes.count) + damping * 0.0
            } else {
                vertex[node] = (1-damping/nodes.count) + damping * score
            }
        }
        return vertex
    }

It is not the most elegant solution but for the time being it seems to do the trick during some initial testing. If it proves to be working in other cases as well, I could submit a pull request. Perhaps it helps with the other related issues as well.

RayKitajima added a commit to RayKitajima/Reductio that referenced this issue Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants