-
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
1 parent
07a5bc7
commit 7ab88eb
Showing
10 changed files
with
87 additions
and
2,989 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
BASE_ROUTE = "klang" | ||
|
||
|
||
# def register_routes(api, app, root="api"): | ||
# from .controller import api as project_api | ||
def register_routes(api, app, root="api"): | ||
from .controller import api as project_api | ||
|
||
# api.add_namespace(project_api, path=f"/{root}/{BASE_ROUTE}") | ||
api.add_namespace(project_api, path=f"/{root}/{BASE_ROUTE}") |
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,31 @@ | ||
from datetime import datetime | ||
from typing import List | ||
|
||
from flask import session | ||
from flask_accepts.decorators.decorators import responds | ||
from flask_restx import Namespace, Resource | ||
|
||
from .service import ConllService | ||
|
||
api = Namespace("Klang", description="Single namespace, single entity") # noqa | ||
|
||
@api.route("/conlls") | ||
class ConllServiceResource(Resource): | ||
"ConllService" | ||
|
||
def get(self) : | ||
return ConllService.get_all() | ||
|
||
|
||
@api.route("/conll/<string:conll_name>") | ||
class ConllNameServiceResource(Resource): | ||
"ConllService" | ||
|
||
def get(self, conll_name) : | ||
conll_string = ConllService.get_by_name(conll_name) | ||
sentences_string = ConllService.seperate_conll_sentences(conll_string) | ||
sentences_audio_token = [] | ||
for sentence_string in sentences_string: | ||
audio_tokens = ConllService.sentence_to_audio_tokens(sentence_string) | ||
sentences_audio_token.append(audio_tokens) | ||
return sentences_audio_token |
613 changes: 0 additions & 613 deletions
613
app/klang/data_prod/Thalia_Guevara_Puzma/Thalia_Guevara_Puzma.intervals.conll
This file was deleted.
Oops, something went wrong.
693 changes: 0 additions & 693 deletions
693
app/klang/data_prod/Veronique_Jezewski/Veronique_Jezewski.intervals.conll
This file was deleted.
Oops, something went wrong.
853 changes: 0 additions & 853 deletions
853
app/klang/data_prod/Zaynab_Affes/Zaynab_Affes.intervals.conll
This file was deleted.
Oops, something went wrong.
810 changes: 0 additions & 810 deletions
810
app/klang/data_prod/Zoe_Sacotte/Zoe_Sacotte.intervals.conll
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 |
---|---|---|
@@ -1,33 +1,55 @@ | ||
import os | ||
import re | ||
from typing import List | ||
|
||
from app import klang_config | ||
|
||
align_begin_and_end_regex = re.compile( | ||
r"^\d+\t(.+?)\t.*AlignBegin=(\d+).*AlignEnd=(\d+)" | ||
) | ||
|
||
class ConllService: | ||
@staticmethod | ||
def get_path_data(): | ||
path_data = klang_config.path | ||
return path_data | ||
|
||
@staticmethod | ||
def get_path_conll(file_name_suffix): | ||
file_name = file_name_suffix + ".intervals.conll" | ||
path_data = ConllService.get_path_data() | ||
path_conll = os.path.join(path_data,file_name_suffix, file_name) | ||
path_conll = os.path.join(path_data, file_name_suffix, file_name) | ||
return path_conll | ||
|
||
@staticmethod | ||
def read_conll(path_conll): | ||
with open(path_conll, "r", encoding="utf-8") as infile: | ||
conll = infile.read() | ||
return conll | ||
|
||
return conll | ||
|
||
@staticmethod | ||
def get_all(): | ||
path_data = ConllService.get_path_data() | ||
conlls = os.listdir(path_data) | ||
return conlls | ||
|
||
# @staticmethod | ||
# def get_by_name(conll_name): | ||
# with | ||
# return True | ||
@staticmethod | ||
def get_by_name(conll_name): | ||
path_conll = ConllService.get_path_conll(conll_name) | ||
conll_string = ConllService.read_conll(path_conll) | ||
return conll_string | ||
|
||
@staticmethod | ||
def seperate_conll_sentences(conll_string: str) -> List[str]: | ||
return list(filter(lambda x: x != "", conll_string.split("\n\n"))) | ||
|
||
@staticmethod | ||
def sentence_to_audio_tokens(sentence_string: str): | ||
audio_tokens = [] | ||
for line in sentence_string.split("\n"): | ||
if line: | ||
if not line.startswith("#"): | ||
m = align_begin_and_end_regex.search(line) | ||
audio_tokens += [(m.group(1), int(m.group(2)), int(m.group(3)))] | ||
|
||
return audio_tokens |
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