-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
889 additions
and
466 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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,21 @@ | ||
from .processor import FroRulesProcessor, FroGlueProcessor | ||
from .tokenizer import FroMemorizingTokenizer | ||
from pie_extended.pipeline.iterators.proto import DataIterator | ||
from pie_extended.pipeline.postprocessor.memory import MemoryzingProcessor | ||
|
||
|
||
def get_iterator_and_processor(): | ||
tokenizer = FroMemorizingTokenizer() | ||
processor = FroRulesProcessor( | ||
apply_on_reinsert=True, | ||
head_processor=MemoryzingProcessor( | ||
tokenizer_memory=tokenizer, | ||
head_processor=FroGlueProcessor() | ||
) | ||
) | ||
iterator = DataIterator( | ||
tokenizer=tokenizer, | ||
remove_from_input=DataIterator.remove_punctuation | ||
) | ||
return iterator, processor | ||
|
This file contains 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,43 @@ | ||
import regex as re | ||
from typing import Dict | ||
|
||
from pie_extended.pipeline.postprocessor.glue import GlueProcessor | ||
from pie_extended.pipeline.postprocessor.rulebased import RuleBasedProcessor | ||
|
||
|
||
class FroRulesProcessor(RuleBasedProcessor): | ||
""" Fro Dataset has not all punctuation signs in it, we remove it and posttag it automatically | ||
""" | ||
PONCTU = re.compile(r"^\W+$") | ||
NUMBER = re.compile(r"\d+") | ||
PONFORT = [".", "...", "!", "?"] | ||
|
||
def rules(self, annotation: Dict[str, str]) -> Dict[str, str]: | ||
token = annotation["form"] | ||
if self.PONCTU.match(token): | ||
if token in self.PONFORT: | ||
pos = "PONfrt" | ||
else: | ||
pos = "PONfbl" | ||
return {"form": token, "lemma": token, "POS": pos, "morph": "MORPH=empty", "treated": token} | ||
elif self.NUMBER.match(token): | ||
annotation["pos"] = "ADJcar" | ||
return annotation | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(FroRulesProcessor, self).__init__(*args, **kwargs) | ||
|
||
|
||
class FroGlueProcessor(GlueProcessor): | ||
""" We glue morphological features into one column | ||
""" | ||
OUTPUT_KEYS = ["form", "lemma", "POS", "morph"] | ||
GLUE = {"morph": ["MODE", "TEMPS", "PERS.", "NOMB.", "GENRE", "CAS", "DEGRE"]} | ||
MAP = {"pos": "POS", "NOMB": "NOMB.", "PERS": "PERS."} | ||
EMPTY_TAG: Dict[str, str] = {"CAS": "_", "NOMB.": "_", "DEGRE": "_", "MODE": "_", "TEMPS": "_", "GENRE": "_", | ||
"PERS.": "_"} | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(FroGlueProcessor, self).__init__(*args, **kwargs) |
Oops, something went wrong.