MCPcopy Index your code
hub / github.com/clips/pattern / test_modality

Method test_modality

test/test_en.py:812–835  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

810 print "pattern.en.mood()"
811
812 def test_modality(self):
813 # Assert -1.0 => +1.0 representing the degree of certainty.
814 v = en.modality(en.Sentence(en.parse("I wish it would stop raining.")))
815 self.assertTrue(v < 0)
816 v = en.modality(en.Sentence(en.parse("It will surely stop raining soon.")))
817 self.assertTrue(v > 0)
818 # Assert the accuracy of the modality algorithm.
819 # Given are the scores for the CoNLL-2010 Shared Task 1 Wikipedia uncertainty data:
820 # http://www.inf.u-szeged.hu/rgai/conll2010st/tasks.html#task1
821 # The baseline should increase (not decrease) when the algorithm is modified.
822 from pattern.db import Datasheet
823 from pattern.metrics import test
824 sentences = []
825 for certain, sentence in Datasheet.load(os.path.join(PATH, "corpora", "uncertainty-conll2010.csv")):
826 sentence = en.parse(sentence, chunks=False, light=True)
827 sentence = en.Sentence(sentence)
828 sentences.append((sentence, int(certain) > 0))
829 A, P, R, F = test(lambda sentence: en.modality(sentence) > 0.5, sentences)
830 #print A, P, R, F
831 self.assertTrue(A > 0.69)
832 self.assertTrue(P > 0.71)
833 self.assertTrue(R > 0.64)
834 self.assertTrue(F > 0.67)
835 print "pattern.en.modality()"
836
837#---------------------------------------------------------------------------------------------------
838

Callers

nothing calls this directly

Calls 4

testFunction · 0.90
parseMethod · 0.45
loadMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected