Class LanguageProfileReader
java.lang.Object
com.optimaize.langdetect.profiles.LanguageProfileReader
Reads
LanguageProfile
s.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final LangProfileReader
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
private boolean
looksLikeLanguageProfileName
(String fileName) private String
makePathForClassLoader
(String profileDirectory, String fileName) private @NotNull String
makeProfileFileName
(@NotNull LdLocale locale) Reads aLanguageProfile
from a File in UTF-8.read
(InputStream inputStream) Reads aLanguageProfile
from an InputStream in UTF-8.read
(ClassLoader classLoader, String profileDirectory, Collection<String> profileFileNames) Load profiles from the classpath in a specific directory.read
(String profileDirectory, Collection<String> profileFileNames) Same asread(ClassLoader, String, java.util.Collection)
using the class loader of this class.read
(Collection<String> profileFileNames) Same asread(ClassLoader, String, java.util.Collection)
using the class loader of this class, and the default profiles directory of this library.readAll()
Deprecated.renamed to readAllBuiltIn()Loads all profiles from the specified directory.Reads all built-in language profiles from the "languages" folder (shipped with the jar).@NotNull LanguageProfile
readBuiltIn
(@NotNull LdLocale locale) @NotNull List
<LanguageProfile> readBuiltIn
(@NotNull Collection<LdLocale> languages)
-
Field Details
-
internalReader
-
PROFILES_DIR
- See Also:
-
-
Constructor Details
-
LanguageProfileReader
public LanguageProfileReader()
-
-
Method Details
-
read
Reads aLanguageProfile
from a File in UTF-8.- Throws:
IOException
-
read
Reads aLanguageProfile
from an InputStream in UTF-8.- Throws:
IOException
-
read
public List<LanguageProfile> read(ClassLoader classLoader, String profileDirectory, Collection<String> profileFileNames) throws IOException Load profiles from the classpath in a specific directory.This is usually used to load built-in profiles, shipped with the jar.
- Parameters:
classLoader
- the ClassLoader to load the profiles from. UseMyClass.class.getClassLoader()
profileDirectory
- profile directory path inside the classpath. The default profiles are in "languages".profileFileNames
- for example ["en", "fr", "de"].- Throws:
IOException
-
makePathForClassLoader
-
read
public List<LanguageProfile> read(String profileDirectory, Collection<String> profileFileNames) throws IOException Same asread(ClassLoader, String, java.util.Collection)
using the class loader of this class.- Throws:
IOException
-
read
Same asread(ClassLoader, String, java.util.Collection)
using the class loader of this class, and the default profiles directory of this library.- Throws:
IOException
-
readBuiltIn
@NotNull public @NotNull LanguageProfile readBuiltIn(@NotNull @NotNull LdLocale locale) throws IOException - Throws:
IOException
-
makeProfileFileName
-
readBuiltIn
@NotNull public @NotNull List<LanguageProfile> readBuiltIn(@NotNull @NotNull Collection<LdLocale> languages) throws IOException - Throws:
IOException
-
readAll
Deprecated.renamed to readAllBuiltIn()- Throws:
IOException
-
readAllBuiltIn
Reads all built-in language profiles from the "languages" folder (shipped with the jar).- Throws:
IOException
-
readAll
Loads all profiles from the specified directory. Do not use this method for files distributed within a jar.- Parameters:
path
- profile directory path- Returns:
- empty if there is no language file in it.
- Throws:
IOException
-
looksLikeLanguageProfileFile
-
looksLikeLanguageProfileName
-