<commit_before>/*
Copyright 2005 <NAME>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package org.gavrog.apps.systre;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;

import org.gavrog.box.collections.Iterators;
import org.gavrog.box.collections.Pair;
import org.gavrog.box.simple.DataFormatException;
import org.gavrog.box.simple.Misc;
import org.gavrog.box.simple.Strings;
import org.gavrog.jane.numbers.FloatingPoint;
import org.gavrog.jane.numbers.IArithmetic;
import org.gavrog.jane.numbers.Real;
import org.gavrog.jane.numbers.Whole;
import org.gavrog.joss.geometry.CoordinateChange;
import org.gavrog.joss.geometry.Operator;
import org.gavrog.joss.geometry.Point;
import org.gavrog.joss.geometry.SpaceGroup;
import org.gavrog.joss.geometry.SpaceGroupCatalogue;
import org.gavrog.joss.geometry.SpaceGroupFinder;
import org.gavrog.joss.geometry.Vector;
import org.gavrog.joss.pgraphs.basic.INode;
import org.gavrog.joss.pgraphs.basic.Morphism;
import org.gavrog.joss.pgraphs.basic.PeriodicGraph;
import org.gavrog.joss.pgraphs.embed.Embedder;
import org.gavrog.joss.pgraphs.embed.ProcessedNet;
import org.gavrog.joss.pgraphs.io.Archive;
import org.gavrog.joss.pgraphs.io.Net;
import org.gavrog.joss.pgraphs.io.NetParser;

import buoy.event.EventSource;

/**
 * The basic commandlne version of Gavrog Systre.
 * 
 * @author <NAME>
 * @version $Id: SystreCmdline.java,v 1.1 2007/05/12 01:32:27 odf Exp $
 */
public class SystreCmdline extends EventSource {
    final static boolean DEBUG = false;
    
    static {
        Locale.setDefault(Locale.US);
    }
    private final static DecimalFormat fmtReal4 = new DecimalFormat("0.0000");

    // --- the last structure processed
    ProcessedNet lastStructure = null;
    
    // --- the output stream
    private PrintStream out = System.out;
    
    // --- the various archives
    private final Archive builtinArchive;
    private final Map name2archive = new HashMap();
    private final Archive internalArchive = new Archive("1.0");
    
    // --- options
    private boolean relaxPositions = true;
    private int relaxPasses = 3;
    private int relaxSteps = 10000;
    private boolean useBuiltinArchive = true;
    private boolean outputFullCell = false;
    private boolean duplicateIsError = false;
    private BufferedWriter outputArchive = null;
    
    // --- the last file that was opened for processing
    private String lastFileNameWithoutExtension;
    
    // --- signals a cancel request from outside
    private boolean cancelled = false;

    // --- text of the last status reported
	private String lastStatus;
    
    /**
     * Constructs an instance.
     */
    public SystreCmdline() {
        builtinArchive = new Archive("1.0");

        // --- read the default archives
        final Package pkg = Archive.class.getPackage();
        final String packagePath = pkg.getName().replaceAll("\\.", "/");
        
        final String rcsrPath = packagePath + "/rcsr.arc";
        final InputStream rcsrStream = ClassLoader.getSystemResourceAsStream(rcsrPath);
        builtinArchive.addAll(new InputStreamReader(rcsrStream));
        final String zeoPath = packagePath + "/zeolites.arc";
        final InputStream zeoStream = ClassLoader.getSystemResourceAsStream(zeoPath);
        builtinArchive.addAll(new InputStreamReader(zeoStream));
    }
    
    /**
    /**
     * Reads an archive file and stores it internally.
     * 
     * @param filename the name of the archive file.
     */
    public void processArchive(final String filename) {<commit_msg>Fixed location of builtin .arc files.<commit_after>/*
Copyright 2005 <NAME>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package org.gavrog.apps.systre;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;

import org.gavrog.box.collections.Iterators;
import org.gavrog.box.collections.Pair;
import org.gavrog.box.simple.DataFormatException;
import org.gavrog.box.simple.Misc;
import org.gavrog.box.simple.Strings;
import org.gavrog.jane.numbers.FloatingPoint;
import org.gavrog.jane.numbers.IArithmetic;
import org.gavrog.jane.numbers.Real;
import org.gavrog.jane.numbers.Whole;
import org.gavrog.joss.geometry.CoordinateChange;
import org.gavrog.joss.geometry.Operator;
import org.gavrog.joss.geometry.Point;
import org.gavrog.joss.geometry.SpaceGroup;
import org.gavrog.joss.geometry.SpaceGroupCatalogue;
import org.gavrog.joss.geometry.SpaceGroupFinder;
import org.gavrog.joss.geometry.Vector;
import org.gavrog.joss.pgraphs.basic.INode;
import org.gavrog.joss.pgraphs.basic.Morphism;
import org.gavrog.joss.pgraphs.basic.PeriodicGraph;
import org.gavrog.joss.pgraphs.embed.Embedder;
import org.gavrog.joss.pgraphs.embed.ProcessedNet;
import org.gavrog.joss.pgraphs.io.Archive;
import org.gavrog.joss.pgraphs.io.Net;
import org.gavrog.joss.pgraphs.io.NetParser;

import buoy.event.EventSource;

/**
 * The basic commandlne version of Gavrog Systre.
 * 
 * @author <NAME>
 * @version $Id: SystreCmdline.java,v 1.2 2007/05/12 01:45:12 odf Exp $
 */
public class SystreCmdline extends EventSource {
    final static boolean DEBUG = false;
    
    static {
        Locale.setDefault(Locale.US);
    }
    private final static DecimalFormat fmtReal4 = new DecimalFormat("0.0000");

    // --- the last structure processed
    ProcessedNet lastStructure = null;
    
    // --- the output stream
    private PrintStream out = System.out;
    
    // --- the various archives
    private final Archive builtinArchive;
    private final Map name2archive = new HashMap();
    private final Archive internalArchive = new Archive("1.0");
    
    // --- options
    private boolean relaxPositions = true;
    private int relaxPasses = 3;
    private int relaxSteps = 10000;
    private boolean useBuiltinArchive = true;
    private boolean outputFullCell = false;
    private boolean duplicateIsError = false;
    private BufferedWriter outputArchive = null;
    
    // --- the last file that was opened for processing
    private String lastFileNameWithoutExtension;
    
    // --- signals a cancel request from outside
    private boolean cancelled = false;

    // --- text of the last status reported
	private String lastStatus;
    
    /**
     * Constructs an instance.
     */
    public SystreCmdline() {
        builtinArchive = new Archive("1.0");

        // --- read the default archives
        final Package pkg = this.getClass().getPackage();
        final String packagePath = pkg.getName().replaceAll("\\.", "/");
        
        final String rcsrPath = packagePath + "/rcsr.arc";
        final InputStream rcsrStream = ClassLoader.getSystemResourceAsStream(rcsrPath);
        builtinArchive.addAll(new InputStreamReader(rcsrStream));
        final String zeoPath = packagePath + "/zeolites.arc";
        final InputStream zeoStream = ClassLoader.getSystemResourceAsStream(zeoPath);
        builtinArchive.addAll(new InputStreamReader(zeoStream));
    }
    
    /**
    /**
     * Reads an archive file and stores it internally.
     * 
     * @param filename the name of the archive file.
     */
    public void processArchive(final String filename) {
{'fraction_non_alphanumeric': 0.09687162891046386, 'fraction_numerical': 0.008845738942826321, 'mean_word_length': 3.6494483450351054, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6193239', 'n_tokens_mistral': 2895, 'n_tokens_neox': 2764, 'n_words': 747}