import pickle from sklearn.feature_extraction import DictVectorizer from itertools import chain import nltk from sklearn.metrics import classification_report, confusion_matrix from sklearn.preprocessing import LabelBinarizer import sklearn import pycrfsuite from loadTuples import load, load2, load3 from sklearn import svm from evalt import * from collections import Counter import sentlex test_sents = load3("test") #print train_sents #print "sent =" +str(len(train_sents)) SWN = sentlex.SWN3Lexicon() f = open("PredictedTags.pkl", 'rb') Eventpredicted = pickle.load(f) f.close() global wordCnt wordCnt = -1 def word2features(sent, i): """get the feautes corresponding to a word in a sentence at a particular position Args:
from sklearn.feature_extraction import DictVectorizer from itertools import chain import nltk from sklearn.metrics import classification_report, confusion_matrix from sklearn.preprocessing import LabelBinarizer import sklearn import pycrfsuite from loadTuples import load, load2, load3 from sklearn import svm from evalt3 import * import pickle import sentlex train_sents = load3("train") # test_sents = load2("test")[:100] #print train_sents #print "sent =" +str(len(train_sents)) SWN = sentlex.SWN3Lexicon() def word2features(sent, i): """get the feautes corresponding to a word in a sentence at a particular position Args: sent: the sentence whose word is to be considered i: the position of the word in the sentence Returns: the dictionary containing the features for the classifier """ word = sent[i][0] postag = sent[i][1] norm = sent[i][2] cui = sent[i][3]
import pickle from sklearn.feature_extraction import DictVectorizer from itertools import chain import nltk from sklearn.metrics import classification_report, confusion_matrix from sklearn.preprocessing import LabelBinarizer import sklearn import pycrfsuite from loadTuples import load,load2, load3 from sklearn import svm from evalt import * import sentlex from collections import Counter test_sents = load3("test") #print train_sents #print "sent =" +str(len(train_sents)) SWN = sentlex.SWN3Lexicon() f=open("PredictedTags.pkl", 'rb') Eventpredicted = pickle.load(f) f.close() global wordCnt wordCnt = -1 def word2features(sent, i): """get the feautes corresponding to a word in a sentence at a particular position Args: sent: the sentence whose word is to be considered
from sklearn.feature_extraction import DictVectorizer from itertools import chain import nltk from sklearn.metrics import classification_report, confusion_matrix from sklearn.preprocessing import LabelBinarizer import sklearn import pycrfsuite from loadTuples import load,load2,load3 from sklearn import svm from evalt3 import * import pickle import sentlex train_sents = load3("train") # test_sents = load2("test")[:100] #print train_sents #print "sent =" +str(len(train_sents)) SWN = sentlex.SWN3Lexicon() def word2features(sent, i): """get the feautes corresponding to a word in a sentence at a particular position Args: sent: the sentence whose word is to be considered i: the position of the word in the sentence Returns: the dictionary containing the features for the classifier """ word = sent[i][0] postag = sent[i][1] norm = sent[i][2] cui = sent[i][3] tui = sent[i][4]