Skip to content

Commit

Permalink
updated after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
SoluMilken committed Jan 31, 2019
1 parent 41501f9 commit 3fa9daa
Show file tree
Hide file tree
Showing 17 changed files with 959 additions and 7,145 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
Extension('uttut.elements.intent', ['uttut/elements/intent.c']),
Extension('uttut.elements.entity', ['uttut/elements/entity.c']),
Extension('uttut.elements.datum', ['uttut/elements/datum.c']),
Extension('uttut.elements.utils', ['uttut/elements/utils.c']),
Extension('uttut.expand_by_entities', ['uttut/expand_by_entities.c']),
Extension('uttut.toolkits.get_kth_combination', ['uttut/toolkits/get_kth_combination.c']),
Extension('uttut.toolkits.partition_by_entities', [
Expand Down
6,774 changes: 605 additions & 6,169 deletions uttut/elements/datum.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion uttut/elements/datum.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cdef class Datum:
cdef class Datum: # noqa: E999

cdef public str utterance
cdef public object intents
Expand Down
19 changes: 10 additions & 9 deletions uttut/elements/datum.pyx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from .intent cimport Intent
import pprint

from .intent cimport Intent # noqa: E999
from .entity cimport Entity

from .exceptions import (
EntityOverlapping,
EntityPositionError,
)
from .utils cimport (
from .utils cimport ( # noqa: E211
entity_position_correct,
overlap,
msg_entity_wrong_position,
Expand All @@ -18,8 +20,8 @@ cdef class Datum:
def __cinit__(
self,
str utterance,
object intents = None, # : List[Intent] = None,
object entities = None, # : List[Entity] = None,
object intents=None, # : List[Intent] = None,
object entities=None, # : List[Entity] = None,
):
self.utterance = utterance
self.intents = [] if intents is None else sorted(intents, key=lambda i: hash(i))
Expand Down Expand Up @@ -47,11 +49,10 @@ cdef class Datum:
return True

def __repr__(self):
return "<Datum {} {} with entities: {}>".format(
self.utterance,
self.intents,
self.entities,
)
intent_str = pprint.pformat(self.intents)
entity_str = pprint.pformat(self.entities)
return f"<Datum {self.utterance}\n with intents: "\
f"{intent_str}\n with entities:\n{entity_str}>"

cpdef bint has_same_utterance_as(self, Datum other):
return self.utterance == other.utterance
Expand Down
16 changes: 8 additions & 8 deletions uttut/elements/entity.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion uttut/elements/entity.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cdef class Entity:
cdef class Entity: # noqa: E999

cdef public unsigned int label
cdef public str value
Expand Down
4 changes: 2 additions & 2 deletions uttut/elements/entity.pyx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cdef class Entity:
cdef class Entity: # noqa: E999

def __cinit__(
self,
unsigned int label,
str value,
unsigned int start,
unsigned int end,
object replacements = None,
object replacements=None,
) -> None:

self.label = label
Expand Down
Loading

0 comments on commit 3fa9daa

Please sign in to comment.