Did I find the right examples for you? yes no

All Samples(76)  |  Call(69)  |  Derive(0)  |  Import(7)

        def colored_print(text, fg_colour=None, bg_colour=None):
    try:
        if len(text) == 0:
            return ''
        if isinstance(text, (str, unicode)):
            pass
        elif len(text) == 1:
            text = text[0]
        else:
            text = "[" + ", ".join(text) + "]"
    except TypeError:
        pass

    if not fg_colour and not bg_colour:
        return text
    if not fg_colour:
        return format_colour('$BG-' + bg_colour.upper() + text + "$RESET", True)
    if not bg_colour:
        return format_colour('$' + fg_colour.upper() + text + "$RESET", True)

    return format_colour('$BG-' + bg_colour.upper() + '$' + fg_colour.upper() + text + "$RESET", True)
        


src/d/i/Dialogs-0.13/src/dialogs/interpretation/resolution.py   Dialogs(Download)
from kb import KbError
 
from dialogs.helpers.helpers import colored_print
 
from dialogs.dialog_exceptions import *
                                                                                                        uae_object_list)
 
        logger.info(colored_print("-> Resolving references and anaphors...", 'green'))
        #Record of current sentence
        self._current_sentence = sentence
            onto_focus = ''
            logger.debug(
                colored_print("Found a demonstrative (this/that...). Trying to resolve it based on current focus...",
                              "magenta"))
 
            if nominal_group.noun and nominal_group.noun[
                0].lower() != 'one': # case "this + category" -> eg "this phone"
                class_name = self._get_class_name_from_ontology(current_speaker, nominal_group)
                logger.debug(colored_print("Looking for : ", "magenta") + colored_print(
                    current_speaker + ' pointsAt ?concept, ?concept rdf:type ' + class_name, None, "magenta"))

src/d/i/Dialogs-0.13/src/dialogs/dialog_core.py   Dialogs(Download)
from kb import KbError
from dialogs.sentence import *
from dialogs.helpers.helpers import colored_print, wait_for_keypress
from dialogs.helpers import emotions
from dialogs.interpretation.anaphora_matching import replacement
                input = self._nl_input_queue.get(True, 0.1).strip()
                ResourcePool().mark_active(self._speaker)
                self._logger.info(colored_print("\n-------[       NL INPUT      ]-------\n", 'green'))
                self._logger.info(colored_print("- " + input + "\n", 'blue'))
                self.in_interaction = True
 
                try:
                    self._process(input)
                except UnsufficientInputError as uie:
                    self._logger.info(colored_print("Not enough informations! Going back to human:", 'magenta'))
                    sys.stdout.write(self._verbalizer.verbalize(uie.value['question']) + "\n")
                    sys.stdout.flush()
                    self._logger.info(colored_print("- " +
                                                    self._verbalizer.verbalize(uie.value['question']),
                                                    'blue') + "\n")

src/d/i/Dialogs-0.13/src/dialogs/interpretation/questions_handler.py   Dialogs(Download)
logger = logging.getLogger("dialogs")
 
from dialogs.helpers.helpers import colored_print
from dialogs.helpers.printers import level_marker
 
        logger.info(level_marker(level=2,
                                 color="yellow") + "Generated statements based on the sentence components: " + colored_print(
            str(self._statements), None, "magenta"))
 
        #Case the question is a y_n_question : check the fact in the ontology
        if sentence.data_type == YES_NO_QUESTION:
            self._statements = self._set_situation_id(self._statements)
            logger.info(
                level_marker(level=2, color="yellow") + "Generated statements for this question: " + colored_print(
                    str(self._statements), None, "magenta"))
                try:
                    logger.debug(level_marker(level=2, color="yellow") + "Checking in the ontology: " + colored_print(
                        str(self._statements), None, "magenta"))
                    self._answer = ResourcePool().ontology_server.check(self._statements)
                except AttributeError: #the ontology server is not started of doesn't know the method
                    logger.info(level_marker(level=2,
                                             color="yellow") + "Generated statements for this question: " + colored_print(
                        str(self._statements), None, "magenta"))
 
                    answers = []

src/d/i/Dialogs-0.13/src/dialogs/interpretation/content_analysis.py   Dialogs(Download)
logger = logging.getLogger("dialogs")
 
from dialogs.helpers.helpers import colored_print
from dialogs.helpers.printers import level_marker
from dialogs.helpers import emotions
 
        if sentence.data_type in [IMPERATIVE, STATEMENT]:
            logger.debug(colored_print("Processing the content of " + (
                "an imperative sentence" if sentence.data_type == IMPERATIVE else "a statement "), "magenta"))
            return self.process_sentence(sentence, current_speaker)
 
        if sentence.data_type in [W_QUESTION, YES_NO_QUESTION]:
            logger.debug(colored_print("Processing the content of " + (
            emotions.satisfied()
            logger.info(
                level_marker(level=2, color="yellow") + "Found: \n" + colored_print(str(answer), None, "magenta"))
        else:
            emotions.sorry()
    def add_stmts(self, stmts):
        logger.info("Generated statements: ")
        for s in stmts:
            logger.info(">> " + colored_print(s, None, 'magenta'))
 

src/d/i/Dialogs-0.13/src/dialogs/helpers/emotions.py   Dialogs(Download)
 
from dialogs.resources_manager import ResourcePool
from dialogs.helpers.helpers import generate_id, colored_print
 
 
                  "myself experiences " + state_id]
    try:
        logger.info(colored_print("Setting my mood to " + state, "magenta"))
        #logger.warning(colored_print("Not setting my mood due to Pellet bugs!", "magenta"))
        ResourcePool().ontology_server.revise(statements, policy)

src/d/i/Dialogs-0.13/src/dialogs/interpretation/statements_safe_adder.py   Dialogs(Download)
 
import random
from dialogs.helpers.helpers import colored_print
 
from dialogs.resources_manager import ResourcePool
            if onto:
                logger.info(
                    colored_print("... Found ID " + onto[0] + " matching description given statements.", "magenta"))
                for s in current_s:
                    stmts.append(s.replace(id, onto[0]))
        try:
            if not ResourcePool().ontology_server.revise(statements, policy):
                logger.debug(colored_print("At least one statement hasn't been " + \
                                           "pushed to the ontology server because it would lead to inconsistencies."))
 

src/d/i/Dialogs-0.13/src/dialogs/sentence.py   Dialogs(Download)
from dialogs.helpers.sentence_atoms import *
from dialogs.helpers.printers import pprint, level_marker
from dialogs.helpers.helpers import colored_print
from dialogs.resources_manager import ResourcePool