-
Notifications
You must be signed in to change notification settings - Fork 0
/
pointwise.py
executable file
·79 lines (69 loc) · 1.53 KB
/
pointwise.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import string
import random
import math
import sys
def main():
fold_num = ['1','2','3','4','5']
fold1 = ['1','2','3','4']
fold2 = ['1','2','3','5']
fold3 = ['1','2','4','5']
fold4 = ['1','3','4','5']
fold5 = ['2','3','4','5']
# Covert original data file to train data file
for l in fold_num:
train_file = open('train'+'fold'+l+'.txt', 'w')
for n in fold_num:
if n == l:
continue
orig_file = open('S'+n+'.txt', 'r')
tmp_docs = orig_file.readline()
while tmp_docs != '':
if tmp_docs[0] == '0':
train_file.write('-1')
else:
train_file.write('+1')
train_file.write(tmp_docs[1:])
tmp_docs = orig_file.readline()
orig_file.close()
train_file.close()
#print len(dict)
#print dict
#if '中国' in dict:
# print '中国'
# read original file
#orig_file = open('RenMinData.txt','r')
#lines = orig_file.readlines()
#orig_file.close()
#for ll in lines:
# tmp = ll[0:4]
# print tmp
#break
#print len(lines)
__comment__ = """
contents = raw_input("Input a sentence: ")
print "You typed '%s'" % (contents)
contents = list(contents.strip(' \n'))
#tmp = contents[-4*3:]
#print tmp
result = []
while len(contents) >= 2*3:
#tmp = contents[-4*3:]
for i in range(-4,-1,1):
tmp = list(contents[i*3:])
#print tmp
if tmp in dict:
print tmp
result.append(tmp)
#del contents[i*3:]
contents.remove(tmp)
print contents
break;
#print contents
#tmp = contents[i*3:]
#break;
print result
"""
main ()