(uri: str)
return lang, term, sense
Extract language, term, and sense from a ConceptNet "concept" URI.
Extract language, term, and sense from a ConceptNet "concept" URI.
Extract language term and sense from a ConceptNet concept URI .
def _parse_concept_uri(uri: str) -> Tuple[str, str, str]:
    """Extract language, term, and sense from a ConceptNet "concept" URI."""
    if not uri.startswith("/c/"):
        raise ValueError(f"invalid concept uri: {uri}")
    uri = _split_uri(uri)
    if len(uri) == 3:
        _, lang, term = uri
        sense = None
    elif len(uri) == 4:
        _, lang, term, sense = uri
    elif len(uri) > 4:
        _, lang, term, sense, *_ = uri
    elif len(uri) < 3:
        raise ValueError(f"not enough parts in uri: {uri}")
    term = term.replace("_", " ")
    return lang, term, sense
def _parse_concept_uri ( uri : str ) -> Tuple [ str , str , str ] : if not uri . startswith ( "/c/" ) : raise ValueError ( f"invalid concept uri: {uri}" ) uri = _split_uri ( uri ) if len ( uri ) == 3 : _ , lang , term = uri sense = None elif len ( uri ) == 4 : _ , lang , term , sense = uri elif len ( uri ) > 4 : _ , lang , term , sense , * _ = uri elif len ( uri ) < 3 : raise ValueError ( f"not enough parts in uri: {uri}" ) term = term . replace ( "_" , " " ) return lang , term , sense