In general, how algorithm should distinguish the word meaning and recognise the word within the context?
I don't think anybody knows how to answer this for the general case. If they did, they'd have basically solved AGI. But we can certainly talk about techniques that get part-of-the-way there, and approaches that could work.
One thing I would consider ...
If I understand you correctly, you should check out Word2Vec. From Wikipedia:
Word2vec is a group of related models that are used to produce word
embeddings. These models are shallow, two-layer neural networks that
are trained to reconstruct linguistic contexts of words. Word2vec
takes as its input a large corpus of text and produces a
I would think you could use a graph database, perhaps Neo4J or Titan or something of that nature. Or, if you want a simple file format, you could use one of the many formats that exist for representing graphs. You can find a list and overview of some of them here.
Another option would be to store them in RDF using a triplestore like Jena.