-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #438 from nicolay-r/master
Sync with latest updates
- Loading branch information
Showing
9 changed files
with
94 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
SynonymObject = "syn_objs" | ||
SynonymSubject = "syn_subjs" | ||
PosTags = "pos_tags" | ||
Text = "text" | ||
|
||
ArgsSep = ',' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from arekit.contrib.utils.data.readers.base import BaseReader | ||
from arekit.contrib.utils.data.storages.jsonl_based import JsonlBasedRowsStorage | ||
|
||
|
||
class JsonlReader(BaseReader): | ||
|
||
def read(self, target): | ||
rows = [] | ||
with open(target, "r") as f: | ||
for line in f.readlines(): | ||
rows.append(line) | ||
return JsonlBasedRowsStorage(rows) | ||
|
||
def target_extension(self): | ||
return ".jsonl" |
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,18 @@ | ||
import json | ||
|
||
from arekit.common.data.storages.base import BaseRowsStorage | ||
|
||
|
||
class JsonlBasedRowsStorage(BaseRowsStorage): | ||
|
||
def __init__(self, rows): | ||
assert(isinstance(rows, list)) | ||
self.__rows = rows | ||
|
||
def _iter_rows(self): | ||
for row_index, row in enumerate(self.__rows): | ||
assert(isinstance(row, str)) | ||
yield row_index, json.loads(row) | ||
|
||
def _get_rows_count(self): | ||
return len(self.__rows) |
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