40 #include "ling_class/EST_Item.h" 41 #include "ling_class/EST_FeatureFunctionPackage.h" 42 #include "EST_FeatureFunctionContext.h" 44 #include "ling_class_init.h" 46 void EST_FeatureFunctionContext::class_init(
void)
48 ling_class_init::use();
55 const EST_String EST_FeatureFunctionContext::separator =
"+";
57 EST_FeatureFunctionContext::EST_FeatureFunctionContext(
void)
62 EST_FeatureFunctionContext::~EST_FeatureFunctionContext(
void)
66 for(p.
begin(packages); p; ++p)
79 for(p.
begin(packages); p; ++p)
82 if (package->name() == name)
88 EST_String EST_FeatureFunctionContext::get_featfunc_name(
const EST_Item_featfunc func,
int &found)
const 94 for(p.
begin(packages); p; ++p)
98 EST_String name = package->lookup(func, found);
111 void EST_FeatureFunctionContext::clear_cache(
void)
116 void EST_FeatureFunctionContext::add_package(
const EST_String name)
119 EST_error(
"Attempt to add package '%s' to global list",
126 EST_error(
"package '%s' not loaded",
130 packages.prepend(package);
137 packages.prepend(package);
142 bool EST_FeatureFunctionContext::package_included(
const EST_String name)
const 144 return get_package(name) != NULL;
147 const EST_Item_featfunc EST_FeatureFunctionContext::get_featfunc(
const EST_String name,
153 if (cache.present(name))
154 return cache.val(name);
156 if ((pos= name.
search(separator, len, 0))>=0)
158 const EST_Item_featfunc func2 =
159 get_featfunc(name.
before(pos,separator.length()),
160 name.
after(pos,separator.length()), must);
163 cache.add_item(name, func2);
171 for(p.
begin(packages); p; ++p)
181 cache.add_item(name, ent.func);
187 EST_error(
"No feature function '%s'", (
const char *)name);
192 const EST_Item_featfunc EST_FeatureFunctionContext::get_featfunc(
const EST_String pname,
201 package->lookup(name, found);
207 EST_error(
"No feature function '%s'", (
const char *)name);
215 template <> EST_Item_featfunc
220 #if defined(INSTANTIATE_TEMPLATES) 222 #include "../base_class/EST_THash.cc" 224 Instantiate_TStringHash(EST_Item_featfunc)
226 #include "../base_class/EST_TList.cc"
int search(const char *s, int len, int &mlen, int pos=0) const
Find a substring.
static EST_String cat(const EST_String s1, const EST_String s2=Empty, const EST_String s3=Empty, const EST_String s4=Empty, const EST_String s5=Empty, const EST_String s6=Empty, const EST_String s7=Empty, const EST_String s8=Empty, const EST_String s9=Empty)
void begin(Container &over)
Set the iterator ready to run over this container.
EST_String before(int pos, int len=0) const
Part before position.
EST_String after(int pos, int len=1) const
Part after pos+len.
void begin(const Container &over)
Set the iterator ready to run over this container.