<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.libraryweasel.stinkpot

import org.libraryweasel.stinkpot.ntriples.*

import java.lang.Object

public class Stinkpot {
    List<Triple> parseTriples(String text) {
        def triples = []
        parseTriples(text) { triples.add(it) }
        return triples
    }

    void parseTriples(String text, Closure<Triple> handler) {
        text.eachLine { line ->
            Iterator<Integer> it = text.chars().iterator()

            if (!it.hasNext()) return;

            Subject subject
            Predicate predicate
            Object object

            Character character = ignoreWhitespace(it)

            if (character == '<') {
                subject = readIRI(it)
            } else if (character == '#') {
                return
            } else if (character == '_' && it.hasNext() && it.next() == ':') {
                subject = readBlank(it)
            } else {
                throw new RuntimeException("Error parsing")
            }

            character = ignoreWhitespace(it)

            if (character == '<') {
                predicate = readIRI(it)
            } else {<commit_msg>fixed handling multiple IRI triples<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.libraryweasel.stinkpot

import org.libraryweasel.stinkpot.ntriples.*

import java.lang.Object

public class Stinkpot {
    List<Triple> parseTriples(String text) {
        def triples = []
        parseTriples(text) { triples.add(it) }
        return triples
    }

    void parseTriples(String text, Closure<Triple> handler) {
        text.eachLine { line ->
            Iterator<Integer> it = line.chars().iterator()

            if (!it.hasNext()) return;

            Subject subject
            Predicate predicate
            Object object

            Character character = ignoreWhitespace(it)

            if (character == '<') {
                subject = readIRI(it)
            } else if (character == '#') {
                return
            } else if (character == '_' && it.hasNext() && it.next() == ':') {
                subject = readBlank(it)
            } else {
                throw new RuntimeException("Error parsing")
            }

            character = ignoreWhitespace(it)

            if (character == '<') {
                predicate = readIRI(it)
            } else {
{'fraction_non_alphanumeric': 0.1084070796460177, 'fraction_numerical': 0.0029498525073746312, 'mean_word_length': 1.8289885297184567, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2011932', 'n_tokens_mistral': 769, 'n_tokens_neox': 726, 'n_words': 208}