-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplag.py
More file actions
17 lines (11 loc) · 1.04 KB
/
plag.py
File metadata and controls
17 lines (11 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import re
sent = "Long ago, when there was no written history, these islands were the home of millions of happy birds; the resort of a hundred times more millions of fishes, sea lions, and other creatures. Here lived innumerable creatures predestined from the creation of the world to lay up a store of wealth for the British farmer, and a store of quite another sort for an immaculate Republican government."
sent1 = "Long ago, when there was no written history, these islands were the home of millions of happy birds; the resort of a hundred times more millions of fishes, sea lions, and other creatures. Here lived innumerable creatures predestined from the creation of the world to lay up a store of wealth for the British farmer, and a store of quite another sort for an immaculate Republican government."
words1 = re.findall(r'\w+', sent.lower())
words2 = re.findall(r'\w+', sent1.lower())
wset1 = set(words1)
wset2 = set(words2)
common = wset1 & wset2
unique = wset1 | wset2
ratio = len(common) / len(unique)
print(f"Jaccard Similarity: {ratio:.2f}")