In order to pass my gensim corpus and dictionary through the pipeline, I have made a convenience case class as follows:
class GensimCorpusAndDict:
def __init__(self, corpus, dict):
self.corpus = corpus
self.dict = dict
It would be helpful to get type hinting on the input parameters. I have read the docs but still not sure how to type hint on third party classes
Read thedocs (PEP-0484) :
Type hints may be [...] and user-defined classes (including those defined in the standard library or third-party modules).
For example:
import numpy as np
import pandas as pd
class GensimCorpusAndDict:
def __init__(self, corpus: np.ndarray, the_dict: pd.DataFrame):
self.corpus = corpus
self.dict = the_dict
Note: it is not good practice to use a variable name that shadows a built-in (in this case dict
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.