python - 从's'中的'data'变量中获取什么数据?
问题描述
我正在尝试理解 NER,我看到以下代码行,我无法弄清楚这一行的含义,
s = self.data[self.data["Sentence #"] == "Sentence: {}".format(self.n_sent)]
我正在阅读来自 https://www.depends-on-the-definition.com/introduction-named-entity-recognition-python/的代码
解决方案
为了n_sent=1
"Sentence: {}".format(self.n_sent)
将生成字符串Sentence: 1
并将其与第一列匹配使用
self.data["Sentence #"] == "Sentence: {}".format(self.n_sent)
最后在条件匹配的地方使用布尔掩码对数据帧进行切片以获取特定句子的数据
s = self.data[self.data["Sentence #"] == "Sentence: {}".format(self.n_sent)]
并进一步n_sent+=1
增加将重复该过程以获得下一个句子
推荐阅读
- php - “return view”和“return make:view”有什么区别?
- python - Python列表元素与转换为元组以进行字符串格式化
- regex - 正则表达式忽略几组符号中的所有内容
- python - 用 pygame 和 pyserial 控制电机
- flutter - 用路径在 Flutter 中绘制复杂元素,然后以不同的角度重绘相同的元素
- python - Python模拟树概率
- javascript - Firebase“运行此应用程序的环境不支持操作”
- java - 使用一种方法从文本文件中读取数字并返回素数
- c# - MenuItem 中的单击事件
- c++ - 是`boost::function
f`是指针还是对象?