<commit_before>#!/usr/bin/python3
# -*- coding: utf-8 -*-

from __future__ import print_function  # , unicode_literals

import argparse
import contextlib
import cStringIO
import datetime
import inspect
import os
import re
import subprocess
import sys
import thread
import time
import uuid
from multiprocessing import Event, Process
from os.path import expanduser
from random import choice

import requests.exceptions

import pyowm
import wikipedia
import wikipedia.exceptions
import youtube_dl
from dragonfire.learn import Learn
from dragonfire.nlplib import Classifiers
from dragonfire.omniscient import Engine
from dragonfire.stray import SystemTrayExitListenerSet, SystemTrayInit
from dragonfire.utilities import TTA
from pykeyboard import PyKeyboard
from pymouse import PyMouse
from tinydb import Query, TinyDB


DRAGONFIRE_PATH = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
FNULL = open(os.devnull, 'w')
GENDER_PREFIX = {'male': 'Sir', 'female': 'My Lady'}
CONVERSATION_ID = uuid.uuid4()
userin = None
learn_ = Learn()
omniscient_ = Engine()
e = Event()

USER_ANSWERING = {'status': False, 'for': None, 'reason': None, 'options': None}

try:
	raw_input          # Python 2
except NameError:
	raw_input = input  # Python 3


def start(args):

	global e

	if (e.is_set()): # System Tray Icon exit must trigger this
		raise KeyboardInterrupt

	if args["cli"]:
		while(True):
			com = raw_input("Enter your command: ")
			thread.start_new_thread(VirtualAssistant.command, (com, args))
			time.sleep(0.5)
	else:
		os.environ["GST_PLUGIN_PATH"] = "/usr/share/kaldi/src/gst-plugin"
		from dragonfire.sr import KaldiRecognizer
		recognizer = KaldiRecognizer()
		recognizer.recognize(args)


class VirtualAssistant():
	@staticmethod
	def exact_match(com):  # if key == com: ...
		if com == "WHO AM I":
			com = "SAY MY NAME"
		app_info = {
			"OPEN BLENDER": (["blender"], "Blender", "Blender 3D computer graphics software"),
			"OPEN DRAW": (["libreoffice", "--draw"], "LibreOffice Draw", "Draw"),
			"OPEN IMPRESS": (["libreoffice", "--impress"], "LibreOffice Impress", "Impress"),
			"OPEN MATH": (["libreoffice", "--math"], "LibreOffice Math", "Math"),
			"OPEN STREAM": (["steam"], "Steam", "Steam Game Store"),
			"OPEN WRITER": (["libreoffice", "--writer"], "LibreOffice Writer", "Writer"),
			"SAY MY NAME": ([" "], user_full_name, "Your name is " + user_full_name + ", " + user_prefix + "."),
			"WHAT IS YOUR GENDER": ([" "], " ", "I have a female voice but I don't have a gender identity. I'm a computer program, " + user_prefix + "."),
			"WHAT IS YOUR NAME": ([" "], "My name is Dragonfire.", "My name is Dragonfire."),
		}.get(com)
		if app_info:
			tts_kill()
			commands, message, say_text = app_info
			userin.define_and_execute(commands, message)
			userin.say()
		return bool(app_info)

	@staticmethod
	def in_match(com):  # if key in com: ...
		if "PHOTO SHOP" in com or "PHOTO EDITOR" in com:
			com = "GIMP"
		elif "VECTOR GRAPHICS" in com or "VECTORIAL DRAWING" in com:
			com = "INKSCAPE"
		apps = {
			"GIMP": (["gimp"], "GIMP", "Photo editor"),
			"INKSCAPE": (["inkscape"], "Inkscape", "Inkscape"),
			"OFFICE SUITE": (["libreoffice"], "LibreOffice", "Office Suite"),
			"VIDEO EDITOR": (["kdenlive"], "Kdenlive", "Video editor"),
			"WEB BROWSER": (["sensible-browser"], "Web Browser", "Web Browser")
		}
		for app_name, app_info in apps:
			if app_name in com:<commit_msg>for app_name, app_info in apps.items():<commit_after>#!/usr/bin/python3
# -*- coding: utf-8 -*-

from __future__ import print_function  # , unicode_literals

