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

Configuration error #4

Open
angadgaikwad opened this issue May 23, 2023 · 1 comment
Open

Configuration error #4

angadgaikwad opened this issue May 23, 2023 · 1 comment

Comments

@angadgaikwad
Copy link

It will show ConfigValidationError: Config validation error disabled field required tokenizer field required before_creation field required after_creation field required after_pipeline_creation field required {'pipeline': ['tok2vec', 'tagger', 'parser', 'ner'], 'lang': 'en', 'batch_size': 1000}

How to solve this?

@SurajSanap
Copy link

The error you're encountering suggests that there are missing or incorrect configuration fields when trying to create a spaCy pipeline. You need to provide a valid configuration to create the spaCy pipeline. The required fields include tokenizer, before_creation, after_creation, and after_pipeline_creation.

Here's an example of how you can create a spaCy pipeline with a valid configuration:

import spacy

# Define your custom components or use the default ones
def custom_before_creation(nlp, **cfg):
    # Add any custom logic before pipeline creation
    return nlp

def custom_after_creation(nlp, **cfg):
    # Add any custom logic after pipeline creation
    return nlp

def custom_after_pipeline_creation(nlp, **cfg):
    # Add any custom logic after each component in the pipeline is created
    return nlp

# Define the spaCy pipeline configuration
config = {
    "pipeline": ["tok2vec", "tagger", "parser", "ner"],
    "lang": "en",
    "batch_size": 1000,
    "before_creation": custom_before_creation,
    "after_creation": custom_after_creation,
    "after_pipeline_creation": custom_after_pipeline_creation,
}

# Create the spaCy pipeline
nlp = spacy.blank("en")
nlp.from_config(config)

# Now, you can use the created pipeline (nlp) for processing text

In this example:

  • custom_before_creation, custom_after_creation, and custom_after_pipeline_creation are placeholder functions where you can add any custom logic you need.
  • The configuration dictionary (config) includes the required fields for creating the pipeline.

Make sure to adapt the custom functions to your specific needs, and provide any additional components or logic required for your spaCy pipeline.

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

No branches or pull requests

2 participants