In [2]:
import pandas as pd
import numpy as np
%matplotlib inline
In [3]:
from pattern.en import parsetree
In [4]:
vcodes_df = pd.read_csv("vcodes.csv")
In [5]:
vcodes_df.head()
Out[5]:
In [6]:
vcodes_df['parsetree'] = vcodes_df['description'].map(parsetree)
In [7]:
vcodes_df.head()
Out[7]:
In [8]:
ptree = vcodes_df.ix[118, 2]
In [9]:
vcodes_df.ix[118, 1]
Out[9]:
In [10]:
for sentence in ptree:
for chunk in sentence.chunks:
print chunk
In [12]:
ptree = vcodes_df.ix[377, 2]
In [14]:
for sentence in ptree:
for chunk in sentence.chunks:
print chunk
In [16]:
vcodes_df.ix[377, 1]
Out[16]:
In [23]:
for sentence in vcodes_df.ix[378, 2]:
for chunk in sentence.chunks:
print chunk
In [24]:
vcodes_df.ix[378, 1]
Out[24]:
In [26]:
sent = ptree[0]
In [30]:
vcodes_df['parsetree'].map(lambda x: len(x[0].subjects)).unique()
Out[30]:
In [47]:
pu_truck = sent.chunks[2]
In [48]:
pu_truck.string
Out[48]: