-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added static methods to infer pack type (#553)
* added static methods to infer pack type * added unit tests for datapack type inference. Co-authored-by: Zhanyuan Zhang <[email protected]>
- Loading branch information
1 parent
2af5029
commit 169718e
Showing
4 changed files
with
68 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import unittest | ||
from ddt import data, ddt | ||
|
||
from forte.data.caster import MultiPackBoxer | ||
from forte.data.data_pack import DataPack | ||
from forte.data.multi_pack import MultiPack | ||
from forte.data.readers.misc_readers import RawPackReader, RawMultiPackReader | ||
from forte.data.readers.multipack_sentence_reader import MultiPackSentenceReader | ||
from forte.data.readers.multipack_terminal_reader import MultiPackTerminalReader | ||
from forte.data.readers.plaintext_reader import PlainTextReader | ||
|
||
|
||
@ddt | ||
class DataPackTypeInferTest(unittest.TestCase): | ||
|
||
@data( | ||
PlainTextReader, | ||
RawPackReader, | ||
) | ||
def test_datapack_reader(self, component): | ||
reader = component() | ||
self.assertTrue(reader.pack_type() is DataPack) | ||
|
||
@data( | ||
MultiPackSentenceReader, | ||
MultiPackTerminalReader, | ||
RawMultiPackReader, | ||
) | ||
def test_multipack_reader(self, component): | ||
reader = component() | ||
self.assertTrue(reader.pack_type() is MultiPack) | ||
|
||
@data( | ||
MultiPackBoxer, | ||
) | ||
def test_multipack_boxer(self, component): | ||
caster = component() | ||
self.assertTrue(caster.input_pack_type() is DataPack) | ||
self.assertTrue(caster.output_pack_type() is MultiPack) |