<commit_before>#include "plugin.h"

#include <sstream>

using namespace Vipster;

auto IdentifyColumns(std::string& line)
{
    std::stringstream ss{line};
    std::string tok;
    //throw away "ITEM: ATOMS"
    ss >> tok >> tok;
    enum coordstate{none=0, unscaled=1, scaled=2, unwrapped=4};
    coordstate cs{};
    auto xparser = [](std::stringstream& ss, Atom& at) {ss >> at.coord[0];};
    auto yparser = [](std::stringstream& ss, Atom& at) {ss >> at.coord[1];};
    auto zparser = [](std::stringstream& ss, Atom& at) {ss >> at.coord[2];};
    auto nparser = [](std::stringstream& ss, Atom& at) {ss >> at.name;};
    auto qparser = [](std::stringstream& ss, Atom& at) {ss >> at.properties->charge;};
    auto dparser = [](std::stringstream& ss, Atom&) {static std::string dummy{}; ss >> dummy;};
    std::vector<void(*)(std::stringstream&, Atom&)> funvec{};
    while ( !(ss >> tok).fail() ) {
        if (tok[0] == 'x' || tok[0] == 'y' || tok[0] == 'z') {
            if ((tok.length() == 1) || (tok[1] != 's')) {
                cs = static_cast<coordstate>(cs | unscaled);
            } else if (tok[1] == 's') {
                cs = static_cast<coordstate>(cs | scaled);
            }
            if (((tok.length() == 2) && (tok[1] == 'u')) || (tok.length() == 3)) {
                cs = static_cast<coordstate>(cs | unwrapped);
            }
            if(tok[0] == 'x') {
                funvec.push_back(xparser);
            } else if(tok[0] == 'y') {
                funvec.push_back(yparser);
            } else if(tok[0] == 'z') {
                funvec.push_back(zparser);
            }
        } else if (tok == "q") {
            funvec.push_back(qparser);
        } else if (tok == "element") {
            funvec.push_back(nparser);
        } else {
            funvec.push_back(dparser);
        }
    }
    switch (static_cast<size_t>(cs)) {
    case unscaled:
        [[fallthrough]];
    case scaled:
        return [=](std::ifstream &file, Step& s){
            if(cs == scaled) {
                s.modScale(AtomFmt::Crystal);
            } else {
                s.modScale(AtomFmt::Angstrom);
            }
            std::string line;
            for (auto& at:s) {<commit_msg>fix unwrapped lammps trajectory parsing<commit_after>#include "plugin.h"

#include <sstream>

using namespace Vipster;

auto IdentifyColumns(std::string& line)
{
    std::stringstream ss{line};
    std::string tok;
    //throw away "ITEM: ATOMS"
    ss >> tok >> tok;
    enum coordstate{none=0, unscaled=1, scaled=2};
    coordstate cs{};
    auto xparser = [](std::stringstream& ss, Atom& at) {ss >> at.coord[0];};
    auto yparser = [](std::stringstream& ss, Atom& at) {ss >> at.coord[1];};
    auto zparser = [](std::stringstream& ss, Atom& at) {ss >> at.coord[2];};
    auto nparser = [](std::stringstream& ss, Atom& at) {ss >> at.name;};
    auto qparser = [](std::stringstream& ss, Atom& at) {ss >> at.properties->charge;};
    auto dparser = [](std::stringstream& ss, Atom&) {static std::string dummy{}; ss >> dummy;};
    std::vector<void(*)(std::stringstream&, Atom&)> funvec{};
    while ( !(ss >> tok).fail() ) {
        if (tok[0] == 'x' || tok[0] == 'y' || tok[0] == 'z') {
            if ((tok.length() == 1) || (tok[1] != 's')) {
                cs = static_cast<coordstate>(cs | unscaled);
            } else if (tok[1] == 's') {
                cs = static_cast<coordstate>(cs | scaled);
            }
            if(tok[0] == 'x') {
                funvec.push_back(xparser);
            } else if(tok[0] == 'y') {
                funvec.push_back(yparser);
            } else if(tok[0] == 'z') {
                funvec.push_back(zparser);
            }
        } else if (tok == "q") {
            funvec.push_back(qparser);
        } else if (tok == "element") {
            funvec.push_back(nparser);
        } else {
            funvec.push_back(dparser);
        }
    }
    switch (static_cast<size_t>(cs)) {
    case unscaled:
        [[fallthrough]];
    case scaled:
        return [=](std::ifstream &file, Step& s){
            if(cs == scaled) {
                s.modScale(AtomFmt::Crystal);
            } else {
                s.modScale(AtomFmt::Angstrom);
            }
            std::string line;
            for (auto& at:s) {
{'fraction_non_alphanumeric': 0.18975198876930277, 'fraction_numerical': 0.007955077211043519, 'mean_word_length': 2.109090909090909, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 52, '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': '4804177', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1452, 'n_words': 315}