Skip to content

Instantly share code, notes, and snippets.

@YoshiRi
Created July 29, 2025 10:29
Show Gist options
  • Select an option

  • Save YoshiRi/2c817cb57608998cb84712fb8cdc87c9 to your computer and use it in GitHub Desktop.

Select an option

Save YoshiRi/2c817cb57608998cb84712fb8cdc87c9 to your computer and use it in GitHub Desktop.
Snippet for patent parsing with jupyter notebook
# WidgetでGooglePatentをParseする
from googlepatentscraper.document import Document
from google.colab import widgets
import ipywidgets as widgets
from IPython.display import display, HTML, clear_output
url_box = widgets.Text(
value='',
placeholder='Google PatentのURLを入力してください',
description='URL:',
disabled=False
)
display(url_box)
# ボタンを押して実行
def on_button_clicked(b):
with output:
clear_output() # 過去の出力をクリア
url = url_box.value
number = url.split("/")[-1]
patent = Document(number)
text = patent.data["description_alt"]
display(HTML(f"<textarea rows=20 cols=100>{text}</textarea>"))
button = widgets.Button(description="取得")
output = widgets.Output() # 出力ウィジェットを作成
button.on_click(on_button_clicked)
display(button, output) # ボタンと出力ウィジェットを表示
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment