<commit_before>/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Written (W) 1999-2008 <NAME>
 * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
 */

#include "lib/config.h"

#if defined(HAVE_OCTAVE) && !defined(HAVE_SWIG)
#include <stdio.h>
#include <string.h>

#include "lib/common.h"
#include "lib/io.h"

#include <octave/config.h>

#include <octave/defun-dld.h>
#include <octave/error.h>
#include <octave/oct-obj.h>
#include <octave/pager.h>
#include <octave/symtab.h>
#include <octave/variables.h>

#include "guilib/GUICommands.h"
#include "guilib/GUIOctave.h"
#include "gui/TextGUI.h"
#include "gui/GUI.h"

static CGUIOctave sg_octave;
extern CTextGUI* gui;

DEFUN_DLD (sg, prhs, nlhs, "shogun.")
{
	int nrhs = prhs.length();
	octave_value_list plhs;
	//int nlhs = plhs.length();

	CHAR* action = NULL;

	if (!gui)
		gui=new CTextGUI(0, NULL);

#ifndef WIN32
    CSignal::set_handler();
#endif

	ASSERT(gui);
	if (!nrhs)
		SG_SERROR( "No input arguments supplied.");
	else if (!prhs(0).is_string())
		SG_SERROR( "input should be string.");
	else
		action= CGUIOctave::get_octaveString(prhs(0).string_value());

	if (action)
	{
		if (!strncmp(action, N_SEND_COMMAND, strlen(N_SEND_COMMAND)))
		{
			if (nrhs==2)
			{
				CHAR* cmd=CGUIOctave::get_octaveString(prhs(1).string_value());
				sg_octave.send_command(cmd);
				delete[] cmd;
			}
			else
				SG_SERROR( "usage is sg('send_command', 'cmdline')");
		}
		else if (!strncmp(action, N_HELP, strlen(N_HELP)))
		{
			if (nrhs==1)
			{
				sg_octave.send_command("help");
			}<commit_msg>built shogun for all interfaces, fixed minor warning for octave<commit_after>/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Written (W) 1999-2008 <NAME>
 * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
 */

#include "lib/config.h"

#if defined(HAVE_OCTAVE) && !defined(HAVE_SWIG)
#include <stdio.h>
#include <string.h>

#include "lib/common.h"
#include "lib/io.h"

#include <octave/config.h>

#include <octave/defun-dld.h>
#include <octave/error.h>
#include <octave/oct-obj.h>
#include <octave/pager.h>
#include <octave/symtab.h>
#include <octave/variables.h>

#include "guilib/GUICommands.h"
#include "guilib/GUIOctave.h"
#include "gui/TextGUI.h"
#include "gui/GUI.h"

static CGUIOctave sg_octave;
extern CTextGUI* gui;

DEFUN_DLD (sg, prhs, nlhs, "shogun.")
{
	int nrhs = prhs.length();
	octave_value_list plhs;
	//int nlhs = plhs.length();

	CHAR* action = NULL;

	if (!gui)
		gui=new CTextGUI(0, NULL);

#ifndef WIN32
    CSignal::set_handler();
#endif

	ASSERT(gui);
	if (!nrhs)
		SG_SERROR( "No input arguments supplied.");
	else if (!prhs(0).is_string())
		SG_SERROR( "input should be string.");
	else
		action= CGUIOctave::get_octaveString(prhs(0).string_value());

	if (action)
	{
		if (!strncmp(action, N_SEND_COMMAND, strlen(N_SEND_COMMAND)))
		{
			if (nrhs==2)
			{
				CHAR* cmd=CGUIOctave::get_octaveString(prhs(1).string_value());
				sg_octave.send_command(cmd);
				delete[] cmd;
			}
			else
				SG_SERROR( "usage is sg('send_command', 'cmdline')");
		}
		else if (!strncmp(action, N_HELP, strlen(N_HELP)))
		{
			if (nrhs==1)
			{
				sg_octave.send_command((CHAR*) "help");
			}
{'fraction_non_alphanumeric': 0.15121412803532008, 'fraction_numerical': 0.01379690949227373, 'mean_word_length': 4.3545051698670605, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '2085308', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1425, 'n_words': 342}