Skip to content
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

Let PipeLine support copy() #1861

Merged
merged 2 commits into from
Dec 6, 2023
Merged

Let PipeLine support copy() #1861

merged 2 commits into from
Dec 6, 2023

Conversation

Vela-zz
Copy link
Contributor

@Vela-zz Vela-zz commented Dec 4, 2023

Let PipeLine support copy()

Description

now pipeline can be copied and add next-preprocessing step on needs withoud write duplicated append().

Fixes # (issue)

Type of Change

Please check any relevant options and delete the rest.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

class TestPipeLine(unittest.TestCase):
    def test_copy(self):
        pipe = hanlp.pipeline().append(hanlp.utils.rules.split_sentence)
        copied_pipe = pipe.copy()
        test_text = "今天天气真好。我要去散步。"
        assert pipe is not copied_pipe
        copied_pipe.append(lambda sent: "".join(sent))
        assert pipe(test_text) != copied_pipe(test_text)

Checklist

Check all items that apply.

  • ⚠️Changes must be made on dev branch instead of master
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have checked my code and corrected any misspellings

@hankcs hankcs merged commit fa9f6ed into hankcs:dev Dec 6, 2023
16 checks passed
@hankcs
Copy link
Owner

hankcs commented Dec 6, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants