AletheiaFact / AletheiaFact/aletheia
Create Wikidata's topic recommendation
- 主要言語
- TypeScript
- スター
- 55
- フォーク
- 20
- 平均マージ
- 2日 6時間
- マージ済み PR(30日)
- 2
説明
Use compromise to extract nouns from the sentence and perform a query to wikidata for each noun pulling the options and asking the user to select the ones that match the desired topics.
Here's a scratch code that shows how to do the query:
```
const nlp = require('pt-compromise');
const sentence = "temos 16 milhões de hectares de florestas nativas em recuperação";
// const sentence = "we have 16 million hectares of native forests in recovery";
// const sentence = "The earth is flat."
// Parse the sentence using compromise
const doc = nlp(sentence)
// Extract named entities
const entities = doc.nouns().out('array');
console.log(entities)
// Search for the entity in Wikidata
entities.forEach(entity => {
fetch(`https://www.wikidata.org/w/api.php?action=wbsearchentities&search=${entity}&language=pt&format=json&origin=*`)
.then(response => response.json())
.then(data => {
if (data.search && data.search.length > 0) {
for (const wbentity of data.search) {
console.log(wbentity)
}
console.log(`Entity: ${entity}, Wikidata ID: ${data.search[0].id}`);
}
});
});
```
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。