import argparse
import contextlib
import cStringIO
import datetime
import inspect
import os
import re
import subprocess
import sys
import thread
import time
import uuid
from multiprocessing import Event, Process
from os.path import expanduser
from random import choice

import requests.exceptions

import pyowm
import wikipedia
import wikipedia.exceptions
import youtube_dl
from dragonfire.learn import Learn
from dragonfire.nlplib import Classifiers
from dragonfire.omniscient import Engine
from dragonfire.stray import SystemTrayExitListenerSet, SystemTrayInit
from dragonfire.utilities import TTA
from pykeyboard import PyKeyboard
from pymouse import PyMouse
from tinydb import Query, TinyDB


DRAGONFIRE_PATH = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
FNULL = open(os.devnull, 'w')
GENDER_PREFIX = {'male': 'Sir', 'female': 'My Lady'}
CONVERSATION_ID = uuid.uuid4()
userin = None
learn_ = Learn()
omniscient_ = Engine()
e = Event()

USER_ANSWERING = {'status': False, 'for': None, 'reason': None, 'options': None}

try:
	raw_input          # Python 2
except NameError:
	raw_input = input  # Python 3


def start(args):

	global e

	if (e.is_set()): # System Tray Icon exit must trigger this
		raise KeyboardInterrupt

	if args["cli"]:
		while(True):
			com = raw_input("Enter your command: ")
			thread.start_new_thread(VirtualAssistant.command, (com, args))
			time.sleep(0.5)
	else:
		os.environ["GST_PLUGIN_PATH"] = "/usr/share/kaldi/src/gst-plugin"
		from dragonfire.sr import KaldiRecognizer
		recognizer = KaldiRecognizer()
		recognizer.recognize(args)


class VirtualAssistant():
	@staticmethod
	def exact_match(com):  # if key == com: ...
		if com == "WHO AM I":
			com = "SAY MY NAME"
		app_info = {
			"OPEN BLENDER": (["blender"], "Blender", "Blender 3D computer graphics software"),
			"OPEN DRAW": (["libreoffice", "--draw"], "LibreOffice Draw", "Draw"),
			"OPEN IMPRESS": (["libreoffice", "--impress"], "LibreOffice Impress", "Impress"),
			"OPEN MATH": (["libreoffice", "--math"], "LibreOffice Math", "Math"),
			"OPEN STREAM": (["steam"], "Steam", "Steam Game Store"),
			"OPEN WRITER": (["libreoffice", "--writer"], "LibreOffice Writer", "Writer"),
			"SAY MY NAME": ([" "], user_full_name, "Your name is " + user_full_name + ", " + user_prefix + "."),
			"WHAT IS YOUR GENDER": ([" "], " ", "I have a female voice but I don't have a gender identity. I'm a computer program, " + user_prefix + "."),
			"WHAT IS YOUR NAME": ([" "], "My name is Dragonfire.", "My name is Dragonfire."),
		}.get(com)
		if app_info:
			tts_kill()
			commands, message, say_text = app_info
			userin.define_and_execute(commands, message)
			userin.say()
		return bool(app_info)

	@staticmethod
	def in_match(com):  # if key in com: ...
		if "PHOTO SHOP" in com or "PHOTO EDITOR" in com:
			com = "GIMP"
		elif "VECTOR GRAPHICS" in com or "VECTORIAL DRAWING" in com:
			com = "INKSCAPE"
		apps = {
			"GIMP": (["gimp"], "GIMP", "Photo editor"),
			"INKSCAPE": (["inkscape"], "Inkscape", "Inkscape"),
			"OFFICE SUITE": (["libreoffice"], "LibreOffice", "Office Suite"),
			"VIDEO EDITOR": (["kdenlive"], "Kdenlive", "Video editor"),
			"WEB BROWSER": (["sensible-browser"], "Web Browser", "Web Browser")
		}
		for app_name, app_info in apps.items():
			if app_name in com:
{'fraction_non_alphanumeric': 0.14576074332171893, 'fraction_numerical': 0.0023228803716608595, 'mean_word_length': 4.578137651821862, 'pattern_counts': {'":': 30, '<': 3, '<?xml version=': 0, '>': 3, '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': '5863173', 'n_tokens_mistral': 2573, 'n_tokens_neox': 2346, 'n_words': 705}