Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
Return list instead of set
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Oct 20, 2021
1 parent 0a243bd commit 19aaf26
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
14 changes: 7 additions & 7 deletions linguars.pyi
@@ -1,20 +1,20 @@
from typing import List, Optional, Set, Union
from typing import List, Optional, Union

class Language:
def iso_code_639_1(self) -> str: ...
def iso_code_639_3(self) -> str: ...
@staticmethod
def all() -> Set["Language"]: ...
def all() -> List["Language"]: ...
@staticmethod
def all_spoken_ones() -> Set["Language"]: ...
def all_spoken_ones() -> List["Language"]: ...
@staticmethod
def all_with_arabic_script() -> Set["Language"]: ...
def all_with_arabic_script() -> List["Language"]: ...
@staticmethod
def all_with_cyrillic_script() -> Set["Language"]: ...
def all_with_cyrillic_script() -> List["Language"]: ...
@staticmethod
def all_with_devanagari_script() -> Set["Language"]: ...
def all_with_devanagari_script() -> List["Language"]: ...
@staticmethod
def all_with_latin_script() -> Set["Language"]: ...
def all_with_latin_script() -> List["Language"]: ...

class LanguageDetector:
def __init__(
Expand Down
14 changes: 6 additions & 8 deletions src/lib.rs
@@ -1,5 +1,3 @@
use std::collections::HashSet;

use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;
use pyo3::PyObjectProtocol;
Expand All @@ -23,47 +21,47 @@ impl Language {
}

#[staticmethod]
fn all() -> HashSet<Self> {
fn all() -> Vec<Self> {
lingua::Language::all()
.into_iter()
.map(|inner| Self { inner })
.collect()
}

#[staticmethod]
fn all_spoken_ones() -> HashSet<Self> {
fn all_spoken_ones() -> Vec<Self> {
lingua::Language::all_spoken_ones()
.into_iter()
.map(|inner| Self { inner })
.collect()
}

#[staticmethod]
fn all_with_arabic_script() -> HashSet<Self> {
fn all_with_arabic_script() -> Vec<Self> {
lingua::Language::all_with_arabic_script()
.into_iter()
.map(|inner| Self { inner })
.collect()
}

#[staticmethod]
fn all_with_cyrillic_script() -> HashSet<Self> {
fn all_with_cyrillic_script() -> Vec<Self> {
lingua::Language::all_with_cyrillic_script()
.into_iter()
.map(|inner| Self { inner })
.collect()
}

#[staticmethod]
fn all_with_devanagari_script() -> HashSet<Self> {
fn all_with_devanagari_script() -> Vec<Self> {
lingua::Language::all_with_devanagari_script()
.into_iter()
.map(|inner| Self { inner })
.collect()
}

#[staticmethod]
fn all_with_latin_script() -> HashSet<Self> {
fn all_with_latin_script() -> Vec<Self> {
lingua::Language::all_with_latin_script()
.into_iter()
.map(|inner| Self { inner })
Expand Down
4 changes: 1 addition & 3 deletions tests/test_linguars.py
Expand Up @@ -14,9 +14,7 @@ def test_detect():
detector = linguars.LanguageDetector(languages=["chinese", "english"])
assert str(detector.detect("中文")) == "chinese"

detector = linguars.LanguageDetector(
languages=list(linguars.Language.all_spoken_ones())
)
detector = linguars.LanguageDetector(languages=linguars.Language.all_spoken_ones())
assert str(detector.detect("中文")) == "chinese"


Expand Down

0 comments on commit 19aaf26

Please sign in to comment.