0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

言語処理100本ノックやってみてる

Last updated at Posted at 2024-06-18

現在チャプター03をpythonにも苦戦しながらやってみてる最中
わかる人がそもそも居るのかという感じでもあるけど、わかる人はわかるかと思うけど特に脳内の調子的にこういう事をやってる場合でもないけど何かと解決しないんでとりあえずやっとく
問題25で詰まってしまってるけどマストドンでの発言以外ではツイッター(現X)以外での発言は2015年?以降ぶりでかつ初めてのコード掲載記事なのでこの感じで

やってみた問題20のテキストの取得のコード
書いたのは先週の13日か14日ぐらいだった気が
なんかwikiのjson.gzファイルを使ってイギリスを指定するらしいので引数にfilenameとcountryとしmain関数から文字列を渡してる。
ほかの人の回答は見たような気もするけどまだちゃんと見てない。

def no20_get_jsontext(filename,country):
 text=''
 with gz.open(filename,mode='rt')as f:
  obj=[js.loads(line) for line in f.readlines()]
  for i,o in enumerate (obj):
   if o[key]==country:
    text=o[value]
 return text
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?