-
Notifications
You must be signed in to change notification settings - Fork 60
MultiPack to SinglePack boxer #564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 35 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
ca91b95
bug435_follow_up
VincentYaoMBZUAI 6c20736
bug435_follow_up_1
VincentYaoMBZUAI b469614
bug435_follow_up
VincentYaoMBZUAI 5f3096c
bug435_follow_up_line_80_fixed
VincentYaoMBZUAI 5cb510a
bug435_follow_up_line_using_raise_attributeerror
VincentYaoMBZUAI e85610e
bug435_follow_up_import_logging_fixed
VincentYaoMBZUAI 1883701
bug435_follow_up_line_80_fixed
VincentYaoMBZUAI fcfa024
bug435_follow_up_using_logging
VincentYaoMBZUAI 68ff87f
bug435_follow_up_using_logging_format_fixed
VincentYaoMBZUAI a00a7c8
bug435_follow_up_using_logging_line_80
VincentYaoMBZUAI 79a69ca
bug435_follow_up_using_raise_error_line_80
VincentYaoMBZUAI a39f852
master_clean
VincentYaoMBZUAI c266b8f
DataPackBoxer_fixed
VincentYaoMBZUAI d47ed7f
Merge branch 'master' into bug561fix
VincentYaoMBZUAI b7df51f
allow using pack_index to take a pack, and make the default value to …
VincentYaoMBZUAI f989586
modification and adding test_multi_pack_to_data_pack_boxer
VincentYaoMBZUAI 8f4eda0
Merge branch 'bug561fix' of https://github.com/VincentYaoMBZUAI/forte…
VincentYaoMBZUAI 135bff3
Merge branch 'master' into bug561fix
VincentYaoMBZUAI d372cc8
created a new boxer test file
VincentYaoMBZUAI c24576d
Merge branch 'bug561fix' of https://github.com/VincentYaoMBZUAI/forte…
VincentYaoMBZUAI e28f791
expected_pack_name modified
VincentYaoMBZUAI 3a4af65
expected_pack_name modified
VincentYaoMBZUAI a40ccd6
return the pack from the multipack that matches the pack_index
VincentYaoMBZUAI 2aa38fb
line 80 fixed
VincentYaoMBZUAI b4524b0
line 80 fixed
VincentYaoMBZUAI f8061f0
line 80 fixed
VincentYaoMBZUAI fc59f01
using pack.num_pack instead of len(_pack_names)
VincentYaoMBZUAI 434fb2f
line_80
VincentYaoMBZUAI d3a88cf
line_80
VincentYaoMBZUAI b67d568
line_80
VincentYaoMBZUAI 853cf48
line_80
VincentYaoMBZUAI ac90f3d
class type check, IndexError, default_config, check for less <, pack_…
VincentYaoMBZUAI 097b8f9
clean
VincentYaoMBZUAI 39ec1aa
00_1 to 00
VincentYaoMBZUAI b5cac94
00 to 00_1
VincentYaoMBZUAI 9438894
randomseed
VincentYaoMBZUAI b7e1d4b
randomseed_cancel
VincentYaoMBZUAI 108740f
using /one_file rather than /00
VincentYaoMBZUAI a6e71f9
using /one_file rather than /00
VincentYaoMBZUAI 8b233fe
line 80
VincentYaoMBZUAI bbc763b
Merge branch 'master' into bug561fix
hunterhector File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,80 @@ | ||
#begin document (bn/abc/00/abc_0039); part 000 | ||
bn/abc/00/abc_0039 0 0 Some DT (TOP(NP* - - - - * - | ||
bn/abc/00/abc_0039 0 1 overseas JJ * - - - - * - | ||
bn/abc/00/abc_0039 0 2 news NN * news - 1 - * - | ||
bn/abc/00/abc_0039 0 3 . . *)) - - - - * - | ||
|
||
bn/abc/00/abc_0039 0 0 Barak NNP (TOP(S(NP(NP*) - - - - (PERSON) * * (ARG1*) * (ARG0* (ARG0* - | ||
bn/abc/00/abc_0039 0 1 , , * - - - - * * * * * * * - | ||
bn/abc/00/abc_0039 0 2 who WP (SBAR(WHNP*) - - - - * * * (R-ARG1*) (ARG0*) * * - | ||
bn/abc/00/abc_0039 0 3 has VBZ (S(VP* have 01 - - * (V*) * * * * * - | ||
bn/abc/00/abc_0039 0 4 been VBN (VP* be 03 - - * * (V*) * * * * - | ||
bn/abc/00/abc_0039 0 5 forced VBN (VP* force 01 1 - * * * (V*) * * * - | ||
bn/abc/00/abc_0039 0 6 to TO (S(VP* - - - - * * * (ARG2* * * * - | ||
bn/abc/00/abc_0039 0 7 call VB (VP* call 03 3 - * * * * (V*) * * - | ||
bn/abc/00/abc_0039 0 8 national JJ (NP* - - - - * * * * (ARG1* * * - | ||
bn/abc/00/abc_0039 0 9 elections NNS *)))))))))) - - - - * * * *) *) *) *) - | ||
bn/abc/00/abc_0039 0 10 , , * - - - - * * * * * * * - | ||
bn/abc/00/abc_0039 0 11 offered VBD (VP* offer 01 3 - * * * * * (V*) * - | ||
bn/abc/00/abc_0039 0 12 to TO (S(VP* - - - - * * * * * (ARG1* * - | ||
bn/abc/00/abc_0039 0 13 recognize VB (VP* recognize 01 3 - * * * * * * (V*) - | ||
bn/abc/00/abc_0039 0 14 a DT (NP* - - - - * * * * * * (ARG1* - | ||
bn/abc/00/abc_0039 0 15 Palestinian JJ * - - - - (NORP) * * * * * * - | ||
bn/abc/00/abc_0039 0 16 state NN *))))) state - 1 - * * * * * *) *) - | ||
bn/abc/00/abc_0039 0 17 . . *)) - - - - * * * * * * * - | ||
|
||
bn/abc/00/abc_0039 0 0 There EX (TOP(S(NP*) - - - - * - | ||
bn/abc/00/abc_0039 0 1 's VBZ (VP* be - 3 - * - | ||
bn/abc/00/abc_0039 0 2 one CD (NP* - - - - (CARDINAL) (0 | ||
bn/abc/00/abc_0039 0 3 very RB (ADJP* - - - - * - | ||
bn/abc/00/abc_0039 0 4 difficult JJ *) - - - - * - | ||
bn/abc/00/abc_0039 0 5 condition NN *)) condition - 1 - * 0) | ||
bn/abc/00/abc_0039 0 6 . . *)) - - - - * - | ||
|
||
bn/abc/00/abc_0039 0 0 There EX (TOP(S(NP*) - - - - * * * - | ||
bn/abc/00/abc_0039 0 1 could MD (VP* - - - - * (ARGM-MOD*) * - | ||
bn/abc/00/abc_0039 0 2 be VB (VP* be 02 5 - * (V*) * - | ||
bn/abc/00/abc_0039 0 3 no DT (NP(NP* - - - - * (ARG1* * (0 | ||
bn/abc/00/abc_0039 0 4 discussion NN *) discussion - 2 - * * * - | ||
bn/abc/00/abc_0039 0 5 for IN (PP* - - - - * * * - | ||
bn/abc/00/abc_0039 0 6 now RB (NP*)) - - - - * * * - | ||
bn/abc/00/abc_0039 0 7 about IN (PP* - - - - * * * - | ||
bn/abc/00/abc_0039 0 8 who WP (SBAR(WHNP*) - - - - * * (ARG0*) - | ||
bn/abc/00/abc_0039 0 9 will MD (S(VP* - - - - * * (ARGM-MOD*) - | ||
bn/abc/00/abc_0039 0 10 have VB (VP* have 03 2 - * * (V*) - | ||
bn/abc/00/abc_0039 0 11 what WDT (NP(NP* - - - - * * (ARG1* - | ||
bn/abc/00/abc_0039 0 12 status NN *) status - 1 - * * * - | ||
bn/abc/00/abc_0039 0 13 in IN (PP* - - - - * * * - | ||
bn/abc/00/abc_0039 0 14 Jerusalem NNP (NP*))))))))))) - - - - (GPE) *) *) 0) | ||
bn/abc/00/abc_0039 0 15 . . *)) - - - - * * * - | ||
|
||
bn/abc/00/abc_0039 0 0 Palestinians NNPS (TOP(S(NP*) - - - - (NORP) * (ARG0*) - | ||
bn/abc/00/abc_0039 0 1 do VBP (VP* do 01 - - * (V*) * - | ||
bn/abc/00/abc_0039 0 2 n't RB * - - - - * * (ARGM-NEG*) - | ||
bn/abc/00/abc_0039 0 3 like VB (VP* like 01 2 - * * (V*) - | ||
bn/abc/00/abc_0039 0 4 it PRP (NP*))) - - - - * * (ARG1*) (0) | ||
bn/abc/00/abc_0039 0 5 . . *)) - - - - * * * - | ||
|
||
bn/abc/00/abc_0039 0 0 In IN (TOP(S(PP* - - - - * * * * * * (ARGM-LOC* - | ||
bn/abc/00/abc_0039 0 1 Bethlehem NNP (NP(NP*) - - - - (GPE) * * * * * * - | ||
bn/abc/00/abc_0039 0 2 , , * - - - - * * * * * * * - | ||
bn/abc/00/abc_0039 0 3 where WRB (SBAR(WHADVP*) - - - - * * * (ARGM-LOC*) * * * - | ||
bn/abc/00/abc_0039 0 4 Christians NNPS (S(NP*) - - - - (NORP) (ARG0*) * * * * * - | ||
bn/abc/00/abc_0039 0 5 believe VBP (VP* believe 01 2 - * (V*) * * * * * - | ||
bn/abc/00/abc_0039 0 6 Jesus NNP (SBAR(S(NP*) - - - - (PERSON) (ARG1* * (ARG1*) * * * - | ||
bn/abc/00/abc_0039 0 7 was VBD (VP* be 03 - - * * (V*) * * * * - | ||
bn/abc/00/abc_0039 0 8 born VBN (VP*))))))))) bear 02 - - * *) * (V*) * * *) - | ||
bn/abc/00/abc_0039 0 9 , , * - - - - * * * * * * * - | ||
bn/abc/00/abc_0039 0 10 Christmas NNP (NP* - - - - (DATE) * * * * * (ARG1* - | ||
bn/abc/00/abc_0039 0 11 plans NNS *) plan - 1 - * * * * * * *) - | ||
bn/abc/00/abc_0039 0 12 have VBP (VP* have 01 - - * * * * (V*) * * - | ||
bn/abc/00/abc_0039 0 13 been VBN (VP* be 03 - - * * * * * (V*) * - | ||
bn/abc/00/abc_0039 0 14 scaled VBN (VP* scale 01 5 - * * * * * * (V*) - | ||
bn/abc/00/abc_0039 0 15 back RP (PRT*) - - - - * * * * * * (ARG5*) - | ||
bn/abc/00/abc_0039 0 16 because IN (PP* - - - - * * * * * * (ARGM-CAU* - | ||
bn/abc/00/abc_0039 0 17 of IN * - - - - * * * * * * * - | ||
bn/abc/00/abc_0039 0 18 the DT (NP* - - - - * * * * * * * - | ||
bn/abc/00/abc_0039 0 19 violence NN *))))) - - - - * * * * * * *) - | ||
bn/abc/00/abc_0039 0 20 . . *)) - - - - * * * * * * * - | ||
|
||
#end document |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,82 @@ | ||
# Copyright 2019 The Forte Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
""" | ||
Unit tests for DataPack Boxer. | ||
""" | ||
|
||
import os | ||
import unittest | ||
from ddt import ddt, data, unpack | ||
from forte.data.caster import MultiPackBoxer, MultiPackUnboxer | ||
from forte.data.data_pack import DataPack | ||
from forte.data.multi_pack import MultiPack | ||
from forte.pipeline import Pipeline | ||
|
||
data_samples_root = os.path.abspath( | ||
os.path.join( | ||
os.path.dirname(os.path.realpath(__file__)), | ||
*([os.path.pardir] * 2), | ||
"data_samples" | ||
) | ||
) | ||
|
||
onto_specs_samples_root = os.path.abspath( | ||
os.path.join( | ||
os.path.dirname(os.path.realpath(__file__)), | ||
*([os.path.pardir] * 1), | ||
"forte", | ||
"data", | ||
"ontology", | ||
"test_specs" | ||
) | ||
) | ||
|
||
|
||
@ddt | ||
class MultiPackUnboxerTest(unittest.TestCase): | ||
def test_multi_pack_to_data_pack_unboxer(self): | ||
from forte.data.readers import OntonotesReader | ||
|
||
# Define and config the Pipeline for MultiPackBoxer test | ||
nlp_1 = Pipeline[DataPack]() | ||
nlp_1.set_reader(OntonotesReader()) | ||
pack_name = "test_pack" | ||
nlp_1.add(MultiPackBoxer(), {"pack_name": pack_name}) | ||
nlp_1.initialize() | ||
|
||
# Define and config the Pipeline for DataPackBoxer test | ||
nlp_2 = Pipeline[DataPack]() | ||
nlp_2.set_reader(OntonotesReader()) | ||
pack_name = "test_pack" | ||
nlp_2.add(MultiPackBoxer(), {"pack_name": pack_name}) | ||
nlp_2.add(MultiPackUnboxer()) | ||
nlp_2.initialize() | ||
|
||
dataset_path = data_samples_root + "/ontonotes/00_1" | ||
expected_pack_name_multi = "bn/abc/00/abc_0039_multi" | ||
expected_pack_name = "bn/abc/00/abc_0039" | ||
|
||
# check that the MultiPack is yielded | ||
pack_1 = nlp_1.process(dataset_path) | ||
self.assertEqual(pack_1.pack_name, expected_pack_name_multi) | ||
hunterhector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.assertTrue(isinstance(pack_1, MultiPack)) | ||
|
||
# check that the unboxed DataPack is yielded from the corresponding MultiPack | ||
pack_2 = nlp_2.process(dataset_path) | ||
self.assertEqual(pack_2.pack_name, expected_pack_name) | ||
self.assertTrue(isinstance(pack_2, DataPack)) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can reuse the current dataset without adding a new file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should remove this file if it is no longer needed