Topic
  • 4 replies
  • Latest Post - ‏2013-01-03T09:43:26Z by SystemAdmin
SystemAdmin
SystemAdmin
197 Posts

Pinned topic Access feature of a Token within a character rule

‏2012-12-19T09:28:43Z |
Hello there,

I have got a question concerning character rules:
Is there a possibility to access the feature of a token used in a character rule and to display it also as a feature of the new character rule?
A short example:

$digit = [0-9]; $number = $digit+ (\, $digit*)?;   $km = km|Kilometer; $km 
{anno:
"com.IBM.Studio.km",inMeters,1000
};   $lengthStatement = $number \p
{Space
}? $km; $lengthStatement = 
{anno:
"com.IBM.Studio.lengthStatement"
};


So how can I set the feature "inMeters" of $km also as feature if $lengthStatement?
Or is there no way to do this?
Updated on 2013-01-03T09:43:26Z at 2013-01-03T09:43:26Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    197 Posts

    Re: Access feature of a Token within a character rule

    ‏2012-12-19T10:25:33Z  
    Hi,

    This is not supported in the current Character rules DB.
  • SystemAdmin
    SystemAdmin
    197 Posts

    Re: Access feature of a Token within a character rule

    ‏2012-12-19T10:51:25Z  
    Hi,

    This is not supported in the current Character rules DB.
    Thank you for the fast reply.
  • bfoyle
    bfoyle
    60 Posts

    Re: Access feature of a Token within a character rule

    ‏2012-12-19T19:45:41Z  
    Thank you for the fast reply.
    Can you explain a little more with examples, what you are trying to accomplish?

    bf
  • SystemAdmin
    SystemAdmin
    197 Posts

    Re: Access feature of a Token within a character rule

    ‏2013-01-03T09:43:26Z  
    • bfoyle
    • ‏2012-12-19T19:45:41Z
    Can you explain a little more with examples, what you are trying to accomplish?

    bf
    I'm trying to create an annotator, which is able to detect and normalize length statements.

    For *bold*example we have the following text and the annotator can handle lengths in meters and kilometers:
    "The distance between A and B is 5 kilometers and between A and C 5,5 kilometers.
    From B to C it's 500 meters."

    Desired Outline:
    lengthStatement:
    • 5 kilometers (lengthInMeters: 5000);
    • 5,5 kilometers (lengthInMeters: 5500);
    • 500 meters (lengthInMeters: 500);

    => The statement in brackets should be a property.

    My first idea was to first annotate the length unit an assign a property with a conversion factor to it.
    In a second step the whole statement, so a number and the length unit, should use the property of the annotated length unit. But there is no function to realize this.
    
    $km = km|kilometer|kilometers; $km 
    {anno:
    "com.IBM.Studio.LengthUnit",ConversionFactorInMeter,
    "1000"
    }; $m = m|meter|meters; $m 
    {anno:
    "com.IBM.Studio.LengthUnit",ConversionFactorInMeter,
    "1"
    }; $lengthUnit = $km|$m;   $lengthStatement = $number \p
    {Space
    }? $lengthUnit; $lengthStatement 
    {anno:
    "com.IBM.Studio.Laengenangaben",value,
    {jregex:
    "(\\d{1,3}(.?\\d{3})*(,\\d+)?)(\\s|\\S)+",
    "$1"
    }
    };       
    // The conversion factor from $lengthUnit should have been included here.
    


    Because this does not work my second approach was to move the conversion factor property direct into $lengthStatement:
    
    $km = km|kilometer|kilometers; $m = m|meter|meters;   $laengenangabe = $number \p
    {Space
    }?; $laengenangabe $km 
    {anno:
    "com.IBM.Studio.Laengenangaben",value,
    {jregex:
    "(\\d{1,3}(.?\\d{3})*(,\\d+)?)(\\s|\\S)+",
    "$1"
    },ConversionFactorInMeter,
    "1000"
    }; $laengenangabe $m 
    {anno:
    "com.IBM.Studio.Laengenangaben",value,
    {jregex:
    "(\\d{1,3}(.?\\d{3})*(,\\d+)?)(\\s|\\S)+",
    "$1"
    },ConversionFactorInMeter,
    "1"
    };
    


    So that's the actual status.
    The detection of length statements works fine. The conversion factor and the value of the number are displayed as properties.
    Normalization does not work up to know. Current issues are:
    • converting the value of the number(String) into an integer value
    • dealing with floating point values

    So if anyone has a hint for me to solve this issues feel free to comment ;)