Datasets:

ArXiv:
Elron commited on
Commit
4895533
1 Parent(s): 787d87e

Upload validate.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. validate.py +20 -20
validate.py CHANGED
@@ -7,40 +7,40 @@ from dataclasses import field
7
  from typing import Dict, Any
8
  from abc import ABC, abstractmethod
9
 
10
-
11
  class Validator(ABC):
12
  pass
13
 
14
-
15
  class ValidateSchema(Validator, StreamInstanceOperator):
 
16
  schema: Features = None
17
-
18
  def verify(self):
19
- assert isinstance(self.schema, Features), "Schema must be an instance of Features"
20
- assert self.schema is not None, "Schema must be specified"
21
-
22
  def verify_first_instance(self, instance):
23
  for field in self.standart_fields:
24
  assert field in instance, f'Field "{field}" is missing in the first instance'
25
-
26
  def process(self, instance: Dict[str, Any], stream_name: str = None) -> Dict[str, Any]:
27
  return instance
28
 
29
-
30
  class StandardSchema(Features):
 
31
  def __init__(self):
32
- super().__init__(
33
- {
34
- "source": Value("string"),
35
- "target": Value("string"),
36
- "references": Sequence(Value("string")),
37
- "metrics": Sequence(Value("string")),
38
- "parser": Value("string"),
39
- # 'group': Value('string'),
40
- # 'guidance': Value('string'),
41
- }
42
- )
43
-
44
 
45
  class ValidateStandartSchema:
 
46
  schema: Features = field(default_factory=StandardSchema)
 
 
 
 
7
  from typing import Dict, Any
8
  from abc import ABC, abstractmethod
9
 
 
10
  class Validator(ABC):
11
  pass
12
 
 
13
  class ValidateSchema(Validator, StreamInstanceOperator):
14
+
15
  schema: Features = None
16
+
17
  def verify(self):
18
+ assert isinstance(self.schema, Features), 'Schema must be an instance of Features'
19
+ assert self.schema is not None, 'Schema must be specified'
20
+
21
  def verify_first_instance(self, instance):
22
  for field in self.standart_fields:
23
  assert field in instance, f'Field "{field}" is missing in the first instance'
24
+
25
  def process(self, instance: Dict[str, Any], stream_name: str = None) -> Dict[str, Any]:
26
  return instance
27
 
 
28
  class StandardSchema(Features):
29
+
30
  def __init__(self):
31
+ super().__init__({
32
+ 'source': Value('string'),
33
+ 'target': Value('string'),
34
+ 'references': Sequence(Value('string')),
35
+ 'metrics': Sequence(Value('string')),
36
+ 'parser': Value('string'),
37
+ # 'group': Value('string'),
38
+ # 'guidance': Value('string'),
39
+ })
 
 
 
40
 
41
  class ValidateStandartSchema:
42
+
43
  schema: Features = field(default_factory=StandardSchema)
44
+
45
+
46
+