How to use the nltools.misc.limit_str function in nltools

To help you get started, we’ve selected a few nltools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gooofy / py-nltools / tests / test_misc.py View on Github external
def test_limit_str(self):

        self.assertEqual(misc.limit_str('1234567890', 10), '1234567890')
        self.assertEqual(misc.limit_str('1234567890',  9), '123456...')
github gooofy / zamia-prolog / zamiaprolog / runtime.py View on Github external
def _trace (self, label, goal):

        if not self.trace:
            return

        # logging.debug ('label: %s, goal: %s' % (label, unicode(goal)))

        depth = goal.get_depth()
        # ind = depth * '  ' + len(label) * ' '

        res = u'!' if goal.negate else u''

        if goal.head:
            res += limit_str(unicode(goal.head), 60)
        else:
            res += u'TOP'
        res += ' '

        for i, t in enumerate(goal.terms):
            if i == goal.inx:
                 res += u" -> " + limit_str(unicode(t), 60)

        res += ' [' + unicode(goal.location) + ']'

        # indent = depth*'  ' + len(label) * ' '
        indent = depth*'  '

        logging.info(u"%s %s: %s" % (indent, label, res))
     
        for k in sorted(goal.env):
github gooofy / zamia-ai / zamiaai / ai_context.py View on Github external
if not token in nd:
                    nd[token] = {}

                if not entity in nd[token]:
                    nd[token][entity] = set([])

                nd[token][entity].add(j)

                # logging.debug ('ner_learn: %4d %s %s: %s -> %s %s' % (i, entity, label, token, cls, lang))

        cnt = 0
        for token in nd:
            # import pdb; pdb.set_trace()
            # s1 = repr(nd[token])
            # s2 = limit_str(s1, 10)
            logging.debug ('ner_learn: nd[%-20s]=%s' % (token, misc.limit_str(repr(nd[token]), 80)))
            cnt += 1
            if cnt > 10:
                break
github gooofy / zamia-prolog / zamiaprolog / runtime.py View on Github external
def _trace_fn (self, label, env):

        if not self.trace:
            return

        indent = '              '

        logging.info(u"%s %s" % (indent, label))
     
        # import pdb; pdb.set_trace()

        for k in sorted(env):
            logging.info(u"%s   %s=%s" % (indent, k, limit_str(repr(env[k]), 80)))
github gooofy / zamia-ai / aiprolog / ner.py View on Github external
if not token in nd:
                nd[token] = {}

            if not entity in nd[token]:
                nd[token][entity] = set([])

            nd[token][entity].add(j)

            # logging.debug ('ner_learn: %4d %s %s: %s -> %s %s' % (i, entity, label, token, cls, lang))

    cnt = 0
    for token in nd:
        # import pdb; pdb.set_trace()
        # s1 = repr(nd[token])
        # s2 = limit_str(s1, 10)
        logging.debug ('ner_learn: nd[%-20s]=%s' % (token, limit_str(repr(nd[token]), 80)))
        cnt += 1
        if cnt > 10:
            break


    return True
github gooofy / zamia-prolog / zamiaprolog / runtime.py View on Github external
res += ' '

        for i, t in enumerate(goal.terms):
            if i == goal.inx:
                 res += u" -> " + limit_str(unicode(t), 60)

        res += ' [' + unicode(goal.location) + ']'

        # indent = depth*'  ' + len(label) * ' '
        indent = depth*'  '

        logging.info(u"%s %s: %s" % (indent, label, res))
     
        for k in sorted(goal.env):
            if k != ASSERT_OVERLAY_VAR_NAME:
                logging.info(u"%s   %s=%s" % (indent, k, limit_str(repr(goal.env[k]), 100)))

        if ASSERT_OVERLAY_VAR_NAME in goal.env:
            goal.env[ASSERT_OVERLAY_VAR_NAME].log_trace(indent)
github gooofy / zamia-prolog / zamiaprolog / logicdb.py View on Github external
def __str__ (self):
        res = u'DBOvl('
        for k in sorted(self.d_assertz):
            for clause in self.d_assertz[k]:
                res += u'+' + limit_str(text_type(clause), 40)
        for k in sorted(self.d_retracted):
            for p in self.d_retracted[k]:
                res += u'-' + limit_str(text_type(p), 40)

        res += u')'
        return res