{"id":15982519,"url":"https://github.com/mddct/knowledge-graph-ass","last_synced_at":"2026-03-05T02:03:50.130Z","repository":{"id":113651150,"uuid":"134503395","full_name":"Mddct/Knowledge-Graph-Ass","owner":"Mddct","description":"知识工程作业","archived":false,"fork":false,"pushed_at":"2018-06-27T07:31:22.000Z","size":12010,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T17:48:18.545Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mddct.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-23T02:44:36.000Z","updated_at":"2018-06-27T07:31:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"c4bb1a77-6279-4c48-a319-fa24eb0ae185","html_url":"https://github.com/Mddct/Knowledge-Graph-Ass","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Mddct/Knowledge-Graph-Ass","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mddct%2FKnowledge-Graph-Ass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mddct%2FKnowledge-Graph-Ass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mddct%2FKnowledge-Graph-Ass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mddct%2FKnowledge-Graph-Ass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mddct","download_url":"https://codeload.github.com/Mddct/Knowledge-Graph-Ass/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mddct%2FKnowledge-Graph-Ass/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30106163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T01:39:18.192Z","status":"online","status_checked_at":"2026-03-05T02:00:06.710Z","response_time":93,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T01:04:32.739Z","updated_at":"2026-03-05T02:03:50.108Z","avatar_url":"https://github.com/Mddct.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"* knowledge grpah 作业\n** 得分系数建议(姓):\n   | 周  | 杨  | 李  |\n   | 1/3 | 1/3 | 1/3 |\n** 系统说明文档\n*** 搜索系统使用MVC golang + ES + dbpedia sparql\n*** 数据存储与查询\n    - 全文搜索引擎 elasticsearch\n    - jena\n    - dbpedia Dataset\n    - 爬虫爬取 电影网1905 5万条数据\n*** 说明\n    - 推荐代码位于 crawel/knowledgegraph下\n    - 由于时间关系，缩小出版物集合重点放在电影部分，当然同时也支持基于名字的对书籍和游戏的查询和全文检索\n    - 推荐功能比较弱，只实现了同种类型查询下的根据名字及查询类型共享最多类型类别的推荐\n    - 局限：部分中文在dbpedia中查询不到， 推荐功能太弱， 日后要改进\n*** 设计思路\n    - elasticsearch 中建立 3个index 分别是movie book game (movie 中id采用电影网的编号)。\n    - 由于sparql的regex匹配速度较慢，响应时间过长，采用把出版物的id和name存入到elasticsearch中，\n    - 获取搜索内容,由ES中全文检索和dbpedia的sparql中构成\n    #+BEGIN_SRC go\n      sparql = fmt.Sprintf(`PREFIX rdf: \u003chttp://www.w3.org/1999/02/22-rdf-syntax-ns#\u003e\n          PREFIX dbo: \u003chttp://dbpedia.org/ontology/\u003e\n          PREFIX rdfs: \u003chttp://www.w3.org/2000/01/rdf-schema#\u003e\n          PREFIX dct: \u003chttp://purl.org/dc/terms/\u003e\n\n      select ?link ?name ?countrys ?abstract ?year ?thumbnail\n      where{\n      ?link rdf:type dbo:Film;\n             rdfs:label ?name;\n             dbp:country ?countrys;\n            rdfs:comment ?abstract;\n            dbo:runtime ?year\n      filter regex(?name,\"%s\")\n      filter(LANG(?abstract)=\"zh\" ).\n      optional {\n      ?link dbo:thumbnail ?thumbnail\n      }`, %s)\n\n    #+END_SRC\n    - 每个页面由左边基于内容查找和右端知识卡片，知识卡片由dbpedia中相应推荐填充\n    #+BEGIN_SRC go\n\n      categoryMost=  `SELECT COUNT(?movie) SAMPLE(?movie)\n            WHERE\n            {\n              ?name rdf:type dbo:film\n              ?name dct:subject ?o .\n                rdfs:label ?name;\n              dbp:country ?countrys;\n              rdfs:comment ?abstract;\n              dbo:runtime ?year\n\n              ?movie dct:subject ?o\n              FILTER (?movie != dbr:?name) .\n            } GROUP BY ?movie\n            ORDER BY DESC(COUNT(?movie))\n            limit 5`\n      type = `SELECT COUNT(?movie) SAMPLE(?movie)\n              WHERE\n              {\n                dbr:A_Trip_to_the_Moon rdf:type ?o .\n                ?movie rdf:type ?o\n                FILTER (?movie != dbr:A_Trip_to_the_Moon) .\n              } GROUP BY ?movie\n              ORDER BY DESC(COUNT(?movie))\n       lim5`\n\n    #+END_SRC\n    - 渲染网页，返回结果。\n\n    注意：\n    - 本文爬虫属于并发，架构如下，支撑elasticsearch和dbpedia中查询结果内容的部分补充\n      比如dbpedia中电影海报，可自定义解析器，本文爬虫爬取豆瓣电影 书籍 的封面。\n    - ES查询 sparql查询并发 缩短响应时间\n    [[file:crawler/并发版.PNG]]\n*** 使用说明：\n    #+BEGIN_SRC go \n      cd crawler/src/\n      go run main.go\n    #+END_SRC\n    #+BEGIN_SRC go\n      for i := range ret {\n        wg.Add(1)\n        go func(i int, imgSrc *string) {\n          defer wg.Done()\n          iui := fmt.Sprintf(`https://www.douban.com/search?q=%s`,\n            ret[i].Name)\n          contents, err := fetcher.Fetch(iui)\n          if err != nil {\n            return\n          }\n          var dom, _ = goquery.NewDocumentFromReader(\n            strings.NewReader(string(contents)))\n\n          ok := false\n          ,*imgSrc, ok = dom.Find(\".pic\").Find(\"img\").Attr(\"src\")\n          if !ok {\n            return\n          }\n        }(i, \u0026(ret[i].ImageSrc))\n\n      }\n\n    #+END_SRC\n\n    [[file:src/static/img/demo0.jpg]]\n    [[file:src/static/img/demo.png]]\n    [[file:src/static/img/demo1.jpg]]\n    [[file:src/static/img/demo2.jpg]]\n    \n** 总结\n\n   项目最有特色的功能是什么，能让用户获得什么好处？\n   1 可以同时获得基于关键字 内容 和知识图谱的多方面内容，提高搜索效率\n   2 支持分页功能，\n   3 并发处理， 可以获得较快的响应速度\n\n   对课程有什么批评建议？\n   1. 希望能在知识图谱构建方面提供更多的材料和内容\n   2. 能够提供基于知识图谱对话系统实现的思路\n   \n\n** 参考 nlp to sparql (或者三元组)\n   - 语义解析\n   参考\n   https://nlp.stanford.edu/pubs/semparseEMNLP13.pdf\n   https://zhuanlan.zhihu.com/p/25759682\n   http://octopuscoder.github.io/2018/02/04/%E7%9F%A5%E8%AF%86%E5%9B%BE%E8%B0%B1%E9%97%AE%E7%AD%94%E6%80%BB%E7%BB%93/\n   http://www.websemanticsjournal.org/index.php/ps/article/view/189\n   https://github.com/IeuanWalker/Dissertation-Project\n   -\n\n   PREFIX owl: \u003chttp://www.w3.org/2002/07/owl#\u003e\n   PREFIX xsd: \u003chttp://www.w3.org/2001/XMLSchema#\u003e\n   PREFIX rdfs: \u003chttp://www.w3.org/2000/01/rdf-schema#\u003e\n   PREFIX rdf: \u003chttp://www.w3.org/1999/02/22-rdf-syntax-ns#\u003e\n   PREFIX foaf: \u003chttp://xmlns.com/foaf/0.1/\u003e\n   PREFIX dc: \u003chttp://purl.org/dc/elements/1.1/\u003e\n   PREFIX : \u003chttp://dbpedia.org/resource/\u003e\n   PREFIX dbpedia2: \u003chttp://dbpedia.org/property/\u003e\n   PREFIX dbpedia: \u003chttp://dbpedia.org/\u003e\n   PREFIX skos: \u003chttp://www.w3.org/2004/02/skos/core#\u003e\n\n   select ?movieLink ?title ?genreLink ?genre ?releaseDate  where{\n   ?movieLink rdf:type db:Film;\n   foaf:name ?title .\n   optional {\n   ?movieLink dbpedia2:genre ?genreLink.\n   ?genreLink rdfs:label ?genre.\n   filter(lang(?genre)='en')\n   }.\n   optional{\n   ?movieLink \u003chttp://dbpedia.org/ontology/releaseDate\u003e ?releaseDate\n   }.\n   {0}{1}\n   filter(lang(?title)='en')\n   }\n\n   @prefix dt:   \u003chttp://example.org/datatype#\u003e .\n   @prefix ns:   \u003chttp://example.org/ns#\u003e .\n   @prefix :     \u003chttp://example.org/ns#\u003e .\n   @prefix xsd:  \u003chttp://www.w3.org/2001/XMLSchema#\u003e .\n\n   :x   ns:p     \"cat\"@en .\n   :y   ns:p     \"42\"^^xsd:integer .\n   :z   ns:p     \"abc\"^^dt:specialDatatype .\n\n   @prefix dc:   \u003chttp://purl.org/dc/elements/1.1/\u003e .\n   @prefix :     \u003chttp://example.org/book/\u003e .\n   @prefix ns:   \u003chttp://example.org/ns#\u003e .\n\n   :book1  dc:title  \"SPARQL Tutorial\" .\n   :book1  ns:price  42 .\n   :book2  dc:title  \"The Semantic Web\" .\n   :book2  ns:price  23 .\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmddct%2Fknowledge-graph-ass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmddct%2Fknowledge-graph-ass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmddct%2Fknowledge-graph-ass/lists"}