|
@@ -23,46 +23,13 @@ from ChildProject.annotations import AnnotationConverter
|
|
|
|
|
|
from consts import ANNOTATION_TYPES
|
|
|
|
|
|
-class AcousticConverter(AnnotationConverter):
|
|
|
- FORMAT = ANNOTATION_TYPES.ACOUSTIC.value[0]
|
|
|
|
|
|
- @staticmethod
|
|
|
- def convert(filename: str, source_file: str = "", **kwargs) -> pd.DataFrame:
|
|
|
- df = pd.read_csv(
|
|
|
- filename,
|
|
|
- sep=r",",
|
|
|
- header=0,
|
|
|
- engine="python",
|
|
|
- )
|
|
|
-
|
|
|
- n_recordings = len(df["file"].unique())
|
|
|
- if n_recordings > 1 and not source_file:
|
|
|
- print(
|
|
|
- f"""WARNING: {filename} contains annotations from {n_recordings} different audio files, """
|
|
|
- """but no filter was specified which means all of these annotations will be imported.\n"""
|
|
|
- """as if they belonged to the same recording. Please make sure this is the intended behavior """
|
|
|
- """(it probably isn't)."""
|
|
|
- )
|
|
|
-
|
|
|
- if source_file:
|
|
|
- df = df[df["file"].str.contains(source_file)]
|
|
|
-
|
|
|
- df.drop(columns=["file"], inplace=True)
|
|
|
-
|
|
|
- return df
|
|
|
-
|
|
|
-
|
|
|
-class ConversationsConverter(AnnotationConverter):
|
|
|
- FORMAT = ANNOTATION_TYPES.CONVERSATIONS.value[0]
|
|
|
+class FilteredCsvConverter(AnnotationConverter):
|
|
|
+ FORMAT = 'filtered_csv'
|
|
|
|
|
|
@staticmethod
|
|
|
def convert(filename: str, source_file: str = "", **kwargs) -> pd.DataFrame:
|
|
|
- df = pd.read_csv(
|
|
|
- filename,
|
|
|
- sep=r",",
|
|
|
- header=0,
|
|
|
- engine="python",
|
|
|
- )
|
|
|
+ df = pd.read_csv(filename)
|
|
|
|
|
|
n_recordings = len(df["recording_filename"].unique())
|
|
|
if n_recordings > 1 and not source_file:
|
|
@@ -76,4 +43,4 @@ class ConversationsConverter(AnnotationConverter):
|
|
|
if source_file:
|
|
|
df = df[df["recording_filename"].str.contains(source_file)]
|
|
|
|
|
|
- return df
|
|
|
+ return df
|