Module sentspace.syntax.features

Expand source code
import pandas as pd
import sys
if sys.version_info[0] < 3:
    from StringIO import StringIO
else:
    from io import StringIO


class Feature:
    def __init__(self):
        self.tree = None
        self.dlt = None
        self.left_corner = None


class Tree:
    """Description of a Tree object"""

    def __init__(self, data=None):
        self.raw = data

    def __repr__(self):
        return repr(self.raw)


def rawdatatodf(data, sentence=None, identifier=None):
    df = pd.read_csv(StringIO(data), sep=' ')
    df.rename(columns={'word': 'token'}, inplace=True)
    df['sentence'] = sentence
    df['index'] = identifier
    df = df[['sentence', 'index', *df.columns[:-2]]]
    return df

DLT = LeftCorner = rawdatatodf

Functions

def DLT(data, sentence=None, identifier=None)
Expand source code
def rawdatatodf(data, sentence=None, identifier=None):
    df = pd.read_csv(StringIO(data), sep=' ')
    df.rename(columns={'word': 'token'}, inplace=True)
    df['sentence'] = sentence
    df['index'] = identifier
    df = df[['sentence', 'index', *df.columns[:-2]]]
    return df
def LeftCorner(data, sentence=None, identifier=None)
Expand source code
def rawdatatodf(data, sentence=None, identifier=None):
    df = pd.read_csv(StringIO(data), sep=' ')
    df.rename(columns={'word': 'token'}, inplace=True)
    df['sentence'] = sentence
    df['index'] = identifier
    df = df[['sentence', 'index', *df.columns[:-2]]]
    return df
def rawdatatodf(data, sentence=None, identifier=None)
Expand source code
def rawdatatodf(data, sentence=None, identifier=None):
    df = pd.read_csv(StringIO(data), sep=' ')
    df.rename(columns={'word': 'token'}, inplace=True)
    df['sentence'] = sentence
    df['index'] = identifier
    df = df[['sentence', 'index', *df.columns[:-2]]]
    return df

Classes

class Feature
Expand source code
class Feature:
    def __init__(self):
        self.tree = None
        self.dlt = None
        self.left_corner = None
class Tree (data=None)

Description of a Tree object

Expand source code
class Tree:
    """Description of a Tree object"""

    def __init__(self, data=None):
        self.raw = data

    def __repr__(self):
        return repr(self.raw)