Package: paspailleur
paspailleurAn add-on for caspailleur to work with Pattern StructuresA Pattern Structure(D, ⊑)represents a description spaceDwhere every two descriptions can be compared by a "less precise" operator⊑.
For example, ifDis a set of ngrams then ngram(hello,)is less precise then(hello, world):(hello, ) ⊑ (hello, world),
that is every ngram that contains(hello, world)contains(hello,).[!WARNING]
The package is in active development stage. Things can change often.Implemented Pattern Structuresfrompaspailleurimportpattern_structuresasPSGeneral useIntervalPSEvery description is a closed interval of real numbers[a,b].
Description[a,b]is less precise than description[c,d]ifa<=c, d<=b.
For example, description[1.5, 3.14]is less precise than[2, 3], i.e.[1.5, 3.14] ⊑ [2, 3](yes the notation is counterintuitive here).d1,d2=(1.5,3.14),(2,3)ps=PS.IntervalPS()assertps.is_less_precise(d1,d2)SubSetPSEvery description is a set of values.
DescriptionAis less precise than descriptionBifAis a subset ofB:A ⊆ B.
For example description{green, cubic}is less precise than{green, cubic, heavy}.d1,d2={'green','cubic'},{'green','cubic','heavy'}ps=PS.SubSetPS()assertps.is_less_precise(d1,d2)SuperSetPSEvery description is a set of values.
DescriptionAis less precise than descriptionBifAis a superset ofB:A ⊇ B.
For example description{green, yellow, red}is less precise than{green, yellow}.d1,d2={'green','yellow','red'},{'green','yellow'}ps=PS.SuperSetPS()assertps.is_less_precise(d1,d2)CartesianPSA pattern structure to combine various independent basic pattern structures in one.# Combining three previous examples togetherd1=[(1.5,3.14),{'green','cubic'},{'green','yellow','red'}]d2=[(2,3),{'green','cubic','heavy'},{'green','yellow'}]basic_structures=[PS.IntervalPS(),PS.SubSetPS(),PS.SuperSetPS()]ps=PS.CartesianPS(basic_structures)assertps.is_less_precise(d1,d2)NLPNgramPSEvery description is a set of incomparable ngram, i.e. set of incomparable tuple of words.NgramA = (a_1, a_2, ..., a_n)is less precise than ngramB = (b_1, b_2, ..., b_m)ifAcan be embedded intoB:
i.e. existsi = 1, ..., m-ns.t.A = B[i:i+n].
For example(hello, world)is less precise than(hello, world, !).DescriptionD_1 = {A_1, A_2, ...}is less precise than descriptionD_2 = {B_1, B_2, ...}if every ngram inD1is less precise than some ngram inD2.d1={('hello','world'),('!',)}d2={('hello','world','!')}ps=PS.NgramPS()assertps.is_less_precise(d1,d2)SynonymPSEvery description is a set of words, representing the synonyms of words contained in some text.
DescriptionAis less precise than descriptionBifAis a subset ofB:A ⊆ B.d1,d2='hello','hello world'ps=PS.SynonymPS()pattern1,pattern2=ps.preprocess_data([d1,d2])assertps.is_less_precise(pattern1,pattern2)print('pattern1:',pattern1)print('pattern2:',pattern2)pattern1: {'hello'}pattern2: {'hello', 'universe'}AntonymPSEvery description is a set of words, representing the antonyms of words contained in some text.
DescriptionAis less precise than descriptionBifAis a subset ofB:A ⊆ B.d1,d2='good','good dog'ps=PS.AntonymPS()pattern1,pattern2=ps.preprocess_data([d1,d2])assertps.is_less_precise(pattern1,pattern2)print('pattern1:',pattern1)print('pattern2:',pattern2)pattern1: {'evil'}pattern2: {'evil'}So, the system does not know any antonym to "dog".Tabular data[!INFO]
Coming soonNumberPSCategoryPSGraphs[!INFO]
Coming soonComing soonGraphPSOrderedGraphPSHow to create a custom Pattern StructureTo be described