Comments (1)
Writing my question down helped me find a solution (see below).
The issue is that alignment_rest_12
does not store the entity IDs but rather the indexes of the entity IDs.
Perhaps there's an easier way. Happy to hear it if it exists.
def get_matches(self, remove_dangling: bool = False) -> list:
candidate_list_kg2 = self.kgs.kg2.entities_set
if remove_dangling:
candidate_list_kg2 = (
candidate_list_kg2
- set([x for x, _ in self.kgs.train_unlinked_entities2])
- set([x for x, _ in self.kgs.valid_unlinked_entities2])
)
candidate_list_kg1 = sorted(list(self.kgs.kg1.entities_set))
candidate_list_kg2 = sorted(list(candidate_list_kg2))
embeds1 = tf.nn.embedding_lookup(self.ent_embeds, candidate_list_kg1).eval(session=self.session)
embeds2 = tf.nn.embedding_lookup(self.ent_embeds, candidate_list_kg2).eval(session=self.session)
mapping = self.mapping_mat.eval(session=self.session) if self.mapping_mat is not None else None
alignment_rest_12, _, _, sim_list = test(
embeds1, embeds2, mapping, self.args.top_k, self.args.test_threads_num,
metric=self.args.eval_metric, normalize=self.args.eval_norm, csls_k=0, accurate=True
)
candidates_kg1 = np.array(candidate_list_kg1)
candidates_kg2 = np.array(candidate_list_kg2)
matches = np.array(list(alignment_rest_12))
# Map from position (index) to ID
matches_reindexed = np.dstack((
candidates_kg1[matches[:, 0]],
candidates_kg2[matches[:, 1]]
)).squeeze()
# Map from ID to name
mapping_kg1_int_name = {v: k for k, v in self.kgs.kg1.entities_id_dict.items()}
mapping_kg2_int_name = {v: k for k, v in self.kgs.kg2.entities_id_dict.items()}
matches_names = np.dstack((
[mapping_kg1_int_name.get(i) for i in matches_reindexed[:, 0]],
[mapping_kg2_int_name.get(i) for i in matches_reindexed[:, 1]]
)).squeeze().tolist()
return matches_names
from openea.
Related Issues (20)
- 关于entity name
- 关于RDF图数据融合 HOT 2
- How to resolve DBPedia and Yago Resource IDs? HOT 3
- 输出文件alignment_results_12的一些问题 HOT 2
- ValueError: Input contains NaN, infinity or a value too large for dtype('float32') HOT 4
- Could you please release the Google Translation version for cross-lingual datasets? HOT 2
- 配置环境的问题
- Marginal Ranking and Background Ranking HOT 1
- word embedding file: wiki-news-300d-1M.vec HOT 1
- 请问下没有GPU,CPU可以运行吗? HOT 2
- 实体对齐后的步骤 HOT 2
- tensorflow version issue HOT 1
- AttributeError: 'Graph' object has no attribute 'label' HOT 1
- Alinet的实验结果
- graph-tool version 2.29 not available through conda HOT 1
- 关于在使用python语句运行程序时的问题 HOT 1
- 关于评价指标的问题
- ValueError: Cannot feed value of shape (20480,) for Tensor triple_placeholder/Variable/Read/ReadVariableOp:0, which has shape (1,) HOT 1
- ModuleNotFoundError: No module named 'tensorflow'请问碰到类似问题如何解决 HOT 1
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 openea.