-
Notifications
You must be signed in to change notification settings - Fork 1
/
plagiarism_cases.m
111 lines (110 loc) · 3.48 KB
/
plagiarism_cases.m
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
function plags=plagiarism_cases(r,c,oi,ol,si,sl)
plags=[];
sents_s=[];
sents_o=[];
index_s=1;
for i=1:size(c,1)
if isempty(sents_s)
sents_s(1,1)=c(i,1);
sents_o(1,1)=r(i,1);
elseif c(i,1)==sents_s(end)+1 || c(i,1)==sents_s(end)
sents_s=[sents_s;c(i,1)];
sents_o=[sents_o;r(i,1)];
else
%length(sents_s)
%i
sents_o_int=[];
plalen_o=0;
plalen_s=0;
plaoffset_o=0;
plaoffset_s=0;
for k=1:size(sents_s,1)
if ismember(sents_o(k),sents_o_int)
plalen_o=plalen_o+ol(1,sents_o(k));
plalen_s=plalen_s+sl(1,sents_s(k));
%if oi(1,sents_o(k))<plaoffset_o
if sents_o(k)<plaoffset_o
%plaoffset_o=oi(1,sents_o(k));
plaoffset_o=sents_o(k);
end
else
if ~isempty(sents_o_int)
%plags=[plags;[plaoffset_o-3 plalen_o plaoffset_s-2 plalen_s]];
plags=[plags;[plaoffset_o plalen_o plaoffset_s plalen_s]];
index_s=k;
end
%plaoffset_o=oi(1,sents_o(k));
%plaoffset_s=si(1,sents_s(k));
plalen_o=ol(1,sents_o(k));
plalen_s=sl(1,sents_s(k));
plaoffset_o=sents_o(k);
plaoffset_s=sents_s(k);
sents_o_int=sents_interval(sents_o,index_s);
end
end
%plags=[plags;[plaoffset_o-3 plalen_o plaoffset_s-2 plalen_s]];
plags=[plags;[plaoffset_o plalen_o plaoffset_s plalen_s]];
index_s=1;
sents_s=[];
sents_o=[];
sents_s(1,1)=c(i,1);
sents_o(1,1)=r(i,1);
end
end
%length(sents_s)
sents_o_int=[];
plalen_o=0;
plalen_s=0;
plaoffset_o=0;
plaoffset_s=0;
for k=1:size(sents_s,1)
if ismember(sents_o(k),sents_o_int)
plalen_o=plalen_o+ol(1,sents_o(k));
plalen_s=plalen_s+sl(1,sents_s(k));
%if oi(1,sents_o(k))<plaoffset_o
if sents_o(k)<plaoffset_o
%plaoffset_o=oi(1,sents_o(k));
plaoffset_o=sents_o(k);
end
else
if ~isempty(sents_o_int)
%plags=[plags;[plaoffset_o-3 plalen_o plaoffset_s-2 plalen_s]];
plags=[plags;[plaoffset_o plalen_o plaoffset_s plalen_s]];
index_s=k;
end
%plaoffset_o=oi(1,sents_o(k));
%plaoffset_s=si(1,sents_s(k));
plalen_o=ol(1,sents_o(k));
plalen_s=sl(1,sents_s(k));
plaoffset_o=sents_o(k);
plaoffset_s=sents_s(k);
%sents_s
%sents_o
%index_s
sents_o_int=sents_interval(sents_o,index_s);
%sents_o_int
%length(sents_o_int)
end
end
%plags=[plags;[plaoffset_o-3 plalen_o plaoffset_s-2 plalen_s]];
plags=[plags;[plaoffset_o plalen_o plaoffset_s plalen_s]];
function sents_o_int=sents_interval(sents_o,index_s)
[sents_o_sorted,index_o]=sort(sents_o);
%Consecutive plagiarized source sentences interval
sents_o_int=sents_o(index_s,1);
%Way up
for j=find(sents_o_sorted==sents_o(index_s,1),1,'first')-1:-1:1
if sents_o_sorted(j)==sents_o_int(1)-1 || sents_o_sorted(j)==sents_o_int(1)
sents_o_int=[sents_o_sorted(j) sents_o_int];
else
break;
end
end
%Way down
for j=find(sents_o_sorted==sents_o(index_s,1),1,'first')+1:1:size(sents_o_sorted,1)
if sents_o_sorted(j)==sents_o_int(end)+1 || sents_o_sorted(j)==sents_o_int(end)
sents_o_int=[sents_o_int sents_o_sorted(j)];
else
break;
end
end