mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-27 17:54:39 +03:00
use field validator
This commit is contained in:
parent
3b37fb6dcf
commit
59d8ee4132
|
@ -1,7 +1,7 @@
|
||||||
import re
|
import re
|
||||||
from typing import Callable, List, Optional, Union
|
from typing import Callable, List, Optional, Union
|
||||||
|
|
||||||
from pydantic import BaseModel, validator
|
from pydantic import BaseModel, field_validator
|
||||||
|
|
||||||
from ..language import Language
|
from ..language import Language
|
||||||
from ..tokens import Doc, Token
|
from ..tokens import Doc, Token
|
||||||
|
@ -137,7 +137,7 @@ def split_noun_coordination(doc: Doc) -> Union[List[str], None]:
|
||||||
class SplittingRule(BaseModel):
|
class SplittingRule(BaseModel):
|
||||||
function: Callable[[Doc], Union[List[str], None]]
|
function: Callable[[Doc], Union[List[str], None]]
|
||||||
|
|
||||||
@validator("function")
|
@field_validator("function")
|
||||||
def check_return_type(cls, v):
|
def check_return_type(cls, v):
|
||||||
dummy_doc = Doc(Language().vocab, words=["dummy", "doc"], spaces=[True, False])
|
dummy_doc = Doc(Language().vocab, words=["dummy", "doc"], spaces=[True, False])
|
||||||
result = v(dummy_doc)
|
result = v(dummy_doc)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user