Comments (3)
Not sure if there is a terminological problem: the concept instances are also the nodes of their lattice object.
You can just iterate over the lattice to walk all concepts:
Lines 202 to 203 in aa45628
In principle you can also directly iterate over
.lattice
(note that the main feature of this library is to produce the full lattice graph for you):
In [1]: import concepts
...: ctx = concepts.Context.fromstring('''
...: |human|knight|king |mysterious|
...: King Arthur| X | X | X | |
...: Sir Robin | X | X | | |
...: holy grail | | | | X |
...: ''')
...: [c.extent for c in ctx.lattice]
Out[1]:
[(),
('King Arthur',),
('holy grail',),
('King Arthur', 'Sir Robin'),
('King Arthur', 'Sir Robin', 'holy grail')]
from concepts.
Oh, i didn't see that.
Thank you for answering, and so quickly.
Maybe you should consider adding a concepts
property, in order to make things even more clear. I love explicit accessors like that, so probably it's affecting my judgement.
from concepts.
Understand. IMO using the native APIs is more pythonic. I think Lattice
should implement a set
-like interface. So I consider to add a .__contains__()
-method that should be simple to implement (once decided on the concrete semantics for the edge cases :) ).
Btw, you could in principle go deeper:
import concepts
ctx = concepts.Context.fromstring('''
|human|knight|king |mysterious|
King Arthur| X | X | X | |
Sir Robin | X | X | | |
holy grail | | | | X |
''')
list(ctx._lattice())
Out[1]:
[(Extent('000'), Intent('1111'), [Extent('100'), Extent('001')], []),
(Extent('100'), Intent('1110'), [Extent('110')], [Extent('000')]),
(Extent('001'), Intent('0001'), [Extent('111')], [Extent('000')]),
(Extent('110'), Intent('1100'), [Extent('111')], [Extent('100')]),
(Extent('111'), Intent('0000'), [], [Extent('001'), Extent('110')])]
These items should contain in principle contain all information about a concept and its lattice position:
[(set(e.members()),
set(i.members()),
[set(u.members()) for u in upper],
[set(l.members()) for l in lower])
for e, i, upper, lower, in ctx._lattice()]
Out[2]:
[(set(),
{'human', 'king', 'knight', 'mysterious'},
[{'King Arthur'}, {'holy grail'}],
[]),
({'King Arthur'},
{'human', 'king', 'knight'},
[{'King Arthur', 'Sir Robin'}],
[set()]),
({'holy grail'},
{'mysterious'},
[{'King Arthur', 'Sir Robin', 'holy grail'}],
[set()]),
({'King Arthur', 'Sir Robin'},
{'human', 'knight'},
[{'King Arthur', 'Sir Robin', 'holy grail'}],
[{'King Arthur'}]),
({'King Arthur', 'Sir Robin', 'holy grail'},
set(),
[],
[{'holy grail'}, {'King Arthur', 'Sir Robin'}])]
from concepts.
Related Issues (8)
- You cant have a context with only one Object. HOT 1
- Saving lattice visualization to a file HOT 3
- lattice_memebers.Concept vs _common.Concept API HOT 6
- Concept from pandas dataframe HOT 2
- missing middle level labels ? HOT 3
- Scalable method for deserializing lattice objects? HOT 15
- Plans for lattice reduction? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from concepts.