-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating a data Structure for the Metric System
- Loading branch information
pedrojlazevedo
committed
Mar 15, 2020
1 parent
d76923a
commit 8e262ff
Showing
7 changed files
with
106 additions
and
70 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from metrics.evidence import Evidence | ||
|
||
|
||
class Claim: | ||
|
||
def __init__(self, _id, name, verifiable): | ||
self.id = _id | ||
self.name = name | ||
if verifiable == "VERIFIABLE": | ||
self.verifiable = 1 | ||
else: | ||
self.verifiable = 0 | ||
self.gold_evidence = [] | ||
|
||
def add_gold_evidence(self, document, evidence, line_num): | ||
evidence = Evidence(document, evidence, line_num) | ||
self.gold_evidence.append(evidence) | ||
|
||
def add_gold_evidences(self, evidences): | ||
for evidence in evidences: | ||
_evidence = Evidence() | ||
if len(evidence) > 1: # needs more than 1 doc to be verifiable | ||
for e in evidence: | ||
_evidence.add_pair(str(e[2]), str(e[3])) | ||
else: | ||
_evidence.add_pair(str(evidence[0][2]), str(evidence[0][3])) | ||
self.gold_evidence.append(_evidence) | ||
|
||
def get_gold_documents(self): | ||
docs = set() | ||
for e in self.gold_evidence: | ||
docs |= e.documents | ||
return docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class Evidence: | ||
|
||
def __init__(self, document="", sentence="", line_num=0): | ||
self.documents = set() | ||
self.sentences = set() | ||
self.pairs = set() | ||
# if arguments are passed | ||
if document != "": | ||
self.documents.add(document) | ||
if sentence != "": | ||
self.sentences.add(sentence) | ||
if line_num != 0: | ||
self.pairs.add((document, line_num)) | ||
|
||
def add_document(self, doc): | ||
self.documents.add(doc) | ||
|
||
def add_sentence(self, sentence): | ||
self.sentences.add(sentence) | ||
|
||
def add_pair(self, doc, line_num): | ||
self.pairs.add((doc, line_num)) | ||
self.add_document(doc) | ||
|
||
def get_difficulty_documents(self): | ||
return len(self.documents) | ||
|
||
def get_difficulty_sentences(self): | ||
return len(self.sentences) | ||
|
||
def get_difficulty(self): | ||
return len(self.pairs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters