This article was first published on the Nebula Graph Community public account
Because the growth trend of graph databases has always been at the forefront, every year the media predicts that this year will be the "Year of Graphs". As a former graph database practitioner, Wang Ertie (Wang Jiankui), the captain of the Nebula Hackthon 2021 team Linjiangxian, has been thinking about why the long-term hot graph database market has not really exploded. In 2018, the graph database lost to the blockchain, and in 2019, it encountered 5G, and then the epidemic began. In Wang Ertie's view, graph databases are currently mainly for the toB and toG markets. In the toC field, there are almost no cases related to graph databases, which is why graph technology is difficult to be known to the public.
So, a new idea emerged, which will be a very good and fun C-side case. What is it? It is the "big adventure of graph database brought by an ancient poem" introduced this time.
remember
There was a time when Ertie accompanied a child to a painting class, and in his spare time, he came across Su Shi's "Linjiang Immortal Fengshui Cave":
四大从来都遍满,此间风水何疑。故应为我发新诗。幽花香涧谷,寒藻舞沦漪。借与玉川生两腋,天仙未必相思。还凭流水送人归。层巅余落日,草露已沾衣。
Because I can't read this poem, I can't appreciate the beauty of its artistic conception. Wang Ertie, who is an old two-dimensional person, used the "Holy Land Tour" among anime fans to think of the way to use poetry to tour -- returning to the place where ancient poetry was created to experience the artistic conception and beauty of poetry. Combined with the graph database, put Chinese ancient poems into the graph, and associate all his poems and creation locations through [Author Search], which forms a travel route of [Poetry Tour]; through [Location Search] ] It is related to all the local ancient poetry creation places, which forms a poetry city full of cultural flavor.
More gameplay can also be derived based on routes and geographic locations. For example, an author's city footprint map may be his promotion history; if multiple authors have poems at the same location, they can verify and learn from each other. Combined with the map, there are more ways to continue to explore.
In addition to the main function of "Holy Land Tour", Ertie also added another function - natal poetry. The idea also comes from a poem, "Liangzhou Ci" by Wang Zhihuan:
黄河远上白云间,一片孤城万仞山。羌笛何须怨杨柳,春风不度玉门关。
An ancient poem containing the names of his children suddenly made the children interested in learning the poem, so he decided to join the natal poems. After the ancient poems got close to people and established a sense of familiarity, they became part of his memory.
dream come true
The idea of the ancient poetry adventure project is mainly to put Chinese ancient poetry into the map. The map of the poetry needs to include the author (name, dynasty, character, number), poetry (poem name, content, creation address, longitude, dimension), city, Others include the mapping of ancient cities and modern cities, the circle of friends of the ancients, etc., forming a complete map.
The data source needs to involve poetry database, Baidu Chinese, travel website, coordinate extraction system, etc. After data processing, data aggregation and graph database modeling, the data is imported into the graph database, and a simple poem graph is formed. Then provide interface services through Java Web, and provide user services through applet. The whole process goes through.
The overall implementation is mainly divided into 3 steps:
- Data processing, data processing is the most difficult point of the whole project. In this part, it is necessary to first clarify the requirements at the product level, conduct graph database modeling according to the requirements, and then infer what data support is needed according to the modeling results, then find the data source, and perform data collection and ETL processing. Finally, several files required in the graph database are formed, for example: vertex-poem.csv, vertex-author.csv, vertex-city.csv, edge-poem-author.csv, edge-poem-city.csv.
- System development, system development is the process of creating and importing the data in the graph database in the first step of building the graph. Because of Nebula's complete product functions and peripheral tools, the development of this step is relatively simple. The project uses the Nebula Graph graph database for data storage, Nebula Graph Studio for graph database modeling and syntax debugging, Nebula Graph Importer for data import, and Nebula Graph Java Client for API service development.
- For applet development, several APIs will be formed after system development, and the applet side will call the API port, and then display the front-end visualization. Among them, the SDK of the map is required, and combined with the collected coordinates, the place where the poem was created can be displayed on the map.
This project seems very simple, but there are hidden secrets. There are two difficulties in the realization of the whole project. One of them is data, because the system itself is not complicated, the amount of code is not much, the core is the understanding of data, and a good product sense. Of course, there is also a tiankeng problem, that is, some good ancient poems cannot find the place of creation or there are historical disputes, such as Chen Ziang's "Dengyouzhou Taige". The second difficulty in calculating the technical breadth is to be familiar with the entire technical route from an idea to product realization. In fact, there is not much deep technology, but it needs an independent development thinking that is not willing to only do screws.
He said
The interesting point of the graph database adventure brought by an ancient poem is in addition to its idea and technical realization. More product details are also eye-catching, such as how geographic locations are handled.
Take Linjiang Xian·Fengshui Cave as an example. The landmark coordinate of the story is the Fengshui Cave. How to locate this Fengshui Cave? There are "Fengshui Caves" all over the place. According to Su Shi's past experience, he finally matched and located the Jinxiu Fengshui Cave in Hangzhou. By extracting the geographical coordinates of the Fengshui Cave, the ancient poem was restored to the holy place of the poem. The implementation of this piece has also gone through some twists and turns. Everyone knows the GEO function that Nebula Graph v2.6 began to support. At the beginning, they considered whether to use GEO instead of storing latitude and longitude. But on second thought, the project itself does not need to use the powerful Nebula Graph GEO function, and the project is in a hurry (the competition has a code deadline for submission), so I did not try the new GEO function.
When it comes to the follow-up project planning, Ertie Wang said, "The more core algorithms such as shortest path, triangular counting, and community discovery in the graph database are not used. You can give us your thoughts and give us ideas. Of course, you are more welcome to come to practice. experience and realization".
Continuation
Click the link to view its project design document: https://github.com/Jerrick/a-tour-of-poetry/blob/main/README.md . BTW, Ertie was a guest on the Nebula Graph Podcast to share his mental journey of this practice. If you read this article, you can click the link to listen to this Podcast: http://xima.tv/1_etO1vh?_sonic=0
Exchange graph database technology? To join the Nebula exchange group, please fill in your Nebula business card first, and the Nebula assistant will pull you into the group~~
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。